Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:18

0001 #include <memory>
0002 
0003 #include "Validation/MuonCSCDigis/interface/CSCStubEfficiencyValidation.h"
0004 #include "Validation/MuonCSCDigis/interface/CSCStubMatcher.h"
0005 
0006 CSCStubEfficiencyValidation::CSCStubEfficiencyValidation(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC)
0007     : CSCBaseValidation(pset) {
0008   const auto& simVertex = pset.getParameter<edm::ParameterSet>("simVertex");
0009   simVertexInput_ = iC.consumes<edm::SimVertexContainer>(simVertex.getParameter<edm::InputTag>("inputTag"));
0010   const auto& simTrack = pset.getParameter<edm::ParameterSet>("simTrack");
0011   simTrackInput_ = iC.consumes<edm::SimTrackContainer>(simTrack.getParameter<edm::InputTag>("inputTag"));
0012 
0013   // Initialize stub matcher
0014   cscStubMatcher_ = std::make_unique<CSCStubMatcher>(pset, std::move(iC));
0015 
0016   // get the eta ranges
0017   etaMins_ = pset.getParameter<std::vector<double>>("etaMins");
0018   etaMaxs_ = pset.getParameter<std::vector<double>>("etaMaxs");
0019 }
0020 
0021 CSCStubEfficiencyValidation::~CSCStubEfficiencyValidation() {}
0022 
0023 void CSCStubEfficiencyValidation::bookHistograms(DQMStore::IBooker& iBooker) {
0024   for (int i = 1; i <= 10; ++i) {
0025     int j = i - 1;
0026     const std::string cn(CSCDetId::chamberName(i));
0027 
0028     std::string t1 = "ALCTEtaDenom_" + cn;
0029     std::string t2 = "CLCTEtaDenom_" + cn;
0030     std::string t3 = "LCTEtaDenom_" + cn;
0031 
0032     iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/ALCT/Occupancy/");
0033     etaALCTDenom[j] = iBooker.book1D(t1, t1 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
0034     etaALCTDenom[j]->getTH1()->SetMinimum(0);
0035     t1 = "ALCTEtaNum_" + cn;
0036     etaALCTNum[j] = iBooker.book1D(t1, t1 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
0037     etaALCTNum[j]->getTH1()->SetMinimum(0);
0038 
0039     iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/CLCT/Occupancy/");
0040     etaCLCTDenom[j] = iBooker.book1D(t2, t2 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
0041     etaCLCTDenom[j]->getTH1()->SetMinimum(0);
0042     t2 = "CLCTEtaNum_" + cn;
0043     etaCLCTNum[j] = iBooker.book1D(t2, t2 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
0044     etaCLCTNum[j]->getTH1()->SetMinimum(0);
0045 
0046     iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/LCT/Occupancy/");
0047     etaLCTDenom[j] = iBooker.book1D(t3, t3 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
0048     etaLCTDenom[j]->getTH1()->SetMinimum(0);
0049     t3 = "LCTEtaNum_" + cn;
0050     etaLCTNum[j] = iBooker.book1D(t3, t3 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
0051     etaLCTNum[j]->getTH1()->SetMinimum(0);
0052   }
0053 }
0054 
0055 void CSCStubEfficiencyValidation::analyze(const edm::Event& e, const edm::EventSetup& eventSetup) {
0056   // Define handles
0057   edm::Handle<edm::SimTrackContainer> sim_tracks;
0058   edm::Handle<edm::SimVertexContainer> sim_vertices;
0059 
0060   // Use token to retreive event information
0061   e.getByToken(simTrackInput_, sim_tracks);
0062   e.getByToken(simVertexInput_, sim_vertices);
0063 
0064   // Initialize StubMatcher
0065   cscStubMatcher_->init(e, eventSetup);
0066 
0067   const edm::SimTrackContainer& sim_track = *sim_tracks.product();
0068   const edm::SimVertexContainer& sim_vert = *sim_vertices.product();
0069 
0070   // select simtracks for true muons
0071   edm::SimTrackContainer sim_track_selected;
0072   for (const auto& t : sim_track) {
0073     if (!isSimTrackGood(t))
0074       continue;
0075     sim_track_selected.push_back(t);
0076   }
0077 
0078   // Skip events with no selected simtracks
0079   if (sim_track_selected.empty())
0080     return;
0081 
0082   // Loop through good tracks, use corresponding vetrex to match stubs, then fill hists of chambers where the stub appears.
0083   for (const auto& t : sim_track_selected) {
0084     std::vector<bool> hitALCT(10);
0085     std::vector<bool> hitCLCT(10);
0086     std::vector<bool> hitLCT(10);
0087 
0088     // Match track to stubs with appropriate vertex
0089     cscStubMatcher_->match(t, sim_vert[t.vertIndex()]);
0090 
0091     // Store matched stubs.
0092     // Key: ChamberID, Value : CSCStubDigiContainer
0093     const auto& alcts = cscStubMatcher_->alcts();
0094     const auto& clcts = cscStubMatcher_->clcts();
0095     const auto& lcts = cscStubMatcher_->lcts();
0096 
0097     // denominator histograms
0098     for (int i = 0; i < 10; ++i) {
0099       etaALCTDenom[i]->Fill(t.momentum().eta());
0100       etaCLCTDenom[i]->Fill(t.momentum().eta());
0101       etaLCTDenom[i]->Fill(t.momentum().eta());
0102     }
0103 
0104     for (auto& [id, container] : alcts) {
0105       const CSCDetId cscId(id);
0106       const unsigned chamberType(cscId.iChamberType());
0107       hitALCT[chamberType - 1] = true;
0108     }
0109 
0110     for (auto& [id, container] : clcts) {
0111       const CSCDetId cscId(id);
0112       const unsigned chamberType(cscId.iChamberType());
0113       hitCLCT[chamberType - 1] = true;
0114     }
0115 
0116     for (auto& [id, container] : lcts) {
0117       const CSCDetId cscId(id);
0118       const unsigned chamberType(cscId.iChamberType());
0119       hitLCT[chamberType - 1] = true;
0120     }
0121 
0122     // numerator histograms
0123     for (int i = 0; i < 10; ++i) {
0124       if (hitALCT[i])
0125         etaALCTNum[i]->Fill(t.momentum().eta());
0126       if (hitCLCT[i])
0127         etaCLCTNum[i]->Fill(t.momentum().eta());
0128       if (hitLCT[i])
0129         etaLCTNum[i]->Fill(t.momentum().eta());
0130     }
0131   }
0132 }