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 
65 
67  void init(int run, int event); // initialize to default values
68  TTree *bookTree(TTree *t, const std::string & name = "Stub_compare");
69 
70  Int_t nEvents;
71  Int_t nRUN;
72  Int_t nEvent;
73  Bool_t firstfill;
77  Int_t nStub_data;
78  Int_t nStub_emul;
79  Int_t chamber;
80  Int_t ring;
81  Int_t endcap;
82  Int_t station;
83  Int_t chambertype;
84  Bool_t has_data;
85  Bool_t has_emul;
86 
87  Int_t quality_data;
88  Int_t bend_data;
89  Int_t bx_data;
90  Int_t quality_emul;
91  Int_t bend_emul;
92  Int_t bx_emul;
93  Int_t bx_corr_emul;//corrected
94  Int_t npretrig;
97  Int_t bend_pretrig;
98  Int_t bx_pretrig;
102  Int_t fullbx_data;
103  Int_t fullbx_emul;
108  Int_t key_WG_data;
109  Int_t key_WG_emul;
110  Int_t key_hs_data;
111  Int_t key_hs_emul;
112  Int_t trknmb_data;
113  Int_t trknmb_emul;
114  Float_t dphi_data;
115  Float_t dphi_emul;
116  Float_t eta_data;
117  Float_t eta_emul;
118  Float_t phi_data;
119  Float_t phi_emul;
120 };
121 
123 {
124  public:
126  explicit CSCTriggerPrimitivesReader(const edm::ParameterSet& conf);
127 
129  virtual ~CSCTriggerPrimitivesReader();
130 
132  void analyze(const edm::Event& event, const edm::EventSetup& setup);
133 
135  void endJob();
136 
137  int chamberSerial( CSCDetId id );
138  int chamberIX( CSCDetId id );
139  int chamberIXi( CSCDetId id );
140  void HotWires(const edm::Event& iEvent);
141 
142  private:
143  int eventsAnalyzed; // event number
144  bool debug; // on/off switch
145  std::string rootFileName; // root file name
146 
147  // Run number, Event number
148  int RUN_;
149  int Event_;
150 
151  // Cache geometry for current event
153 
154  // Cache conditions data for bad chambers
156 
157  // Define which LCTs are present in the input file. This will determine the
158  // workflow of the Reader.
161 
163 
164  // Flag to plot or not plot ME1/A as a separate chamber.
165  bool plotME1A;
166 
167  // Flag to plot or not plot ME4/2.
168  bool plotME42;
169 
170  // Producer's labels
177 
181 
191 
192  // a prefix for results ps files
194 
195  // whether to perform check against known "bad chambers" list
197 
198  // not data vs. mc, but mc vs mc
200 
201 
202  // The file which will store the histos
203  // TFile *theFile;
204 
205  enum trig_cscs {MAX_ENDCAPS = 2, MAX_STATIONS = 4, CSC_TYPES = 10};
206  enum {MAXPAGES = 20}; // max. number of pages in postscript files
207  static const double TWOPI; // 2.*pi
208 
209  // Various useful constants
210  static const std::string csc_type[CSC_TYPES];
211  static const std::string csc_type_plus[CSC_TYPES];
212  static const std::string csc_type_minus[CSC_TYPES];
213  static const int NCHAMBERS[CSC_TYPES];
214  static const int MAX_WG[CSC_TYPES];
215  static const int MAX_HS[CSC_TYPES];
216  static const int ptype_TMB07[CSCConstants::NUM_CLCT_PATTERNS];
217 
218  static const int lut_wg_vs_hs_me1b[48][2];
219  static const int lut_wg_vs_hs_me1a[48][2];
220  static const int lut_wg_vs_hs_me1ag[48][2];
221  // LCT counters
222  static int numALCT;
223  static int numCLCT;
224  static int numLCTTMB;
225  static int numLCTMPC;
226 
227  static bool bookedHotWireHistos;
228  static bool bookedALCTHistos;
229  static bool bookedCLCTHistos;
230  static bool bookedLCTTMBHistos;
231  static bool bookedLCTMPCHistos;
232 
233  static bool bookedCompHistos;
234 
235  static bool bookedResolHistos;
236  static bool bookedEfficHistos;
237 
238  static bool printps;
239 
240 
241  void setRootStyle();
242 
243  void bookHotWireHistos();
244  void bookALCTHistos();
245  void bookCLCTHistos();
246  void bookLCTTMBHistos();
247  void bookLCTMPCHistos();
248  void fillALCTHistos(const CSCALCTDigiCollection* alcts);
249  void fillCLCTHistos(const CSCCLCTDigiCollection* clcts);
250  void fillLCTTMBHistos(const CSCCorrelatedLCTDigiCollection* lcts);
251  void fillLCTMPCHistos(const CSCCorrelatedLCTDigiCollection* lcts);
252  void drawALCTHistos();
253  void drawCLCTHistos();
254  void drawLCTTMBHistos();
255  void drawLCTMPCHistos();
256 
257  void bookResolHistos();
258  void drawResolHistos();
259  void bookEfficHistos();
260  void drawEfficHistos();
261  void drawHistosForTalks();
262 
263  GlobalPoint getGlobalPosition(unsigned int rawId, int keWg, int keyHS) const;
264  bool doesALCTCrossCLCT(CSCDetId id, int key_wg, int key_hs) const;
265  int getCSCType(const CSCDetId& id);
266  double getHsPerRad(const int idh);
267 
268  void compare(const CSCALCTDigiCollection* alcts_data,
269  const CSCALCTDigiCollection* alcts_emul,
270  const CSCCLCTDigiCollection* clcts_data,
271  const CSCCLCTDigiCollection* clcts_emul,
272  const CSCCLCTPreTriggerDigiCollection* pretrigs_emul,
273  const CSCCorrelatedLCTDigiCollection* lcts_data,
274  const CSCCorrelatedLCTDigiCollection* lcts_emul);//,
275  //const CSCCorrelatedLCTDigiCollection* mpclcts_data,
276  //const CSCCorrelatedLCTDigiCollection* mpclcts_emul);
277  void bookCompHistos();
278  void compareALCTs(const CSCALCTDigiCollection* alcts_data,
279  const CSCALCTDigiCollection* alcts_emul);
280  void compareCLCTs(const CSCCLCTDigiCollection* clcts_data,
281  const CSCCLCTDigiCollection* clcts_emul,
282  const CSCCLCTPreTriggerDigiCollection* pretrigs_emul);
283  void compareLCTs(const CSCCorrelatedLCTDigiCollection* lcts_data,
284  const CSCCorrelatedLCTDigiCollection* lcts_emul,
285  const CSCALCTDigiCollection* alcts_data,
286  const CSCCLCTDigiCollection* clcts_data);
287  void compareMPCLCTs(const CSCCorrelatedLCTDigiCollection* lcts_data,
288  const CSCCorrelatedLCTDigiCollection* lcts_emul,
289  const CSCALCTDigiCollection* alcts_data,
290  const CSCCLCTDigiCollection* clcts_data);
291  int convertBXofLCT(const int emul_bx, const CSCDetId& detid,
292  const CSCALCTDigiCollection* alcts_data,
293  const CSCCLCTDigiCollection* clcts_data);
294  void drawCompHistos();
295 
296  void MCStudies(const edm::Event& ev,
297  const CSCALCTDigiCollection* alcts,
298  const CSCCLCTDigiCollection* clcts);
299 
300  void calcResolution(const CSCALCTDigiCollection* alcts,
301  const CSCCLCTDigiCollection* clcts,
302  const CSCWireDigiCollection* wiredc,
303  const CSCComparatorDigiCollection* compdc,
304  const edm::PSimHitContainer& allSimHits);
305 
306  void calcEfficiency(const CSCALCTDigiCollection* alcts,
307  const CSCCLCTDigiCollection* clcts,
308  const edm::PSimHitContainer& allSimHits);
309 
310  int maxRing(int station);
311 
312 
313  //fill 3 Trees
314  MyStubComparison stubs_comparison[4];
315  TTree *stub_tree[4];
316  //fill 3 Trees: alct, clct, lct for data and emul
317  TreePerStub perStub[6];
318  TTree *event_tree[6];
319 
320  // Histograms
321  //Hot wires
322  TH1F *hHotWire1, *hHotCham1;
323 
324  // ALCTs, data
325  TH1F *hAlctPerEvent, *hAlctPerChamber, *hAlctPerCSC;
326  TH1F *hAlctCsc[MAX_ENDCAPS][CSC_TYPES];
327  TH1F *hAlctValid, *hAlctQuality, *hAlctAccel, *hAlctCollis, *hAlctKeyGroup;
328  TH1F *hAlctBXN;
329  // CLCTs
330  TH1F *hClctPerEvent, *hClctPerChamber, *hClctPerCSC;
331  TH1F *hClctCsc[MAX_ENDCAPS][CSC_TYPES];
332  TH1F *hClctValid, *hClctQuality, *hClctStripType, *hClctSign, *hClctCFEB;
333  TH1F *hClctBXN;
334  TH1F *hClctKeyStrip[2], *hClctPattern[2];
335  TH1F *hClctBendCsc[CSC_TYPES][2], *hClctKeyStripCsc[CSC_TYPES];
336  // Correlated LCTs in TMB
337  TH1F *hLctTMBPerEvent, *hLctTMBPerChamber;
338  TH1F *hLctTMBPerCSC, *hCorrLctTMBPerCSC;
339  TH1F *hLctTMBEndcap, *hLctTMBStation, *hLctTMBSector, *hLctTMBRing;
340  TH1F *hLctTMBChamber[MAX_STATIONS], *hLctTMBCsc[MAX_ENDCAPS][CSC_TYPES];
341  TH1F *hLctTMBValid, *hLctTMBQuality, *hLctTMBKeyGroup;
342  TH1F *hLctTMBKeyStrip, *hLctTMBStripType;
343  TH1F *hLctTMBPattern, *hLctTMBBend, *hLctTMBBXN;
344  // Correlated LCTs in MPC
345  TH1F *hLctMPCPerEvent, *hLctMPCPerCSC, *hCorrLctMPCPerCSC;
346  TH1F *hLctMPCEndcap, *hLctMPCStation, *hLctMPCSector, *hLctMPCRing;
347  TH1F *hLctMPCChamber[MAX_STATIONS];
348  TH1F *hLctMPCValid, *hLctMPCQuality, *hLctMPCKeyGroup;
349  TH1F *hLctMPCKeyStrip, *hLctMPCStripType;
350  TH1F *hLctMPCPattern, *hLctMPCBend, *hLctMPCBXN;
351 
352  //Chad's hists
353 
358 
363 
368 
373 
382 
387 
392 
397 
402 
407 
412 
413  // Histograms for firmware-emulator comparisons
414  // ALCTs
415  TH1F *hAlctCompFoundCsc[MAX_ENDCAPS][CSC_TYPES];
416  TH1F *hAlctCompSameNCsc[MAX_ENDCAPS][CSC_TYPES];
417  TH1F *hAlctCompTotalCsc[MAX_ENDCAPS][CSC_TYPES];
418  TH1F *hAlctCompMatchCsc[MAX_ENDCAPS][CSC_TYPES];
419  // CLCTs
420  TH1F *hClctCompFoundCsc[MAX_ENDCAPS][CSC_TYPES];
421  TH1F *hClctCompSameNCsc[MAX_ENDCAPS][CSC_TYPES];
422  TH1F *hClctCompTotalCsc[MAX_ENDCAPS][CSC_TYPES];
423  TH1F *hClctCompMatchCsc[MAX_ENDCAPS][CSC_TYPES];
424  // Correlated LCTs
425  TH1F *hLctCompFoundCsc[MAX_ENDCAPS][CSC_TYPES];
426  TH1F *hLctCompSameNCsc[MAX_ENDCAPS][CSC_TYPES];
427  TH1F *hLctCompTotalCsc[MAX_ENDCAPS][CSC_TYPES];
428  TH1F *hLctCompMatchCsc[MAX_ENDCAPS][CSC_TYPES];
429 
430  // Resolution histograms
431  // ALCT
433  TH1F *hResolDeltaWG, *hResolDeltaEta;
434  TH1F *hAlctVsEta[MAX_STATIONS];
435  TH1F *hEtaDiffVsEta[MAX_STATIONS];
436  TH1F *hEtaDiffCsc[CSC_TYPES][3];
437  TH2F *hEtaDiffVsWireCsc[CSC_TYPES];
438  // CLCT
440  TH1F *hResolDeltaHS, *hResolDeltaDS;
441  TH1F *hResolDeltaPhi, *hResolDeltaPhiHS, *hResolDeltaPhiDS;
442  TH1F *hClctVsPhi[MAX_STATIONS];
443  TH1F *hPhiDiffVsPhi[MAX_STATIONS];
444  TH1F *hPhiDiffCsc[CSC_TYPES][5];
445  TH2F *hPhiDiffVsStripCsc[CSC_TYPES][2];
446  TH1F *hTrueBendCsc[CSC_TYPES];
447  TH1F *hPhiDiffPattern[CSCConstants::NUM_CLCT_PATTERNS];
448  // Efficiency histograms
449  TH1F *hEfficHitsEta[MAX_STATIONS];
450  TH1F *hEfficALCTEta[MAX_STATIONS], *hEfficCLCTEta[MAX_STATIONS];
451  TH1F *hEfficHitsEtaCsc[CSC_TYPES];
452  TH1F *hEfficALCTEtaCsc[CSC_TYPES], *hEfficCLCTEtaCsc[CSC_TYPES];
453 
460 };
461 
462 #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_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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...