CMS 3D CMS Logo

CSCTriggerPrimitivesReader.h
Go to the documentation of this file.
1 #ifndef L1Trigger_CSCTriggerPrimitives_CSCTriggerPrimitivesReader_h
2 #define L1Trigger_CSCTriggerPrimitives_CSCTriggerPrimitivesReader_h
3 
21 
30 
32 
34 
35 #include <TH1.h>
36 #include <TH2.h>
37 #include <TTree.h>
38 #include <sstream>
39 #define MAXSTUBS 100
40 
41 class CSCGeometry;
42 class CSCBadChambers;
43 class TFile;
44 
45 struct TreePerStub {
46  void init(int run, int event); // initialize to default values
47  TTree *bookTree(TTree *t, const std::string &name = "TreePerStub");
48 
50  Int_t t_RUN;
51  Int_t t_Event;
52  Int_t t_nStubs;
53  Int_t t_nStubs_readout; //only for emulation
57 
58  Int_t t_chamber;
59  Int_t t_ring;
60  Int_t t_endcap;
61  Int_t t_station;
63 };
64 
66  void init(int run, int event); // initialize to default values
67  TTree *bookTree(TTree *t, const std::string &name = "Stub_compare");
68 
69  Int_t nEvents;
70  Int_t nRUN;
71  Int_t nEvent;
72  Bool_t firstfill;
76  Int_t nStub_data;
77  Int_t nStub_emul;
78  Int_t chamber;
79  Int_t ring;
80  Int_t endcap;
81  Int_t station;
82  Int_t chambertype;
83  Bool_t has_data;
84  Bool_t has_emul;
85 
86  Int_t quality_data;
87  Int_t bend_data;
88  Int_t bx_data;
89  Int_t quality_emul;
90  Int_t bend_emul;
91  Int_t bx_emul;
92  Int_t bx_corr_emul; //corrected
93  Int_t npretrig;
96  Int_t bend_pretrig;
97  Int_t bx_pretrig;
101  Int_t fullbx_data;
102  Int_t fullbx_emul;
107  Int_t key_WG_data;
108  Int_t key_WG_emul;
109  Int_t key_hs_data;
110  Int_t key_hs_emul;
111  Int_t trknmb_data;
112  Int_t trknmb_emul;
113  Float_t dphi_data;
114  Float_t dphi_emul;
115  Float_t eta_data;
116  Float_t eta_emul;
117  Float_t phi_data;
118  Float_t phi_emul;
119 };
120 
122 public:
124  explicit CSCTriggerPrimitivesReader(const edm::ParameterSet &conf);
125 
127  ~CSCTriggerPrimitivesReader() override;
128 
130  void analyze(const edm::Event &event, const edm::EventSetup &setup) override;
131 
133  void endJob() override;
134 
135  int chamberSerial(CSCDetId id);
136  int chamberIX(CSCDetId id);
137  int chamberIXi(CSCDetId id);
138  void HotWires(const edm::Event &iEvent);
139 
140 private:
141  int eventsAnalyzed; // event number
142  bool debug; // on/off switch
143  std::string rootFileName; // root file name
144 
145  // Run number, Event number
146  int RUN_;
147  int Event_;
148 
149  // Cache geometry for current event
151 
152  // Cache conditions data for bad chambers
154 
155  // Define which LCTs are present in the input file. This will determine the
156  // workflow of the Reader.
159 
161 
162  // Flag to plot or not plot ME1/A as a separate chamber.
163  bool plotME1A;
164 
165  // Flag to plot or not plot ME4/2.
166  bool plotME42;
167 
168  // Producer's labels
175 
179 
189 
190  // a prefix for results ps files
192 
193  // whether to perform check against known "bad chambers" list
195 
196  // not data vs. mc, but mc vs mc
198 
199  // The file which will store the histos
200  // TFile *theFile;
201 
202  enum trig_cscs { MAX_ENDCAPS = 2, MAX_STATIONS = 4, CSC_TYPES = 10 };
203  enum { MAXPAGES = 20 }; // max. number of pages in postscript files
204  static const double TWOPI; // 2.*pi
205 
206  // Various useful constants
207  static const std::string csc_type[CSC_TYPES];
208  static const std::string csc_type_plus[CSC_TYPES];
209  static const std::string csc_type_minus[CSC_TYPES];
210  static const int NCHAMBERS[CSC_TYPES];
211  static const int MAX_WG[CSC_TYPES];
212  static const int MAX_HS[CSC_TYPES];
213  static const int ptype_TMB07[CSCConstants::NUM_CLCT_PATTERNS];
214 
215  static const int lut_wg_vs_hs_me1b[48][2];
216  static const int lut_wg_vs_hs_me1a[48][2];
217  static const int lut_wg_vs_hs_me1ag[48][2];
218  // LCT counters
219  static int numALCT;
220  static int numCLCT;
221  static int numLCTTMB;
222  static int numLCTMPC;
223 
224  static bool bookedHotWireHistos;
225  static bool bookedALCTHistos;
226  static bool bookedCLCTHistos;
227  static bool bookedLCTTMBHistos;
228  static bool bookedLCTMPCHistos;
229 
230  static bool bookedCompHistos;
231 
232  static bool bookedResolHistos;
233  static bool bookedEfficHistos;
234 
235  static bool printps;
236 
237  void setRootStyle();
238 
239  void bookHotWireHistos();
240  void bookALCTHistos();
241  void bookCLCTHistos();
242  void bookLCTTMBHistos();
243  void bookLCTMPCHistos();
244  void fillALCTHistos(const CSCALCTDigiCollection *alcts);
245  void fillCLCTHistos(const CSCCLCTDigiCollection *clcts);
246  void fillLCTTMBHistos(const CSCCorrelatedLCTDigiCollection *lcts);
247  void fillLCTMPCHistos(const CSCCorrelatedLCTDigiCollection *lcts);
248  void drawALCTHistos();
249  void drawCLCTHistos();
250  void drawLCTTMBHistos();
251  void drawLCTMPCHistos();
252 
253  void bookResolHistos();
254  void drawResolHistos();
255  void bookEfficHistos();
256  void drawEfficHistos();
257  void drawHistosForTalks();
258 
259  GlobalPoint getGlobalPosition(unsigned int rawId, int keWg, int keyHS) const;
260  bool doesALCTCrossCLCT(CSCDetId id, int key_wg, int key_hs) const;
261  int getCSCType(const CSCDetId &id);
262  double getHsPerRad(const int idh);
263 
264  void compare(const CSCALCTDigiCollection *alcts_data,
265  const CSCALCTDigiCollection *alcts_emul,
266  const CSCCLCTDigiCollection *clcts_data,
267  const CSCCLCTDigiCollection *clcts_emul,
268  const CSCCLCTPreTriggerDigiCollection *pretrigs_emul,
269  const CSCCorrelatedLCTDigiCollection *lcts_data,
270  const CSCCorrelatedLCTDigiCollection *lcts_emul); //,
271  //const CSCCorrelatedLCTDigiCollection* mpclcts_data,
272  //const CSCCorrelatedLCTDigiCollection* mpclcts_emul);
273  void bookCompHistos();
274  void compareALCTs(const CSCALCTDigiCollection *alcts_data, const CSCALCTDigiCollection *alcts_emul);
275  void compareCLCTs(const CSCCLCTDigiCollection *clcts_data,
276  const CSCCLCTDigiCollection *clcts_emul,
277  const CSCCLCTPreTriggerDigiCollection *pretrigs_emul);
278  void compareLCTs(const CSCCorrelatedLCTDigiCollection *lcts_data,
279  const CSCCorrelatedLCTDigiCollection *lcts_emul,
280  const CSCALCTDigiCollection *alcts_data,
281  const CSCCLCTDigiCollection *clcts_data);
282  void compareMPCLCTs(const CSCCorrelatedLCTDigiCollection *lcts_data,
283  const CSCCorrelatedLCTDigiCollection *lcts_emul,
284  const CSCALCTDigiCollection *alcts_data,
285  const CSCCLCTDigiCollection *clcts_data);
286  int convertBXofLCT(const int emul_bx,
287  const CSCDetId &detid,
288  const CSCALCTDigiCollection *alcts_data,
289  const CSCCLCTDigiCollection *clcts_data);
290  void drawCompHistos();
291 
292  void MCStudies(const edm::Event &ev, const CSCALCTDigiCollection *alcts, const CSCCLCTDigiCollection *clcts);
293 
294  void calcResolution(const CSCALCTDigiCollection *alcts,
295  const CSCCLCTDigiCollection *clcts,
296  const CSCWireDigiCollection *wiredc,
297  const CSCComparatorDigiCollection *compdc,
298  const edm::PSimHitContainer &allSimHits);
299 
300  void calcEfficiency(const CSCALCTDigiCollection *alcts,
301  const CSCCLCTDigiCollection *clcts,
302  const edm::PSimHitContainer &allSimHits);
303 
304  int maxRing(int station);
305 
306  //fill 3 Trees
307  MyStubComparison stubs_comparison[4];
308  TTree *stub_tree[4];
309  //fill 3 Trees: alct, clct, lct for data and emul
310  TreePerStub perStub[6];
311  TTree *event_tree[6];
312 
313  // Histograms
314  //Hot wires
315  TH1F *hHotWire1, *hHotCham1;
316 
317  // ALCTs, data
318  TH1F *hAlctPerEvent, *hAlctPerChamber, *hAlctPerCSC;
319  TH1F *hAlctCsc[MAX_ENDCAPS][CSC_TYPES];
320  TH1F *hAlctValid, *hAlctQuality, *hAlctAccel, *hAlctCollis, *hAlctKeyGroup;
321  TH1F *hAlctBXN;
322  // CLCTs
323  TH1F *hClctPerEvent, *hClctPerChamber, *hClctPerCSC;
324  TH1F *hClctCsc[MAX_ENDCAPS][CSC_TYPES];
325  TH1F *hClctValid, *hClctQuality, *hClctStripType, *hClctSign, *hClctCFEB;
326  TH1F *hClctBXN;
327  TH1F *hClctKeyStrip[2], *hClctPattern[2];
328  TH1F *hClctBendCsc[CSC_TYPES][2], *hClctKeyStripCsc[CSC_TYPES];
329  // Correlated LCTs in TMB
330  TH1F *hLctTMBPerEvent, *hLctTMBPerChamber;
331  TH1F *hLctTMBPerCSC, *hCorrLctTMBPerCSC;
332  TH1F *hLctTMBEndcap, *hLctTMBStation, *hLctTMBSector, *hLctTMBRing;
333  TH1F *hLctTMBChamber[MAX_STATIONS], *hLctTMBCsc[MAX_ENDCAPS][CSC_TYPES];
334  TH1F *hLctTMBValid, *hLctTMBQuality, *hLctTMBKeyGroup;
335  TH1F *hLctTMBKeyStrip, *hLctTMBStripType;
336  TH1F *hLctTMBPattern, *hLctTMBBend, *hLctTMBBXN;
337  // Correlated LCTs in MPC
338  TH1F *hLctMPCPerEvent, *hLctMPCPerCSC, *hCorrLctMPCPerCSC;
339  TH1F *hLctMPCEndcap, *hLctMPCStation, *hLctMPCSector, *hLctMPCRing;
340  TH1F *hLctMPCChamber[MAX_STATIONS];
341  TH1F *hLctMPCValid, *hLctMPCQuality, *hLctMPCKeyGroup;
342  TH1F *hLctMPCKeyStrip, *hLctMPCStripType;
343  TH1F *hLctMPCPattern, *hLctMPCBend, *hLctMPCBXN;
344 
345  //Chad's hists
346 
351 
356 
361 
366 
375 
380 
385 
390 
395 
400 
405 
406  // Histograms for firmware-emulator comparisons
407  // ALCTs
408  TH1F *hAlctCompFoundCsc[MAX_ENDCAPS][CSC_TYPES];
409  TH1F *hAlctCompSameNCsc[MAX_ENDCAPS][CSC_TYPES];
410  TH1F *hAlctCompTotalCsc[MAX_ENDCAPS][CSC_TYPES];
411  TH1F *hAlctCompMatchCsc[MAX_ENDCAPS][CSC_TYPES];
412  // CLCTs
413  TH1F *hClctCompFoundCsc[MAX_ENDCAPS][CSC_TYPES];
414  TH1F *hClctCompSameNCsc[MAX_ENDCAPS][CSC_TYPES];
415  TH1F *hClctCompTotalCsc[MAX_ENDCAPS][CSC_TYPES];
416  TH1F *hClctCompMatchCsc[MAX_ENDCAPS][CSC_TYPES];
417  // Correlated LCTs
418  TH1F *hLctCompFoundCsc[MAX_ENDCAPS][CSC_TYPES];
419  TH1F *hLctCompSameNCsc[MAX_ENDCAPS][CSC_TYPES];
420  TH1F *hLctCompTotalCsc[MAX_ENDCAPS][CSC_TYPES];
421  TH1F *hLctCompMatchCsc[MAX_ENDCAPS][CSC_TYPES];
422 
423  // Resolution histograms
424  // ALCT
426  TH1F *hResolDeltaWG, *hResolDeltaEta;
427  TH1F *hAlctVsEta[MAX_STATIONS];
428  TH1F *hEtaDiffVsEta[MAX_STATIONS];
429  TH1F *hEtaDiffCsc[CSC_TYPES][3];
430  TH2F *hEtaDiffVsWireCsc[CSC_TYPES];
431  // CLCT
433  TH1F *hResolDeltaHS, *hResolDeltaDS;
434  TH1F *hResolDeltaPhi, *hResolDeltaPhiHS, *hResolDeltaPhiDS;
435  TH1F *hClctVsPhi[MAX_STATIONS];
436  TH1F *hPhiDiffVsPhi[MAX_STATIONS];
437  TH1F *hPhiDiffCsc[CSC_TYPES][5];
438  TH2F *hPhiDiffVsStripCsc[CSC_TYPES][2];
439  TH1F *hTrueBendCsc[CSC_TYPES];
440  TH1F *hPhiDiffPattern[CSCConstants::NUM_CLCT_PATTERNS];
441  // Efficiency histograms
442  TH1F *hEfficHitsEta[MAX_STATIONS];
443  TH1F *hEfficALCTEta[MAX_STATIONS], *hEfficCLCTEta[MAX_STATIONS];
444  TH1F *hEfficHitsEtaCsc[CSC_TYPES];
445  TH1F *hEfficALCTEtaCsc[CSC_TYPES], *hEfficCLCTEtaCsc[CSC_TYPES];
446 
453 };
454 
455 #endif
bool compare(const P &i, const P &j)
edm::EDGetTokenT< CSCALCTDigiCollection > alcts_e_token_
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > lcts_tmb_e_token_
edm::EDGetTokenT< CSCWireDigiCollection > wireDigi_token_
bool ev
void init(int run, int event)
edm::EDGetTokenT< CSCCLCTDigiCollection > clcts_e_token_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
list CSC_TYPES
Definition: mutypes.py:7
TTree * bookTree(TTree *t, const std::string &name="TreePerStub")
edm::EDGetTokenT< CSCALCTDigiCollection > alcts_d_token_
edm::EDGetTokenT< CSCComparatorDigiCollection > compDigi_token_
edm::EDGetTokenT< CSCCLCTDigiCollection > clcts_d_token_
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > lcts_mpc_e_token_
edm::EDGetTokenT< edm::PSimHitContainer > simHit_token_
std::vector< PSimHit > PSimHitContainer
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > lcts_mpc_d_token_
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > lcts_tmb_d_token_
Definition: event.py:1
edm::EDGetTokenT< CSCCLCTPreTriggerDigiCollection > pretrigs_e_token_
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...