CMS 3D CMS Logo

CSCStubEfficiencyValidation.cc
Go to the documentation of this file.
1 #include <memory>
2 
5 
8  const auto& simVertex = pset.getParameter<edm::ParameterSet>("simVertex");
9  simVertexInput_ = iC.consumes<edm::SimVertexContainer>(simVertex.getParameter<edm::InputTag>("inputTag"));
10  const auto& simTrack = pset.getParameter<edm::ParameterSet>("simTrack");
11  simTrackInput_ = iC.consumes<edm::SimTrackContainer>(simTrack.getParameter<edm::InputTag>("inputTag"));
12 
13  // Initialize stub matcher
14  cscStubMatcher_ = std::make_unique<CSCStubMatcher>(pset, std::move(iC));
15 
16  // get the eta ranges
17  etaMins_ = pset.getParameter<std::vector<double>>("etaMins");
18  etaMaxs_ = pset.getParameter<std::vector<double>>("etaMaxs");
19 }
20 
22 
24  for (int i = 1; i <= 10; ++i) {
25  int j = i - 1;
27 
28  std::string t1 = "ALCTEtaDenom_" + cn;
29  std::string t2 = "CLCTEtaDenom_" + cn;
30  std::string t3 = "LCTEtaDenom_" + cn;
31 
32  iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/ALCT/Occupancy/");
33  etaALCTDenom[j] = iBooker.book1D(t1, t1 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
34  etaALCTDenom[j]->getTH1()->SetMinimum(0);
35  t1 = "ALCTEtaNum_" + cn;
36  etaALCTNum[j] = iBooker.book1D(t1, t1 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
37  etaALCTNum[j]->getTH1()->SetMinimum(0);
38 
39  iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/CLCT/Occupancy/");
40  etaCLCTDenom[j] = iBooker.book1D(t2, t2 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
41  etaCLCTDenom[j]->getTH1()->SetMinimum(0);
42  t2 = "CLCTEtaNum_" + cn;
43  etaCLCTNum[j] = iBooker.book1D(t2, t2 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
44  etaCLCTNum[j]->getTH1()->SetMinimum(0);
45 
46  iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/LCT/Occupancy/");
47  etaLCTDenom[j] = iBooker.book1D(t3, t3 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
48  etaLCTDenom[j]->getTH1()->SetMinimum(0);
49  t3 = "LCTEtaNum_" + cn;
50  etaLCTNum[j] = iBooker.book1D(t3, t3 + ";True Muon |#eta|; Entries", 50, etaMins_[j], etaMaxs_[j]);
51  etaLCTNum[j]->getTH1()->SetMinimum(0);
52  }
53 }
54 
56  // Define handles
59 
60  // Use token to retreive event information
61  e.getByToken(simTrackInput_, sim_tracks);
62  e.getByToken(simVertexInput_, sim_vertices);
63 
64  // Initialize StubMatcher
66 
67  const edm::SimTrackContainer& sim_track = *sim_tracks.product();
68  const edm::SimVertexContainer& sim_vert = *sim_vertices.product();
69 
70  // select simtracks for true muons
71  edm::SimTrackContainer sim_track_selected;
72  for (const auto& t : sim_track) {
73  if (!isSimTrackGood(t))
74  continue;
75  sim_track_selected.push_back(t);
76  }
77 
78  // Skip events with no selected simtracks
79  if (sim_track_selected.empty())
80  return;
81 
82  // Loop through good tracks, use corresponding vetrex to match stubs, then fill hists of chambers where the stub appears.
83  for (const auto& t : sim_track_selected) {
84  std::vector<bool> hitALCT(10);
85  std::vector<bool> hitCLCT(10);
86  std::vector<bool> hitLCT(10);
87 
88  // Match track to stubs with appropriate vertex
89  cscStubMatcher_->match(t, sim_vert[t.vertIndex()]);
90 
91  // Store matched stubs.
92  // Key: ChamberID, Value : CSCStubDigiContainer
93  const auto& alcts = cscStubMatcher_->alcts();
94  const auto& clcts = cscStubMatcher_->clcts();
95  const auto& lcts = cscStubMatcher_->lcts();
96 
97  // denominator histograms
98  for (int i = 0; i < 10; ++i) {
99  etaALCTDenom[i]->Fill(t.momentum().eta());
100  etaCLCTDenom[i]->Fill(t.momentum().eta());
101  etaLCTDenom[i]->Fill(t.momentum().eta());
102  }
103 
104  for (auto& [id, container] : alcts) {
105  const CSCDetId cscId(id);
106  const unsigned chamberType(cscId.iChamberType());
107  hitALCT[chamberType - 1] = true;
108  }
109 
110  for (auto& [id, container] : clcts) {
111  const CSCDetId cscId(id);
112  const unsigned chamberType(cscId.iChamberType());
113  hitCLCT[chamberType - 1] = true;
114  }
115 
116  for (auto& [id, container] : lcts) {
117  const CSCDetId cscId(id);
118  const unsigned chamberType(cscId.iChamberType());
119  hitLCT[chamberType - 1] = true;
120  }
121 
122  // numerator histograms
123  for (int i = 0; i < 10; ++i) {
124  if (hitALCT[i])
125  etaALCTNum[i]->Fill(t.momentum().eta());
126  if (hitCLCT[i])
127  etaCLCTNum[i]->Fill(t.momentum().eta());
128  if (hitLCT[i])
129  etaLCTNum[i]->Fill(t.momentum().eta());
130  }
131  }
132 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< edm::SimTrackContainer > simTrackInput_
unsigned short iChamberType() const
Definition: CSCDetId.h:96
CSCStubEfficiencyValidation(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
void bookHistograms(DQMStore::IBooker &)
void Fill(long long x)
bool isSimTrackGood(const SimTrack &t) const
std::string chamberName() const
Definition: CSCDetId.cc:92
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< SimVertex > SimVertexContainer
virtual TH1 * getTH1() const
edm::EDGetTokenT< edm::SimVertexContainer > simVertexInput_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::unique_ptr< CSCStubMatcher > cscStubMatcher_
std::vector< SimTrack > SimTrackContainer
def move(src, dest)
Definition: eostools.py:511