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