CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCValidation.cc
Go to the documentation of this file.
1 /*
2  * validation package for CSC DIGIs, RECHITs and SEGMENTs + more.
3  *
4  * Michael Schmitt
5  * Andy Kubik
6  * Northwestern University
7  */
9 
10 using namespace std;
11 using namespace edm;
12 
14 // CONSTRUCTOR //
17  // Get the various input parameters
18  rootFileName = pset.getUntrackedParameter<std::string>("rootFileName", "valHists.root");
19  isSimulation = pset.getUntrackedParameter<bool>("isSimulation", false);
20  writeTreeToFile = pset.getUntrackedParameter<bool>("writeTreeToFile", true);
21  detailedAnalysis = pset.getUntrackedParameter<bool>("detailedAnalysis", false);
22  useDigis = pset.getUntrackedParameter<bool>("useDigis", true);
23 
24  // event quality filter
25  useQualityFilter = pset.getUntrackedParameter<bool>("useQualityFilter", false);
26  pMin = pset.getUntrackedParameter<double>("pMin", 4.);
27  chisqMax = pset.getUntrackedParameter<double>("chisqMax", 20.);
28  nCSCHitsMin = pset.getUntrackedParameter<int>("nCSCHitsMin", 10);
29  nCSCHitsMax = pset.getUntrackedParameter<int>("nCSCHitsMax", 25);
30  lengthMin = pset.getUntrackedParameter<double>("lengthMin", 140.);
31  lengthMax = pset.getUntrackedParameter<double>("lengthMax", 600.);
32  deltaPhiMax = pset.getUntrackedParameter<double>("deltaPhiMax", 0.2);
33  polarMax = pset.getUntrackedParameter<double>("polarMax", 0.7);
34  polarMin = pset.getUntrackedParameter<double>("polarMin", 0.3);
35 
36  // trigger filter
37  useTriggerFilter = pset.getUntrackedParameter<bool>("useTriggerFilter", false);
38 
39  // input tags for collections
40  rd_token = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("rawDataTag"));
41  sd_token = consumes<CSCStripDigiCollection>(pset.getParameter<edm::InputTag>("stripDigiTag"));
42  wd_token = consumes<CSCWireDigiCollection>(pset.getParameter<edm::InputTag>("wireDigiTag"));
43  cd_token = consumes<CSCComparatorDigiCollection>(pset.getParameter<edm::InputTag>("compDigiTag"));
44  al_token = consumes<CSCALCTDigiCollection>(pset.getParameter<edm::InputTag>("alctDigiTag"));
45  cl_token = consumes<CSCCLCTDigiCollection>(pset.getParameter<edm::InputTag>("clctDigiTag"));
46  co_token = consumes<CSCCorrelatedLCTDigiCollection>(pset.getParameter<edm::InputTag>("corrlctDigiTag"));
47  rh_token = consumes<CSCRecHit2DCollection>(pset.getParameter<edm::InputTag>("cscRecHitTag"));
48  se_token = consumes<CSCSegmentCollection>(pset.getParameter<edm::InputTag>("cscSegTag"));
49  sa_token = consumes<reco::TrackCollection>(pset.getParameter<edm::InputTag>("saMuonTag"));
50  l1_token = consumes<L1MuGMTReadoutCollection>(pset.getParameter<edm::InputTag>("l1aTag"));
51  tr_token = consumes<TriggerResults>(pset.getParameter<edm::InputTag>("hltTag"));
52  sh_token = consumes<PSimHitContainer>(pset.getParameter<edm::InputTag>("simHitTag"));
53 
54  // flags to switch on/off individual modules
55  makeOccupancyPlots = pset.getUntrackedParameter<bool>("makeOccupancyPlots", true);
56  makeTriggerPlots = pset.getUntrackedParameter<bool>("makeTriggerPlots", false);
57  makeStripPlots = pset.getUntrackedParameter<bool>("makeStripPlots", true);
58  makeWirePlots = pset.getUntrackedParameter<bool>("makeWirePlots", true);
59  makeRecHitPlots = pset.getUntrackedParameter<bool>("makeRecHitPlots", true);
60  makeSimHitPlots = pset.getUntrackedParameter<bool>("makeSimHitPlots", true);
61  makeSegmentPlots = pset.getUntrackedParameter<bool>("makeSegmentPlots", true);
62  makeResolutionPlots = pset.getUntrackedParameter<bool>("makeResolutionPlots", true);
63  makePedNoisePlots = pset.getUntrackedParameter<bool>("makePedNoisePlots", true);
64  makeEfficiencyPlots = pset.getUntrackedParameter<bool>("makeEfficiencyPlots", true);
65  makeGasGainPlots = pset.getUntrackedParameter<bool>("makeGasGainPlots", true);
66  makeAFEBTimingPlots = pset.getUntrackedParameter<bool>("makeAFEBTimingPlots", true);
67  makeCompTimingPlots = pset.getUntrackedParameter<bool>("makeCompTimingPlots", true);
68  makeADCTimingPlots = pset.getUntrackedParameter<bool>("makeADCTimingPlots", true);
69  makeRHNoisePlots = pset.getUntrackedParameter<bool>("makeRHNoisePlots", false);
70  makeCalibPlots = pset.getUntrackedParameter<bool>("makeCalibPlots", false);
71  makeStandalonePlots = pset.getUntrackedParameter<bool>("makeStandalonePlots", false);
72  makeTimeMonitorPlots = pset.getUntrackedParameter<bool>("makeTimeMonitorPlots", false);
73  makeHLTPlots = pset.getUntrackedParameter<bool>("makeHLTPlots", false);
74 
75  // set counters to zero
76  nEventsAnalyzed = 0;
77  rhTreeCount = 0;
78  segTreeCount = 0;
79  firstEvent = true;
80 
81  // Create the root file for the histograms
82  theFile = new TFile(rootFileName.c_str(), "RECREATE");
83  theFile->cd();
84 
85  // Create object of class CSCValHists to manage histograms
86  histos = new CSCValHists();
87 
88  // book Occupancy Histos
89  hOWires = new TH2I("hOWires", "Wire Digi Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
90  hOStrips = new TH2I("hOStrips", "Strip Digi Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
91  hORecHits = new TH2I("hORecHits", "RecHit Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
92  hOSegments = new TH2I("hOSegments", "Segments Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
93 
94  // book Eff histos
95  hSSTE = new TH1F("hSSTE", "hSSTE", 40, 0, 40);
96  hRHSTE = new TH1F("hRHSTE", "hRHSTE", 40, 0, 40);
97  hSEff = new TH1F("hSEff", "Segment Efficiency", 20, 0.5, 20.5);
98  hRHEff = new TH1F("hRHEff", "recHit Efficiency", 20, 0.5, 20.5);
99 
100  const int nChambers = 36;
101  const int nTypes = 18;
102  float nCH_min = 0.5;
103  float nCh_max = float(nChambers) + 0.5;
104  float nT_min = 0.5;
105  float nT_max = float(nTypes) + 0.5;
106 
107  hSSTE2 = new TH2F("hSSTE2", "hSSTE2", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
108  hRHSTE2 = new TH2F("hRHSTE2", "hRHSTE2", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
109  hStripSTE2 = new TH2F("hStripSTE2", "hStripSTE2", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
110  hWireSTE2 = new TH2F("hWireSTE2", "hWireSTE2", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
111 
112  hEffDenominator = new TH2F("hEffDenominator", "hEffDenominator", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
113  hSEff2 = new TH2F("hSEff2", "Segment Efficiency 2D", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
114  hRHEff2 = new TH2F("hRHEff2", "recHit Efficiency 2D", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
115 
116  hStripEff2 = new TH2F("hStripEff2", "strip Efficiency 2D", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
117  hWireEff2 = new TH2F("hWireEff2", "wire Efficiency 2D", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
118 
119  hSensitiveAreaEvt =
120  new TH2F("hSensitiveAreaEvt", "events in sensitive area", nChambers, nCH_min, nCh_max, nTypes, nT_min, nT_max);
121 
122  // setup trees to hold global position data for rechits and segments
123  if (writeTreeToFile)
124  histos->setupTrees();
125 }
126 
128 // DESTRUCTOR //
131  // produce final efficiency histograms
132  histoEfficiency(hRHSTE, hRHEff);
133  histoEfficiency(hSSTE, hSEff);
134  hSEff2->Divide(hSSTE2, hEffDenominator, 1., 1., "B");
135  hRHEff2->Divide(hRHSTE2, hEffDenominator, 1., 1., "B");
136  hStripEff2->Divide(hStripSTE2, hEffDenominator, 1., 1., "B");
137  hWireEff2->Divide(hWireSTE2, hEffDenominator, 1., 1., "B");
138 
139  histos->insertPlot(hRHSTE, "hRHSTE", "Efficiency");
140  histos->insertPlot(hSSTE, "hSSTE", "Efficiency");
141  histos->insertPlot(hSSTE2, "hSSTE2", "Efficiency");
142  histos->insertPlot(hEffDenominator, "hEffDenominator", "Efficiency");
143  histos->insertPlot(hRHSTE2, "hRHSTE2", "Efficiency");
144  histos->insertPlot(hStripSTE2, "hStripSTE2", "Efficiency");
145  histos->insertPlot(hWireSTE2, "hWireSTE2", "Efficiency");
146 
147  //moving this to post job macros
148  histos->insertPlot(hSEff, "hSEff", "Efficiency");
149  histos->insertPlot(hRHEff, "hRHEff", "Efficiency");
150 
151  histos->insertPlot(hSEff2, "hSEff2", "Efficiency");
152  histos->insertPlot(hRHEff2, "hRHEff2", "Efficiency");
153  histos->insertPlot(hStripEff2, "hStripff2", "Efficiency");
154  histos->insertPlot(hWireEff2, "hWireff2", "Efficiency");
155 
156  histos->insertPlot(hSensitiveAreaEvt, "", "Efficiency");
157 
158  // throw in occupancy plots so they're saved
159  histos->insertPlot(hOWires, "hOWires", "Digis");
160  histos->insertPlot(hOStrips, "hOStrips", "Digis");
161  histos->insertPlot(hORecHits, "hORecHits", "recHits");
162  histos->insertPlot(hOSegments, "hOSegments", "Segments");
163 
164  // write histos to the specified file
165  histos->writeHists(theFile);
166  if (writeTreeToFile)
167  histos->writeTrees(theFile);
168  theFile->Close();
169 }
170 
172 // Analysis //
174 void CSCValidation::analyze(const Event& event, const EventSetup& eventSetup) {
175  // increment counter
176  nEventsAnalyzed++;
177 
178  //int iRun = event.id().run();
179  //int iEvent = event.id().event();
180 
181  // Get the Digis
188  if (useDigis) {
189  event.getByToken(sd_token, strips);
190  event.getByToken(wd_token, wires);
191  event.getByToken(cd_token, compars);
192  event.getByToken(al_token, alcts);
193  event.getByToken(cl_token, clcts);
194  event.getByToken(co_token, correlatedlcts);
195  }
196 
197  // Get the CSC Geometry :
199  eventSetup.get<MuonGeometryRecord>().get(cscGeom);
200 
201  // Get the RecHits collection :
203  event.getByToken(rh_token, recHits);
204 
205  //CSCRecHit2DCollection::const_iterator recIt;
206  //for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
207  // recIt->print();
208  // }
209 
210  // Get the SimHits (if applicable)
212  if (isSimulation)
213  event.getByToken(sh_token, simHits);
214 
215  // get CSC segment collection
217  event.getByToken(se_token, cscSegments);
218 
219  // get the trigger collection
221  if (makeTriggerPlots || useTriggerFilter || (useDigis && makeTimeMonitorPlots)) {
222  event.getByToken(l1_token, pCollection);
223  }
225  if (makeHLTPlots) {
226  event.getByToken(tr_token, hlt);
227  }
228 
229  // get the standalone muon collection
231  if (makeStandalonePlots || useQualityFilter) {
232  event.getByToken(sa_token, saMuons);
233  }
234 
236  // Run the modules //
238 
239  // Only do this for the first event
240  // this is probably outdated and needs to be looked at
241  if (nEventsAnalyzed == 1 && makeCalibPlots)
242  doCalibrations(eventSetup);
243 
244  // Look at the l1a trigger info (returns true if csc L1A present)
245  bool CSCL1A = false;
246  if (makeTriggerPlots || useTriggerFilter)
247  CSCL1A = doTrigger(pCollection);
248  if (!useTriggerFilter)
249  CSCL1A = true; // always true if not filtering on trigger
250 
251  cleanEvent = false;
252  if (makeStandalonePlots || useQualityFilter)
253  cleanEvent = filterEvents(recHits, cscSegments, saMuons);
254  if (!useQualityFilter)
255  cleanEvent = true; // always true if not filtering on event quality
256 
257  // look at various chamber occupancies
258  // keep this outside of filter for diagnostics???
259  if (makeOccupancyPlots && CSCL1A)
260  doOccupancies(strips, wires, recHits, cscSegments);
261 
262  if (makeHLTPlots)
263  doHLT(hlt);
264 
265  if (cleanEvent && CSCL1A) {
266  // general look at strip digis
267  if (makeStripPlots && useDigis)
268  doStripDigis(strips);
269 
270  // general look at wire digis
271  if (makeWirePlots && useDigis)
272  doWireDigis(wires);
273 
274  // general look at rechits
275  if (makeRecHitPlots)
276  doRecHits(recHits, cscGeom);
277 
278  // look at simHits
279  if (isSimulation && makeSimHitPlots)
280  doSimHits(recHits, simHits);
281 
282  // general look at Segments
283  if (makeSegmentPlots)
284  doSegments(cscSegments, cscGeom);
285 
286  // look at hit resolution
287  if (makeResolutionPlots)
288  doResolution(cscSegments, cscGeom);
289 
290  // look at Pedestal Noise
291  if (makePedNoisePlots && useDigis)
292  doPedestalNoise(strips);
293 
294  // look at recHit and segment efficiencies
295  if (makeEfficiencyPlots)
296  doEfficiencies(wires, strips, recHits, cscSegments, cscGeom);
297 
298  // gas gain
299  if (makeGasGainPlots && useDigis)
300  doGasGain(*wires, *strips, *recHits);
301 
302  // AFEB timing
303  if (makeAFEBTimingPlots && useDigis)
304  doAFEBTiming(*wires);
305 
306  // Comparators timing
307  if (makeCompTimingPlots && useDigis)
308  doCompTiming(*compars);
309 
310  // strip ADC timing
311  if (makeADCTimingPlots)
312  doADCTiming(*recHits);
313 
314  // recHit Noise
315  if (makeRHNoisePlots && useDigis)
316  doNoiseHits(recHits, cscSegments, cscGeom, strips);
317 
318  // look at standalone muons (not implemented yet)
319  if (makeStandalonePlots)
320  doStandalone(saMuons);
321 
322  // make plots for monitoring the trigger and offline timing
323  if (makeTimeMonitorPlots)
324  doTimeMonitoring(recHits, cscSegments, alcts, clcts, correlatedlcts, pCollection, cscGeom, eventSetup, event);
325 
326  firstEvent = false;
327  }
328 }
329 
330 // ==============================================
331 //
332 // event filter, returns true only for events with "good" standalone muon
333 //
334 // ==============================================
335 
339  //int nGoodSAMuons = 0;
340 
341  if (recHits->size() < 4 || recHits->size() > 100)
342  return false;
343  if (cscSegments->size() < 1 || cscSegments->size() > 15)
344  return false;
345  return true;
346  //if (saMuons->size() != 1) return false;
347  /*
348  for(reco::TrackCollection::const_iterator muon = saMuons->begin(); muon != saMuons->end(); ++ muon ) {
349  double p = muon->p();
350  double reducedChisq = muon->normalizedChi2();
351 
352  GlobalPoint innerPnt(muon->innerPosition().x(),muon->innerPosition().y(),muon->innerPosition().z());
353  GlobalPoint outerPnt(muon->outerPosition().x(),muon->outerPosition().y(),muon->outerPosition().z());
354  GlobalVector innerKin(muon->innerMomentum().x(),muon->innerMomentum().y(),muon->innerMomentum().z());
355  GlobalVector outerKin(muon->outerMomentum().x(),muon->outerMomentum().y(),muon->outerMomentum().z());
356  GlobalVector deltaPnt = innerPnt - outerPnt;
357  double crudeLength = deltaPnt.mag();
358  double deltaPhi = innerPnt.phi() - outerPnt.phi();
359  double innerGlobalPolarAngle = innerKin.theta();
360  double outerGlobalPolarAngle = outerKin.theta();
361 
362  int nCSCHits = 0;
363  for (trackingRecHit_iterator hit = muon->recHitsBegin(); hit != muon->recHitsEnd(); ++hit ) {
364  if ( (*hit)->isValid() ) {
365  const DetId detId( (*hit)->geographicalId() );
366  if (detId.det() == DetId::Muon) {
367  if (detId.subdetId() == MuonSubdetId::CSC) {
368  nCSCHits++;
369  } // this is a CSC hit
370  } // this is a muon hit
371  } // hit is valid
372  } // end loop over rechits
373 
374  bool goodSAMuon = (p > pMin)
375  && ( reducedChisq < chisqMax )
376  && ( nCSCHits >= nCSCHitsMin )
377  && ( nCSCHits <= nCSCHitsMax )
378  && ( crudeLength > lengthMin )
379  && ( crudeLength < lengthMax );
380 
381 
382  goodSAMuon = goodSAMuon && ( fabs(deltaPhi) < deltaPhiMax );
383  goodSAMuon = goodSAMuon &&
384  (
385  ( ( innerGlobalPolarAngle > polarMin) && ( innerGlobalPolarAngle < polarMax) ) ||
386  ( (M_PI-innerGlobalPolarAngle > polarMin) && (M_PI-innerGlobalPolarAngle < polarMax) )
387  );
388  goodSAMuon = goodSAMuon &&
389  (
390  ( ( outerGlobalPolarAngle > polarMin) && ( outerGlobalPolarAngle < polarMax) ) ||
391  ( (M_PI-outerGlobalPolarAngle > polarMin) && (M_PI-outerGlobalPolarAngle < polarMax) )
392  );
393 
394  //goodSAMuon = goodSAMuon && (nCSCHits > nCSCHitsMin) && (nCSCHits < 13);
395  //goodSAMuon = goodSAMuon && (nCSCHits > 13) && (nCSCHits < 19);
396  //goodSAMuon = goodSAMuon && (nCSCHits > 19) && (nCSCHits < nCSCHitsMax);
397 
398 
399  if (goodSAMuon) nGoodSAMuons++;
400 
401  } // end loop over stand-alone muon collection
402 
403 
404  histos->fill1DHist(nGoodSAMuons,"hNGoodMuons", "Number of Good STA Muons per Event",11,-0.5,10.5,"STAMuons");
405 
406  if (nGoodSAMuons == 1) return true;
407  return false;
408  */
409 }
410 
411 // ==============================================
412 //
413 // look at Occupancies
414 //
415 // ==============================================
416 
421  bool wireo[2][4][4][36];
422  bool stripo[2][4][4][36];
423  bool rechito[2][4][4][36];
424  bool segmento[2][4][4][36];
425 
426  bool hasWires = false;
427  bool hasStrips = false;
428  bool hasRecHits = false;
429  bool hasSegments = false;
430 
431  for (int e = 0; e < 2; e++) {
432  for (int s = 0; s < 4; s++) {
433  for (int r = 0; r < 4; r++) {
434  for (int c = 0; c < 36; c++) {
435  wireo[e][s][r][c] = false;
436  stripo[e][s][r][c] = false;
437  rechito[e][s][r][c] = false;
438  segmento[e][s][r][c] = false;
439  }
440  }
441  }
442  }
443 
444  if (useDigis) {
445  //wires
446  for (CSCWireDigiCollection::DigiRangeIterator wi = wires->begin(); wi != wires->end(); wi++) {
447  CSCDetId id = (CSCDetId)(*wi).first;
448  int kEndcap = id.endcap();
449  int kRing = id.ring();
450  int kStation = id.station();
451  int kChamber = id.chamber();
452  std::vector<CSCWireDigi>::const_iterator wireIt = (*wi).second.first;
453  std::vector<CSCWireDigi>::const_iterator lastWire = (*wi).second.second;
454  for (; wireIt != lastWire; ++wireIt) {
455  if (!wireo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
456  wireo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
457  hOWires->Fill(kChamber, typeIndex(id));
458  histos->fill1DHist(
459  chamberSerial(id), "hOWireSerial", "Wire Occupancy by Chamber Serial", 601, -0.5, 600.5, "Digis");
460  hasWires = true;
461  }
462  }
463  }
464 
465  //strips
466  for (CSCStripDigiCollection::DigiRangeIterator si = strips->begin(); si != strips->end(); si++) {
467  CSCDetId id = (CSCDetId)(*si).first;
468  int kEndcap = id.endcap();
469  int kRing = id.ring();
470  int kStation = id.station();
471  int kChamber = id.chamber();
472  std::vector<CSCStripDigi>::const_iterator stripIt = (*si).second.first;
473  std::vector<CSCStripDigi>::const_iterator lastStrip = (*si).second.second;
474  for (; stripIt != lastStrip; ++stripIt) {
475  std::vector<int> myADCVals = stripIt->getADCCounts();
476  bool thisStripFired = false;
477  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
478  float threshold = 13.3;
479  float diff = 0.;
480  for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
481  diff = (float)myADCVals[iCount] - thisPedestal;
482  if (diff > threshold) {
483  thisStripFired = true;
484  }
485  }
486  if (thisStripFired) {
487  if (!stripo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
488  stripo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
489  hOStrips->Fill(kChamber, typeIndex(id));
490  histos->fill1DHist(
491  chamberSerial(id), "hOStripSerial", "Strip Occupancy by Chamber Serial", 601, -0.5, 600.5, "Digis");
492  hasStrips = true;
493  }
494  }
495  }
496  }
497  }
498 
499  //rechits
501  for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
502  CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
503  int kEndcap = idrec.endcap();
504  int kRing = idrec.ring();
505  int kStation = idrec.station();
506  int kChamber = idrec.chamber();
507  if (!rechito[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
508  rechito[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
509  histos->fill1DHist(
510  chamberSerial(idrec), "hORecHitsSerial", "RecHit Occupancy by Chamber Serial", 601, -0.5, 600.5, "recHits");
511  hORecHits->Fill(kChamber, typeIndex(idrec));
512  hasRecHits = true;
513  }
514  }
515 
516  //segments
517  for (CSCSegmentCollection::const_iterator segIt = cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
518  CSCDetId id = (CSCDetId)(*segIt).cscDetId();
519  int kEndcap = id.endcap();
520  int kRing = id.ring();
521  int kStation = id.station();
522  int kChamber = id.chamber();
523  if (!segmento[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
524  segmento[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
525  histos->fill1DHist(
526  chamberSerial(id), "hOSegmentsSerial", "Segment Occupancy by Chamber Serial", 601, -0.5, 600.5, "Segments");
527  hOSegments->Fill(kChamber, typeIndex(id));
528  hasSegments = true;
529  }
530  }
531 
532  // overall CSC occupancy (events with CSC data compared to total)
533  histos->fill1DHist(1, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
534  if (hasWires)
535  histos->fill1DHist(3, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
536  if (hasStrips)
537  histos->fill1DHist(5, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
538  if (hasWires && hasStrips)
539  histos->fill1DHist(7, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
540  if (hasRecHits)
541  histos->fill1DHist(9, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
542  if (hasSegments)
543  histos->fill1DHist(11, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
544  if (!cleanEvent)
545  histos->fill1DHist(13, "hCSCOccupancy", "overall CSC occupancy", 15, -0.5, 14.5, "GeneralHists");
546 }
547 
548 // ==============================================
549 //
550 // look at Trigger info
551 //
552 // ==============================================
553 
555  std::vector<L1MuGMTReadoutRecord> L1Mrec = pCollection->getRecords();
556  std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
557 
558  bool csc_l1a = false;
559  bool dt_l1a = false;
560  bool rpcf_l1a = false;
561  bool rpcb_l1a = false;
562  bool beamHaloTrigger = false;
563 
564  int myBXNumber = -1000;
565 
566  for (igmtrr = L1Mrec.begin(); igmtrr != L1Mrec.end(); igmtrr++) {
567  std::vector<L1MuRegionalCand>::const_iterator iter1;
568  std::vector<L1MuRegionalCand> rmc;
569 
570  // CSC
571  int icsc = 0;
572  rmc = igmtrr->getCSCCands();
573  for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
574  if (!(*iter1).empty()) {
575  icsc++;
576  int kQuality = (*iter1).quality(); // kQuality = 1 means beam halo
577  if (kQuality == 1)
578  beamHaloTrigger = true;
579  }
580  }
581  if (igmtrr->getBxInEvent() == 0 && icsc > 0)
582  csc_l1a = true;
583  if (igmtrr->getBxInEvent() == 0) {
584  myBXNumber = igmtrr->getBxNr();
585  }
586 
587  // DT
588  int idt = 0;
589  rmc = igmtrr->getDTBXCands();
590  for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
591  if (!(*iter1).empty()) {
592  idt++;
593  }
594  }
595  if (igmtrr->getBxInEvent() == 0 && idt > 0)
596  dt_l1a = true;
597 
598  // RPC Barrel
599  int irpcb = 0;
600  rmc = igmtrr->getBrlRPCCands();
601  for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
602  if (!(*iter1).empty()) {
603  irpcb++;
604  }
605  }
606  if (igmtrr->getBxInEvent() == 0 && irpcb > 0)
607  rpcb_l1a = true;
608 
609  // RPC Forward
610  int irpcf = 0;
611  rmc = igmtrr->getFwdRPCCands();
612  for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
613  if (!(*iter1).empty()) {
614  irpcf++;
615  }
616  }
617  if (igmtrr->getBxInEvent() == 0 && irpcf > 0)
618  rpcf_l1a = true;
619  }
620 
621  // Fill some histograms with L1A info
622  if (csc_l1a)
623  histos->fill1DHist(myBXNumber, "vtBXNumber", "BX Number", 4001, -0.5, 4000.5, "Trigger");
624  if (csc_l1a)
625  histos->fill1DHist(1, "vtBits", "trigger bits", 11, -0.5, 10.5, "Trigger");
626  if (dt_l1a)
627  histos->fill1DHist(2, "vtBits", "trigger bits", 11, -0.5, 10.5, "Trigger");
628  if (rpcb_l1a)
629  histos->fill1DHist(3, "vtBits", "trigger bits", 11, -0.5, 10.5, "Trigger");
630  if (rpcf_l1a)
631  histos->fill1DHist(4, "vtBits", "trigger bits", 11, -0.5, 10.5, "Trigger");
632  if (beamHaloTrigger)
633  histos->fill1DHist(8, "vtBits", "trigger bits", 11, -0.5, 10.5, "Trigger");
634 
635  if (csc_l1a) {
636  histos->fill1DHist(1, "vtCSCY", "trigger bits", 11, -0.5, 10.5, "Trigger");
637  if (dt_l1a)
638  histos->fill1DHist(2, "vtCSCY", "trigger bits", 11, -0.5, 10.5, "Trigger");
639  if (rpcb_l1a)
640  histos->fill1DHist(3, "vtCSCY", "trigger bits", 11, -0.5, 10.5, "Trigger");
641  if (rpcf_l1a)
642  histos->fill1DHist(4, "vtCSCY", "trigger bits", 11, -0.5, 10.5, "Trigger");
643  if (dt_l1a || rpcb_l1a || rpcf_l1a)
644  histos->fill1DHist(5, "vtCSCY", "trigger bits", 11, -0.5, 10.5, "Trigger");
645  if (!(dt_l1a || rpcb_l1a || rpcf_l1a))
646  histos->fill1DHist(6, "vtCSCY", "trigger bits", 11, -0.5, 10.5, "Trigger");
647  } else {
648  histos->fill1DHist(1, "vtCSCN", "trigger bits", 11, -0.5, 10.5, "Trigger");
649  if (dt_l1a)
650  histos->fill1DHist(2, "vtCSCN", "trigger bits", 11, -0.5, 10.5, "Trigger");
651  if (rpcb_l1a)
652  histos->fill1DHist(3, "vtCSCN", "trigger bits", 11, -0.5, 10.5, "Trigger");
653  if (rpcf_l1a)
654  histos->fill1DHist(4, "vtCSCN", "trigger bits", 11, -0.5, 10.5, "Trigger");
655  if (dt_l1a || rpcb_l1a || rpcf_l1a)
656  histos->fill1DHist(5, "vtCSCN", "trigger bits", 11, -0.5, 10.5, "Trigger");
657  if (!(dt_l1a || rpcb_l1a || rpcf_l1a))
658  histos->fill1DHist(6, "vtCSCN", "trigger bits", 11, -0.5, 10.5, "Trigger");
659  }
660 
661  // if valid CSC L1A then return true for possible use elsewhere
662 
663  if (csc_l1a)
664  return true;
665 
666  return false;
667 }
668 
669 // ==============================================
670 //
671 // look at HLT Trigger
672 //
673 // ==============================================
674 
676  // HLT stuff
677  int hltSize = hlt->size();
678  for (int i = 0; i < hltSize; ++i) {
679  if (hlt->accept(i))
680  histos->fill1DHist(i, "hltBits", "HLT Trigger Bits", hltSize + 1, -0.5, (float)hltSize + 0.5, "Trigger");
681  }
682 
683  return true;
684 }
685 
686 // ==============================================
687 //
688 // look at Calibrations
689 //
690 // ==============================================
691 
693  // Only do this for the first event
694  if (nEventsAnalyzed == 1) {
695  LogDebug("Calibrations") << "Loading Calibrations...";
696 
697  // get the gains
699  eventSetup.get<CSCDBGainsRcd>().get(hGains);
700  const CSCDBGains* pGains = hGains.product();
701  // get the crosstalks
703  eventSetup.get<CSCDBCrosstalkRcd>().get(hCrosstalk);
704  const CSCDBCrosstalk* pCrosstalk = hCrosstalk.product();
705  // get the noise matrix
706  edm::ESHandle<CSCDBNoiseMatrix> hNoiseMatrix;
707  eventSetup.get<CSCDBNoiseMatrixRcd>().get(hNoiseMatrix);
708  const CSCDBNoiseMatrix* pNoiseMatrix = hNoiseMatrix.product();
709  // get pedestals
711  eventSetup.get<CSCDBPedestalsRcd>().get(hPedestals);
712  const CSCDBPedestals* pPedestals = hPedestals.product();
713 
714  LogDebug("Calibrations") << "Calibrations Loaded!";
715 
716  for (int i = 0; i < 400; i++) {
717  int bin = i + 1;
718  histos->fillCalibHist(pGains->gains[i].gain_slope, "hCalibGainsS", "Gains Slope", 400, 0, 400, bin, "Calib");
719  histos->fillCalibHist(
720  pCrosstalk->crosstalk[i].xtalk_slope_left, "hCalibXtalkSL", "Xtalk Slope Left", 400, 0, 400, bin, "Calib");
721  histos->fillCalibHist(
722  pCrosstalk->crosstalk[i].xtalk_slope_right, "hCalibXtalkSR", "Xtalk Slope Right", 400, 0, 400, bin, "Calib");
723  histos->fillCalibHist(pCrosstalk->crosstalk[i].xtalk_intercept_left,
724  "hCalibXtalkIL",
725  "Xtalk Intercept Left",
726  400,
727  0,
728  400,
729  bin,
730  "Calib");
731  histos->fillCalibHist(pCrosstalk->crosstalk[i].xtalk_intercept_right,
732  "hCalibXtalkIR",
733  "Xtalk Intercept Right",
734  400,
735  0,
736  400,
737  bin,
738  "Calib");
739  histos->fillCalibHist(pPedestals->pedestals[i].ped, "hCalibPedsP", "Peds", 400, 0, 400, bin, "Calib");
740  histos->fillCalibHist(pPedestals->pedestals[i].rms, "hCalibPedsR", "Peds RMS", 400, 0, 400, bin, "Calib");
741  histos->fillCalibHist(
742  pNoiseMatrix->matrix[i].elem33, "hCalibNoise33", "Noise Matrix 33", 400, 0, 400, bin, "Calib");
743  histos->fillCalibHist(
744  pNoiseMatrix->matrix[i].elem34, "hCalibNoise34", "Noise Matrix 34", 400, 0, 400, bin, "Calib");
745  histos->fillCalibHist(
746  pNoiseMatrix->matrix[i].elem35, "hCalibNoise35", "Noise Matrix 35", 400, 0, 400, bin, "Calib");
747  histos->fillCalibHist(
748  pNoiseMatrix->matrix[i].elem44, "hCalibNoise44", "Noise Matrix 44", 400, 0, 400, bin, "Calib");
749  histos->fillCalibHist(
750  pNoiseMatrix->matrix[i].elem45, "hCalibNoise45", "Noise Matrix 45", 400, 0, 400, bin, "Calib");
751  histos->fillCalibHist(
752  pNoiseMatrix->matrix[i].elem46, "hCalibNoise46", "Noise Matrix 46", 400, 0, 400, bin, "Calib");
753  histos->fillCalibHist(
754  pNoiseMatrix->matrix[i].elem55, "hCalibNoise55", "Noise Matrix 55", 400, 0, 400, bin, "Calib");
755  histos->fillCalibHist(
756  pNoiseMatrix->matrix[i].elem56, "hCalibNoise56", "Noise Matrix 56", 400, 0, 400, bin, "Calib");
757  histos->fillCalibHist(
758  pNoiseMatrix->matrix[i].elem57, "hCalibNoise57", "Noise Matrix 57", 400, 0, 400, bin, "Calib");
759  histos->fillCalibHist(
760  pNoiseMatrix->matrix[i].elem66, "hCalibNoise66", "Noise Matrix 66", 400, 0, 400, bin, "Calib");
761  histos->fillCalibHist(
762  pNoiseMatrix->matrix[i].elem67, "hCalibNoise67", "Noise Matrix 67", 400, 0, 400, bin, "Calib");
763  histos->fillCalibHist(
764  pNoiseMatrix->matrix[i].elem77, "hCalibNoise77", "Noise Matrix 77", 400, 0, 400, bin, "Calib");
765  }
766  }
767 }
768 
769 // ==============================================
770 //
771 // look at WIRE DIGIs
772 //
773 // ==============================================
774 
776  int nWireGroupsTotal = 0;
777  for (CSCWireDigiCollection::DigiRangeIterator dWDiter = wires->begin(); dWDiter != wires->end(); dWDiter++) {
778  CSCDetId id = (CSCDetId)(*dWDiter).first;
779  std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
780  std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
781  for (; wireIter != lWire; ++wireIter) {
782  int myWire = wireIter->getWireGroup();
783  int myTBin = wireIter->getTimeBin();
784  nWireGroupsTotal++;
785  histos->fill1DHistByType(myWire, "hWireWire", "Wiregroup Numbers Fired", id, 113, -0.5, 112.5, "Digis");
786  histos->fill1DHistByType(myTBin, "hWireTBin", "Wire TimeBin Fired", id, 17, -0.5, 16.5, "Digis");
787  histos->fillProfile(
788  chamberSerial(id), myTBin, "hWireTBinProfile", "Wire TimeBin Fired", 601, -0.5, 600.5, -0.5, 16.5, "Digis");
789  if (detailedAnalysis) {
790  histos->fill1DHistByLayer(
791  myWire, "hWireWire", "Wiregroup Numbers Fired", id, 113, -0.5, 112.5, "WireNumberByLayer");
792  histos->fill1DHistByLayer(myTBin, "hWireTBin", "Wire TimeBin Fired", id, 17, -0.5, 16.5, "WireTimeByLayer");
793  }
794  }
795  } // end wire loop
796 
797  // this way you can zero suppress but still store info on # events with no digis
798  if (nWireGroupsTotal == 0)
799  nWireGroupsTotal = -1;
800 
801  histos->fill1DHist(nWireGroupsTotal, "hWirenGroupsTotal", "Wires Fired Per Event", 151, -0.5, 150.5, "Digis");
802 }
803 
804 // ==============================================
805 //
806 // look at STRIP DIGIs
807 //
808 // ==============================================
809 
811  int nStripsFired = 0;
812  for (CSCStripDigiCollection::DigiRangeIterator dSDiter = strips->begin(); dSDiter != strips->end(); dSDiter++) {
813  CSCDetId id = (CSCDetId)(*dSDiter).first;
814  std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
815  std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
816  for (; stripIter != lStrip; ++stripIter) {
817  int myStrip = stripIter->getStrip();
818  std::vector<int> myADCVals = stripIter->getADCCounts();
819  bool thisStripFired = false;
820  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
821  float threshold = 13.3;
822  float diff = 0.;
823  for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
824  diff = (float)myADCVals[iCount] - thisPedestal;
825  if (diff > threshold) {
826  thisStripFired = true;
827  }
828  }
829  if (thisStripFired) {
830  nStripsFired++;
831  // fill strip histos
832  histos->fill1DHistByType(myStrip, "hStripStrip", "Strip Number", id, 81, -0.5, 80.5, "Digis");
833  if (detailedAnalysis) {
834  histos->fill1DHistByLayer(myStrip, "hStripStrip", "Strip Number", id, 81, -0.5, 80.5, "StripNumberByLayer");
835  }
836  }
837  }
838  } // end strip loop
839 
840  if (nStripsFired == 0)
841  nStripsFired = -1;
842 
843  histos->fill1DHist(nStripsFired, "hStripNFired", "Fired Strips per Event", 251, -0.5, 250.5, "Digis");
844 }
845 
846 //=======================================================
847 //
848 // Look at the Pedestal Noise Distributions
849 //
850 //=======================================================
851 
853  for (CSCStripDigiCollection::DigiRangeIterator dPNiter = strips->begin(); dPNiter != strips->end(); dPNiter++) {
854  CSCDetId id = (CSCDetId)(*dPNiter).first;
855  std::vector<CSCStripDigi>::const_iterator pedIt = (*dPNiter).second.first;
856  std::vector<CSCStripDigi>::const_iterator lStrip = (*dPNiter).second.second;
857  for (; pedIt != lStrip; ++pedIt) {
858  int myStrip = pedIt->getStrip();
859  std::vector<int> myADCVals = pedIt->getADCCounts();
860  float TotalADC = getSignal(*strips, id, myStrip);
861  bool thisStripFired = false;
862  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
863  float thisSignal =
864  (1. / 6) * (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
865  float threshold = 13.3;
866  if (id.station() == 1 && id.ring() == 4) {
867  if (myStrip <= 16)
868  myStrip += 64; // no trapping for any bizarreness
869  }
870  if (TotalADC > threshold) {
871  thisStripFired = true;
872  }
873  if (!thisStripFired) {
874  float ADC = thisSignal - thisPedestal;
875  histos->fill1DHist(ADC, "hStripPed", "Pedestal Noise Distribution", 50, -25., 25., "PedestalNoise");
876  histos->fill1DHistByType(ADC, "hStripPedME", "Pedestal Noise Distribution", id, 50, -25., 25., "PedestalNoise");
877  histos->fillProfile(chamberSerial(id),
878  ADC,
879  "hStripPedMEProfile",
880  "Wire TimeBin Fired",
881  601,
882  -0.5,
883  600.5,
884  -25,
885  25,
886  "PedestalNoise");
887  if (detailedAnalysis) {
888  histos->fill1DHistByLayer(
889  ADC, "hStripPedME", "Pedestal Noise Distribution", id, 50, -25., 25., "PedestalNoiseByLayer");
890  }
891  }
892  }
893  }
894 }
895 
896 // ==============================================
897 //
898 // look at RECHITs
899 //
900 // ==============================================
901 
903  // Get the RecHits collection :
904  int nRecHits = recHits->size();
905 
906  // ---------------------
907  // Loop over rechits
908  // ---------------------
909  int iHit = 0;
910 
911  // Build iterator for rechits and loop :
913  for (dRHIter = recHits->begin(); dRHIter != recHits->end(); dRHIter++) {
914  iHit++;
915 
916  // Find chamber with rechits in CSC
917  CSCDetId idrec = (CSCDetId)(*dRHIter).cscDetId();
918  int kEndcap = idrec.endcap();
919  int kRing = idrec.ring();
920  int kStation = idrec.station();
921  int kChamber = idrec.chamber();
922  int kLayer = idrec.layer();
923 
924  // Store rechit as a Local Point:
925  LocalPoint rhitlocal = (*dRHIter).localPosition();
926  float xreco = rhitlocal.x();
927  float yreco = rhitlocal.y();
928  LocalError rerrlocal = (*dRHIter).localPositionError();
929  //these errors are squared!
930  float xxerr = rerrlocal.xx();
931  float yyerr = rerrlocal.yy();
932  float xyerr = rerrlocal.xy();
933  // errors in strip units
934  float stpos = (*dRHIter).positionWithinStrip();
935  float sterr = (*dRHIter).errorWithinStrip();
936 
937  // Find the charge associated with this hit
938  float rHSumQ = 0;
939  float sumsides = 0.;
940  int adcsize = dRHIter->nStrips() * dRHIter->nTimeBins();
941  for (unsigned int i = 0; i < dRHIter->nStrips(); i++) {
942  for (unsigned int j = 0; j < dRHIter->nTimeBins() - 1; j++) {
943  rHSumQ += dRHIter->adcs(i, j);
944  if (i != 1)
945  sumsides += dRHIter->adcs(i, j);
946  }
947  }
948 
949  float rHratioQ = sumsides / rHSumQ;
950  if (adcsize != 12)
951  rHratioQ = -99;
952 
953  // Get the signal timing of this hit
954  float rHtime = 0;
955  rHtime = (*dRHIter).tpeak() / 50.;
956 
957  // Get pointer to the layer:
958  const CSCLayer* csclayer = cscGeom->layer(idrec);
959 
960  // Transform hit position from local chamber geometry to global CMS geom
961  GlobalPoint rhitglobal = csclayer->toGlobal(rhitlocal);
962  float grecx = rhitglobal.x();
963  float grecy = rhitglobal.y();
964 
965  // Fill the rechit position branch
966  if (writeTreeToFile && rhTreeCount < 1500000) {
967  histos->fillRechitTree(xreco, yreco, grecx, grecy, kEndcap, kStation, kRing, kChamber, kLayer);
968  rhTreeCount++;
969  }
970 
971  // Fill some histograms
972  // only fill if 3 strips were used in the hit
973  histos->fill2DHistByStation(
974  grecx, grecy, "hRHGlobal", "recHit Global Position", idrec, 100, -800., 800., 100, -800., 800., "recHits");
975  if (kStation == 1 && (kRing == 1 || kRing == 4))
976  histos->fill1DHistByType(rHSumQ, "hRHSumQ", "Sum 3x3 recHit Charge", idrec, 125, 0, 4000, "recHits");
977  else
978  histos->fill1DHistByType(rHSumQ, "hRHSumQ", "Sum 3x3 recHit Charge", idrec, 125, 0, 2000, "recHits");
979  histos->fill1DHistByType(rHratioQ, "hRHRatioQ", "Charge Ratio (Ql+Qr)/Qt", idrec, 120, -0.1, 1.1, "recHits");
980  histos->fill1DHistByType(rHtime, "hRHTiming", "recHit Timing", idrec, 200, -10, 10, "recHits");
981  histos->fill1DHistByType(sqrt(xxerr), "hRHxerr", "RecHit Error on Local X", idrec, 100, -0.1, 2, "recHits");
982  histos->fill1DHistByType(sqrt(yyerr), "hRHyerr", "RecHit Error on Local Y", idrec, 100, -0.1, 2, "recHits");
983  histos->fill1DHistByType(xyerr, "hRHxyerr", "Corr. RecHit XY Error", idrec, 100, -1, 2, "recHits");
984  if (adcsize == 12)
985  histos->fill1DHistByType(stpos, "hRHstpos", "Reconstructed Position on Strip", idrec, 120, -0.6, 0.6, "recHits");
986  histos->fill1DHistByType(
987  sterr, "hRHsterr", "Estimated Error on Strip Measurement", idrec, 120, -0.05, 0.25, "recHits");
988  histos->fillProfile(
989  chamberSerial(idrec), rHSumQ, "hRHSumQProfile", "Sum 3x3 recHit Charge", 601, -0.5, 600.5, 0, 4000, "recHits");
990  histos->fillProfile(
991  chamberSerial(idrec), rHtime, "hRHTimingProfile", "recHit Timing", 601, -0.5, 600.5, -11, 11, "recHits");
992  if (detailedAnalysis) {
993  if (kStation == 1 && (kRing == 1 || kRing == 4))
994  histos->fill1DHistByLayer(rHSumQ, "hRHSumQ", "Sum 3x3 recHit Charge", idrec, 125, 0, 4000, "RHQByLayer");
995  else
996  histos->fill1DHistByLayer(rHSumQ, "hRHSumQ", "Sum 3x3 recHit Charge", idrec, 125, 0, 2000, "RHQByLayer");
997  histos->fill1DHistByLayer(rHratioQ, "hRHRatioQ", "Charge Ratio (Ql+Qr)/Qt", idrec, 120, -0.1, 1.1, "RHQByLayer");
998  histos->fill1DHistByLayer(rHtime, "hRHTiming", "recHit Timing", idrec, 200, -10, 10, "RHTimingByLayer");
999  histos->fill2DHistByLayer(xreco,
1000  yreco,
1001  "hRHLocalXY",
1002  "recHit Local Position",
1003  idrec,
1004  50,
1005  -100.,
1006  100.,
1007  75,
1008  -150.,
1009  150.,
1010  "RHLocalXYByLayer");
1011  histos->fill1DHistByLayer(
1012  sqrt(xxerr), "hRHxerr", "RecHit Error on Local X", idrec, 100, -0.1, 2, "RHErrorsByLayer");
1013  histos->fill1DHistByLayer(
1014  sqrt(yyerr), "hRHyerr", "RecHit Error on Local Y", idrec, 100, -0.1, 2, "RHErrorsByLayer");
1015  histos->fill1DHistByType(
1016  stpos, "hRHstpos", "Reconstructed Position on Strip", idrec, 120, -0.6, 0.6, "RHStripPosByLayer");
1017  histos->fill1DHistByType(
1018  sterr, "hRHsterr", "Estimated Error on Strip Measurement", idrec, 120, -0.05, 0.25, "RHStripPosByLayer");
1019  }
1020 
1021  } //end rechit loop
1022 
1023  if (nRecHits == 0)
1024  nRecHits = -1;
1025 
1026  histos->fill1DHist(nRecHits, "hRHnrechits", "recHits per Event (all chambers)", 151, -0.5, 150.5, "recHits");
1027 }
1028 
1029 // ==============================================
1030 //
1031 // look at SIMHITS
1032 //
1033 // ==============================================
1034 
1037  for (dSHrecIter = recHits->begin(); dSHrecIter != recHits->end(); dSHrecIter++) {
1038  CSCDetId idrec = (CSCDetId)(*dSHrecIter).cscDetId();
1039  LocalPoint rhitlocal = (*dSHrecIter).localPosition();
1040  float xreco = rhitlocal.x();
1041  float yreco = rhitlocal.y();
1042  float xError = sqrt((*dSHrecIter).localPositionError().xx());
1043  float yError = sqrt((*dSHrecIter).localPositionError().yy());
1044  float simHitXres = -99;
1045  float simHitYres = -99;
1046  float xPull = -99;
1047  float yPull = -99;
1048  float mindiffX = 99;
1049  float mindiffY = 10;
1050  // If MC, find closest muon simHit to check resolution:
1051  PSimHitContainer::const_iterator dSHsimIter;
1052  for (dSHsimIter = simHits->begin(); dSHsimIter != simHits->end(); dSHsimIter++) {
1053  // Get DetID for this simHit:
1054  CSCDetId sId = (CSCDetId)(*dSHsimIter).detUnitId();
1055  // Check if the simHit detID matches that of current recHit
1056  // and make sure it is a muon hit:
1057  if (sId == idrec && abs((*dSHsimIter).particleType()) == 13) {
1058  // Get the position of this simHit in local coordinate system:
1059  LocalPoint sHitlocal = (*dSHsimIter).localPosition();
1060  // Now we need to make reasonably sure that this simHit is
1061  // responsible for this recHit:
1062  if ((sHitlocal.x() - xreco) < mindiffX && (sHitlocal.y() - yreco) < mindiffY) {
1063  simHitXres = (sHitlocal.x() - xreco);
1064  simHitYres = (sHitlocal.y() - yreco);
1065  mindiffX = (sHitlocal.x() - xreco);
1066  xPull = simHitXres / xError;
1067  yPull = simHitYres / yError;
1068  }
1069  }
1070  }
1071 
1072  histos->fill1DHistByType(
1073  simHitXres, "hSimXResid", "SimHitX - Reconstructed X", idrec, 100, -1.0, 1.0, "Resolution");
1074  histos->fill1DHistByType(
1075  simHitYres, "hSimYResid", "SimHitY - Reconstructed Y", idrec, 100, -5.0, 5.0, "Resolution");
1076  histos->fill1DHistByType(xPull, "hSimXPull", "Local X Pulls", idrec, 100, -5.0, 5.0, "Resolution");
1077  histos->fill1DHistByType(yPull, "hSimYPull", "Local Y Pulls", idrec, 100, -5.0, 5.0, "Resolution");
1078  }
1079 }
1080 
1081 // ==============================================
1082 //
1083 // look at SEGMENTs
1084 //
1085 // ===============================================
1086 
1088  // get CSC segment collection
1089  int nSegments = cscSegments->size();
1090 
1091  // -----------------------
1092  // loop over segments
1093  // -----------------------
1094  int iSegment = 0;
1095  for (CSCSegmentCollection::const_iterator dSiter = cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
1096  iSegment++;
1097  //
1098  CSCDetId id = (CSCDetId)(*dSiter).cscDetId();
1099  int kEndcap = id.endcap();
1100  int kRing = id.ring();
1101  int kStation = id.station();
1102  int kChamber = id.chamber();
1103 
1104  //
1105  float chisq = (*dSiter).chi2();
1106  int nhits = (*dSiter).nRecHits();
1107  int nDOF = 2 * nhits - 4;
1108  double chisqProb = ChiSquaredProbability((double)chisq, nDOF);
1109  LocalPoint localPos = (*dSiter).localPosition();
1110  float segX = localPos.x();
1111  float segY = localPos.y();
1112  LocalVector segDir = (*dSiter).localDirection();
1113  double theta = segDir.theta();
1114 
1115  // global transformation
1116  float globX = 0.;
1117  float globY = 0.;
1118  float globTheta = 0.;
1119  float globPhi = 0.;
1120  const CSCChamber* cscchamber = cscGeom->chamber(id);
1121  if (cscchamber) {
1122  GlobalPoint globalPosition = cscchamber->toGlobal(localPos);
1123  globX = globalPosition.x();
1124  globY = globalPosition.y();
1125  GlobalVector globalDirection = cscchamber->toGlobal(segDir);
1126  globTheta = globalDirection.theta();
1127  globPhi = globalDirection.phi();
1128  }
1129 
1130  // Fill segment position branch
1131  if (writeTreeToFile && segTreeCount < 1500000) {
1132  histos->fillSegmentTree(segX, segY, globX, globY, kEndcap, kStation, kRing, kChamber);
1133  segTreeCount++;
1134  }
1135 
1136  // Fill histos
1137  histos->fill2DHistByStation(globX,
1138  globY,
1139  "hSGlobal",
1140  "Segment Global Positions;global x (cm)",
1141  id,
1142  100,
1143  -800.,
1144  800.,
1145  100,
1146  -800.,
1147  800.,
1148  "Segments");
1149  histos->fill1DHistByType(nhits, "hSnHits", "N hits on Segments", id, 8, -0.5, 7.5, "Segments");
1150  histos->fill1DHistByType(theta, "hSTheta", "local theta segments", id, 128, -3.2, 3.2, "Segments");
1151  histos->fill1DHistByType((chisq / nDOF), "hSChiSq", "segments chi-squared/ndof", id, 110, -0.05, 10.5, "Segments");
1152  histos->fill1DHistByType(
1153  chisqProb, "hSChiSqProb", "segments chi-squared probability", id, 110, -0.05, 1.05, "Segments");
1154  histos->fill1DHist(globTheta, "hSGlobalTheta", "segment global theta", 128, 0, 3.2, "Segments");
1155  histos->fill1DHist(globPhi, "hSGlobalPhi", "segment global phi", 128, -3.2, 3.2, "Segments");
1156  histos->fillProfile(
1157  chamberSerial(id), nhits, "hSnHitsProfile", "N hits on Segments", 601, -0.5, 600.5, -0.5, 7.5, "Segments");
1158  if (detailedAnalysis) {
1159  histos->fill1DHistByChamber(nhits, "hSnHits", "N hits on Segments", id, 8, -0.5, 7.5, "HitsOnSegmentByChamber");
1160  histos->fill1DHistByChamber(theta, "hSTheta", "local theta segments", id, 128, -3.2, 3.2, "DetailedSegments");
1161  histos->fill1DHistByChamber(
1162  (chisq / nDOF), "hSChiSq", "segments chi-squared/ndof", id, 110, -0.05, 10.5, "SegChi2ByChamber");
1163  histos->fill1DHistByChamber(
1164  chisqProb, "hSChiSqProb", "segments chi-squared probability", id, 110, -0.05, 1.05, "SegChi2ByChamber");
1165  }
1166 
1167  } // end segment loop
1168 
1169  if (nSegments == 0)
1170  nSegments = -1;
1171 
1172  histos->fill1DHist(nSegments, "hSnSegments", "Segments per Event", 31, -0.5, 30.5, "Segments");
1173 }
1174 
1175 // ==============================================
1176 //
1177 // look at hit Resolution
1178 //
1179 // ===============================================
1180 
1182  for (CSCSegmentCollection::const_iterator dSiter = cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
1183  CSCDetId id = (CSCDetId)(*dSiter).cscDetId();
1184 
1185  //
1186  // try to get the CSC recHits that contribute to this segment.
1187  std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
1188  int nRH = (*dSiter).nRecHits();
1189  int jRH = 0;
1190  CLHEP::HepMatrix sp(6, 1);
1191  CLHEP::HepMatrix se(6, 1);
1192  for (std::vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
1193  jRH++;
1194  CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
1195  int kRing = idRH.ring();
1196  int kStation = idRH.station();
1197  int kLayer = idRH.layer();
1198 
1199  // Find the strip containing this hit
1200  int centerid = iRH->nStrips() / 2;
1201  int centerStrip = iRH->channels(centerid);
1202 
1203  // If this segment has 6 hits, find the position of each hit on the strip in units of stripwidth and store values
1204  if (nRH == 6) {
1205  float stpos = (*iRH).positionWithinStrip();
1206  se(kLayer, 1) = (*iRH).errorWithinStrip();
1207  // Take into account half-strip staggering of layers (ME1/1 has no staggering)
1208  if (kStation == 1 && (kRing == 1 || kRing == 4))
1209  sp(kLayer, 1) = stpos + centerStrip;
1210  else {
1211  if (kLayer == 1 || kLayer == 3 || kLayer == 5)
1212  sp(kLayer, 1) = stpos + centerStrip;
1213  if (kLayer == 2 || kLayer == 4 || kLayer == 6)
1214  sp(kLayer, 1) = stpos - 0.5 + centerStrip;
1215  }
1216  }
1217  }
1218 
1219  float residual = -99;
1220  float pull = -99;
1221  // Fit all points except layer 3, then compare expected value for layer 3 to reconstructed value
1222  if (nRH == 6) {
1223  float expected = fitX(sp, se);
1224  residual = expected - sp(3, 1);
1225  pull = residual / se(3, 1);
1226  }
1227 
1228  // Fill histos
1229  histos->fill1DHistByType(
1230  residual, "hSResid", "Fitted Position on Strip - Reconstructed for Layer 3", id, 100, -0.5, 0.5, "Resolution");
1231  histos->fill1DHistByType(pull, "hSStripPosPull", "Strip Measurement Pulls", id, 100, -5.0, 5.0, "Resolution");
1232  histos->fillProfile(chamberSerial(id),
1233  residual,
1234  "hSResidProfile",
1235  "Fitted Position on Strip - Reconstructed for Layer 3",
1236  601,
1237  -0.5,
1238  600.5,
1239  -0.5,
1240  0.5,
1241  "Resolution");
1242  if (detailedAnalysis) {
1243  histos->fill1DHistByChamber(residual,
1244  "hSResid",
1245  "Fitted Position on Strip - Reconstructed for Layer 3",
1246  id,
1247  100,
1248  -0.5,
1249  0.5,
1250  "DetailedResolution");
1251  histos->fill1DHistByChamber(pull, "hSStripPosPull", "Strip Measurement Pulls", id, 100, -5.0, 5.0, "Resolution");
1252  }
1253  }
1254 }
1255 
1256 // ==============================================
1257 //
1258 // look at Standalone Muons
1259 //
1260 // ==============================================
1261 
1263  int nSAMuons = saMuons->size();
1264  histos->fill1DHist(nSAMuons, "trNSAMuons", "N Standalone Muons per Event", 6, -0.5, 5.5, "STAMuons");
1265 
1266  for (reco::TrackCollection::const_iterator muon = saMuons->begin(); muon != saMuons->end(); ++muon) {
1267  float preco = muon->p();
1268  float ptreco = muon->pt();
1269  int n = muon->recHitsSize();
1270  float chi2 = muon->chi2();
1271  float normchi2 = muon->normalizedChi2();
1272 
1273  // loop over hits
1274  int nDTHits = 0;
1275  int nCSCHits = 0;
1276  int nCSCHitsp = 0;
1277  int nCSCHitsm = 0;
1278  int nRPCHits = 0;
1279  int nRPCHitsp = 0;
1280  int nRPCHitsm = 0;
1281  int np = 0;
1282  int nm = 0;
1283  std::vector<CSCDetId> staChambers;
1284  for (trackingRecHit_iterator hit = muon->recHitsBegin(); hit != muon->recHitsEnd(); ++hit) {
1285  const DetId detId((*hit)->geographicalId());
1286  if (detId.det() == DetId::Muon) {
1287  if (detId.subdetId() == MuonSubdetId::RPC) {
1288  RPCDetId rpcId(detId.rawId());
1289  nRPCHits++;
1290  if (rpcId.region() == 1) {
1291  nRPCHitsp++;
1292  np++;
1293  }
1294  if (rpcId.region() == -1) {
1295  nRPCHitsm++;
1296  nm++;
1297  }
1298  }
1299  if (detId.subdetId() == MuonSubdetId::DT) {
1300  nDTHits++;
1301  } else if (detId.subdetId() == MuonSubdetId::CSC) {
1302  CSCDetId cscId(detId.rawId());
1303  staChambers.push_back(detId.rawId());
1304  nCSCHits++;
1305  if (cscId.endcap() == 1) {
1306  nCSCHitsp++;
1307  np++;
1308  }
1309  if (cscId.endcap() == 2) {
1310  nCSCHitsm++;
1311  nm++;
1312  }
1313  }
1314  }
1315  }
1316 
1317  GlobalPoint innerPnt(muon->innerPosition().x(), muon->innerPosition().y(), muon->innerPosition().z());
1318  GlobalPoint outerPnt(muon->outerPosition().x(), muon->outerPosition().y(), muon->outerPosition().z());
1319  GlobalVector innerKin(muon->innerMomentum().x(), muon->innerMomentum().y(), muon->innerMomentum().z());
1320  GlobalVector outerKin(muon->outerMomentum().x(), muon->outerMomentum().y(), muon->outerMomentum().z());
1321  GlobalVector deltaPnt = innerPnt - outerPnt;
1322  double crudeLength = deltaPnt.mag();
1323  double deltaPhi = innerPnt.phi() - outerPnt.phi();
1324  double innerGlobalPolarAngle = innerKin.theta();
1325  double outerGlobalPolarAngle = outerKin.theta();
1326 
1327  // fill histograms
1328  histos->fill1DHist(n, "trN", "N hits on a STA Muon Track", 51, -0.5, 50.5, "STAMuons");
1329  if (np != 0)
1330  histos->fill1DHist(np, "trNp", "N hits on a STA Muon Track (plus endcap)", 51, -0.5, 50.5, "STAMuons");
1331  if (nm != 0)
1332  histos->fill1DHist(nm, "trNm", "N hits on a STA Muon Track (minus endcap)", 51, -0.5, 50.5, "STAMuons");
1333  histos->fill1DHist(nDTHits, "trNDT", "N DT hits on a STA Muon Track", 51, -0.5, 50.5, "STAMuons");
1334  histos->fill1DHist(nCSCHits, "trNCSC", "N CSC hits on a STA Muon Track", 51, -0.5, 50.5, "STAMuons");
1335  if (nCSCHitsp != 0)
1336  histos->fill1DHist(nCSCHitsp, "trNCSCp", "N CSC hits on a STA Muon Track (+ endcap)", 51, -0.5, 50.5, "STAMuons");
1337  if (nCSCHitsm != 0)
1338  histos->fill1DHist(nCSCHitsm, "trNCSCm", "N CSC hits on a STA Muon Track (- endcap)", 51, -0.5, 50.5, "STAMuons");
1339  histos->fill1DHist(nRPCHits, "trNRPC", "N RPC hits on a STA Muon Track", 51, -0.5, 50.5, "STAMuons");
1340  if (nRPCHitsp != 0)
1341  histos->fill1DHist(nRPCHitsp, "trNRPCp", "N RPC hits on a STA Muon Track (+ endcap)", 51, -0.5, 50.5, "STAMuons");
1342  if (nRPCHitsm != 0)
1343  histos->fill1DHist(nRPCHitsm, "trNRPCm", "N RPC hits on a STA Muon Track (- endcap)", 51, -0.5, 50.5, "STAMuons");
1344  histos->fill1DHist(preco, "trP", "STA Muon Momentum", 100, 0, 300, "STAMuons");
1345  histos->fill1DHist(ptreco, "trPT", "STA Muon pT", 100, 0, 40, "STAMuons");
1346  histos->fill1DHist(chi2, "trChi2", "STA Muon Chi2", 100, 0, 200, "STAMuons");
1347  histos->fill1DHist(normchi2, "trNormChi2", "STA Muon Normalized Chi2", 100, 0, 10, "STAMuons");
1348  histos->fill1DHist(crudeLength, "trLength", "Straight Line Length of STA Muon", 120, 0., 2400., "STAMuons");
1349  histos->fill1DHist(
1350  deltaPhi, "trDeltaPhi", "Delta-Phi Between Inner and Outer STA Muon Pos.", 100, -0.5, 0.5, "STAMuons");
1351  histos->fill1DHist(
1352  innerGlobalPolarAngle, "trInnerPolar", "Polar Angle of Inner P Vector (STA muons)", 128, 0, 3.2, "STAMuons");
1353  histos->fill1DHist(
1354  outerGlobalPolarAngle, "trOuterPolar", "Polar Angle of Outer P Vector (STA muons)", 128, 0, 3.2, "STAMuons");
1355  histos->fill1DHist(innerPnt.phi(), "trInnerPhi", "Phi of Inner Position (STA muons)", 256, -3.2, 3.2, "STAMuons");
1356  histos->fill1DHist(outerPnt.phi(), "trOuterPhi", "Phi of Outer Position (STA muons)", 256, -3.2, 3.2, "STAMuons");
1357  }
1358 }
1359 
1360 //--------------------------------------------------------------
1361 // Compute a serial number for the chamber.
1362 // This is useful when filling histograms and working with arrays.
1363 //--------------------------------------------------------------
1365  int st = id.station();
1366  int ri = id.ring();
1367  int ch = id.chamber();
1368  int ec = id.endcap();
1369  int kSerial = ch;
1370  if (st == 1 && ri == 1)
1371  kSerial = ch;
1372  if (st == 1 && ri == 2)
1373  kSerial = ch + 36;
1374  if (st == 1 && ri == 3)
1375  kSerial = ch + 72;
1376  if (st == 1 && ri == 4)
1377  kSerial = ch;
1378  if (st == 2 && ri == 1)
1379  kSerial = ch + 108;
1380  if (st == 2 && ri == 2)
1381  kSerial = ch + 126;
1382  if (st == 3 && ri == 1)
1383  kSerial = ch + 162;
1384  if (st == 3 && ri == 2)
1385  kSerial = ch + 180;
1386  if (st == 4 && ri == 1)
1387  kSerial = ch + 216;
1388  if (st == 4 && ri == 2)
1389  kSerial = ch + 234; // one day...
1390  if (ec == 2)
1391  kSerial = kSerial + 300;
1392  return kSerial;
1393 }
1394 
1395 //--------------------------------------------------------------
1396 // Compute a serial number for the ring.
1397 // This is useful when filling histograms and working with arrays.
1398 //--------------------------------------------------------------
1400  int st = id.station();
1401  int ri = id.ring();
1402  int ec = id.endcap();
1403  int kSerial = 0;
1404  if (st == 1 && ri == 1)
1405  kSerial = ri;
1406  if (st == 1 && ri == 2)
1407  kSerial = ri;
1408  if (st == 1 && ri == 3)
1409  kSerial = ri;
1410  if (st == 1 && ri == 4)
1411  kSerial = 1;
1412  if (st == 2)
1413  kSerial = ri + 3;
1414  if (st == 3)
1415  kSerial = ri + 5;
1416  if (st == 4)
1417  kSerial = ri + 7;
1418  if (ec == 2)
1419  kSerial = kSerial * (-1);
1420  return kSerial;
1421 }
1422 
1423 //-------------------------------------------------------------------------------------
1424 // Fits a straight line to a set of 5 points with errors. Functions assumes 6 points
1425 // and removes hit in layer 3. It then returns the expected position value in layer 3
1426 // based on the fit.
1427 //-------------------------------------------------------------------------------------
1428 float CSCValidation::fitX(const CLHEP::HepMatrix& points, const CLHEP::HepMatrix& errors) {
1429  float S = 0;
1430  float Sx = 0;
1431  float Sy = 0;
1432  float Sxx = 0;
1433  float Sxy = 0;
1434  float sigma2 = 0;
1435 
1436  for (int i = 1; i < 7; i++) {
1437  if (i != 3) {
1438  sigma2 = errors(i, 1) * errors(i, 1);
1439  S = S + (1 / sigma2);
1440  Sy = Sy + (points(i, 1) / sigma2);
1441  Sx = Sx + ((i) / sigma2);
1442  Sxx = Sxx + (i * i) / sigma2;
1443  Sxy = Sxy + (((i)*points(i, 1)) / sigma2);
1444  }
1445  }
1446 
1447  float delta = S * Sxx - Sx * Sx;
1448  float intercept = (Sxx * Sy - Sx * Sxy) / delta;
1449  float slope = (S * Sxy - Sx * Sy) / delta;
1450 
1451  //float chi = 0;
1452  //float chi2 = 0;
1453 
1454  // calculate chi2 (not currently used)
1455  //for (int i=1;i<7;i++){
1456  // chi = (points(i,1) - intercept - slope*i)/(errors(i,1));
1457  // chi2 = chi2 + chi*chi;
1458  //}
1459 
1460  return (intercept + slope * 3);
1461 }
1462 
1463 //----------------------------------------------------------------------------
1464 // Calculate basic efficiencies for recHits and Segments
1465 // Author: S. Stoynev
1466 //----------------------------------------------------------------------------
1467 
1472  edm::ESHandle<CSCGeometry> cscGeom) {
1473  bool allWires[2][4][4][36][6];
1474  bool allStrips[2][4][4][36][6];
1475  bool AllRecHits[2][4][4][36][6];
1476  bool AllSegments[2][4][4][36];
1477 
1478  //bool MultiSegments[2][4][4][36];
1479  for (int iE = 0; iE < 2; iE++) {
1480  for (int iS = 0; iS < 4; iS++) {
1481  for (int iR = 0; iR < 4; iR++) {
1482  for (int iC = 0; iC < 36; iC++) {
1483  AllSegments[iE][iS][iR][iC] = false;
1484  //MultiSegments[iE][iS][iR][iC] = false;
1485  for (int iL = 0; iL < 6; iL++) {
1486  allWires[iE][iS][iR][iC][iL] = false;
1487  allStrips[iE][iS][iR][iC][iL] = false;
1488  AllRecHits[iE][iS][iR][iC][iL] = false;
1489  }
1490  }
1491  }
1492  }
1493  }
1494 
1495  if (useDigis) {
1496  // Wires
1497  for (CSCWireDigiCollection::DigiRangeIterator dWDiter = wires->begin(); dWDiter != wires->end(); dWDiter++) {
1498  CSCDetId idrec = (CSCDetId)(*dWDiter).first;
1499  std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
1500  std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
1501  for (; wireIter != lWire; ++wireIter) {
1502  allWires[idrec.endcap() - 1][idrec.station() - 1][idrec.ring() - 1][idrec.chamber() - 1][idrec.layer() - 1] =
1503  true;
1504  break;
1505  }
1506  }
1507 
1508  //---- STRIPS
1509  for (CSCStripDigiCollection::DigiRangeIterator dSDiter = strips->begin(); dSDiter != strips->end(); dSDiter++) {
1510  CSCDetId idrec = (CSCDetId)(*dSDiter).first;
1511  std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
1512  std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
1513  for (; stripIter != lStrip; ++stripIter) {
1514  std::vector<int> myADCVals = stripIter->getADCCounts();
1515  bool thisStripFired = false;
1516  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1517  float threshold = 13.3;
1518  float diff = 0.;
1519  for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
1520  diff = (float)myADCVals[iCount] - thisPedestal;
1521  if (diff > threshold) {
1522  thisStripFired = true;
1523  break;
1524  }
1525  }
1526  if (thisStripFired) {
1527  allStrips[idrec.endcap() - 1][idrec.station() - 1][idrec.ring() - 1][idrec.chamber() - 1][idrec.layer() - 1] =
1528  true;
1529  break;
1530  }
1531  }
1532  }
1533  }
1534 
1535  // Rechits
1536  for (CSCRecHit2DCollection::const_iterator recEffIt = recHits->begin(); recEffIt != recHits->end(); recEffIt++) {
1537  //CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
1538  CSCDetId idrec = (CSCDetId)(*recEffIt).cscDetId();
1539  AllRecHits[idrec.endcap() - 1][idrec.station() - 1][idrec.ring() - 1][idrec.chamber() - 1][idrec.layer() - 1] =
1540  true;
1541  }
1542 
1543  std::vector<unsigned int> seg_ME2(2, 0);
1544  std::vector<unsigned int> seg_ME3(2, 0);
1545  std::vector<std::pair<CSCDetId, CSCSegment> > theSegments(4);
1546  // Segments
1547  for (CSCSegmentCollection::const_iterator segEffIt = cscSegments->begin(); segEffIt != cscSegments->end();
1548  segEffIt++) {
1549  CSCDetId idseg = (CSCDetId)(*segEffIt).cscDetId();
1550  //if(AllSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()]){
1551  //MultiSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()] = true;
1552  //}
1553  AllSegments[idseg.endcap() - 1][idseg.station() - 1][idseg.ring() - 1][idseg.chamber() - 1] = true;
1554  // "Intrinsic" efficiency measurement relies on "good" segment extrapolation - we need the pre-selection below
1555  // station 2 "good" segment will be used for testing efficiencies in ME1 and ME3
1556  // station 3 "good" segment will be used for testing efficiencies in ME2 and ME4
1557  if (2 == idseg.station() || 3 == idseg.station()) {
1558  unsigned int seg_tmp;
1559  if (2 == idseg.station()) {
1560  ++seg_ME2[idseg.endcap() - 1];
1561  seg_tmp = seg_ME2[idseg.endcap() - 1];
1562  } else {
1563  ++seg_ME3[idseg.endcap() - 1];
1564  seg_tmp = seg_ME3[idseg.endcap() - 1];
1565  }
1566  // is the segment good
1567  if (1 == seg_tmp && 6 == (*segEffIt).nRecHits() && (*segEffIt).chi2() / (*segEffIt).degreesOfFreedom() < 3.) {
1568  std::pair<CSCDetId, CSCSegment> specSeg = make_pair((CSCDetId)(*segEffIt).cscDetId(), *segEffIt);
1569  theSegments[2 * (idseg.endcap() - 1) + (idseg.station() - 2)] = specSeg;
1570  }
1571  }
1572  /*
1573  if(2==idseg.station()){
1574  ++seg_ME2[idseg.endcap() -1];
1575  if(1==seg_ME2[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
1576  std::pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
1577  theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
1578  }
1579  }
1580  else if(3==idseg.station()){
1581  ++seg_ME3[idseg.endcap() -1];
1582  if(1==seg_ME3[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
1583  std::pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
1584  theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
1585  }
1586  }
1587  */
1588  }
1589  // Simple efficiency calculations
1590  for (int iE = 0; iE < 2; iE++) {
1591  for (int iS = 0; iS < 4; iS++) {
1592  for (int iR = 0; iR < 4; iR++) {
1593  for (int iC = 0; iC < 36; iC++) {
1594  int NumberOfLayers = 0;
1595  for (int iL = 0; iL < 6; iL++) {
1596  if (AllRecHits[iE][iS][iR][iC][iL]) {
1597  NumberOfLayers++;
1598  }
1599  }
1600  int bin = 0;
1601  if (iS == 0)
1602  bin = iR + 1 + (iE * 10);
1603  else
1604  bin = (iS + 1) * 2 + (iR + 1) + (iE * 10);
1605  if (NumberOfLayers > 1) {
1606  //if(!(MultiSegments[iE][iS][iR][iC])){
1607  if (AllSegments[iE][iS][iR][iC]) {
1608  //---- Efficient segment evenents
1609  hSSTE->AddBinContent(bin);
1610  }
1611  //---- All segment events (normalization)
1612  hSSTE->AddBinContent(20 + bin);
1613  //}
1614  }
1615  if (AllSegments[iE][iS][iR][iC]) {
1616  if (NumberOfLayers == 6) {
1617  //---- Efficient rechit events
1618  hRHSTE->AddBinContent(bin);
1619  ;
1620  }
1621  //---- All rechit events (normalization)
1622  hRHSTE->AddBinContent(20 + bin);
1623  ;
1624  }
1625  }
1626  }
1627  }
1628  }
1629 
1630  // pick a segment only if there are no others in the station
1631  std::vector<std::pair<CSCDetId, CSCSegment>*> theSeg;
1632  if (1 == seg_ME2[0])
1633  theSeg.push_back(&theSegments[0]);
1634  if (1 == seg_ME3[0])
1635  theSeg.push_back(&theSegments[1]);
1636  if (1 == seg_ME2[1])
1637  theSeg.push_back(&theSegments[2]);
1638  if (1 == seg_ME3[1])
1639  theSeg.push_back(&theSegments[3]);
1640 
1641  // Needed for plots
1642  // at the end the chamber types will be numbered as 1 to 18
1643  // (ME-4/1, -ME3/2, -ME3/1, ..., +ME3/1, +ME3/2, ME+4/1 )
1644  std::map<std::string, float> chamberTypes;
1645  chamberTypes["ME1/a"] = 0.5;
1646  chamberTypes["ME1/b"] = 1.5;
1647  chamberTypes["ME1/2"] = 2.5;
1648  chamberTypes["ME1/3"] = 3.5;
1649  chamberTypes["ME2/1"] = 4.5;
1650  chamberTypes["ME2/2"] = 5.5;
1651  chamberTypes["ME3/1"] = 6.5;
1652  chamberTypes["ME3/2"] = 7.5;
1653  chamberTypes["ME4/1"] = 8.5;
1654 
1655  if (!theSeg.empty()) {
1656  std::map<int, GlobalPoint> extrapolatedPoint;
1657  std::map<int, GlobalPoint>::iterator it;
1658  const CSCGeometry::ChamberContainer& ChamberContainer = cscGeom->chambers();
1659  // Pick which chamber with which segment to test
1660  for (size_t nCh = 0; nCh < ChamberContainer.size(); nCh++) {
1661  const CSCChamber* cscchamber = ChamberContainer[nCh];
1662  std::pair<CSCDetId, CSCSegment>* thisSegment = nullptr;
1663  for (size_t iSeg = 0; iSeg < theSeg.size(); ++iSeg) {
1664  if (cscchamber->id().endcap() == theSeg[iSeg]->first.endcap()) {
1665  if (1 == cscchamber->id().station() || 3 == cscchamber->id().station()) {
1666  if (2 == theSeg[iSeg]->first.station()) {
1667  thisSegment = theSeg[iSeg];
1668  }
1669  } else if (2 == cscchamber->id().station() || 4 == cscchamber->id().station()) {
1670  if (3 == theSeg[iSeg]->first.station()) {
1671  thisSegment = theSeg[iSeg];
1672  }
1673  }
1674  }
1675  }
1676  // this chamber is to be tested with thisSegment
1677  if (thisSegment) {
1678  CSCSegment* seg = &(thisSegment->second);
1679  const CSCChamber* segChamber = cscGeom->chamber(thisSegment->first);
1680  LocalPoint localCenter(0., 0., 0);
1681  GlobalPoint cscchamberCenter = cscchamber->toGlobal(localCenter);
1682  // try to save some time (extrapolate a segment to a certain position only once)
1683  it = extrapolatedPoint.find(int(cscchamberCenter.z()));
1684  if (it == extrapolatedPoint.end()) {
1685  GlobalPoint segPos = segChamber->toGlobal(seg->localPosition());
1686  GlobalVector segDir = segChamber->toGlobal(seg->localDirection());
1687  double paramaterLine = lineParametrization(segPos.z(), cscchamberCenter.z(), segDir.z());
1688  double xExtrapolated = extrapolate1D(segPos.x(), segDir.x(), paramaterLine);
1689  double yExtrapolated = extrapolate1D(segPos.y(), segDir.y(), paramaterLine);
1690  GlobalPoint globP(xExtrapolated, yExtrapolated, cscchamberCenter.z());
1691  extrapolatedPoint[int(cscchamberCenter.z())] = globP;
1692  }
1693  // Where does the extrapolated point lie in the (tested) chamber local frame? Here:
1694  LocalPoint extrapolatedPointLocal = cscchamber->toLocal(extrapolatedPoint[int(cscchamberCenter.z())]);
1695  const CSCLayer* layer_p = cscchamber->layer(1); //layer 1
1696  const CSCLayerGeometry* layerGeom = layer_p->geometry();
1697  const std::array<const float, 4>& layerBounds = layerGeom->parameters();
1698  float shiftFromEdge = 15.; //cm
1699  float shiftFromDeadZone = 10.;
1700  // is the extrapolated point within a sensitive region
1701  bool pass = withinSensitiveRegion(extrapolatedPointLocal,
1702  layerBounds,
1703  cscchamber->id().station(),
1704  cscchamber->id().ring(),
1705  shiftFromEdge,
1706  shiftFromDeadZone);
1707  if (pass) { // the extrapolation point of the segment lies within sensitive region of that chamber
1708  // how many rechit layers are there in the chamber?
1709  // 0 - maybe the muon died or is deflected at large angle? do not use that case
1710  // 1 - could be noise...
1711  // 2 or more - this is promissing; this is our definition of a reliable signal; use it below
1712  // is other definition better?
1713  int nRHLayers = 0;
1714  for (int iL = 0; iL < 6; ++iL) {
1715  if (AllRecHits[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1716  [cscchamber->id().chamber() - 1][iL]) {
1717  ++nRHLayers;
1718  }
1719  }
1720  //std::cout<<" nRHLayers = "<<nRHLayers<<std::endl;
1721  float verticalScale = chamberTypes[cscchamber->specs()->chamberTypeName()];
1722  if (cscchamberCenter.z() < 0) {
1723  verticalScale = -verticalScale;
1724  }
1725  verticalScale += 9.5;
1726  hSensitiveAreaEvt->Fill(float(cscchamber->id().chamber()), verticalScale);
1727  if (nRHLayers > 1) { // this chamber contains a reliable signal
1728  //chamberTypes[cscchamber->specs()->chamberTypeName()];
1729  // "intrinsic" efficiencies
1730  //std::cout<<" verticalScale = "<<verticalScale<<" chType = "<<cscchamber->specs()->chamberTypeName()<<std::endl;
1731  // this is the denominator forr all efficiencies
1732  hEffDenominator->Fill(float(cscchamber->id().chamber()), verticalScale);
1733  // Segment efficiency
1734  if (AllSegments[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1735  [cscchamber->id().chamber() - 1]) {
1736  hSSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale));
1737  }
1738 
1739  for (int iL = 0; iL < 6; ++iL) {
1740  float weight = 1. / 6.;
1741  // one shold account for the weight in the efficiency...
1742  // Rechit efficiency
1743  if (AllRecHits[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1744  [cscchamber->id().chamber() - 1][iL]) {
1745  hRHSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale), weight);
1746  }
1747  if (useDigis) {
1748  // Wire efficiency
1749  if (allWires[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1750  [cscchamber->id().chamber() - 1][iL]) {
1751  // one shold account for the weight in the efficiency...
1752  hWireSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale), weight);
1753  }
1754  // Strip efficiency
1755  if (allStrips[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1]
1756  [cscchamber->id().ring() - 1][cscchamber->id().chamber() - 1][iL]) {
1757  // one shold account for the weight in the efficiency...
1758  hStripSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale), weight);
1759  }
1760  }
1761  }
1762  }
1763  }
1764  }
1765  }
1766  }
1767  //
1768 }
1769 
1770 void CSCValidation::getEfficiency(float bin, float Norm, std::vector<float>& eff) {
1771  //---- Efficiency with binomial error
1772  float Efficiency = 0.;
1773  float EffError = 0.;
1774  if (fabs(Norm) > 0.000000001) {
1775  Efficiency = bin / Norm;
1776  if (bin < Norm) {
1777  EffError = sqrt((1. - Efficiency) * Efficiency / Norm);
1778  }
1779  }
1780  eff[0] = Efficiency;
1781  eff[1] = EffError;
1782 }
1783 
1784 void CSCValidation::histoEfficiency(TH1F* readHisto, TH1F* writeHisto) {
1785  std::vector<float> eff(2);
1786  int Nbins = readHisto->GetSize() - 2; //without underflows and overflows
1787  std::vector<float> bins(Nbins);
1788  std::vector<float> Efficiency(Nbins);
1789  std::vector<float> EffError(Nbins);
1790  float Num = 1;
1791  float Den = 1;
1792  for (int i = 0; i < 20; i++) {
1793  Num = readHisto->GetBinContent(i + 1);
1794  Den = readHisto->GetBinContent(i + 21);
1795  getEfficiency(Num, Den, eff);
1796  Efficiency[i] = eff[0];
1797  EffError[i] = eff[1];
1798  writeHisto->SetBinContent(i + 1, Efficiency[i]);
1799  writeHisto->SetBinError(i + 1, EffError[i]);
1800  }
1801 }
1802 
1804  const std::array<const float, 4>& layerBounds,
1805  int station,
1806  int ring,
1807  float shiftFromEdge,
1808  float shiftFromDeadZone) {
1809  //---- check if it is in a good local region (sensitive area - geometrical and HV boundaries excluded)
1810  bool pass = false;
1811 
1812  float y_center = 0.;
1813  double yUp = layerBounds[3] + y_center;
1814  double yDown = -layerBounds[3] + y_center;
1815  double xBound1Shifted = layerBounds[0] - shiftFromEdge; //
1816  double xBound2Shifted = layerBounds[1] - shiftFromEdge; //
1817  double lineSlope = (yUp - yDown) / (xBound2Shifted - xBound1Shifted);
1818  double lineConst = yUp - lineSlope * xBound2Shifted;
1819  double yBorder = lineSlope * abs(localPos.x()) + lineConst;
1820 
1821  //bool withinChamberOnly = false;// false = "good region"; true - boundaries only
1822  std::vector<float> deadZoneCenter(6);
1823  float cutZone = shiftFromDeadZone; //cm
1824  //---- hardcoded... not good
1825  if (station > 1 && station < 5) {
1826  if (2 == ring) {
1827  deadZoneCenter[0] = -162.48;
1828  deadZoneCenter[1] = -81.8744;
1829  deadZoneCenter[2] = -21.18165;
1830  deadZoneCenter[3] = 39.51105;
1831  deadZoneCenter[4] = 100.2939;
1832  deadZoneCenter[5] = 160.58;
1833 
1834  if (localPos.y() > yBorder &&
1835  ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
1836  (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
1837  (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone) ||
1838  (localPos.y() > deadZoneCenter[3] + cutZone && localPos.y() < deadZoneCenter[4] - cutZone) ||
1839  (localPos.y() > deadZoneCenter[4] + cutZone && localPos.y() < deadZoneCenter[5] - cutZone))) {
1840  pass = true;
1841  }
1842  } else if (1 == ring) {
1843  if (2 == station) {
1844  deadZoneCenter[0] = -95.80;
1845  deadZoneCenter[1] = -27.47;
1846  deadZoneCenter[2] = 33.67;
1847  deadZoneCenter[3] = 90.85;
1848  } else if (3 == station) {
1849  deadZoneCenter[0] = -89.305;
1850  deadZoneCenter[1] = -39.705;
1851  deadZoneCenter[2] = 20.195;
1852  deadZoneCenter[3] = 77.395;
1853  } else if (4 == station) {
1854  deadZoneCenter[0] = -75.645;
1855  deadZoneCenter[1] = -26.055;
1856  deadZoneCenter[2] = 23.855;
1857  deadZoneCenter[3] = 70.575;
1858  }
1859  if (localPos.y() > yBorder &&
1860  ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
1861  (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
1862  (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone))) {
1863  pass = true;
1864  }
1865  }
1866  } else if (1 == station) {
1867  if (3 == ring) {
1868  deadZoneCenter[0] = -83.155;
1869  deadZoneCenter[1] = -22.7401;
1870  deadZoneCenter[2] = 27.86665;
1871  deadZoneCenter[3] = 81.005;
1872  if (localPos.y() > yBorder &&
1873  ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
1874  (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
1875  (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone))) {
1876  pass = true;
1877  }
1878  } else if (2 == ring) {
1879  deadZoneCenter[0] = -86.285;
1880  deadZoneCenter[1] = -32.88305;
1881  deadZoneCenter[2] = 32.867423;
1882  deadZoneCenter[3] = 88.205;
1883  if (localPos.y() > (yBorder) &&
1884  ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
1885  (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
1886  (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone))) {
1887  pass = true;
1888  }
1889  } else {
1890  deadZoneCenter[0] = -81.0;
1891  deadZoneCenter[1] = 81.0;
1892  if (localPos.y() > (yBorder) &&
1893  (localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone)) {
1894  pass = true;
1895  }
1896  }
1897  }
1898  return pass;
1899 }
1900 
1901 //---------------------------------------------------------------------------------------
1902 // Given a set of digis, the CSCDetId, and the central strip of your choosing, returns
1903 // the avg. Signal-Pedestal for 6 time bin x 5 strip .
1904 //
1905 // Author: P. Jindal
1906 //---------------------------------------------------------------------------------------
1907 
1908 float CSCValidation::getSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idCS, int centerStrip) {
1909  float SigADC[5];
1910  float TotalADC = 0;
1911  SigADC[0] = 0;
1912  SigADC[1] = 0;
1913  SigADC[2] = 0;
1914  SigADC[3] = 0;
1915  SigADC[4] = 0;
1916 
1917  // Loop over strip digis
1919 
1920  for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++) {
1921  CSCDetId id = (CSCDetId)(*sIt).first;
1922  if (id == idCS) {
1923  // First, find the Signal-Pedestal for center strip
1924  std::vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
1925  std::vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
1926  for (; digiItr != last; ++digiItr) {
1927  int thisStrip = digiItr->getStrip();
1928  if (thisStrip == (centerStrip)) {
1929  std::vector<int> myADCVals = digiItr->getADCCounts();
1930  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1931  float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1932  SigADC[0] = thisSignal - 6 * thisPedestal;
1933  }
1934  // Now,find the Signal-Pedestal for neighbouring 4 strips
1935  if (thisStrip == (centerStrip + 1)) {
1936  std::vector<int> myADCVals = digiItr->getADCCounts();
1937  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1938  float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1939  SigADC[1] = thisSignal - 6 * thisPedestal;
1940  }
1941  if (thisStrip == (centerStrip + 2)) {
1942  std::vector<int> myADCVals = digiItr->getADCCounts();
1943  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1944  float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1945  SigADC[2] = thisSignal - 6 * thisPedestal;
1946  }
1947  if (thisStrip == (centerStrip - 1)) {
1948  std::vector<int> myADCVals = digiItr->getADCCounts();
1949  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1950  float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1951  SigADC[3] = thisSignal - 6 * thisPedestal;
1952  }
1953  if (thisStrip == (centerStrip - 2)) {
1954  std::vector<int> myADCVals = digiItr->getADCCounts();
1955  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1956  float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1957  SigADC[4] = thisSignal - 6 * thisPedestal;
1958  }
1959  }
1960  TotalADC = 0.2 * (SigADC[0] + SigADC[1] + SigADC[2] + SigADC[3] + SigADC[4]);
1961  }
1962  }
1963  return TotalADC;
1964 }
1965 
1966 //---------------------------------------------------------------------------------------
1967 // Look at non-associated recHits
1968 // Author: P. Jindal
1969 //---------------------------------------------------------------------------------------
1970 
1976  for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
1977  CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
1978 
1979  //Store the Rechits into a Map
1980  AllRechits.insert(std::pair<CSCDetId, CSCRecHit2D>(idrec, *recIt));
1981 
1982  // Find the strip containing this hit
1983  int centerid = recIt->nStrips() / 2;
1984  int centerStrip = recIt->channels(centerid);
1985 
1986  float rHsignal = getthisSignal(*strips, idrec, centerStrip);
1987  histos->fill1DHist(
1988  rHsignal, "hrHSignal", "Signal in the 4th time bin for centre strip", 1100, -99, 1000, "recHits");
1989  }
1990 
1991  for (CSCSegmentCollection::const_iterator it = cscSegments->begin(); it != cscSegments->end(); it++) {
1992  std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
1993  for (std::vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
1994  CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
1995  LocalPoint lpRH = (*iRH).localPosition();
1996  float xrec = lpRH.x();
1997  float yrec = lpRH.y();
1998  float zrec = lpRH.z();
1999  bool RHalreadyinMap = false;
2000  //Store the rechits associated with segments into a Map
2001  multimap<CSCDetId, CSCRecHit2D>::iterator segRHit;
2002  segRHit = SegRechits.find(idRH);
2003  if (segRHit != SegRechits.end()) {
2004  for (; segRHit != SegRechits.upper_bound(idRH); ++segRHit) {
2005  //for( segRHit = SegRechits.begin(); segRHit != SegRechits.end() ;++segRHit){
2006  LocalPoint lposRH = (segRHit->second).localPosition();
2007  float xpos = lposRH.x();
2008  float ypos = lposRH.y();
2009  float zpos = lposRH.z();
2010  if (xrec == xpos && yrec == ypos && zrec == zpos) {
2011  RHalreadyinMap = true;
2012  //std::cout << " Already exists " <<std ::endl;
2013  break;
2014  }
2015  }
2016  }
2017  if (!RHalreadyinMap) {
2018  SegRechits.insert(std::pair<CSCDetId, CSCRecHit2D>(idRH, *iRH));
2019  }
2020  }
2021  }
2022 
2023  findNonAssociatedRecHits(cscGeom, strips);
2024 }
2025 
2026 //---------------------------------------------------------------------------------------
2027 // Given the list of all rechits and the rechits on a segment finds the rechits
2028 // not associated to a segment and stores in a list
2029 //
2030 //---------------------------------------------------------------------------------------
2031 
2034  for (std::multimap<CSCDetId, CSCRecHit2D>::iterator allRHiter = AllRechits.begin(); allRHiter != AllRechits.end();
2035  ++allRHiter) {
2036  CSCDetId idRH = allRHiter->first;
2037  LocalPoint lpRH = (allRHiter->second).localPosition();
2038  float xrec = lpRH.x();
2039  float yrec = lpRH.y();
2040  float zrec = lpRH.z();
2041 
2042  bool foundmatch = false;
2043  multimap<CSCDetId, CSCRecHit2D>::iterator segRHit;
2044  segRHit = SegRechits.find(idRH);
2045  if (segRHit != SegRechits.end()) {
2046  for (; segRHit != SegRechits.upper_bound(idRH); ++segRHit) {
2047  LocalPoint lposRH = (segRHit->second).localPosition();
2048  float xpos = lposRH.x();
2049  float ypos = lposRH.y();
2050  float zpos = lposRH.z();
2051 
2052  if (xrec == xpos && yrec == ypos && zrec == zpos) {
2053  foundmatch = true;
2054  }
2055 
2056  float d = 0.;
2057  float dclose = 1000.;
2058 
2059  if (!foundmatch) {
2060  d = sqrt(pow(xrec - xpos, 2) + pow(yrec - ypos, 2) + pow(zrec - zpos, 2));
2061  if (d < dclose) {
2062  dclose = d;
2063  if (distRHmap.find((allRHiter->second)) ==
2064  distRHmap.end()) { // entry for rechit does not yet exist, create one
2065  distRHmap.insert(make_pair(allRHiter->second, dclose));
2066  } else {
2067  // we already have an entry for the detid.
2068  distRHmap.erase(allRHiter->second);
2069  distRHmap.insert(
2070  make_pair(allRHiter->second, dclose)); // fill rechits for the segment with the given detid
2071  }
2072  }
2073  }
2074  }
2075  }
2076  if (!foundmatch) {
2077  NonAssociatedRechits.insert(std::pair<CSCDetId, CSCRecHit2D>(idRH, allRHiter->second));
2078  }
2079  }
2080 
2081  for (std::map<CSCRecHit2D, float, ltrh>::iterator iter = distRHmap.begin(); iter != distRHmap.end(); ++iter) {
2082  histos->fill1DHist(iter->second,
2083  "hdistRH",
2084  "Distance of Non Associated RecHit from closest Segment RecHit",
2085  500,
2086  0.,
2087  100.,
2088  "NonAssociatedRechits");
2089  }
2090 
2091  for (std::multimap<CSCDetId, CSCRecHit2D>::iterator iter = NonAssociatedRechits.begin();
2092  iter != NonAssociatedRechits.end();
2093  ++iter) {
2094  CSCDetId idrec = iter->first;
2095  int kEndcap = idrec.endcap();
2096  int cEndcap = idrec.endcap();
2097  if (kEndcap == 2)
2098  cEndcap = -1;
2099  int kRing = idrec.ring();
2100  int kStation = idrec.station();
2101  int kChamber = idrec.chamber();
2102  int kLayer = idrec.layer();
2103 
2104  // Store rechit as a Local Point:
2105  LocalPoint rhitlocal = (iter->second).localPosition();
2106  float xreco = rhitlocal.x();
2107  float yreco = rhitlocal.y();
2108 
2109  // Find the strip containing this hit
2110  int centerid = (iter->second).nStrips() / 2;
2111  int centerStrip = (iter->second).channels(centerid);
2112 
2113  // Find the charge associated with this hit
2114  float rHSumQ = 0;
2115  float sumsides = 0.;
2116  int adcsize = (iter->second).nStrips() * (iter->second).nTimeBins();
2117  for (unsigned int i = 0; i < (iter->second).nStrips(); i++) {
2118  for (unsigned int j = 0; j < (iter->second).nTimeBins() - 1; j++) {
2119  rHSumQ += (iter->second).adcs(i, j);
2120  if (i != 1)
2121  sumsides += (iter->second).adcs(i, j);
2122  }
2123  }
2124 
2125  float rHratioQ = sumsides / rHSumQ;
2126  if (adcsize != 12)
2127  rHratioQ = -99;
2128 
2129  // Get the signal timing of this hit
2130  float rHtime = (iter->second).tpeak() / 50;
2131 
2132  // Get the width of this hit
2133  int rHwidth = getWidth(*strips, idrec, centerStrip);
2134 
2135  // Get pointer to the layer:
2136  const CSCLayer* csclayer = cscGeom->layer(idrec);
2137 
2138  // Transform hit position from local chamber geometry to global CMS geom
2139  GlobalPoint rhitglobal = csclayer->toGlobal(rhitlocal);
2140  float grecx = rhitglobal.x();
2141  float grecy = rhitglobal.y();
2142 
2143  // Simple occupancy variables
2144  int kCodeBroad = cEndcap * (4 * (kStation - 1) + kRing);
2145  int kCodeNarrow = cEndcap * (100 * (kRing - 1) + kChamber);
2146 
2147  //Fill the non-associated rechits parameters in histogram
2148  histos->fill1DHist(
2149  kCodeBroad, "hNARHCodeBroad", "broad scope code for recHits", 33, -16.5, 16.5, "NonAssociatedRechits");
2150  if (kStation == 1)
2151  histos->fill1DHist(kCodeNarrow,
2152  "hNARHCodeNarrow1",
2153  "narrow scope recHit code station 1",
2154  801,
2155  -400.5,
2156  400.5,
2157  "NonAssociatedRechits");
2158  if (kStation == 2)
2159  histos->fill1DHist(kCodeNarrow,
2160  "hNARHCodeNarrow2",
2161  "narrow scope recHit code station 2",
2162  801,
2163  -400.5,
2164  400.5,
2165  "NonAssociatedRechits");
2166  if (kStation == 3)
2167  histos->fill1DHist(kCodeNarrow,
2168  "hNARHCodeNarrow3",
2169  "narrow scope recHit code station 3",
2170  801,
2171  -400.5,
2172  400.5,
2173  "NonAssociatedRechits");
2174  if (kStation == 4)
2175  histos->fill1DHist(kCodeNarrow,
2176  "hNARHCodeNarrow4",
2177  "narrow scope recHit code station 4",
2178  801,
2179  -400.5,
2180  400.5,
2181  "NonAssociatedRechits");
2182  histos->fill1DHistByType(kLayer, "hNARHLayer", "RecHits per Layer", idrec, 8, -0.5, 7.5, "NonAssociatedRechits");
2183  histos->fill1DHistByType(xreco, "hNARHX", "Local X of recHit", idrec, 160, -80., 80., "NonAssociatedRechits");
2184  histos->fill1DHistByType(yreco, "hNARHY", "Local Y of recHit", idrec, 60, -180., 180., "NonAssociatedRechits");
2185  if (kStation == 1 && (kRing == 1 || kRing == 4))
2186  histos->fill1DHistByType(
2187  rHSumQ, "hNARHSumQ", "Sum 3x3 recHit Charge", idrec, 250, 0, 4000, "NonAssociatedRechits");
2188  else
2189  histos->fill1DHistByType(
2190  rHSumQ, "hNARHSumQ", "Sum 3x3 recHit Charge", idrec, 250, 0, 2000, "NonAssociatedRechits");
2191  histos->fill1DHistByType(
2192  rHratioQ, "hNARHRatioQ", "Ratio (Ql+Qr)/Qt)", idrec, 120, -0.1, 1.1, "NonAssociatedRechits");
2193  histos->fill1DHistByType(rHtime, "hNARHTiming", "recHit Timing", idrec, 200, -10, 10, "NonAssociatedRechits");
2194  histos->fill2DHistByStation(grecx,
2195  grecy,
2196  "hNARHGlobal",
2197  "recHit Global Position",
2198  idrec,
2199  400,
2200  -800.,
2201  800.,
2202  400,
2203  -800.,
2204  800.,
2205  "NonAssociatedRechits");
2206  histos->fill1DHistByType(
2207  rHwidth, "hNARHwidth", "width for Non associated recHit", idrec, 21, -0.5, 20.5, "NonAssociatedRechits");
2208  }
2209 
2210  for (std::multimap<CSCDetId, CSCRecHit2D>::iterator iter = SegRechits.begin(); iter != SegRechits.end(); ++iter) {
2211  CSCDetId idrec = iter->first;
2212  int kEndcap = idrec.endcap();
2213  int cEndcap = idrec.endcap();
2214  if (kEndcap == 2)
2215  cEndcap = -1;
2216  int kRing = idrec.ring();
2217  int kStation = idrec.station();
2218  int kChamber = idrec.chamber();
2219  int kLayer = idrec.layer();
2220 
2221  // Store rechit as a Local Point:
2222  LocalPoint rhitlocal = (iter->second).localPosition();
2223  float xreco = rhitlocal.x();
2224  float yreco = rhitlocal.y();
2225 
2226  // Find the strip containing this hit
2227  int centerid = (iter->second).nStrips() / 2;
2228  int centerStrip = (iter->second).channels(centerid);
2229 
2230  // Find the charge associated with this hit
2231 
2232  float rHSumQ = 0;
2233  float sumsides = 0.;
2234  int adcsize = (iter->second).nStrips() * (iter->second).nTimeBins();
2235  for (unsigned int i = 0; i < (iter->second).nStrips(); i++) {
2236  for (unsigned int j = 0; j < (iter->second).nTimeBins() - 1; j++) {
2237  rHSumQ += (iter->second).adcs(i, j);
2238  if (i != 1)
2239  sumsides += (iter->second).adcs(i, j);
2240  }
2241  }
2242 
2243  float rHratioQ = sumsides / rHSumQ;
2244  if (adcsize != 12)
2245  rHratioQ = -99;
2246 
2247  // Get the signal timing of this hit
2248  float rHtime = (iter->second).tpeak() / 50;
2249 
2250  // Get the width of this hit
2251  int rHwidth = getWidth(*strips, idrec, centerStrip);
2252 
2253  // Get pointer to the layer:
2254  const CSCLayer* csclayer = cscGeom->layer(idrec);
2255 
2256  // Transform hit position from local chamber geometry to global CMS geom
2257  GlobalPoint rhitglobal = csclayer->toGlobal(rhitlocal);
2258  float grecx = rhitglobal.x();
2259  float grecy = rhitglobal.y();
2260 
2261  // Simple occupancy variables
2262  int kCodeBroad = cEndcap * (4 * (kStation - 1) + kRing);
2263  int kCodeNarrow = cEndcap * (100 * (kRing - 1) + kChamber);
2264 
2265  //Fill the non-associated rechits global position in histogram
2266  histos->fill1DHist(
2267  kCodeBroad, "hSegRHCodeBroad", "broad scope code for recHits", 33, -16.5, 16.5, "AssociatedRechits");
2268  if (kStation == 1)
2269  histos->fill1DHist(kCodeNarrow,
2270  "hSegRHCodeNarrow1",
2271  "narrow scope recHit code station 1",
2272  801,
2273  -400.5,
2274  400.5,
2275  "AssociatedRechits");
2276  if (kStation == 2)
2277  histos->fill1DHist(kCodeNarrow,
2278  "hSegRHCodeNarrow2",
2279  "narrow scope recHit code station 2",
2280  801,
2281  -400.5,
2282  400.5,
2283  "AssociatedRechits");
2284  if (kStation == 3)
2285  histos->fill1DHist(kCodeNarrow,
2286  "hSegRHCodeNarrow3",
2287  "narrow scope recHit code station 3",
2288  801,
2289  -400.5,
2290  400.5,
2291  "AssociatedRechits");
2292  if (kStation == 4)
2293  histos->fill1DHist(kCodeNarrow,
2294  "hSegRHCodeNarrow4",
2295  "narrow scope recHit code station 4",
2296  801,
2297  -400.5,
2298  400.5,
2299  "AssociatedRechits");
2300  histos->fill1DHistByType(kLayer, "hSegRHLayer", "RecHits per Layer", idrec, 8, -0.5, 7.5, "AssociatedRechits");
2301  histos->fill1DHistByType(xreco, "hSegRHX", "Local X of recHit", idrec, 160, -80., 80., "AssociatedRechits");
2302  histos->fill1DHistByType(yreco, "hSegRHY", "Local Y of recHit", idrec, 60, -180., 180., "AssociatedRechits");
2303  if (kStation == 1 && (kRing == 1 || kRing == 4))
2304  histos->fill1DHistByType(rHSumQ, "hSegRHSumQ", "Sum 3x3 recHit Charge", idrec, 250, 0, 4000, "AssociatedRechits");
2305  else
2306  histos->fill1DHistByType(rHSumQ, "hSegRHSumQ", "Sum 3x3 recHit Charge", idrec, 250, 0, 2000, "AssociatedRechits");
2307  histos->fill1DHistByType(rHratioQ, "hSegRHRatioQ", "Ratio (Ql+Qr)/Qt)", idrec, 120, -0.1, 1.1, "AssociatedRechits");
2308  histos->fill1DHistByType(rHtime, "hSegRHTiming", "recHit Timing", idrec, 200, -10, 10, "AssociatedRechits");
2309  histos->fill2DHistByStation(grecx,
2310  grecy,
2311  "hSegRHGlobal",
2312  "recHit Global Position",
2313  idrec,
2314  400,
2315  -800.,
2316  800.,
2317  400,
2318  -800.,
2319  800.,
2320  "AssociatedRechits");
2321  histos->fill1DHistByType(
2322  rHwidth, "hSegRHwidth", "width for Non associated recHit", idrec, 21, -0.5, 20.5, "AssociatedRechits");
2323  }
2324 
2325  distRHmap.clear();
2326  AllRechits.clear();
2327  SegRechits.clear();
2328  NonAssociatedRechits.clear();
2329 }
2330 
2331 float CSCValidation::getthisSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip) {
2332  // Loop over strip digis responsible for this recHit
2334  float thisADC = 0.;
2335  //bool foundRHid = false;
2336  // std::cout<<"iD S/R/C/L = "<<idRH<<" "<<idRH.station()<<"/"<<idRH.ring()<<"/"<<idRH.chamber()<<"/"<<idRH.layer()<<std::endl;
2337  for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++) {
2338  CSCDetId id = (CSCDetId)(*sIt).first;
2339  //std::cout<<"STRIPS: id S/R/C/L = "<<id<<" "<<id.station()<<"/"<<id.ring()<<"/"<<id.chamber()<<"/"<<id.layer()<<std::endl;
2340  if (id == idRH) {
2341  //foundRHid = true;
2342  vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
2343  vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
2344  //if(digiItr == last ) {std::cout << " Attention1 :: Size of digi collection is zero " << std::endl;}
2345  int St = idRH.station();
2346  int Rg = idRH.ring();
2347  if (St == 1 && Rg == 4) {
2348  while (centerStrip > 16)
2349  centerStrip -= 16;
2350  }
2351  for (; digiItr != last; ++digiItr) {
2352  int thisStrip = digiItr->getStrip();
2353  //std::cout<<" thisStrip = "<<thisStrip<<" centerStrip = "<<centerStrip<<std::endl;
2354  std::vector<int> myADCVals = digiItr->getADCCounts();
2355  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
2356  float Signal = (float)myADCVals[3];
2357  if (thisStrip == (centerStrip)) {
2358  thisADC = Signal - thisPedestal;
2359  //if(thisADC >= 0. && thisADC <2.) {std::cout << " Attention2 :: The Signal is equal to the pedestal " << std::endl;
2360  //}
2361  //if(thisADC < 0.) {std::cout << " Attention3 :: The Signal is less than the pedestal " << std::endl;
2362  //}
2363  }
2364  if (thisStrip == (centerStrip + 1)) {
2365  std::vector<int> myADCVals = digiItr->getADCCounts();
2366  }
2367  if (thisStrip == (centerStrip - 1)) {
2368  std::vector<int> myADCVals = digiItr->getADCCounts();
2369  }
2370  }
2371  }
2372  }
2373  //if(!foundRHid){std::cout << " Attention4 :: Did not find a matching RH id in the Strip Digi collection " << std::endl;}
2374  return thisADC;
2375 }
2376 
2377 //---------------------------------------------------------------------------------------
2378 //
2379 // Function is meant to take the DetId and center strip number of a recHit and return
2380 // the width in terms of strips
2381 //---------------------------------------------------------------------------------------
2382 
2383 int CSCValidation::getWidth(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip) {
2384  int width = 1;
2385  int widthpos = 0;
2386  int widthneg = 0;
2387 
2388  // Loop over strip digis responsible for this recHit and sum charge
2390 
2391  for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++) {
2392  CSCDetId id = (CSCDetId)(*sIt).first;
2393  if (id == idRH) {
2394  std::vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
2395  std::vector<CSCStripDigi>::const_iterator first = (*sIt).second.first;
2396  std::vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
2397  std::vector<CSCStripDigi>::const_iterator it = (*sIt).second.first;
2398  std::vector<CSCStripDigi>::const_iterator itr = (*sIt).second.first;
2399  //std::cout << " IDRH " << id <<std::endl;
2400  int St = idRH.station();
2401  int Rg = idRH.ring();
2402  if (St == 1 && Rg == 4) {
2403  while (centerStrip > 16)
2404  centerStrip -= 16;
2405  }
2406  for (; digiItr != last; ++digiItr) {
2407  int thisStrip = digiItr->getStrip();
2408  if (thisStrip == (centerStrip)) {
2409  it = digiItr;
2410  for (; it != last; ++it) {
2411  int strip = it->getStrip();
2412  std::vector<int> myADCVals = it->getADCCounts();
2413  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
2414  if (((float)myADCVals[3] - thisPedestal) < 6 || widthpos == 10 || it == last) {
2415  break;
2416  }
2417  if (strip != centerStrip) {
2418  widthpos += 1;
2419  }
2420  }
2421  itr = digiItr;
2422  for (; itr != first; --itr) {
2423  int strip = itr->getStrip();
2424  std::vector<int> myADCVals = itr->getADCCounts();
2425  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
2426  if (((float)myADCVals[3] - thisPedestal) < 6 || widthneg == 10 || itr == first) {
2427  break;
2428  }
2429  if (strip != centerStrip) {
2430  widthneg += 1;
2431  }
2432  }
2433  }
2434  }
2435  }
2436  }
2437  //std::cout << "Widthneg - " << widthneg << "Widthpos + " << widthpos << std::endl;
2438  width = width + widthneg + widthpos;
2439  //std::cout << "Width " << width << std::endl;
2440  return width;
2441 }
2442 
2443 //---------------------------------------------------------------------------
2444 // Module for looking at gas gains
2445 // Author N. Terentiev
2446 //---------------------------------------------------------------------------
2447 
2449  const CSCStripDigiCollection& strpcltn,
2450  const CSCRecHit2DCollection& rechitcltn) {
2451  int channel = 0, mult, wire, layer, idlayer, idchamber, ring;
2452  int wire_strip_rechit_present;
2453  std::string name, title, endcapstr;
2454  ostringstream ss;
2455  CSCIndexer indexer;
2456  std::map<int, int>::iterator intIt;
2457 
2458  m_single_wire_layer.clear();
2459 
2460  if (firstEvent) {
2461  // HV segments, their # and location in terms of wire groups
2462 
2463  m_wire_hvsegm.clear();
2464  std::map<int, std::vector<int> >::iterator intvecIt;
2465  // ME1a ME1b ME1/2 ME1/3 ME2/1 ME2/2 ME3/1 ME3/2 ME4/1 ME4/2
2466  int csctype[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
2467  int hvsegm_layer[10] = {1, 1, 3, 3, 3, 5, 3, 5, 3, 5};
2468  int id;
2469  nmbhvsegm.clear();
2470  for (int i = 0; i < 10; i++)
2471  nmbhvsegm.push_back(hvsegm_layer[i]);
2472  // For ME1/1a
2473  std::vector<int> zer_1_1a(49, 0);
2474  id = csctype[0];
2475  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2476  m_wire_hvsegm[id] = zer_1_1a;
2477  intvecIt = m_wire_hvsegm.find(id);
2478  for (int wire = 1; wire <= 48; wire++)
2479  intvecIt->second[wire] = 1; // Segment 1
2480 
2481  // For ME1/1b
2482  std::vector<int> zer_1_1b(49, 0);
2483  id = csctype[1];
2484  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2485  m_wire_hvsegm[id] = zer_1_1b;
2486  intvecIt = m_wire_hvsegm.find(id);
2487  for (int wire = 1; wire <= 48; wire++)
2488  intvecIt->second[wire] = 1; // Segment 1
2489 
2490  // For ME1/2
2491  std::vector<int> zer_1_2(65, 0);
2492  id = csctype[2];
2493  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2494  m_wire_hvsegm[id] = zer_1_2;
2495  intvecIt = m_wire_hvsegm.find(id);
2496  for (int wire = 1; wire <= 24; wire++)
2497  intvecIt->second[wire] = 1; // Segment 1
2498  for (int wire = 25; wire <= 48; wire++)
2499  intvecIt->second[wire] = 2; // Segment 2
2500  for (int wire = 49; wire <= 64; wire++)
2501  intvecIt->second[wire] = 3; // Segment 3
2502 
2503  // For ME1/3
2504  std::vector<int> zer_1_3(33, 0);
2505  id = csctype[3];
2506  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2507  m_wire_hvsegm[id] = zer_1_3;
2508  intvecIt = m_wire_hvsegm.find(id);
2509  for (int wire = 1; wire <= 12; wire++)
2510  intvecIt->second[wire] = 1; // Segment 1
2511  for (int wire = 13; wire <= 22; wire++)
2512  intvecIt->second[wire] = 2; // Segment 2
2513  for (int wire = 23; wire <= 32; wire++)
2514  intvecIt->second[wire] = 3; // Segment 3
2515 
2516  // For ME2/1
2517  std::vector<int> zer_2_1(113, 0);
2518  id = csctype[4];
2519  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2520  m_wire_hvsegm[id] = zer_2_1;
2521  intvecIt = m_wire_hvsegm.find(id);
2522  for (int wire = 1; wire <= 44; wire++)
2523  intvecIt->second[wire] = 1; // Segment 1
2524  for (int wire = 45; wire <= 80; wire++)
2525  intvecIt->second[wire] = 2; // Segment 2
2526  for (int wire = 81; wire <= 112; wire++)
2527  intvecIt->second[wire] = 3; // Segment 3
2528 
2529  // For ME2/2
2530  std::vector<int> zer_2_2(65, 0);
2531  id = csctype[5];
2532  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2533  m_wire_hvsegm[id] = zer_2_2;
2534  intvecIt = m_wire_hvsegm.find(id);
2535  for (int wire = 1; wire <= 16; wire++)
2536  intvecIt->second[wire] = 1; // Segment 1
2537  for (int wire = 17; wire <= 28; wire++)
2538  intvecIt->second[wire] = 2; // Segment 2
2539  for (int wire = 29; wire <= 40; wire++)
2540  intvecIt->second[wire] = 3; // Segment 3
2541  for (int wire = 41; wire <= 52; wire++)
2542  intvecIt->second[wire] = 4; // Segment 4
2543  for (int wire = 53; wire <= 64; wire++)
2544  intvecIt->second[wire] = 5; // Segment 5
2545 
2546  // For ME3/1
2547  std::vector<int> zer_3_1(97, 0);
2548  id = csctype[6];
2549  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2550  m_wire_hvsegm[id] = zer_3_1;
2551  intvecIt = m_wire_hvsegm.find(id);
2552  for (int wire = 1; wire <= 32; wire++)
2553  intvecIt->second[wire] = 1; // Segment 1
2554  for (int wire = 33; wire <= 64; wire++)
2555  intvecIt->second[wire] = 2; // Segment 2
2556  for (int wire = 65; wire <= 96; wire++)
2557  intvecIt->second[wire] = 3; // Segment 3
2558 
2559  // For ME3/2
2560  std::vector<int> zer_3_2(65, 0);
2561  id = csctype[7];
2562  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2563  m_wire_hvsegm[id] = zer_3_2;
2564  intvecIt = m_wire_hvsegm.find(id);
2565  for (int wire = 1; wire <= 16; wire++)
2566  intvecIt->second[wire] = 1; // Segment 1
2567  for (int wire = 17; wire <= 28; wire++)
2568  intvecIt->second[wire] = 2; // Segment 2
2569  for (int wire = 29; wire <= 40; wire++)
2570  intvecIt->second[wire] = 3; // Segment 3
2571  for (int wire = 41; wire <= 52; wire++)
2572  intvecIt->second[wire] = 4; // Segment 4
2573  for (int wire = 53; wire <= 64; wire++)
2574  intvecIt->second[wire] = 5; // Segment 5
2575 
2576  // For ME4/1
2577  std::vector<int> zer_4_1(97, 0);
2578  id = csctype[8];
2579  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2580  m_wire_hvsegm[id] = zer_4_1;
2581  intvecIt = m_wire_hvsegm.find(id);
2582  for (int wire = 1; wire <= 32; wire++)
2583  intvecIt->second[wire] = 1; // Segment 1
2584  for (int wire = 33; wire <= 64; wire++)
2585  intvecIt->second[wire] = 2; // Segment 2
2586  for (int wire = 65; wire <= 96; wire++)
2587  intvecIt->second[wire] = 3; // Segment 3
2588 
2589  // For ME4/2
2590  std::vector<int> zer_4_2(65, 0);
2591  id = csctype[9];
2592  if (m_wire_hvsegm.find(id) == m_wire_hvsegm.end())
2593  m_wire_hvsegm[id] = zer_4_2;
2594  intvecIt = m_wire_hvsegm.find(id);
2595  for (int wire = 1; wire <= 16; wire++)
2596  intvecIt->second[wire] = 1; // Segment 1
2597  for (int wire = 17; wire <= 28; wire++)
2598  intvecIt->second[wire] = 2; // Segment 2
2599  for (int wire = 29; wire <= 40; wire++)
2600  intvecIt->second[wire] = 3; // Segment 3
2601  for (int wire = 41; wire <= 52; wire++)
2602  intvecIt->second[wire] = 4; // Segment 4
2603  for (int wire = 53; wire <= 64; wire++)
2604  intvecIt->second[wire] = 5; // Segment 5
2605 
2606  } // end of if(nEventsAnalyzed==1)
2607 
2608  // do wires, strips and rechits present?
2609  wire_strip_rechit_present = 0;
2610  if (wirecltn.begin() != wirecltn.end())
2611  wire_strip_rechit_present = wire_strip_rechit_present + 1;
2612  if (strpcltn.begin() != strpcltn.end())
2613  wire_strip_rechit_present = wire_strip_rechit_present + 2;
2614  if (rechitcltn.begin() != rechitcltn.end())
2615  wire_strip_rechit_present = wire_strip_rechit_present + 4;
2616 
2617  if (wire_strip_rechit_present == 7) {
2618  // std::cout<<"Event "<<nEventsAnalyzed<<std::endl;
2619  // std::cout<<std::endl;
2620 
2621  // cycle on wire collection for all CSC to select single wire hit layers
2623 
2624  for (wiredetUnitIt = wirecltn.begin(); wiredetUnitIt != wirecltn.end(); ++wiredetUnitIt) {
2625  const CSCDetId id = (*wiredetUnitIt).first;
2626  idlayer = indexer.dbIndex(id, channel);
2627  idchamber = idlayer / 10;
2628  layer = id.layer();
2629  // looping in the layer of given CSC
2630  mult = 0;
2631  wire = 0;
2632  const CSCWireDigiCollection::Range& range = (*wiredetUnitIt).second;
2633  for (CSCWireDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
2634  wire = (*digiIt).getWireGroup();
2635  mult++;
2636  } // end of digis loop in layer
2637 
2638  // select layers with single wire hit
2639  if (mult == 1) {
2640  if (m_single_wire_layer.find(idlayer) == m_single_wire_layer.end())
2641  m_single_wire_layer[idlayer] = wire;
2642  } // end of if(mult==1)
2643  } // end of cycle on detUnit
2644 
2645  // Looping thru rechit collection
2648 
2649  for (recIt = rechitcltn.begin(); recIt != rechitcltn.end(); ++recIt) {
2650  CSCDetId id = (CSCDetId)(*recIt).cscDetId();
2651  idlayer = indexer.dbIndex(id, channel);
2652  idchamber = idlayer / 10;
2653  layer = id.layer();
2654  // select layer with single wire rechit
2655  if (m_single_wire_layer.find(idlayer) != m_single_wire_layer.end()) {
2656  if (recIt->nStrips() == 3) {
2657  // get 3X3 ADC Sum
2658  unsigned int binmx = 0;
2659  float adcmax = 0.0;
2660 
2661  for (unsigned int i = 0; i < recIt->nStrips(); i++)
2662  for (unsigned int j = 0; j < recIt->nTimeBins(); j++)
2663  if (recIt->adcs(i, j) > adcmax) {
2664  adcmax = recIt->adcs(i, j);
2665  binmx = j;
2666  }
2667 
2668  float adc_3_3_sum = 0.0;
2669  //well, this really only works for 3 strips in readout - not sure the right fix for general case
2670  for (unsigned int i = 0; i < recIt->nStrips(); i++)
2671  for (unsigned int j = binmx - 1; j <= binmx + 1; j++)
2672  adc_3_3_sum += recIt->adcs(i, j);
2673 
2674  if (adc_3_3_sum > 0.0 && adc_3_3_sum < 2000.0) {
2675  // temporary fix for ME1/1a to avoid triple entries
2676  int flag = 0;
2677  if (id.station() == 1 && id.ring() == 4 && recIt->channels(1) > 16)
2678  flag = 1;
2679  // end of temporary fix
2680  if (flag == 0) {
2681  wire = m_single_wire_layer[idlayer];
2682  int chambertype = id.iChamberType(id.station(), id.ring());
2683  int hvsgmtnmb = m_wire_hvsegm[chambertype][wire];
2684  int nmbofhvsegm = nmbhvsegm[chambertype - 1];
2685  int location = (layer - 1) * nmbofhvsegm + hvsgmtnmb;
2686 
2687  ss << "gas_gain_rechit_adc_3_3_sum_location_ME_" << idchamber;
2688  name = ss.str();
2689  ss.str("");
2690  if (id.endcap() == 1)
2691  endcapstr = "+";
2692  ring = id.ring();
2693  if (id.station() == 1 && id.ring() == 4)
2694  ring = 1;
2695  if (id.endcap() == 2)
2696  endcapstr = "-";
2697  ss << "Gas Gain Rechit ADC3X3 Sum ME" << endcapstr << id.station() << "/" << ring << "/" << id.chamber();
2698  title = ss.str();
2699  ss.str("");
2700  float x = location;
2701  float y = adc_3_3_sum;
2702  histos->fill2DHist(x, y, name, title, 30, 1.0, 31.0, 50, 0.0, 2000.0, "GasGain");
2703 
2704  /*
2705  std::cout<<idchamber<<" "<<id.station()<<" "<<id.ring()<<" "
2706  <<id.chamber()<<" "<<layer<<" "<< wire<<" "<<m_strip[1]<<" "<<
2707  chambertype<<" "<< hvsgmtnmb<<" "<< nmbofhvsegm<<" "<<
2708  location<<" "<<adc_3_3_sum<<std::endl;
2709  */
2710  } // end of if flag==0
2711  } // end if(adcsum>0.0 && adcsum<2000.0)
2712  } // end of if if(m_strip.size()==3
2713  } // end of if single wire
2714  } // end of looping thru rechit collection
2715  } // end of if wire and strip and rechit present
2716 }
2717 
2718 //---------------------------------------------------------------------------
2719 // Module for looking at AFEB Timing
2720 // Author N. Terentiev
2721 //---------------------------------------------------------------------------
2722 
2724  ostringstream ss;
2725  std::string name, title, endcapstr;
2726  float x, y;
2727  int wire, wiretbin, nmbwiretbin, layer, afeb, idlayer, idchamber;
2728  int channel = 0; // for CSCIndexer::dbIndex(id, channel); irrelevant here
2729  CSCIndexer indexer;
2730 
2731  if (wirecltn.begin() != wirecltn.end()) {
2732  //std::cout<<std::endl;
2733  //std::cout<<"Event "<<nEventsAnalyzed<<std::endl;
2734  //std::cout<<std::endl;
2735 
2736  // cycle on wire collection for all CSC
2738  for (wiredetUnitIt = wirecltn.begin(); wiredetUnitIt != wirecltn.end(); ++wiredetUnitIt) {
2739  const CSCDetId id = (*wiredetUnitIt).first;
2740  idlayer = indexer.dbIndex(id, channel);
2741  idchamber = idlayer / 10;
2742  layer = id.layer();
2743 
2744  if (id.endcap() == 1)
2745  endcapstr = "+";
2746  if (id.endcap() == 2)
2747  endcapstr = "-";
2748 
2749  // looping in the layer of given CSC
2750 
2751  const CSCWireDigiCollection::Range& range = (*wiredetUnitIt).second;
2752  for (CSCWireDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
2753  wire = (*digiIt).getWireGroup();
2754  wiretbin = (*digiIt).getTimeBin();
2755  nmbwiretbin = (*digiIt).getTimeBinsOn().size();
2756  afeb = 3 * ((wire - 1) / 8) + (layer + 1) / 2;
2757 
2758  // Anode wire group time bin vs afeb for each CSC
2759  x = afeb;
2760  y = wiretbin;
2761  ss << "afeb_time_bin_vs_afeb_occupancy_ME_" << idchamber;
2762  name = ss.str();
2763  ss.str("");
2764  ss << "Time Bin vs AFEB Occupancy ME" << endcapstr << id.station() << "/" << id.ring() << "/" << id.chamber();
2765  title = ss.str();
2766  ss.str("");
2767  histos->fill2DHist(x, y, name, title, 42, 1., 43., 16, 0., 16., "AFEBTiming");
2768 
2769  // Number of anode wire group time bin vs afeb for each CSC
2770  x = afeb;
2771  y = nmbwiretbin;
2772  ss << "nmb_afeb_time_bins_vs_afeb_ME_" << idchamber;
2773  name = ss.str();
2774  ss.str("");
2775  ss << "Number of Time Bins vs AFEB ME" << endcapstr << id.station() << "/" << id.ring() << "/" << id.chamber();
2776  title = ss.str();
2777  ss.str("");
2778  histos->fill2DHist(x, y, name, title, 42, 1., 43., 16, 0., 16., "AFEBTiming");
2779 
2780  } // end of digis loop in layer
2781  } // end of wire collection loop
2782  } // end of if(wirecltn.begin() != wirecltn.end())
2783 }
2784 
2785 //---------------------------------------------------------------------------
2786 // Module for looking at Comparitor Timing
2787 // Author N. Terentiev
2788 //---------------------------------------------------------------------------
2789 
2791  ostringstream ss;
2793  float x, y;
2794  int strip, tbin, cfeb, idlayer, idchamber;
2795  int channel = 0; // for CSCIndexer::dbIndex(id, channel); irrelevant here
2796  CSCIndexer indexer;
2797 
2798  if (compars.begin() != compars.end()) {
2799  //std::cout<<std::endl;
2800  //std::cout<<"Event "<<nEventsAnalyzed<<std::endl;
2801  //std::cout<<std::endl;
2802 
2803  // cycle on comparators collection for all CSC
2805  for (compdetUnitIt = compars.begin(); compdetUnitIt != compars.end(); ++compdetUnitIt) {
2806  const CSCDetId id = (*compdetUnitIt).first;
2807  idlayer = indexer.dbIndex(id, channel); // channel irrelevant here
2808  idchamber = idlayer / 10;
2809 
2810  if (id.endcap() == 1)
2811  endcap = "+";
2812  if (id.endcap() == 2)
2813  endcap = "-";
2814  // looping in the layer of given CSC
2815  const CSCComparatorDigiCollection::Range& range = (*compdetUnitIt).second;
2816  for (CSCComparatorDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
2817  strip = (*digiIt).getStrip();
2818  /*
2819  if(id.station()==1 && (id.ring()==1 || id.ring()==4))
2820  std::cout<<idchamber<<" "<<id.station()<<" "<<id.ring()<<" "
2821  <<strip <<std::endl;
2822  */
2823  indexer.dbIndex(id, strip); // strips 1-16 of ME1/1a
2824  // become strips 65-80 of ME1/1
2825  tbin = (*digiIt).getTimeBin();
2826  cfeb = (strip - 1) / 16 + 1;
2827 
2828  // time bin vs cfeb for each CSC
2829 
2830  x = cfeb;
2831  y = tbin;
2832  ss << "comp_time_bin_vs_cfeb_occupancy_ME_" << idchamber;
2833  name = ss.str();
2834  ss.str("");
2835  ss << "Comparator Time Bin vs CFEB Occupancy ME" << endcap << id.station() << "/" << id.ring() << "/"
2836  << id.chamber();
2837  title = ss.str();
2838  ss.str("");
2839  histos->fill2DHist(x, y, name, title, 5, 1., 6., 16, 0., 16., "CompTiming");
2840 
2841  } // end of digis loop in layer
2842  } // end of collection loop
2843  } // end of if(compars.begin() !=compars.end())
2844 }
2845 
2846 //---------------------------------------------------------------------------
2847 // Module for looking at Strip Timing
2848 // Author N. Terentiev
2849 //---------------------------------------------------------------------------
2850 
2852  float adc_3_3_sum, adc_3_3_wtbin, x, y;
2853  int cfeb, idchamber, ring;
2854 
2855  std::string name, title, endcapstr;
2856  ostringstream ss;
2857  std::vector<float> zer(6, 0.0);
2858 
2859  CSCIndexer indexer;
2860  std::map<int, int>::iterator intIt;
2861 
2862  if (rechitcltn.begin() != rechitcltn.end()) {
2863  // std::cout<<"Event "<<nEventsAnalyzed <<std::endl;
2864 
2865  // Looping thru rechit collection
2868  for (recIt = rechitcltn.begin(); recIt != rechitcltn.end(); ++recIt) {
2869  CSCDetId id = (CSCDetId)(*recIt).cscDetId();
2870  // getting strips comprising rechit
2871  if (recIt->nStrips() == 3) {
2872  // get 3X3 ADC Sum
2873  // get 3X3 ADC Sum
2874  unsigned int binmx = 0;
2875  float adcmax = 0.0;
2876 
2877  for (unsigned int i = 0; i < recIt->nStrips(); i++)
2878  for (unsigned int j = 0; j < recIt->nTimeBins(); j++)
2879  if (recIt->adcs(i, j) > adcmax) {
2880  adcmax = recIt->adcs(i, j);
2881  binmx = j;
2882  }
2883 
2884  adc_3_3_sum = 0.0;
2885  //well, this really only works for 3 strips in readout - not sure the right fix for general case
2886  for (unsigned int i = 0; i < recIt->nStrips(); i++)
2887  for (unsigned int j = binmx - 1; j <= binmx + 1; j++)
2888  adc_3_3_sum += recIt->adcs(i, j);
2889 
2890  // ADC weighted time bin
2891  if (adc_3_3_sum > 100.0) {
2892  int centerStrip = recIt->channels(1); //take central from 3 strips;
2893  // temporary fix
2894  int flag = 0;
2895  if (id.station() == 1 && id.ring() == 4 && centerStrip > 16)
2896  flag = 1;
2897  // end of temporary fix
2898  if (flag == 0) {
2899  adc_3_3_wtbin = (*recIt).tpeak() / 50; //getTiming(strpcltn, id, centerStrip);
2900  idchamber = indexer.dbIndex(id, centerStrip) / 10; //strips 1-16 ME1/1a
2901  // become strips 65-80 ME1/1 !!!
2902  /*
2903  if(id.station()==1 && (id.ring()==1 || id.ring()==4))
2904  std::cout<<idchamber<<" "<<id.station()<<" "<<id.ring()<<" "<<m_strip[1]<<" "<<
2905  " "<<centerStrip<<
2906  " "<<adc_3_3_wtbin<<" "<<adc_3_3_sum<<std::endl;
2907  */
2908  ss << "adc_3_3_weight_time_bin_vs_cfeb_occupancy_ME_" << idchamber;
2909  name = ss.str();
2910  ss.str("");
2911 
2912  std::string endcapstr;
2913  if (id.endcap() == 1)
2914  endcapstr = "+";
2915  if (id.endcap() == 2)
2916  endcapstr = "-";
2917  ring = id.ring();
2918  if (id.ring() == 4)
2919  ring = 1;
2920  ss << "ADC 3X3 Weighted Time Bin vs CFEB Occupancy ME" << endcapstr << id.station() << "/" << ring << "/"
2921  << id.chamber();
2922  title = ss.str();
2923  ss.str("");
2924 
2925  cfeb = (centerStrip - 1) / 16 + 1;
2926  x = cfeb;
2927  y = adc_3_3_wtbin;
2928  histos->fill2DHist(x, y, name, title, 5, 1., 6., 80, -8., 8., "ADCTiming");
2929  } // end of if flag==0
2930  } // end of if (adc_3_3_sum > 100.0)
2931  } // end of if if(m_strip.size()==3
2932  } // end of the pass thru CSCRecHit2DCollection
2933  } // end of if (rechitcltn.begin() != rechitcltn.end())
2934 }
2935 
2936 //---------------------------------------------------------------------------------------
2937 // Construct histograms for monitoring the trigger and offline timing
2938 // Author: A. Deisher
2939 //---------------------------------------------------------------------------------------
2940 
2948  const edm::EventSetup& eventSetup,
2949  const edm::Event& event) {
2950  map<CSCDetId, float> segment_median_map; //structure for storing the median time for segments in a chamber
2951  map<CSCDetId, GlobalPoint> segment_position_map; //structure for storing the global position for segments in a chamber
2952 
2953  // -----------------------
2954  // loop over segments
2955  // -----------------------
2956  int iSegment = 0;
2957  for (CSCSegmentCollection::const_iterator dSiter = cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
2958  iSegment++;
2959 
2960  CSCDetId id = (CSCDetId)(*dSiter).cscDetId();
2961  LocalPoint localPos = (*dSiter).localPosition();
2962  GlobalPoint globalPosition = GlobalPoint(0.0, 0.0, 0.0);
2963  const CSCChamber* cscchamber = cscGeom->chamber(id);
2964  if (cscchamber) {
2965  globalPosition = cscchamber->toGlobal(localPos);
2966  }
2967 
2968  // try to get the CSC recHits that contribute to this segment.
2969  std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
2970  int nRH = (*dSiter).nRecHits();
2971  if (nRH < 4)
2972  continue;
2973 
2974  //Store the recHit times of a segment in a vector for later sorting
2975  vector<float> non_zero;
2976 
2977  for (vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
2978  non_zero.push_back(iRH->tpeak());
2979 
2980  } // end rechit loop
2981 
2982  //Sort the vector of hit times for this segment and average the center two
2983  sort(non_zero.begin(), non_zero.end());
2984  int middle_index = non_zero.size() / 2;
2985  float average_two = (non_zero.at(middle_index - 1) + non_zero.at(middle_index)) / 2.;
2986  if (non_zero.size() % 2)
2987  average_two = non_zero.at(middle_index);
2988 
2989  //If we've vetoed events with multiple segments per chamber, this should never overwrite informations
2990  segment_median_map[id] = average_two;
2991  segment_position_map[id] = globalPosition;
2992 
2993  double distToIP = sqrt(globalPosition.x() * globalPosition.x() + globalPosition.y() * globalPosition.y() +
2994  globalPosition.z() * globalPosition.z());
2995 
2996  histos->fillProfile(chamberSerial(id),
2997  average_two,
2998  "timeChamber",
2999  "Segment mean time",
3000  601,
3001  -0.5,
3002  600.5,
3003  -400.,
3004  400.,
3005  "TimeMonitoring");
3006  histos->fillProfileByType(id.chamber(),
3007  average_two,
3008  "timeChamberByType",
3009  "Segment mean time by chamber",
3010  id,
3011  36,
3012  0.5,
3013  36.5,
3014  -400,
3015  400.,
3016  "TimeMonitoring");
3017  histos->fill2DHist(distToIP,
3018  average_two,
3019  "seg_time_vs_distToIP",
3020  "Segment time vs. Distance to IP",
3021  80,
3022  600.,
3023  1400.,
3024  800,
3025  -400,
3026  400.,
3027  "TimeMonitoring");
3028  histos->fill2DHist(globalPosition.z(),
3029  average_two,
3030  "seg_time_vs_globZ",
3031  "Segment time vs. z position",
3032  240,
3033  -1200,
3034  1200,
3035  800,
3036  -400.,
3037  400.,
3038  "TimeMonitoring");
3039  histos->fill2DHist(fabs(globalPosition.z()),
3040  average_two,
3041  "seg_time_vs_absglobZ",
3042  "Segment time vs. abs(z position)",
3043  120,
3044  0.,
3045  1200.,
3046  800,
3047  -400.,
3048  400.,
3049  "TimeMonitoring");
3050 
3051  } //end segment loop
3052 
3053  //Now that the information for each segment we're interest in is stored, it is time to go through the pairs and make plots
3054  map<CSCDetId, float>::const_iterator it_outer; //for the outer loop
3055  map<CSCDetId, float>::const_iterator it_inner; //for the nested inner loop
3056  for (it_outer = segment_median_map.begin(); it_outer != segment_median_map.end(); it_outer++) {
3057  CSCDetId id_outer = it_outer->first;
3058  float t_outer = it_outer->second;
3059 
3060  //begin the inner loop
3061  for (it_inner = segment_median_map.begin(); it_inner != segment_median_map.end(); it_inner++) {
3062  CSCDetId id_inner = it_inner->first;
3063  float t_inner = it_inner->second;
3064 
3065  // we're looking at ordered pairs, so combinations will be double counted
3066  // (chamber a, chamber b) will be counted as well as (chamber b, chamber a)
3067  // We will avoid (chamber a, chamber a) with the following line
3068  if (chamberSerial(id_outer) == chamberSerial(id_inner))
3069  continue;
3070 
3071  // Calculate expected TOF (in ns units)
3072  // GlobalPoint gp_outer = segment_position_map.find(id_outer)->second;
3073  // GlobalPoint gp_inner = segment_position_map.find(id_inner)->second;
3074  // GlobalVector flight = gp_outer - gp_inner; //in cm
3075  // float TOF = flight.mag()/30.0; //to ns
3076 
3077  //Plot t(ME+) - t(ME-) for chamber pairs in the same stations and rings but opposite endcaps
3078  if (id_outer.endcap() == 1 && id_inner.endcap() == 2 && id_outer.station() == id_inner.station() &&
3079  id_outer.ring() == id_inner.ring()) {
3080  histos->fill1DHist(t_outer - t_inner,
3081  "diff_opposite_endcaps",
3082  "#Delta t [ME+]-[ME-] for chambers in same station and ring",
3083  800,
3084  -400.,
3085  400.,
3086  "TimeMonitoring");
3087  histos->fill1DHistByType(t_outer - t_inner,
3088  "diff_opposite_endcaps_byType",
3089  "#Delta t [ME+]-[ME-] for chambers in same station and ring",
3090  id_outer,
3091  800,
3092  -400.,
3093  400.,
3094  "TimeMonitoring");
3095  }
3096 
3097  } //end inner loop of segment pairs
3098  } //end outer loop of segment pairs
3099 
3100  //if the digis, return here
3101  if (!useDigis)
3102  return;
3103 
3104  //looking for the global trigger number
3105  vector<L1MuGMTReadoutRecord> L1Mrec = pCollection->getRecords();
3106  vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
3107  int L1GMT_BXN = -100;
3108  bool has_CSCTrigger = false;
3109  bool has_beamHaloTrigger = false;
3110  for (igmtrr = L1Mrec.begin(); igmtrr != L1Mrec.end(); igmtrr++) {
3111  std::vector<L1MuRegionalCand>::const_iterator iter1;
3112  std::vector<L1MuRegionalCand> rmc;
3113  // CSC
3114  int icsc = 0;
3115  rmc = igmtrr->getCSCCands();
3116  for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
3117  if (!(*iter1).empty()) {
3118  icsc++;
3119  int kQuality = (*iter1).quality(); // kQuality = 1 means beam halo
3120  if (kQuality == 1)
3121  has_beamHaloTrigger = true;
3122  }
3123  }
3124  if (igmtrr->getBxInEvent() == 0 && icsc > 0) {
3125  //printf("L1 CSCCands exist. L1MuGMTReadoutRecord BXN = %d \n", igmtrr->getBxNr());
3126  L1GMT_BXN = igmtrr->getBxNr();
3127  has_CSCTrigger = true;
3128  } else if (igmtrr->getBxInEvent() == 0) {
3129  //printf("L1 CSCCands do not exist. L1MuGMTReadoutRecord BXN = %d \n", igmtrr->getBxNr());
3130  L1GMT_BXN = igmtrr->getBxNr();
3131  }
3132  }
3133 
3134  // *************************************************
3135  // *** ALCT Digis **********************************
3136  // *************************************************
3137 
3138  int n_alcts = 0;
3139  map<CSCDetId, int> ALCT_KeyWG_map; //structure for storing the key wire group for the first ALCT for each chamber
3140  for (CSCALCTDigiCollection::DigiRangeIterator j = alcts->begin(); j != alcts->end(); j++) {
3141  const CSCALCTDigiCollection::Range& range = (*j).second;
3142  const CSCDetId& idALCT = (*j).first;
3143  for (CSCALCTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
3144  // Valid digi in the chamber (or in neighbouring chamber)
3145  if ((*digiIt).isValid()) {
3146  n_alcts++;
3147  histos->fill1DHist((*digiIt).getBX(), "ALCT_getBX", "ALCT.getBX()", 11, -0.5, 10.5, "TimeMonitoring");
3148  histos->fill1DHist(
3149  (*digiIt).getFullBX(), "ALCT_getFullBX", "ALCT.getFullBX()", 3601, -0.5, 3600.5, "TimeMonitoring");
3150  //if we don't already have digi information stored for this chamber, then we fill it
3151  if (ALCT_KeyWG_map.find(idALCT.chamberId()) == ALCT_KeyWG_map.end()) {
3152  ALCT_KeyWG_map[idALCT.chamberId()] = (*digiIt).getKeyWG();
3153  //printf("I did fill ALCT info for Chamber %d %d %d %d \n",idALCT.chamberId().endcap(), idALCT.chamberId().station(), idALCT.chamberId().ring(), idALCT.chamberId().chamber());
3154  }
3155  }
3156  }
3157  }
3158 
3159  // *************************************************
3160  // *** CLCT Digis **********************************
3161  // *************************************************
3162  int n_clcts = 0;
3163  map<CSCDetId, int> CLCT_getFullBx_map; //structure for storing the pretrigger bxn for the first CLCT for each chamber
3164  for (CSCCLCTDigiCollection::DigiRangeIterator j = clcts->begin(); j != clcts->end(); j++) {
3165  const CSCCLCTDigiCollection::Range& range = (*j).second;
3166  const CSCDetId& idCLCT = (*j).first;
3167  for (CSCCLCTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
3168  // Valid digi in the chamber (or in neighbouring chamber)
3169  if ((*digiIt).isValid()) {
3170  n_clcts++;
3171  histos->fill1DHist((*digiIt).getBX(), "CLCT_getBX", "CLCT.getBX()", 11, -0.5, 10.5, "TimeMonitoring");
3172  histos->fill1DHist(
3173  (*digiIt).getFullBX(), "CLCT_getFullBX", "CLCT.getFullBX()", 3601, -0.5, 3600.5, "TimeMonitoring");
3174  //if we don't already have digi information stored for this chamber, then we fill it
3175  if (CLCT_getFullBx_map.find(idCLCT.chamberId()) == CLCT_getFullBx_map.end()) {
3176  CLCT_getFullBx_map[idCLCT.chamberId()] = (*digiIt).getFullBX();
3177  //printf("I did fill CLCT info for Chamber %d %d %d %d \n",idCLCT.chamberId().endcap(), idCLCT.chamberId().station(), idCLCT.chamberId().ring(), idCLCT.chamberId().chamber());
3178  }
3179  }
3180  }
3181  }
3182 
3183  // *************************************************
3184  // *** CorrelatedLCT Digis *************************
3185  // *************************************************
3186  int n_correlatedlcts = 0;
3187  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j = correlatedlcts->begin(); j != correlatedlcts->end(); j++) {
3188  const CSCCorrelatedLCTDigiCollection::Range& range = (*j).second;
3189  for (CSCCorrelatedLCTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
3190  if ((*digiIt).isValid()) {
3191  n_correlatedlcts++;
3192  histos->fill1DHist(
3193  (*digiIt).getBX(), "CorrelatedLCTS_getBX", "CorrelatedLCT.getBX()", 11, -0.5, 10.5, "TimeMonitoring");
3194  }
3195  }
3196  }
3197 
3198  int nRecHits = recHits->size();
3199  int nSegments = cscSegments->size();
3200  if (has_CSCTrigger) {
3201  histos->fill1DHist(L1GMT_BXN, "BX_L1CSCCand", "BX of L1 CSC Cand", 4001, -0.5, 4000.5, "TimeMonitoring");
3202  histos->fill2DHist(L1GMT_BXN,
3203  n_alcts,
3204  "n_ALCTs_v_BX_L1CSCCand",
3205  "Number of ALCTs vs. BX of L1 CSC Cand",
3206  4001,
3207  -0.5,
3208  4000.5,
3209  51,
3210  -0.5,
3211  50.5,
3212  "TimeMonitoring");
3213  histos->fill2DHist(L1GMT_BXN,
3214  n_clcts,
3215  "n_CLCTs_v_BX_L1CSCCand",
3216  "Number of CLCTs vs. BX of L1 CSC Cand",
3217  4001,
3218  -0.5,
3219  4000.5,
3220  51,
3221  -0.5,
3222  50.5,
3223  "TimeMonitoring");
3224  histos->fill2DHist(L1GMT_BXN,
3225  n_correlatedlcts,
3226  "n_CorrelatedLCTs_v_BX_L1CSCCand",
3227  "Number of CorrelatedLCTs vs. BX of L1 CSC Cand",
3228  4001,
3229  -0.5,
3230  4000.5,
3231  51,
3232  -0.5,
3233  50.5,
3234  "TimeMonitoring");
3235  histos->fill2DHist(L1GMT_BXN,
3236  nRecHits,
3237  "n_RecHits_v_BX_L1CSCCand",
3238  "Number of RecHits vs. BX of L1 CSC Cand",
3239  4001,
3240  -0.5,
3241  4000.5,
3242  101,
3243  -0.5,
3244  100.5,
3245  "TimeMonitoring");
3246  histos->fill2DHist(L1GMT_BXN,
3247  nSegments,
3248  "n_Segments_v_BX_L1CSCCand",
3249  "Number of Segments vs. BX of L1 CSC Cand",
3250  4001,
3251  -0.5,
3252  4000.5,
3253  51,
3254  -0.5,
3255  50.5,
3256  "TimeMonitoring");
3257  }
3258  if (has_CSCTrigger && has_beamHaloTrigger) {
3259  histos->fill1DHist(
3260  L1GMT_BXN, "BX_L1CSCCand_w_beamHalo", "BX of L1 CSC (w beamHalo bit)", 4001, -0.5, 4000.5, "TimeMonitoring");
3261  histos->fill2DHist(L1GMT_BXN,
3262  n_alcts,
3263  "n_ALCTs_v_BX_L1CSCCand_w_beamHalo",
3264  "Number of ALCTs vs. BX of L1 CSC Cand (w beamHalo bit)",
3265  4001,
3266  -0.5,
3267  4000.5,
3268  51,
3269  -0.5,
3270  50.5,
3271  "TimeMonitoring");
3272  histos->fill2DHist(L1GMT_BXN,
3273  n_clcts,
3274  "n_CLCTs_v_BX_L1CSCCand_w_beamHalo",
3275  "Number of CLCTs vs. BX of L1 CSC Cand (w beamHalo bit)",
3276  4001,
3277  -0.5,
3278  4000.5,
3279  51,
3280  -0.5,
3281  50.5,
3282  "TimeMonitoring");
3283  histos->fill2DHist(L1GMT_BXN,
3284  n_correlatedlcts,
3285  "n_CorrelatedLCTs_v_BX_L1CSCCand_w_beamHalo",
3286  "Number of CorrelatedLCTs vs. BX of L1 CSC Cand (w beamHalo bit)",
3287  4001,
3288  -0.5,
3289  4000.5,
3290  51,
3291  -0.5,
3292  50.5,
3293  "TimeMonitoring");
3294  histos->fill2DHist(L1GMT_BXN,
3295  nRecHits,
3296  "n_RecHits_v_BX_L1CSCCand_w_beamHalo",
3297  "Number of RecHits vs. BX of L1 CSC Cand (w beamHalo bit)",
3298  4001,
3299  -0.5,
3300  4000.5,
3301  101,
3302  -0.5,
3303  100.5,
3304  "TimeMonitoring");
3305  histos->fill2DHist(L1GMT_BXN,
3306  nSegments,
3307  "n_Segments_v_BX_L1CSCCand_w_beamHalo",
3308  "Number of Segments vs. BX of L1 CSC Cand (w beamHalo bit)",
3309  4001,
3310  -0.5,
3311  4000.5,
3312  51,
3313  -0.5,
3314  50.5,
3315  "TimeMonitoring");
3316  }
3317 
3318  // *******************************************************************
3319  // Get information from the TMB header.
3320  // Can this eventually come out of the digis?
3321  // Taking code from EventFilter/CSCRawToDigis/CSCDCCUnpacker.cc
3322  // *******************************************************************
3323 
3325  eventSetup.get<CSCCrateMapRcd>().get(hcrate);
3326  const CSCCrateMap* pcrate = hcrate.product();
3327 
3330  event.getByToken(rd_token, rawdata);
3331  bool goodEvent = false;
3332  // If set selective unpacking mode
3333  // hardcoded examiner mask below to check for DCC and DDU level errors will be used first
3334  // then examinerMask for CSC level errors will be used during unpacking of each CSC block
3335  unsigned long dccBinCheckMask = 0x06080016;
3336  unsigned int examinerMask = 0x1FEBF3F6;
3337  unsigned int errorMask = 0x0;
3338 
3339  for (int id = FEDNumbering::MINCSCFEDID; id <= FEDNumbering::MAXCSCFEDID; ++id) {
3340  // loop over DCCs
3343 
3345  const FEDRawData& fedData = rawdata->FEDData(id);
3346  unsigned long length = fedData.size();
3347 
3348  if (length >= 32) {
3349  CSCDCCExaminer* examiner = nullptr;
3350  std::stringstream examiner_out, examiner_err;
3351  goodEvent = true;
3353  //CSCDCCExaminer examiner;
3354  examiner = new CSCDCCExaminer();
3355  if (examinerMask & 0x40000)
3356  examiner->crcCFEB(true);
3357  if (examinerMask & 0x8000)
3358  examiner->crcTMB(true);
3359  if (examinerMask & 0x0400)
3360  examiner->crcALCT(true);
3361  examiner->setMask(examinerMask);
3362  const short unsigned int* data = (short unsigned int*)fedData.data();
3363 
3364  if (examiner->check(data, long(fedData.size() / 2)) < 0) {
3365  goodEvent = false;
3366  } else {
3367  goodEvent = !(examiner->errors() & dccBinCheckMask);
3368  }
3369 
3370  if (goodEvent) {
3372  CSCDCCExaminer* ptrExaminer = examiner;
3373  CSCDCCEventData dccData((short unsigned int*)fedData.data(), ptrExaminer);
3374 
3376  const std::vector<CSCDDUEventData>& dduData = dccData.dduData();
3377 
3379  CSCDetId layer(1, 1, 1, 1, 1);
3380 
3381  for (unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU) { // loop over DDUs
3384  if (dduData[iDDU].trailer().errorstat() & errorMask) {
3385  LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "DDU# " << iDDU << " has serious error - no digis unpacked! "
3386  << std::hex << dduData[iDDU].trailer().errorstat();
3387  continue; // to next iteration of DDU loop
3388  }
3389 
3391  const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
3392  for (unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC) { // loop over CSCs
3393 
3394  int vmecrate = cscData[iCSC].dmbHeader()->crateID();
3395  int dmb = cscData[iCSC].dmbHeader()->dmbID();
3396 
3398  // SKIPPING MTCC redefinition of vmecrate
3399 
3400  int icfeb = 0;
3401  int ilayer = 0;
3402 
3403  if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
3404  layer = pcrate->detId(vmecrate, dmb, icfeb, ilayer);
3405  } else {
3406  LogTrace("CSCTimingAlignment|CSCDCCUnpacker|CSCRawToDigi") << " detID input out of range!!! ";
3407  LogTrace("CSCTimingAlignment|CSCDCCUnpacker|CSCRawToDigi")
3408  << " skipping chamber vme= " << vmecrate << " dmb= " << dmb;
3409  continue; // to next iteration of iCSC loop
3410  }
3411 
3413  int nalct = cscData[iCSC].dmbHeader()->nalct();
3414  bool goodALCT = false;
3415  //if (nalct&&(cscData[iCSC].dataPresent>>6&0x1)==1) {
3416  if (nalct && cscData[iCSC].alctHeader()) {
3417  if (cscData[iCSC].alctHeader()->check()) {
3418  goodALCT = true;
3419  }
3420  }
3421 
3423  int nclct = cscData[iCSC].dmbHeader()->nclct();
3424  bool goodTMB = false;
3425  if (nclct && cscData[iCSC].tmbData()) {
3426  if (cscData[iCSC].tmbHeader()->check()) {
3427  if (cscData[iCSC].clctData()->check())
3428  goodTMB = true;
3429  }
3430  }
3431 
3432  if (goodTMB && goodALCT) {
3433  if (ALCT_KeyWG_map.find(layer) == ALCT_KeyWG_map.end()) {
3434  printf("no ALCT info for Chamber %d %d %d %d \n",
3435  layer.endcap(),
3436  layer.station(),
3437  layer.ring(),
3438  layer.chamber());
3439  continue;
3440  }
3441  if (CLCT_getFullBx_map.find(layer) == CLCT_getFullBx_map.end()) {
3442  printf("no CLCT info for Chamber %d %d %d %d \n",
3443  layer.endcap(),
3444  layer.station(),
3445  layer.ring(),
3446  layer.chamber());
3447  continue;
3448  }
3449  int ALCT0Key = ALCT_KeyWG_map.find(layer)->second;
3450  int CLCTPretrigger = CLCT_getFullBx_map.find(layer)->second;
3451 
3452  const CSCTMBHeader* tmbHead = cscData[iCSC].tmbHeader();
3453 
3454  histos->fill1DHistByStation(tmbHead->BXNCount(),
3455  "TMB_BXNCount",
3456  "TMB_BXNCount",
3457  layer.chamberId(),
3458  3601,
3459  -0.5,
3460  3600.5,
3461  "TimeMonitoring");
3462  histos->fill1DHistByStation(tmbHead->ALCTMatchTime(),
3463  "TMB_ALCTMatchTime",
3464  "TMB_ALCTMatchTime",
3465  layer.chamberId(),
3466  7,
3467  -0.5,
3468  6.5,
3469  "TimeMonitoring");
3470 
3471  histos->fill1DHist(
3472  tmbHead->BXNCount(), "TMB_BXNCount", "TMB_BXNCount", 3601, -0.5, 3600.5, "TimeMonitoring");
3473  histos->fill1DHist(
3474  tmbHead->ALCTMatchTime(), "TMB_ALCTMatchTime", "TMB_ALCTMatchTime", 7, -0.5, 6.5, "TimeMonitoring");
3475 
3476  histos->fill1DHistByType(tmbHead->ALCTMatchTime(),
3477  "TMB_ALCTMatchTime",
3478  "TMB_ALCTMatchTime",
3479  layer.chamberId(),
3480  7,
3481  -0.5,
3482  6.5,
3483  "TimeMonitoring");
3484 
3485  histos->fillProfile(chamberSerial(layer.chamberId()),
3486  tmbHead->ALCTMatchTime(),
3487  "prof_TMB_ALCTMatchTime",
3488  "prof_TMB_ALCTMatchTime",
3489  601,
3490  -0.5,
3491  600.5,
3492  -0.5,
3493  7.5,
3494  "TimeMonitoring");
3495  histos->fillProfile(ALCT0Key,
3496  tmbHead->ALCTMatchTime(),
3497  "prof_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3498  "prof_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3499  128,
3500  -0.5,
3501  127.5,
3502  0,
3503  7,
3504  "TimeMonitoring");
3505  histos->fillProfileByType(ALCT0Key,
3506  tmbHead->ALCTMatchTime(),
3507  "prf_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3508  "prf_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3509  layer.chamberId(),
3510  128,
3511  -0.5,
3512  127.5,
3513  0,
3514  7,
3515  "TimeMonitoring");
3516 
3517  //Attempt to make a few sum plots
3518 
3519  int TMB_ALCT_rel_L1A = tmbHead->BXNCount() - (CLCTPretrigger + 2 + tmbHead->ALCTMatchTime());
3520  if (TMB_ALCT_rel_L1A > 3563)
3521  TMB_ALCT_rel_L1A = TMB_ALCT_rel_L1A - 3564;
3522  if (TMB_ALCT_rel_L1A < 0)
3523  TMB_ALCT_rel_L1A = TMB_ALCT_rel_L1A + 3564;
3524 
3525  //Plot TMB_ALCT_rel_L1A
3526  histos->fill1DHist(
3527  TMB_ALCT_rel_L1A, "h1D_TMB_ALCT_rel_L1A", "h1D_TMB_ALCT_rel_L1A", 11, 144.5, 155.5, "TimeMonitoring");
3528  histos->fill2DHist(chamberSerial(layer.chamberId()),
3529  TMB_ALCT_rel_L1A,
3530  "h2D_TMB_ALCT_rel_L1A",
3531  "h2D_TMB_ALCT_rel_L1A",
3532  601,
3533  -0.5,
3534  600.5,
3535  11,
3536  144.5,
3537  155.5,
3538  "TimeMonitoring");
3539  histos->fill2DHist(ringSerial(layer.chamberId()),
3540  TMB_ALCT_rel_L1A,
3541  "h2D_TMB_ALCT_rel_L1A_by_ring",
3542  "h2D_TMB_ALCT_rel_L1A_by_ring",
3543  19,
3544  -9.5,
3545  9.5,
3546  11,
3547  144.5,
3548  155.5,
3549  "TimeMonitoring");
3550  histos->fillProfile(chamberSerial(layer.chamberId()),
3551  TMB_ALCT_rel_L1A,
3552  "prof_TMB_ALCT_rel_L1A",
3553  "prof_TMB_ALCT_rel_L1A",
3554  601,
3555  -0.5,
3556  600.5,
3557  145,
3558  155,
3559  "TimeMonitoring");
3560  histos->fillProfile(ringSerial(layer.chamberId()),
3561  TMB_ALCT_rel_L1A,
3562  "prof_TMB_ALCT_rel_L1A_by_ring",
3563  "prof_TMB_ALCT_rel_L1A_by_ring",
3564  19,
3565  -9.5,
3566  9.5,
3567  145,
3568  155,
3569  "TimeMonitoring");
3570 
3571  histos->fill2DHist(ALCT0Key,
3572  TMB_ALCT_rel_L1A,
3573  "h2D_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3574  "h2D_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3575  128,
3576  -0.5,
3577  127.5,
3578  11,
3579  144.5,
3580  155.5,
3581  "TimeMonitoring");
3582  histos->fillProfile(ALCT0Key,
3583  TMB_ALCT_rel_L1A,
3584  "prof_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3585  "prof_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3586  128,
3587  -0.5,
3588  127.5,
3589  145,
3590  155,
3591  "TimeMonitoring");
3592  histos->fillProfileByType(ALCT0Key,
3593  TMB_ALCT_rel_L1A,
3594  "prf_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3595  "prf_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3596  layer.chamberId(),
3597  128,
3598  -0.5,
3599  127.5,
3600  145,
3601  155,
3602  "TimeMonitoring");
3603  }
3604 
3605  } // end CSCData loop
3606  } // end ddu data loop
3607  } // end if goodEvent
3608  if (examiner != nullptr)
3609  delete examiner;
3610  } // end if non-zero fed data
3611  } // end DCC loop for NON-REFERENCE
3612 }
3613 
3614 void CSCValidation::endJob() { std::cout << "Events in " << nEventsAnalyzed << std::endl; }
3615 
#define LogDebug(id)
uint16_t BXNCount() const
Definition: CSCTMBHeader.h:37
01/20/05 A.Tumanov
float getthisSignal(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip)
int chamber() const
Definition: CSCDetId.h:62
T getParameter(std::string const &) const
void crcCFEB(bool enable)
T getUntrackedParameter(std::string const &, T const &) const
float xx() const
Definition: LocalError.h:22
float fitX(const CLHEP::HepMatrix &sp, const CLHEP::HepMatrix &ep)
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
virtual const std::array< const float, 4 > parameters() const
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:34
static const double slope[3]
CSCDetId detId(int vme, int dmb, int cfeb, int layer=0) const
Definition: CSCCrateMap.cc:9
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
bool accept() const
Has at least one path accepted the event?
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const std::vector< CSCDDUEventData > & dduData() const
accessor to dduData
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:60
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
void doNoiseHits(edm::Handle< CSCRecHit2DCollection > recHits, edm::Handle< CSCSegmentCollection > cscSegments, edm::ESHandle< CSCGeometry > cscGeom, edm::Handle< CSCStripDigiCollection > strips)
Definition: weight.py:1
const ChamberContainer & chambers() const
Return a vector of all chambers.
Definition: CSCGeometry.cc:96
void endJob() override
GainContainer gains
Definition: CSCDBGains.h:24
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
void doRecHits(edm::Handle< CSCRecHit2DCollection > recHits, edm::ESHandle< CSCGeometry > cscGeom)
int layer() const
Definition: CSCDetId.h:56
void doEfficiencies(edm::Handle< CSCWireDigiCollection > wires, edm::Handle< CSCStripDigiCollection > strips, edm::Handle< CSCRecHit2DCollection > recHits, edm::Handle< CSCSegmentCollection > cscSegments, edm::ESHandle< CSCGeometry > cscGeom)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
bool withinSensitiveRegion(LocalPoint localPos, const std::array< const float, 4 > &layerBounds, int station, int ring, float shiftFromEdge, float shiftFromDeadZone)
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
bool doTrigger(edm::Handle< L1MuGMTReadoutCollection > pCollection)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
std::string chamberTypeName() const
int endcap() const
Definition: CSCDetId.h:85
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void doCompTiming(const CSCComparatorDigiCollection &)
float xy() const
Definition: LocalError.h:23
void doPedestalNoise(edm::Handle< CSCStripDigiCollection > strips)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T mag() const
Definition: PV3DBase.h:64
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int np
Definition: AMPTWrapper.h:43
int dbIndex(const CSCDetId &id, int &channel)
Definition: CSCIndexer.cc:231
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:39
float yy() const
Definition: LocalError.h:24
void doStripDigis(edm::Handle< CSCStripDigiCollection > strips)
T sqrt(T t)
Definition: SSEVec.h:19
unsigned int size() const
Get number of paths stored.
int getWidth(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip)
void histoEfficiency(TH1F *readHisto, TH1F *writeHisto)
int ringSerial(CSCDetId id)
T z() const
Definition: PV3DBase.h:61
void crcTMB(bool enable)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
~CSCValidation() override
Destructor.
CSCDetId chamberId() const
Definition: CSCDetId.h:47
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
bool filterEvents(edm::Handle< CSCRecHit2DCollection > recHits, edm::Handle< CSCSegmentCollection > cscSegments, edm::Handle< reco::TrackCollection > saMuons)
bool doHLT(edm::Handle< edm::TriggerResults > hltResults)
float ChiSquaredProbability(double chiSquared, double nrDOF)
static const std::string kLayer("layer")
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Perform the analysis.
void doSimHits(edm::Handle< CSCRecHit2DCollection > recHits, edm::Handle< edm::PSimHitContainer > simHits)
d
Definition: ztail.py:151
#define LogTrace(id)
uint16_t ALCTMatchTime() const
Definition: CSCTMBHeader.h:38
void doGasGain(const CSCWireDigiCollection &, const CSCStripDigiCollection &, const CSCRecHit2DCollection &)
int ring() const
Definition: CSCDetId.h:68
Definition: DetId.h:17
void getEfficiency(float bin, float Norm, std::vector< float > &eff)
void doResolution(edm::Handle< CSCSegmentCollection > cscSegments, edm::ESHandle< CSCGeometry > cscGeom)
void findNonAssociatedRecHits(edm::ESHandle< CSCGeometry > cscGeom, edm::Handle< CSCStripDigiCollection > strips)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
std::pair< const_iterator, const_iterator > Range
static constexpr int RPC
Definition: MuonSubdetId.h:13
std::vector< DigiType >::const_iterator const_iterator
int32_t check(const uint16_t *&buffer, int32_t length)
histos
Definition: combine.py:4
void doAFEBTiming(const CSCWireDigiCollection &)
void doTimeMonitoring(edm::Handle< CSCRecHit2DCollection > recHits, edm::Handle< CSCSegmentCollection > cscSegments, edm::Handle< CSCALCTDigiCollection > alcts, edm::Handle< CSCCLCTDigiCollection > clcts, edm::Handle< CSCCorrelatedLCTDigiCollection > correlatedlcts, edm::Handle< L1MuGMTReadoutCollection > pCollection, edm::ESHandle< CSCGeometry > cscGeom, const edm::EventSetup &eventSetup, const edm::Event &event)
std::vector< const CSCChamber * > ChamberContainer
Definition: CSCGeometry.h:30
float getSignal(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip)
PedestalContainer pedestals
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void doStandalone(edm::Handle< reco::TrackCollection > saMuons)
int chamberSerial(CSCDetId id)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
T get() const
Definition: EventSetup.h:73
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void doWireDigis(edm::Handle< CSCWireDigiCollection > wires)
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
int station() const
Definition: CSCDetId.h:79
Definition: errors.py:1
void doADCTiming(const CSCRecHit2DCollection &)
CrosstalkContainer crosstalk
NoiseMatrixContainer matrix
static constexpr int DT
Definition: MuonSubdetId.h:11
CSCValidation(const edm::ParameterSet &pset)
Constructor.
void doSegments(edm::Handle< CSCSegmentCollection > cscSegments, edm::ESHandle< CSCGeometry > cscGeom)
static constexpr int CSC
Definition: MuonSubdetId.h:12
T x() const
Definition: PV3DBase.h:59
T const * product() const
Definition: ESHandle.h:86
void doOccupancies(edm::Handle< CSCStripDigiCollection > strips, edm::Handle< CSCWireDigiCollection > wires, edm::Handle< CSCRecHit2DCollection > recHits, edm::Handle< CSCSegmentCollection > cscSegments)
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
void setMask(ExaminerMaskType mask)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
Definition: event.py:1
void doCalibrations(const edm::EventSetup &eventSetup)
Definition: vlib.h:28