CMS 3D CMS Logo

L1TCompare.cc
Go to the documentation of this file.
1 /*
2  * \file L1TCompare.cc
3  * \author P. Wittich
4  * \brief Compare different parts of the trigger chain (e.g., RCT-GCT )
5  *
6  *
7  * organized message logger
8  *
9  * Revision 1.12 2008/03/14 20:35:46 berryhil
10  *
11  *
12  * stripped out obsolete parameter settings
13  *
14  * rpc tpg restored with correct dn access and dbe handling
15  *
16  * Revision 1.11 2008/03/12 17:24:24 berryhil
17  *
18  *
19  * eliminated log files, truncated HCALTPGXana histo output
20  *
21  * Revision 1.10 2008/03/01 00:40:00 lat
22  * DQM core migration.
23  *
24  * Revision 1.9 2008/01/22 18:56:01 muzaffar
25  * include cleanup. Only for cc/cpp files
26  *
27  * Revision 1.8 2007/12/21 20:04:50 wsun
28  * Migrated L1EtMissParticle -> L1EtMissParticleCollection.
29  *
30  * Revision 1.7 2007/12/21 17:41:20 berryhil
31  *
32  *
33  * try/catch removal
34  *
35  * Revision 1.6 2007/11/19 15:08:22 lorenzo
36  * changed top folder name
37  *
38  * Revision 1.5 2007/09/27 22:58:15 ratnik
39  * QA campaign: fixes to compensate includes cleanup in DataFormats/L1Trigger
40  *
41  * Revision 1.4 2007/07/19 18:05:06 berryhil
42  *
43  *
44  * L1CaloRegionDetId dataformat migration for L1TCompare
45  *
46  * Revision 1.3 2007/06/13 11:33:39 wittich
47  * add axis titles
48  *
49  * Revision 1.2 2007/06/08 08:37:43 wittich
50  * Add ECAL TP - RCT comparisons. Lingering problems with
51  * mismatches right now - still needs work.
52  *
53  * Revision 1.1 2007/06/06 14:55:51 wittich
54  * compare within trigger subsystems
55  *
56  */
57 
59 
60 // stl
61 #include <algorithm>
62 
63 using namespace l1extra;
64 using namespace edm;
65 
66 const unsigned int PHIBINS = 18;
67 const float PHIMIN = -0.5;
68 const float PHIMAX = 17.5;
69 
70 // Ranks 6, 10 and 12 bits
71 const unsigned int R6BINS = 64;
72 const float R6MIN = -0.5;
73 const float R6MAX = 63.5;
74 
75 // For GCT this should be 15 bins, -14.5 to 14.5
76 //
77 const unsigned int ETABINS = 22;
78 const float ETAMIN = -0.5;
79 const float ETAMAX = 21.5;
80 
81 // TPG
82 const unsigned int TPPHIBINS = 72;
83 const float TPPHIMIN = 0.5;
84 const float TPPHIMAX = 72.5;
85 
86 const unsigned int TPETABINS = 65;
87 const float TPETAMIN = -32.5;
88 const float TPETAMAX = 32.5;
89 
91  : rctSourceEm_token_(consumes<L1CaloEmCollection>(ps.getParameter<InputTag>("rctSource"))),
92  rctSourceRctEmRgn_token_(consumes<L1CaloRegionCollection>(ps.getParameter<InputTag>("rctSource"))),
93  rctSource_(ps.getParameter<InputTag>("rctSource")),
94  gctSource_(ps.getParameter<InputTag>("gctSource")),
95  ecalTpgSource_(ps.getParameter<edm::InputTag>("ecalTpgSource")),
96  ecalTpgSource_token_(consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("ecalTpgSource")))
97 
98 {
99  // verbosity switch
100  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
101 
102  if (verbose())
103  std::cout << "L1TCompare: constructor...." << std::endl;
104 
105  outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
106  if (!outputFile_.empty()) {
107  std::cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << std::endl;
108  }
109 
110  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
111  if (disable) {
112  outputFile_ = "";
113  }
114 
115  //set Token(-s)
116  edm::InputTag gctCenJetsTag_(gctSource_.label(), "cenJets");
117  edm::InputTag gctIsoEmCandsTag_(gctSource_.label(), "isoEm");
118  edm::InputTag gctNonIsoEmCandsTag_(gctSource_.label(), "nonIsoEm");
119 
120  gctCenJetsToken_ = consumes<L1GctJetCandCollection>(gctCenJetsTag_);
121  gctIsoEmCandsToken_ = consumes<L1GctEmCandCollection>(gctIsoEmCandsTag_);
122  gctNonIsoEmCandsToken_ = consumes<L1GctEmCandCollection>(gctNonIsoEmCandsTag_);
123 }
124 
126 
128  //
129 }
130 
131 void L1TCompare::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
132  nev_ = 0;
133 
134  ibooker.setCurrentFolder("L1T/Compare");
135 
136  // -------------------------------------------
137  // RCT-GCT
138  // -------------------------------------------
139  // Isolated
141  ibooker.book2D("rctGctLeadingIsoEmRank", "RCT-GCT: rank", R6BINS, R6MIN, R6MAX, R6BINS, R6MIN, R6MAX);
145  ibooker.book2D("rctGctLeadingIsoEmEta", "RCT-GCT: #eta", ETABINS, ETAMIN, ETAMAX, ETABINS, ETAMIN, ETAMAX);
148 
150  ibooker.book2D("rctGctLeadingIsoEmPhi", "RCT-GCT: #phi", PHIBINS, PHIMIN, PHIMAX, PHIBINS, PHIMIN, PHIMAX);
153  // non-Isolated
155  ibooker.book2D("rctGctLeadingNonIsoEmRank", "RCT-GCT: rank", R6BINS, R6MIN, R6MAX, R6BINS, R6MIN, R6MAX);
158 
160  ibooker.book2D("rctGctLeadingNonIsoEmEta", "RCT-GCT: #eta", ETABINS, ETAMIN, ETAMAX, ETABINS, ETAMIN, ETAMAX);
163 
165  ibooker.book2D("rctGctLeadingNonIsoEmPhi", "RCT-GCT: #phi", PHIBINS, PHIMIN, PHIMAX, PHIBINS, PHIMIN, PHIMAX);
168  // -------------------------------------------
169  // ECAL TPG - RCT
170  // -------------------------------------------
172  ibooker.book2D("ecalTpgRctLeadingEmRank", "ECAL TPG-RCT: rank", R6BINS, R6MIN, R6MAX, R6BINS, R6MIN, R6MAX);
175 
177  ibooker.book2D("ecalTpgRctLeadingEmEta", "ECAL TPG-RCT: #eta", 15, -0.5, 14.5, TPETABINS, TPETAMIN, TPETAMAX);
181  ibooker.book2D("ecalTpgRctLeadingEmEta2", "ECAL TPG-RCT: #eta (2)", 13, -6.5, 6.5, TPETABINS, TPETAMIN, TPETAMAX);
185  "ecalTpgRctLeadingEmPhi", "ECAL TPG-RCT: #phi", PHIBINS, PHIMIN, PHIMAX, TPPHIBINS, TPPHIMIN, TPPHIMAX);
188  //}
189 }
190 
191 void L1TCompare::analyze(const Event& e, const EventSetup& c) {
192  ++nev_;
193  if (verbose()) {
194  std::cout << "L1TCompare: analyze...." << std::endl;
195  }
196 
197  // L1E
203  // edm::Handle < L1EtMissParticle > l1eEtMiss;
205  // RCT
206  edm::Handle<L1CaloEmCollection> em; // collection of L1CaloEmCands
208 
209  // GCT
212  edm::Handle<L1GctEmCandCollection> gctNonIsoEmCands;
213 
214  e.getByToken(rctSourceEm_token_, em);
215 
216  if (!em.isValid()) {
217  edm::LogInfo("DataNotFound") << "can't find L1CaloEmCollection with label " << rctSource_.label();
218  return;
219  }
220 
221  e.getByToken(rctSourceRctEmRgn_token_, rctEmRgn);
222 
223  if (!rctEmRgn.isValid()) {
224  edm::LogInfo("DataNotFound") << "can't find "
225  << "L1CaloRegionCollection with label " << rctSource_.label();
226  return;
227  }
228 
229  e.getByToken(gctCenJetsToken_, gctCenJets);
230  e.getByToken(gctIsoEmCandsToken_, gctIsoEmCands);
231  e.getByToken(gctNonIsoEmCandsToken_, gctNonIsoEmCands);
232 
233  if (!gctCenJets.isValid()) {
234  std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
235  return;
236  }
237  if (!gctIsoEmCands.isValid()) {
238  std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
239  return;
240  }
241  if (!gctNonIsoEmCands.isValid()) {
242  std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
243  return;
244  }
245 
246  // GCT
247  if (verbose()) {
248  for (L1GctEmCandCollection::const_iterator iem = gctIsoEmCands->begin(); iem != gctIsoEmCands->end(); ++iem) {
249  if (!iem->empty())
250  std::cout << "GCT EM: " << iem->rank() << ", " << iem->etaIndex()
251  << "("
252  //<< int(iem->etaIndex()&0x3)*((iem->etaIndex()&0x4)?1:-1)
253  << "), " << iem->phiIndex() << std::endl;
254  }
255  }
256  // rct phi: 0-17
257  // rct eta: 0-21
258 
259  // Fill the RCT histograms
260 
261  // Regions
262  RctObjectCollection rcj, rcj_iso, rcj_non_iso;
263  for (L1CaloEmCollection::const_iterator iem = em->begin(); iem != em->end(); ++iem) {
264  // L1CaloRegionDetId id(false, iem->rctCrate(), iem->rctCard(),
265  // iem->rctRegion());
266  L1CaloRegionDetId id(iem->rctCrate(), iem->rctCard(), iem->rctRegion());
267 
268  // RctObject h(id.gctEta(), id.gctPhi(), iem->rank());
269  RctObject h(id.rctEta(), id.rctPhi(), iem->rank());
270  if (!iem->isolated())
271  rcj_non_iso.push_back(h);
272  else
273  rcj_iso.push_back(h);
274  rcj.push_back(h);
275  }
276  // not so smart but ...
277  std::sort(rcj.begin(), rcj.end(), rctObjectComp);
278  std::sort(rcj_non_iso.begin(), rcj_non_iso.end(), rctObjectComp);
279  std::sort(rcj_iso.begin(), rcj_iso.end(), rctObjectComp);
280  if (verbose()) {
281  for (RctObjectCollection::reverse_iterator ij = rcj_iso.rbegin();
282  ij != rcj_iso.rend() && ij != rcj_iso.rbegin() + 8;
283  ++ij) {
284  std::cout << "RCT cj: " << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_ << std::endl;
285  }
286  }
287  L1GctEmCandCollection::const_iterator lead_em = gctIsoEmCands->begin();
288  if (!lead_em->empty()) { // equivalent to rank == 0
289  rctGctLeadingIsoEmEta_->Fill(lead_em->etaIndex(), rcj_iso.rbegin()->eta_);
290  rctGctLeadingIsoEmPhi_->Fill(lead_em->phiIndex(), rcj_iso.rbegin()->phi_);
291  rctGctLeadingIsoEmRank_->Fill(lead_em->rank(), rcj_iso.rbegin()->rank_);
292  }
293 
294  // non-isolated
295  if (verbose()) {
296  for (L1GctEmCandCollection::const_iterator iem = gctNonIsoEmCands->begin(); iem != gctNonIsoEmCands->end(); ++iem) {
297  if (!iem->empty())
298  std::cout << "GCT EM non: " << iem->rank() << ", "
299  << iem->etaIndex() //<< "("
300  //<< int(iem->etaIndex()&0x3)*((iem->etaIndex()&0x4)?1:-1)
301  //<< ")"
302  << ", " << iem->phiIndex() << std::endl;
303  }
304  }
305  if (verbose()) {
306  for (RctObjectCollection::reverse_iterator ij = rcj_non_iso.rbegin();
307  ij != rcj_non_iso.rend() && ij != rcj_non_iso.rbegin() + 8;
308  ++ij) {
309  std::cout << "RCT cj non: " << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_ << std::endl;
310  }
311  }
312  lead_em = gctNonIsoEmCands->begin();
313  if (!lead_em->empty()) { // equivalent to rank != 0
314  rctGctLeadingNonIsoEmEta_->Fill(lead_em->etaIndex(), rcj_non_iso.rbegin()->eta_);
315  rctGctLeadingNonIsoEmPhi_->Fill(lead_em->phiIndex(), rcj_non_iso.rbegin()->phi_);
316  rctGctLeadingNonIsoEmRank_->Fill(lead_em->rank(), rcj_non_iso.rbegin()->rank_);
317  }
318 
319  // ECAL TPG's to RCT EM
321  e.getByToken(ecalTpgSource_token_, eTP);
322 
323  if (!eTP.isValid()) {
324  edm::LogInfo("DataNotFound") << "can't find EcalTrigPrimCollection with label " << ecalTpgSource_.label();
325  return;
326  }
327  RctObjectCollection ecalobs;
328  for (EcalTrigPrimDigiCollection::const_iterator ieTP = eTP->begin(); ieTP != eTP->end(); ieTP++) {
329  ecalobs.push_back(RctObject(ieTP->id().ieta(), ieTP->id().iphi(), ieTP->compressedEt()));
330  }
331  std::sort(ecalobs.begin(), ecalobs.end(), rctObjectComp);
332  if (verbose()) {
333  for (RctObjectCollection::reverse_iterator ij = ecalobs.rbegin();
334  ij != ecalobs.rend() && ij != ecalobs.rbegin() + 8;
335  ++ij) {
336  std::cout << "ECAL cj : " << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_ << std::endl;
337  }
338  }
339  // abritrary cut
340  if (rcj.rbegin()->rank_ > 4) {
341  ecalTpgRctLeadingEmEta_->Fill(rcj.rbegin()->eta_, ecalobs.rbegin()->eta_);
342  int e2 = (rcj.rbegin()->eta_ & 0x7UL) * ((rcj.rbegin()->eta_ & 0x8UL) ? 1 : -1);
343  ecalTpgRctLeadingEmEta2_->Fill(e2, ecalobs.rbegin()->eta_);
344  ecalTpgRctLeadingEmPhi_->Fill(rcj.rbegin()->phi_, ecalobs.rbegin()->phi_);
345  ecalTpgRctLeadingEmRank_->Fill(rcj.rbegin()->rank_, ecalobs.rbegin()->rank_);
346  }
347  if (verbose()) {
348  int seta = rcj.rbegin()->eta_;
349  seta = (seta & 0x7UL) * (seta & 0x8 ? -1 : 1);
350  std::cout << "ZZ: " << rcj.rbegin()->eta_ << " " << rcj.rbegin()->phi_ << " " << rcj.rbegin()->rank_ << " "
351  << (++rcj.rbegin())->rank_ << " " << ecalobs.rbegin()->eta_ << " " << ecalobs.rbegin()->phi_ << " "
352  << ecalobs.rbegin()->rank_ << " " << (++ecalobs.rbegin())->rank_ << " " << seta << " " << std::endl;
353  }
354 }
ETAMIN
const float ETAMIN
Definition: L1TCompare.cc:78
L1TCompare::rctSourceEm_token_
edm::EDGetTokenT< L1CaloEmCollection > rctSourceEm_token_
Definition: L1TCompare.h:104
L1TCompare::rctGctLeadingNonIsoEmEta_
MonitorElement * rctGctLeadingNonIsoEmEta_
Definition: L1TCompare.h:87
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
L1TCompare::RctObjectCollection
std::vector< L1TCompare::RctObject > RctObjectCollection
Definition: L1TCompare.h:123
R6MIN
const float R6MIN
Definition: L1TCompare.cc:72
TPPHIMAX
const float TPPHIMAX
Definition: L1TCompare.cc:84
edm::Run
Definition: Run.h:45
L1TCompare::bookHistograms
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override
Definition: L1TCompare.cc:131
edm
HLT enums.
Definition: AlignableModifier.h:19
L1TCompare::rctGctLeadingIsoEmPhi_
MonitorElement * rctGctLeadingIsoEmPhi_
Definition: L1TCompare.h:84
R6BINS
const unsigned int R6BINS
Definition: L1TCompare.cc:71
L1TCompare::nev_
int nev_
Definition: L1TCompare.h:97
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1TCompare::gctCenJetsToken_
edm::EDGetTokenT< L1GctJetCandCollection > gctCenJetsToken_
Definition: L1TCompare.h:112
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
L1TCompare::ecalTpgSource_token_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTpgSource_token_
Definition: L1TCompare.h:109
edm::SortedCollection
Definition: SortedCollection.h:49
L1TCompare::ecalTpgSource_
edm::InputTag ecalTpgSource_
Definition: L1TCompare.h:108
L1TCompare::rctGctLeadingNonIsoEmPhi_
MonitorElement * rctGctLeadingNonIsoEmPhi_
Definition: L1TCompare.h:88
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
h
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::Handle
Definition: AssociativeIterator.h:50
L1TCompare::gctIsoEmCandsToken_
edm::EDGetTokenT< L1GctEmCandCollection > gctIsoEmCandsToken_
Definition: L1TCompare.h:113
L1TCompare::verbose
bool verbose() const
Definition: L1TCompare.h:100
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
TPPHIBINS
const unsigned int TPPHIBINS
Definition: L1TCompare.cc:82
L1TCompare::ecalTpgRctLeadingEmPhi_
MonitorElement * ecalTpgRctLeadingEmPhi_
Definition: L1TCompare.h:94
TPPHIMIN
const float TPPHIMIN
Definition: L1TCompare.cc:83
L1TCompare::RctObject
Definition: L1TCompare.h:116
L1CaloEmCollection
std::vector< L1CaloEmCand > L1CaloEmCollection
Definition: L1CaloCollections.h:10
h
L1TCompare::outputFile_
std::string outputFile_
Definition: L1TCompare.h:98
L1TCompare::ecalTpgRctLeadingEmEta_
MonitorElement * ecalTpgRctLeadingEmEta_
Definition: L1TCompare.h:92
L1CaloRegionDetId
Definition: L1CaloRegionDetId.h:18
L1TCompare::gctNonIsoEmCandsToken_
edm::EDGetTokenT< L1GctEmCandCollection > gctNonIsoEmCandsToken_
Definition: L1TCompare.h:114
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
L1TCompare::rctGctLeadingNonIsoEmRank_
MonitorElement * rctGctLeadingNonIsoEmRank_
Definition: L1TCompare.h:89
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
L1TCompare::rctGctLeadingIsoEmRank_
MonitorElement * rctGctLeadingIsoEmRank_
Definition: L1TCompare.h:85
L1TCompare::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: L1TCompare.cc:191
L1TCompare::rctSourceRctEmRgn_token_
edm::EDGetTokenT< L1CaloRegionCollection > rctSourceRctEmRgn_token_
Definition: L1TCompare.h:105
edm::ParameterSet
Definition: ParameterSet.h:47
L1TCompare::~L1TCompare
~L1TCompare() override
Definition: L1TCompare.cc:125
L1TCompare::L1TCompare
L1TCompare(const edm::ParameterSet &ps)
Definition: L1TCompare.cc:90
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
L1TCompare::dqmBeginRun
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: L1TCompare.cc:127
TPETAMAX
const float TPETAMAX
Definition: L1TCompare.cc:88
L1TCompare.h
PHIBINS
const unsigned int PHIBINS
Definition: L1TCompare.cc:66
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
R6MAX
const float R6MAX
Definition: L1TCompare.cc:73
L1TCompare::ecalTpgRctLeadingEmRank_
MonitorElement * ecalTpgRctLeadingEmRank_
Definition: L1TCompare.h:95
L1TCompare::verbose_
bool verbose_
Definition: L1TCompare.h:99
L1CaloRegionCollection
std::vector< L1CaloRegion > L1CaloRegionCollection
Definition: L1CaloCollections.h:11
L1TCompare::rctGctLeadingIsoEmEta_
MonitorElement * rctGctLeadingIsoEmEta_
Definition: L1TCompare.h:83
ETABINS
const unsigned int ETABINS
Definition: L1TCompare.cc:77
L1TCompare::rctSource_
edm::InputTag rctSource_
Definition: L1TCompare.h:106
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
PHIMAX
const float PHIMAX
Definition: L1TCompare.cc:68
TPETABINS
const unsigned int TPETABINS
Definition: L1TCompare.cc:86
ETAMAX
const float ETAMAX
Definition: L1TCompare.cc:79
L1TCompare::ecalTpgRctLeadingEmEta2_
MonitorElement * ecalTpgRctLeadingEmEta2_
Definition: L1TCompare.h:93
dqm::implementation::IBooker
Definition: DQMStore.h:43
TPETAMIN
const float TPETAMIN
Definition: L1TCompare.cc:87
L1TCompare::gctSource_
edm::InputTag gctSource_
Definition: L1TCompare.h:107
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
l1extra
Definition: L1EmParticle.h:26
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
L1TCompare::rctObjectComp
static bool rctObjectComp(const RctObject &a, const RctObject &b)
Definition: L1TCompare.h:128
edm::Event
Definition: Event.h:73
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:791
edm::InputTag
Definition: InputTag.h:15
PHIMIN
const float PHIMIN
Definition: L1TCompare.cc:67
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37