Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:43

0001 #include "DPGAnalysis/SiStripTools/interface/TSOSHistogramMaker.h"
0002 #include <iostream>
0003 #include "TH1F.h"
0004 #include "TH2F.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ServiceRegistry/interface/Service.h"
0007 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0008 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0009 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0010 
0011 TSOSHistogramMaker::TSOSHistogramMaker()
0012     : m_2dhistos(false),
0013       m_detsels(),
0014       m_selnames(),
0015       m_seltitles(),
0016       m_histocluslenangle(),
0017       m_tsosy(),
0018       m_tsosx(),
0019       m_tsosxy(),
0020       m_ttrhy(),
0021       m_ttrhx(),
0022       m_ttrhxy(),
0023       m_tsosdy(),
0024       m_tsosdx(),
0025       m_tsosdxdy() {}
0026 
0027 TSOSHistogramMaker::TSOSHistogramMaker(const edm::ParameterSet& iConfig)
0028     : m_2dhistos(iConfig.getUntrackedParameter<bool>("wanted2DHistos", false)),
0029       m_detsels(),
0030       m_selnames(),
0031       m_seltitles(),
0032       m_histocluslenangle(),
0033       m_tsosy(),
0034       m_tsosx(),
0035       m_tsosxy(),
0036       m_ttrhy(),
0037       m_ttrhx(),
0038       m_ttrhxy(),
0039       m_tsosdy(),
0040       m_tsosdx(),
0041       m_tsosdxdy() {
0042   edm::Service<TFileService> tfserv;
0043 
0044   std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
0045 
0046   std::cout << "selections found: " << wantedsubds.size() << std::endl;
0047 
0048   for (std::vector<edm::ParameterSet>::iterator ps = wantedsubds.begin(); ps != wantedsubds.end(); ++ps) {
0049     m_selnames.push_back(ps->getParameter<std::string>("detLabel"));
0050     if (ps->existsAs<std::string>("title")) {
0051       m_seltitles.push_back(ps->getParameter<std::string>("title"));
0052     } else {
0053       m_seltitles.push_back(ps->getParameter<std::string>("detLabel"));
0054     }
0055     m_detsels.push_back(DetIdSelector(ps->getUntrackedParameter<std::vector<std::string> >("selection")));
0056   }
0057 
0058   for (unsigned int isel = 0; isel < m_detsels.size(); ++isel) {
0059     TFileDirectory subdir = tfserv->mkdir(m_selnames[isel]);
0060 
0061     std::string name = "tsosy_" + m_selnames[isel];
0062     std::string title = "TSOS y " + m_seltitles[isel];
0063     m_tsosy.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 200, -20., 20.));
0064     name = "tsosx_" + m_selnames[isel];
0065     title = "TSOS x " + m_seltitles[isel];
0066     m_tsosx.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 200, -20., 20.));
0067     if (m_2dhistos) {
0068       name = "tsosxy_" + m_selnames[isel];
0069       title = "TSOS y vs x " + m_seltitles[isel];
0070       m_tsosxy.push_back(subdir.make<TH2F>(name.c_str(), title.c_str(), 200, -20., 20., 200, -20., 20.));
0071     }
0072 
0073     name = "tsosprojx_" + m_selnames[isel];
0074     title = "TSOS x projection " + m_seltitles[isel];
0075     m_tsosprojx.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 400, -2., 2.));
0076     name = "tsosprojy_" + m_selnames[isel];
0077     title = "TSOS y projection " + m_seltitles[isel];
0078     m_tsosprojy.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 400, -2., 2.));
0079 
0080     name = "ttrhy_" + m_selnames[isel];
0081     title = "TT RecHit y " + m_seltitles[isel];
0082     m_ttrhy.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 200, -20., 20.));
0083     name = "ttrhx_" + m_selnames[isel];
0084     title = "TT RecHit x " + m_seltitles[isel];
0085     m_ttrhx.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 200, -20., 20.));
0086     if (m_2dhistos) {
0087       name = "ttrhxy_" + m_selnames[isel];
0088       title = "TT RecHit y vs x  " + m_seltitles[isel];
0089       m_ttrhxy.push_back(subdir.make<TH2F>(name.c_str(), title.c_str(), 200, -20., 20., 200, -20., 20.));
0090     }
0091 
0092     name = "tsosdy_" + m_selnames[isel];
0093     title = "TSOS-TTRH y " + m_seltitles[isel];
0094     m_tsosdy.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 200, -5., 5.));
0095     name = "tsosdx_" + m_selnames[isel];
0096     title = "TSOS-TTRH x " + m_seltitles[isel];
0097     m_tsosdx.push_back(subdir.make<TH1F>(name.c_str(), title.c_str(), 200, -0.1, 0.1));
0098     if (m_2dhistos) {
0099       name = "tsosdxdy_" + m_selnames[isel];
0100       title = "TSOS-TTRH dy vs dy " + m_seltitles[isel];
0101       m_tsosdxdy.push_back(subdir.make<TH2F>(name.c_str(), title.c_str(), 200, -0.1, 0.1, 200, -5., 5.));
0102     }
0103 
0104     name = "cluslenangle_" + m_selnames[isel];
0105     title = "Cluster Length vs Track Angle " + m_seltitles[isel];
0106     m_histocluslenangle.push_back(subdir.make<TH2F>(name.c_str(), title.c_str(), 200, -1., 1., 40, -0.5, 39.5));
0107   }
0108 }
0109 
0110 void TSOSHistogramMaker::fill(const TrajectoryStateOnSurface& tsos,
0111                               TransientTrackingRecHit::ConstRecHitPointer hit) const {
0112   if (hit == nullptr || !hit->isValid())
0113     return;
0114 
0115   for (unsigned int i = 0; i < m_detsels.size(); ++i) {
0116     if (m_detsels[i].isSelected(hit->geographicalId())) {
0117       m_tsosy[i]->Fill(tsos.localPosition().y());
0118       m_tsosx[i]->Fill(tsos.localPosition().x());
0119       if (m_2dhistos)
0120         m_tsosxy[i]->Fill(tsos.localPosition().x(), tsos.localPosition().y());
0121       m_ttrhy[i]->Fill(hit->localPosition().y());
0122       m_ttrhx[i]->Fill(hit->localPosition().x());
0123       if (m_2dhistos)
0124         m_ttrhxy[i]->Fill(hit->localPosition().x(), hit->localPosition().y());
0125       m_tsosdy[i]->Fill(tsos.localPosition().y() - hit->localPosition().y());
0126       m_tsosdx[i]->Fill(tsos.localPosition().x() - hit->localPosition().x());
0127       if (m_2dhistos)
0128         m_tsosdxdy[i]->Fill(tsos.localPosition().x() - hit->localPosition().x(),
0129                             tsos.localPosition().y() - hit->localPosition().y());
0130 
0131       if (tsos.localDirection().z() != 0) {
0132         m_tsosprojx[i]->Fill(tsos.localDirection().x() / tsos.localDirection().z());
0133         m_tsosprojy[i]->Fill(tsos.localDirection().y() / tsos.localDirection().z());
0134       }
0135     }
0136   }
0137 }