CMS 3D CMS Logo

CSCEfficiency.cc
Go to the documentation of this file.
1 /*
2  * Routine to calculate CSC efficiencies
3  * Comments about the program logic are denoted by //----
4  *
5  * Stoyan Stoynev, Northwestern University.
6  */
7 
9 
17 
19 
20 using namespace std;
21 
23  passTheEvent = false;
24  DataFlow->Fill(0.);
26 
27  //---- increment counter
28  nEventsAnalyzed++;
29  // printalot debug output
30  printalot = (nEventsAnalyzed < int(printout_NEvents)); //
31  edm::RunNumber_t const iRun = event.id().run();
32  edm::EventNumber_t const iEvent = event.id().event();
33  if (0 == fmod(double(nEventsAnalyzed), double(1000))) {
34  if (printalot) {
35  printf("\n==enter==CSCEfficiency===== run %u\tevent %llu\tn Analyzed %i\n", iRun, iEvent, nEventsAnalyzed);
36  }
37  }
38  theService->update(eventSetup);
39  //---- These declarations create handles to the types of records that you want
40  //---- to retrieve from event "e".
41  if (printalot)
42  printf("\tget handles for digi collections\n");
43 
44  //---- Pass the handle to the method "getByType", which is used to retrieve
45  //---- one and only one instance of the type in question out of event "e". If
46  //---- zero or more than one instance exists in the event an exception is thrown.
47  if (printalot)
48  printf("\tpass handles\n");
56  edm::Handle<edm::View<reco::Track> > trackCollectionH;
58 
59  if (useDigis) {
60  event.getByToken(wd_token, wires);
61  event.getByToken(sd_token, strips);
62  event.getByToken(al_token, alcts);
63  event.getByToken(cl_token, clcts);
64  event.getByToken(co_token, correlatedlcts);
65  }
66  if (!isData) {
67  event.getByToken(sh_token, simhits);
68  }
69  event.getByToken(rh_token, rechits);
70  event.getByToken(se_token, segments);
71  event.getByToken(tk_token, trackCollectionH);
72  const edm::View<reco::Track> trackCollection = *(trackCollectionH.product());
73 
74  //---- Get the CSC Geometry :
75  if (printalot)
76  printf("\tget the CSC geometry.\n");
77  edm::ESHandle<CSCGeometry> cscGeom = eventSetup.getHandle(geomToken_);
78 
79  // use theTrackingGeometry instead of cscGeom?
80  edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
81  eventSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
82 
83  bool triggerPassed = true;
84  if (useTrigger) {
85  // access the trigger information
86  // trigger names can be find in HLTrigger/Configuration/python/HLT_2E30_cff.py (or?)
87  // get hold of TriggerResults
89  event.getByToken(ht_token, hltR);
90  const edm::TriggerNames &triggerNames = event.triggerNames(*hltR);
91  triggerPassed = applyTrigger(hltR, triggerNames);
92  }
93  if (!triggerPassed) {
94  return triggerPassed;
95  }
96  DataFlow->Fill(1.);
97  GlobalPoint gpZero(0., 0., 0.);
98  if (theService->magneticField()->inTesla(gpZero).mag2() < 0.1) {
99  magField = false;
100  } else {
101  magField = true;
102  }
103 
104  //---- store info from digis
105  fillDigiInfo(alcts, clcts, correlatedlcts, wires, strips, simhits, rechits, segments, cscGeom);
106  //
108  edm::InputTag muonTag_("muons");
109  event.getByLabel(muonTag_, muons);
110 
111  edm::Handle<reco::BeamSpot> beamSpotHandle;
112  event.getByLabel("offlineBeamSpot", beamSpotHandle);
113  reco::BeamSpot vertexBeamSpot = *beamSpotHandle;
114  //
115  std::vector<reco::MuonCollection::const_iterator> goodMuons_it;
116  unsigned int nPositiveZ = 0;
117  unsigned int nNegativeZ = 0;
118  float muonOuterZPosition = -99999.;
119  if (isIPdata) {
120  if (printalot)
121  std::cout << " muons.size() = " << muons->size() << std::endl;
122  for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
123  DataFlow->Fill(31.);
124  if (printalot) {
125  std::cout << " iMuon = " << muon - muons->begin() << " charge = " << muon->charge() << " p = " << muon->p()
126  << " pt = " << muon->pt() << " eta = " << muon->eta() << " phi = " << muon->phi()
127  << " matches = " << muon->matches().size()
128  << " matched Seg = " << muon->numberOfMatches(reco::Muon::SegmentAndTrackArbitration)
129  << " GLB/TR/STA = " << muon->isGlobalMuon() << "/" << muon->isTrackerMuon() << "/"
130  << muon->isStandAloneMuon() << std::endl;
131  }
132  if (!(muon->isTrackerMuon() && muon->isGlobalMuon())) {
133  continue;
134  }
135  DataFlow->Fill(32.);
136  double relISO =
137  (muon->isolationR03().sumPt + muon->isolationR03().emEt + muon->isolationR03().hadEt) / muon->track()->pt();
138  if (printalot) {
139  std::cout << " relISO = " << relISO << " emVetoEt = " << muon->isolationR03().emVetoEt
140  << " caloComp = " << muon::caloCompatibility(*(muon))
141  << " dxy = " << fabs(muon->track()->dxy(vertexBeamSpot.position())) << std::endl;
142  }
143  if (
144  //relISO>0.1 || muon::caloCompatibility(*(muon))<.90 ||
145  fabs(muon->track()->dxy(vertexBeamSpot.position())) > 0.2 || muon->pt() < 6.) {
146  continue;
147  }
148  DataFlow->Fill(33.);
149  if (muon->track()->hitPattern().numberOfValidPixelHits() < 1 ||
150  muon->track()->hitPattern().numberOfValidTrackerHits() < 11 ||
151  muon->combinedMuon()->hitPattern().numberOfValidMuonHits() < 1 ||
152  muon->combinedMuon()->normalizedChi2() > 10. || muon->numberOfMatches() < 2) {
153  continue;
154  }
155  DataFlow->Fill(34.);
156  float zOuter = muon->combinedMuon()->outerPosition().z();
157  float rhoOuter = muon->combinedMuon()->outerPosition().rho();
158  bool passDepth = true;
159  // barrel region
160  //if ( fabs(zOuter) < 660. && rhoOuter > 400. && rhoOuter < 480.){
161  if (fabs(zOuter) < 660. && rhoOuter > 400. && rhoOuter < 540.) {
162  passDepth = false;
163  }
164  // endcap region
165  //else if( fabs(zOuter) > 550. && fabs(zOuter) < 650. && rhoOuter < 300.){
166  else if (fabs(zOuter) > 550. && fabs(zOuter) < 650. && rhoOuter < 300.) {
167  passDepth = false;
168  }
169  // overlap region
170  //else if ( fabs(zOuter) > 680. && fabs(zOuter) < 730. && rhoOuter < 480.){
171  else if (fabs(zOuter) > 680. && fabs(zOuter) < 880. && rhoOuter < 540.) {
172  passDepth = false;
173  }
174  if (!passDepth) {
175  continue;
176  }
177  DataFlow->Fill(35.);
178  goodMuons_it.push_back(muon);
179  if (muon->track()->momentum().z() > 0.) {
180  ++nPositiveZ;
181  }
182  if (muon->track()->momentum().z() < 0.) {
183  ++nNegativeZ;
184  }
185  }
186  }
187 
188  //
189 
190  if (printalot)
191  std::cout << "Start track loop over " << trackCollection.size() << " tracks" << std::endl;
192  for (edm::View<reco::Track>::size_type i = 0; i < trackCollection.size(); ++i) {
193  DataFlow->Fill(2.);
194  edm::RefToBase<reco::Track> track(trackCollectionH, i);
195  //std::cout<<" iTR = "<<i<<" eta = "<<track->eta()<<" phi = "<<track->phi()<<std::cout<<" pt = "<<track->pt()<<std::endl;
196  if (isIPdata) {
197  if (printalot) {
198  std::cout << " nNegativeZ = " << nNegativeZ << " nPositiveZ = " << nPositiveZ << std::endl;
199  }
200  if (nNegativeZ > 1 || nPositiveZ > 1) {
201  break;
202  }
203  bool trackOK = false;
204  if (printalot) {
205  std::cout << " goodMuons_it.size() = " << goodMuons_it.size() << std::endl;
206  }
207  for (size_t iM = 0; iM < goodMuons_it.size(); ++iM) {
208  //std::cout<<" iM = "<<iM<<" eta = "<<goodMuons_it[iM]->track()->eta()<<
209  //" phi = "<<goodMuons_it[iM]->track()->phi()<<
210  //" pt = "<<goodMuons_it[iM]->track()->pt()<<std::endl;
211  float deltaR = pow(track->phi() - goodMuons_it[iM]->track()->phi(), 2) +
212  pow(track->eta() - goodMuons_it[iM]->track()->eta(), 2);
213  deltaR = sqrt(deltaR);
214  if (printalot) {
215  std::cout << " TR mu match to a tr: deltaR = " << deltaR
216  << " dPt = " << track->pt() - goodMuons_it[iM]->track()->pt() << std::endl;
217  }
218  if (deltaR > 0.01 || fabs(track->pt() - goodMuons_it[iM]->track()->pt()) > 0.1) {
219  continue;
220  } else {
221  trackOK = true;
222  if (printalot) {
223  std::cout << " trackOK " << std::endl;
224  }
225  muonOuterZPosition = goodMuons_it[iM]->combinedMuon()->outerPosition().z();
226  break;
227  //++nChosenTracks;
228  }
229  }
230  if (!trackOK) {
231  if (printalot) {
232  std::cout << " failed: trackOK " << std::endl;
233  }
234  continue;
235  }
236  } else {
237  //---- Do we need a better "clean track" definition?
238  if (trackCollection.size() > 2) {
239  break;
240  }
241  DataFlow->Fill(3.);
242  if (!i && 2 == trackCollection.size()) {
244  edm::RefToBase<reco::Track> trackTwo(trackCollectionH, tType);
245  if (track->outerPosition().z() * trackTwo->outerPosition().z() > 0) { // in one and the same "endcap"
246  break;
247  }
248  }
249  }
250  DataFlow->Fill(4.);
251  if (printalot) {
252  std::cout << "i track = " << i << " P = " << track->p() << " chi2/ndf = " << track->normalizedChi2()
253  << " nSeg = " << segments->size() << std::endl;
254  std::cout << "quality undef/loose/tight/high/confirmed/goodIt/size " << track->quality(reco::Track::undefQuality)
255  << "/" << track->quality(reco::Track::loose) << "/" << track->quality(reco::Track::tight) << "/"
256  << track->quality(reco::Track::highPurity) << "/" << track->quality(reco::Track::confirmed) << "/"
257  << track->quality(reco::Track::goodIterative) << "/" << track->quality(reco::Track::qualitySize)
258  << std::endl;
259  std::cout << " pt = " << track->pt() << " +-" << track->ptError() << " q/pt = " << track->qoverp() << " +- "
260  << track->qoverpError() << std::endl;
261  //std::cout<<" const Pmin = "<<minTrackMomentum<<" pMax = "<<maxTrackMomentum<<" maxNormChi2 = "<<maxNormChi2<<std::endl;
262  std::cout << " track inner position = " << track->innerPosition()
263  << " outer position = " << track->outerPosition() << std::endl;
264  std::cout << "track eta (outer) = " << track->outerPosition().eta()
265  << " phi (outer) = " << track->outerPosition().phi() << std::endl;
266  if (fabs(track->innerPosition().z()) > 500.) {
267  DetId innerDetId(track->innerDetId());
268  std::cout << " dump inner state MUON detid = " << debug.dumpMuonId(innerDetId) << std::endl;
269  }
270  if (fabs(track->outerPosition().z()) > 500.) {
271  DetId outerDetId(track->outerDetId());
272  std::cout << " dump outer state MUON detid = " << debug.dumpMuonId(outerDetId) << std::endl;
273  }
274 
275  std::cout << " nHits = " << track->found() << std::endl;
276  /*
277  trackingRecHit_iterator rhbegin = track->recHitsBegin();
278  trackingRecHit_iterator rhend = track->recHitsEnd();
279  int iRH = 0;
280  for(trackingRecHit_iterator recHit = rhbegin; recHit != rhend; ++recHit){
281  const GeomDet* geomDet = theTrackingGeometry->idToDet((*recHit)->geographicalId());
282  std::cout<<"hit "<<iRH<<" loc pos = " <<(*recHit)->localPosition()<<
283  " glob pos = " <<geomDet->toGlobal((*recHit)->localPosition())<<std::endl;
284  ++iRH;
285  }
286  */
287  }
288  float dpT_ov_pT = 0.;
289  if (fabs(track->pt()) > 0.001) {
290  dpT_ov_pT = track->ptError() / track->pt();
291  }
292  //---- These define a "good" track
293  if (track->normalizedChi2() > maxNormChi2) { // quality
294  break;
295  }
296  DataFlow->Fill(5.);
297  if (track->found() < minTrackHits) { // enough data points
298  break;
299  }
300  DataFlow->Fill(6.);
301  if (!segments->size()) { // better have something in the CSC
302  break;
303  }
304  DataFlow->Fill(7.);
305  if (magField && (track->p() < minP || track->p() > maxP)) { // proper energy range
306  break;
307  }
308  DataFlow->Fill(8.);
309  if (magField && (dpT_ov_pT > 0.5)) { // not too crazy uncertainty
310  break;
311  }
312  DataFlow->Fill(9.);
313 
314  passTheEvent = true;
315  if (printalot)
316  std::cout << "good Track" << std::endl;
317  CLHEP::Hep3Vector r3T_inner(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
318  CLHEP::Hep3Vector r3T(track->outerPosition().x(), track->outerPosition().y(), track->outerPosition().z());
319  chooseDirection(r3T_inner, r3T); // for non-IP
320 
321  CLHEP::Hep3Vector p3T(track->outerMomentum().x(), track->outerMomentum().y(), track->outerMomentum().z());
322  CLHEP::Hep3Vector p3_propagated, r3_propagated;
323  AlgebraicSymMatrix66 cov_propagated, covT;
324  covT *= 1e-20;
325  cov_propagated *= 1e-20;
326  int charge = track->charge();
327  FreeTrajectoryState ftsStart = getFromCLHEP(p3T, r3T, charge, covT, &*(theService->magneticField()));
328  if (printalot) {
329  std::cout << " p = " << track->p() << " norm chi2 = " << track->normalizedChi2() << std::endl;
330  std::cout << " dump the very first FTS = " << debug.dumpFTS(ftsStart) << std::endl;
331  }
332  TrajectoryStateOnSurface tSOSDest;
333  int endcap = 0;
334  //---- which endcap to look at
335  if (track->outerPosition().z() > 0) {
336  endcap = 1;
337  } else {
338  endcap = 2;
339  }
340  int chamber = 1;
341  //---- a "refference" CSCDetId for each ring
342  std::vector<CSCDetId> refME;
343  for (int iS = 1; iS < 5; ++iS) {
344  for (int iR = 1; iR < 4; ++iR) {
345  if (1 != iS && iR > 2) {
346  continue;
347  } else if (4 == iS && iR > 1) {
348  continue;
349  }
350  refME.push_back(CSCDetId(endcap, iS, iR, chamber));
351  }
352  }
353  //---- loop over the "refference" CSCDetIds
354  for (size_t iSt = 0; iSt < refME.size(); ++iSt) {
355  if (printalot) {
356  std::cout << "loop iStatation = " << iSt << std::endl;
357  std::cout << "refME[iSt]: st = " << refME[iSt].station() << " rg = " << refME[iSt].ring() << std::endl;
358  }
359  std::map<std::string, bool> chamberTypes;
360  chamberTypes["ME11"] = false;
361  chamberTypes["ME12"] = false;
362  chamberTypes["ME13"] = false;
363  chamberTypes["ME21"] = false;
364  chamberTypes["ME22"] = false;
365  chamberTypes["ME31"] = false;
366  chamberTypes["ME32"] = false;
367  chamberTypes["ME41"] = false;
368  const CSCChamber *cscChamber_base = cscGeom->chamber(refME[iSt].chamberId());
369  DetId detId = cscChamber_base->geographicalId();
370  if (printalot) {
371  std::cout << " base iStation : eta = " << cscGeom->idToDet(detId)->surface().position().eta()
372  << " phi = " << cscGeom->idToDet(detId)->surface().position().phi()
373  << " y = " << cscGeom->idToDet(detId)->surface().position().y() << std::endl;
374  std::cout << " dump base iStation detid = " << debug.dumpMuonId(detId) << std::endl;
375  std::cout << " dump FTS start = " << debug.dumpFTS(ftsStart) << std::endl;
376  }
377  //---- propagate to this ME
378  tSOSDest = propagate(ftsStart, cscGeom->idToDet(detId)->surface());
379  if (tSOSDest.isValid()) {
380  ftsStart = *tSOSDest.freeState();
381  if (printalot)
382  std::cout << " dump FTS end = " << debug.dumpFTS(ftsStart) << std::endl;
383  getFromFTS(ftsStart, p3_propagated, r3_propagated, charge, cov_propagated);
384  float feta = fabs(r3_propagated.eta());
385  float phi = r3_propagated.phi();
386  //---- which rings are (possibly) penetrated
387  ringCandidates(refME[iSt].station(), feta, chamberTypes);
388 
389  map<std::string, bool>::iterator iter;
390  int iterations = 0;
391  //---- loop over ring candidates
392  for (iter = chamberTypes.begin(); iter != chamberTypes.end(); iter++) {
393  ++iterations;
394  //---- is this ME a machinig candidate station
395  if (iter->second && (iterations - 1) == int(iSt)) {
396  if (printalot) {
397  std::cout << " Chamber type " << iter->first << " is a candidate..." << std::endl;
398  std::cout << " station() = " << refME[iSt].station() << " ring() = " << refME[iSt].ring()
399  << " iSt = " << iSt << std::endl;
400  }
401  std::vector<int> coupleOfChambers;
402  //---- which chamber (and its closes neighbor) is penetrated by the track - candidates
403  chamberCandidates(refME[iSt].station(), refME[iSt].ring(), phi, coupleOfChambers);
404  //---- loop over the two chamber candidates
405  for (size_t iCh = 0; iCh < coupleOfChambers.size(); ++iCh) {
406  DataFlow->Fill(11.);
407  if (printalot)
408  std::cout << " Check chamber N = " << coupleOfChambers.at(iCh) << std::endl;
409  ;
410  if ((!getAbsoluteEfficiency) &&
411  (true == emptyChambers[refME[iSt].endcap() - 1][refME[iSt].station() - 1][refME[iSt].ring() - 1]
412  [coupleOfChambers.at(iCh) - FirstCh])) {
413  continue;
414  }
415  CSCDetId theCSCId(refME[iSt].endcap(), refME[iSt].station(), refME[iSt].ring(), coupleOfChambers.at(iCh));
416  const CSCChamber *cscChamber = cscGeom->chamber(theCSCId.chamberId());
417  const BoundPlane bpCh = cscGeom->idToDet(cscChamber->geographicalId())->surface();
418  float zFTS = ftsStart.position().z();
419  float dz = fabs(bpCh.position().z() - zFTS);
420  float zDistInner = track->innerPosition().z() - bpCh.position().z();
421  float zDistOuter = track->outerPosition().z() - bpCh.position().z();
422  //---- only detectors between the inner and outer points of the track are considered for non IP-data
423  if (printalot) {
424  std::cout << " zIn = " << track->innerPosition().z() << " zOut = " << track->outerPosition().z()
425  << " zSurf = " << bpCh.position().z() << std::endl;
426  }
427  if (!isIPdata && (zDistInner * zDistOuter > 0. || fabs(zDistInner) < 15. ||
428  fabs(zDistOuter) < 15.)) { // for non IP-data
429  if (printalot) {
430  std::cout << " Not an intermediate (as defined) point... Skip." << std::endl;
431  }
432  continue;
433  }
434  if (isIPdata && fabs(track->eta()) < 1.8) {
435  if (fabs(muonOuterZPosition) - fabs(bpCh.position().z()) < 0 ||
436  fabs(muonOuterZPosition - bpCh.position().z()) < 15.) {
437  continue;
438  }
439  }
440  DataFlow->Fill(13.);
441  //---- propagate to the chamber (from this ME) if it is a different surface (odd/even chambers)
442  if (dz > 0.1) { // i.e. non-zero (float 0 check is bad)
443  //if(fabs(zChanmber - zFTS ) > 0.1){
444  tSOSDest = propagate(ftsStart, cscGeom->idToDet(cscChamber->geographicalId())->surface());
445  if (tSOSDest.isValid()) {
446  ftsStart = *tSOSDest.freeState();
447  } else {
448  if (printalot)
449  std::cout << "TSOS not valid! Break." << std::endl;
450  break;
451  }
452  } else {
453  if (printalot)
454  std::cout << " info: dz<0.1" << std::endl;
455  }
456  DataFlow->Fill(15.);
457  FreeTrajectoryState ftsInit = ftsStart;
458  bool inDeadZone = false;
459  //---- loop over the 6 layers
460  for (int iLayer = 0; iLayer < 6; ++iLayer) {
461  bool extrapolationPassed = true;
462  if (printalot) {
463  std::cout << " iLayer = " << iLayer << " dump FTS init = " << debug.dumpFTS(ftsInit) << std::endl;
464  std::cout << " dump detid = " << debug.dumpMuonId(cscChamber->geographicalId()) << std::endl;
465  std::cout << "Surface to propagate to: pos = " << cscChamber->layer(iLayer + 1)->surface().position()
466  << " eta = " << cscChamber->layer(iLayer + 1)->surface().position().eta()
467  << " phi = " << cscChamber->layer(iLayer + 1)->surface().position().phi() << std::endl;
468  }
469  //---- propagate to this layer
470  tSOSDest = propagate(ftsInit, cscChamber->layer(iLayer + 1)->surface());
471  if (tSOSDest.isValid()) {
472  ftsInit = *tSOSDest.freeState();
473  if (printalot)
474  std::cout << " Propagation between layers successful: dump FTS end = " << debug.dumpFTS(ftsInit)
475  << std::endl;
476  getFromFTS(ftsInit, p3_propagated, r3_propagated, charge, cov_propagated);
477  } else {
478  if (printalot)
479  std::cout << "Propagation between layers not successful - notValid TSOS" << std::endl;
480  extrapolationPassed = false;
481  inDeadZone = true;
482  }
483  //}
484  //---- Extrapolation passed? For each layer?
485  if (extrapolationPassed) {
486  GlobalPoint theExtrapolationPoint(r3_propagated.x(), r3_propagated.y(), r3_propagated.z());
487  LocalPoint theLocalPoint = cscChamber->layer(iLayer + 1)->toLocal(theExtrapolationPoint);
488  //std::cout<<" Candidate chamber: extrapolated LocalPoint = "<<theLocalPoint<<std::endl;
489  inDeadZone = (inDeadZone ||
490  !inSensitiveLocalRegion(
491  theLocalPoint.x(), theLocalPoint.y(), refME[iSt].station(), refME[iSt].ring()));
492  if (printalot) {
493  std::cout << " Candidate chamber: extrapolated LocalPoint = " << theLocalPoint
494  << "inDeadZone = " << inDeadZone << std::endl;
495  }
496  //---- break if in dead zone for any layer ("clean" tracks)
497  if (inDeadZone) {
498  break;
499  }
500  } else {
501  break;
502  }
503  }
504  DataFlow->Fill(17.);
505  //---- Is a track in a sensitive area for each layer?
506  if (!inDeadZone) { //---- for any layer
507  DataFlow->Fill(19.);
508  if (printalot)
509  std::cout << "Do efficiencies..." << std::endl;
510  //---- Do efficiencies
511  // angle cuts applied (if configured)
512  bool angle_flag = true;
513  angle_flag = efficienciesPerChamber(theCSCId, cscChamber, ftsStart);
514  if (useDigis && angle_flag) {
515  stripWire_Efficiencies(theCSCId, ftsStart);
516  }
517  if (angle_flag) {
518  recHitSegment_Efficiencies(theCSCId, cscChamber, ftsStart);
519  if (!isData) {
520  recSimHitEfficiency(theCSCId, ftsStart);
521  }
522  }
523  } else {
524  if (printalot)
525  std::cout << " Not in active area for all layers" << std::endl;
526  }
527  }
528  if (tSOSDest.isValid()) {
529  ftsStart = *tSOSDest.freeState();
530  }
531  }
532  }
533  } else {
534  if (printalot)
535  std::cout << " TSOS not valid..." << std::endl;
536  }
537  }
538  }
539  //---- End
540  if (printalot)
541  printf("==exit===CSCEfficiency===== run %u\tevent %llu\n\n", iRun, iEvent);
542  return passTheEvent;
543 }
544 
545 //
546 bool CSCEfficiency::inSensitiveLocalRegion(double xLocal, double yLocal, int station, int ring) {
547  //---- Good region means sensitive area of a chamber. "Local" stands for the local system
548  bool pass = false;
549  std::vector<double> chamberBounds(3); // the sensitive area
550  float y_center = 99999.;
551  //---- hardcoded... not good
552  if (station > 1 && station < 5) {
553  if (2 == ring) {
554  chamberBounds[0] = 66.46 / 2; // (+-)x1 shorter
555  chamberBounds[1] = 127.15 / 2; // (+-)x2 longer
556  chamberBounds[2] = 323.06 / 2;
557  y_center = -0.95;
558  } else {
559  if (2 == station) {
560  chamberBounds[0] = 54.00 / 2; // (+-)x1 shorter
561  chamberBounds[1] = 125.71 / 2; // (+-)x2 longer
562  chamberBounds[2] = 189.66 / 2;
563  y_center = -0.955;
564  } else if (3 == station) {
565  chamberBounds[0] = 61.40 / 2; // (+-)x1 shorter
566  chamberBounds[1] = 125.71 / 2; // (+-)x2 longer
567  chamberBounds[2] = 169.70 / 2;
568  y_center = -0.97;
569  } else if (4 == station) {
570  chamberBounds[0] = 69.01 / 2; // (+-)x1 shorter
571  chamberBounds[1] = 125.65 / 2; // (+-)x2 longer
572  chamberBounds[2] = 149.42 / 2;
573  y_center = -0.94;
574  }
575  }
576  } else if (1 == station) {
577  if (3 == ring) {
578  chamberBounds[0] = 63.40 / 2; // (+-)x1 shorter
579  chamberBounds[1] = 92.10 / 2; // (+-)x2 longer
580  chamberBounds[2] = 164.16 / 2;
581  y_center = -1.075;
582  } else if (2 == ring) {
583  chamberBounds[0] = 51.00 / 2; // (+-)x1 shorter
584  chamberBounds[1] = 83.74 / 2; // (+-)x2 longer
585  chamberBounds[2] = 174.49 / 2;
586  y_center = -0.96;
587  } else { // to be investigated
588  chamberBounds[0] = 30. / 2; //40./2; // (+-)x1 shorter
589  chamberBounds[1] = 60. / 2; //100./2; // (+-)x2 longer
590  chamberBounds[2] = 160. / 2; //142./2;
591  y_center = 0.;
592  }
593  }
594  double yUp = chamberBounds[2] + y_center;
595  double yDown = -chamberBounds[2] + y_center;
596  double xBound1Shifted = chamberBounds[0] - distanceFromDeadZone; //
597  double xBound2Shifted = chamberBounds[1] - distanceFromDeadZone; //
598  double lineSlope = (yUp - yDown) / (xBound2Shifted - xBound1Shifted);
599  double lineConst = yUp - lineSlope * xBound2Shifted;
600  double yBoundary = lineSlope * abs(xLocal) + lineConst;
601  pass = checkLocal(yLocal, yBoundary, station, ring);
602  return pass;
603 }
604 
605 bool CSCEfficiency::checkLocal(double yLocal, double yBoundary, int station, int ring) {
606  //---- check if it is in a good local region (sensitive area - geometrical and HV boundaries excluded)
607  bool pass = false;
608  std::vector<float> deadZoneCenter(6);
609  const float deadZoneHalf = 0.32 * 7 / 2; // wire spacing * (wires missing + 1)/2
610  float cutZone = deadZoneHalf + distanceFromDeadZone; //cm
611  //---- hardcoded... not good
612  if (station > 1 && station < 5) {
613  if (2 == ring) {
614  deadZoneCenter[0] = -162.48;
615  deadZoneCenter[1] = -81.8744;
616  deadZoneCenter[2] = -21.18165;
617  deadZoneCenter[3] = 39.51105;
618  deadZoneCenter[4] = 100.2939;
619  deadZoneCenter[5] = 160.58;
620 
621  if (yLocal > yBoundary && ((yLocal > deadZoneCenter[0] + cutZone && yLocal < deadZoneCenter[1] - cutZone) ||
622  (yLocal > deadZoneCenter[1] + cutZone && yLocal < deadZoneCenter[2] - cutZone) ||
623  (yLocal > deadZoneCenter[2] + cutZone && yLocal < deadZoneCenter[3] - cutZone) ||
624  (yLocal > deadZoneCenter[3] + cutZone && yLocal < deadZoneCenter[4] - cutZone) ||
625  (yLocal > deadZoneCenter[4] + cutZone && yLocal < deadZoneCenter[5] - cutZone))) {
626  pass = true;
627  }
628  } else if (1 == ring) {
629  if (2 == station) {
630  deadZoneCenter[0] = -95.94;
631  deadZoneCenter[1] = -27.47;
632  deadZoneCenter[2] = 33.67;
633  deadZoneCenter[3] = 93.72;
634  } else if (3 == station) {
635  deadZoneCenter[0] = -85.97;
636  deadZoneCenter[1] = -36.21;
637  deadZoneCenter[2] = 23.68;
638  deadZoneCenter[3] = 84.04;
639  } else if (4 == station) {
640  deadZoneCenter[0] = -75.82;
641  deadZoneCenter[1] = -26.14;
642  deadZoneCenter[2] = 23.85;
643  deadZoneCenter[3] = 73.91;
644  }
645  if (yLocal > yBoundary && ((yLocal > deadZoneCenter[0] + cutZone && yLocal < deadZoneCenter[1] - cutZone) ||
646  (yLocal > deadZoneCenter[1] + cutZone && yLocal < deadZoneCenter[2] - cutZone) ||
647  (yLocal > deadZoneCenter[2] + cutZone && yLocal < deadZoneCenter[3] - cutZone))) {
648  pass = true;
649  }
650  }
651  } else if (1 == station) {
652  if (3 == ring) {
653  deadZoneCenter[0] = -83.155;
654  deadZoneCenter[1] = -22.7401;
655  deadZoneCenter[2] = 27.86665;
656  deadZoneCenter[3] = 81.005;
657  if (yLocal > yBoundary && ((yLocal > deadZoneCenter[0] + cutZone && yLocal < deadZoneCenter[1] - cutZone) ||
658  (yLocal > deadZoneCenter[1] + cutZone && yLocal < deadZoneCenter[2] - cutZone) ||
659  (yLocal > deadZoneCenter[2] + cutZone && yLocal < deadZoneCenter[3] - cutZone))) {
660  pass = true;
661  }
662  } else if (2 == ring) {
663  deadZoneCenter[0] = -86.285;
664  deadZoneCenter[1] = -32.88305;
665  deadZoneCenter[2] = 32.867423;
666  deadZoneCenter[3] = 88.205;
667  if (yLocal > (yBoundary) && ((yLocal > deadZoneCenter[0] + cutZone && yLocal < deadZoneCenter[1] - cutZone) ||
668  (yLocal > deadZoneCenter[1] + cutZone && yLocal < deadZoneCenter[2] - cutZone) ||
669  (yLocal > deadZoneCenter[2] + cutZone && yLocal < deadZoneCenter[3] - cutZone))) {
670  pass = true;
671  }
672  } else {
673  deadZoneCenter[0] = -81.0;
674  deadZoneCenter[1] = 81.0;
675  if (yLocal > (yBoundary) && ((yLocal > deadZoneCenter[0] + cutZone && yLocal < deadZoneCenter[1] - cutZone))) {
676  pass = true;
677  }
678  }
679  }
680  return pass;
681 }
682 
691  edm::ESHandle<CSCGeometry> &cscGeom) {
692  for (int iE = 0; iE < 2; iE++) {
693  for (int iS = 0; iS < 4; iS++) {
694  for (int iR = 0; iR < 4; iR++) {
695  for (int iC = 0; iC < NumCh; iC++) {
696  allSegments[iE][iS][iR][iC].clear();
697  allCLCT[iE][iS][iR][iC] = allALCT[iE][iS][iR][iC] = allCorrLCT[iE][iS][iR][iC] = false;
698  for (int iL = 0; iL < 6; iL++) {
699  allStrips[iE][iS][iR][iC][iL].clear();
700  allWG[iE][iS][iR][iC][iL].clear();
701  allRechits[iE][iS][iR][iC][iL].clear();
702  allSimhits[iE][iS][iR][iC][iL].clear();
703  }
704  }
705  }
706  }
707  }
708  //
709  if (useDigis) {
710  fillLCT_info(alcts, clcts, correlatedlcts);
711  fillWG_info(wires, cscGeom);
712  fillStrips_info(strips);
713  }
714  fillRechitsSegments_info(rechits, segments, cscGeom);
715  if (!isData) {
716  fillSimhit_info(simhits);
717  }
718 }
719 
723  //---- ALCTDigis
724  int nSize = 0;
725  for (CSCALCTDigiCollection::DigiRangeIterator j = alcts->begin(); j != alcts->end(); j++) {
726  ++nSize;
727  const CSCDetId &id = (*j).first;
728  const CSCALCTDigiCollection::Range &range = (*j).second;
729  for (CSCALCTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
730  // Valid digi in the chamber (or in neighbouring chamber)
731  if ((*digiIt).isValid()) {
732  allALCT[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh] = true;
733  }
734  } // for digis in layer
735  } // end of for (j=...
736  ALCTPerEvent->Fill(nSize);
737  //---- CLCTDigis
738  nSize = 0;
739  for (CSCCLCTDigiCollection::DigiRangeIterator j = clcts->begin(); j != clcts->end(); j++) {
740  ++nSize;
741  const CSCDetId &id = (*j).first;
742  std::vector<CSCCLCTDigi>::const_iterator digiIt = (*j).second.first;
743  std::vector<CSCCLCTDigi>::const_iterator last = (*j).second.second;
744  for (; digiIt != last; ++digiIt) {
745  // Valid digi in the chamber (or in neighbouring chamber)
746  if ((*digiIt).isValid()) {
747  allCLCT[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh] = true;
748  }
749  }
750  }
751  CLCTPerEvent->Fill(nSize);
752  //---- CorrLCTDigis
753  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j = correlatedlcts->begin(); j != correlatedlcts->end(); j++) {
754  const CSCDetId &id = (*j).first;
755  std::vector<CSCCorrelatedLCTDigi>::const_iterator digiIt = (*j).second.first;
756  std::vector<CSCCorrelatedLCTDigi>::const_iterator last = (*j).second.second;
757  for (; digiIt != last; ++digiIt) {
758  // Valid digi in the chamber (or in neighbouring chamber)
759  if ((*digiIt).isValid()) {
760  allCorrLCT[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh] = true;
761  }
762  }
763  }
764 }
765 //
767  //---- WIRE GROUPS
768  for (CSCWireDigiCollection::DigiRangeIterator j = wires->begin(); j != wires->end(); j++) {
769  CSCDetId id = (CSCDetId)(*j).first;
770  const CSCLayer *layer_p = cscGeom->layer(id);
771  const CSCLayerGeometry *layerGeom = layer_p->geometry();
772  //
773  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
774  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
775  //
776  for (; digiItr != last; ++digiItr) {
777  std::pair<int, float> WG_pos(digiItr->getWireGroup(), layerGeom->yOfWireGroup(digiItr->getWireGroup()));
778  std::pair<std::pair<int, float>, int> LayerSignal(WG_pos, digiItr->getTimeBin());
779 
780  //---- AllWG contains basic information about WG (WG number and Y-position, time bin)
781  allWG[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh][id.layer() - 1].push_back(
782  LayerSignal);
783  if (printalot) {
784  //std::cout<<" WG check : "<<std::endl;
785  //printf("\t\tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",id.endcap(),id.station(),id.ring(),id.chamber(),id.layer());
786  //std::cout<<" WG size = "<<allWG[id.endcap()-1][id.station()-1][id.ring()-1][id.chamber()-FirstCh]
787  //[id.layer()-1].size()<<std::endl;
788  }
789  }
790  }
791 }
793  //---- STRIPS
794  const float threshold = 13.3;
795  for (CSCStripDigiCollection::DigiRangeIterator j = strips->begin(); j != strips->end(); j++) {
796  CSCDetId id = (CSCDetId)(*j).first;
797  int largestADCValue = -1;
798  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
799  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
800  for (; digiItr != last; ++digiItr) {
801  int maxADC = largestADCValue;
802  int myStrip = digiItr->getStrip();
803  std::vector<int> myADCVals = digiItr->getADCCounts();
804  float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
805  float peakADC = -1000.;
806  for (int myADCVal : myADCVals) {
807  float diff = (float)myADCVal - thisPedestal;
808  if (diff > threshold) {
809  if (myADCVal > largestADCValue)
810  largestADCValue = myADCVal;
811  if (diff > peakADC)
812  peakADC = diff;
813  }
814  }
815  if (largestADCValue > maxADC) { // FIX IT!!!
816  std::pair<int, float> LayerSignal(myStrip, peakADC);
817  //---- AllStrips contains basic information about strips
818  //---- (strip number and peak signal for most significant strip in the layer)
819  allStrips[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - 1][id.layer() - 1].clear();
820  allStrips[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - 1][id.layer() - 1].push_back(
821  LayerSignal);
822  }
823  }
824  }
825 }
827  //---- SIMHITS
828  edm::PSimHitContainer::const_iterator dSHsimIter;
829  for (dSHsimIter = simhits->begin(); dSHsimIter != simhits->end(); dSHsimIter++) {
830  // Get DetID for this simHit:
831  CSCDetId sId = (CSCDetId)(*dSHsimIter).detUnitId();
832  std::pair<LocalPoint, int> simHitPos((*dSHsimIter).localPosition(), (*dSHsimIter).particleType());
833  allSimhits[sId.endcap() - 1][sId.station() - 1][sId.ring() - 1][sId.chamber() - FirstCh][sId.layer() - 1].push_back(
834  simHitPos);
835  }
836 }
837 //
840  edm::ESHandle<CSCGeometry> &cscGeom) {
841  //---- RECHITS AND SEGMENTS
842  //---- Loop over rechits
843  if (printalot) {
844  //printf("\tGet the recHits collection.\t ");
845  printf(" The size of the rechit collection is %i\n", int(rechits->size()));
846  //printf("\t...start loop over rechits...\n");
847  }
848  recHitsPerEvent->Fill(rechits->size());
849  //---- Build iterator for rechits and loop :
851  for (recIt = rechits->begin(); recIt != rechits->end(); recIt++) {
852  //---- Find chamber with rechits in CSC
853  CSCDetId id = (CSCDetId)(*recIt).cscDetId();
854  if (printalot) {
855  const CSCLayer *csclayer = cscGeom->layer(id);
856  LocalPoint rhitlocal = (*recIt).localPosition();
857  LocalError rerrlocal = (*recIt).localPositionError();
858  GlobalPoint rhitglobal = csclayer->toGlobal(rhitlocal);
859  printf("\t\tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",
860  id.endcap(),
861  id.station(),
862  id.ring(),
863  id.chamber(),
864  id.layer());
865  printf("\t\tx,y,z: %f, %f, %f\texx,eey,exy: %f, %f, %f\tglobal x,y,z: %f, %f, %f \n",
866  rhitlocal.x(),
867  rhitlocal.y(),
868  rhitlocal.z(),
869  rerrlocal.xx(),
870  rerrlocal.yy(),
871  rerrlocal.xy(),
872  rhitglobal.x(),
873  rhitglobal.y(),
874  rhitglobal.z());
875  }
876  std::pair<LocalPoint, bool> recHitPos((*recIt).localPosition(), false);
877  allRechits[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh][id.layer() - 1].push_back(
878  recHitPos);
879  }
880  //---- "Empty" chambers
881  for (int iE = 0; iE < 2; iE++) {
882  for (int iS = 0; iS < 4; iS++) {
883  for (int iR = 0; iR < 4; iR++) {
884  for (int iC = 0; iC < NumCh; iC++) {
885  int numLayers = 0;
886  for (int iL = 0; iL < 6; iL++) {
887  if (!allRechits[iE][iS][iR][iC][iL].empty()) {
888  ++numLayers;
889  }
890  }
891  if (numLayers > 1) {
892  emptyChambers[iE][iS][iR][iC] = false;
893  } else {
894  emptyChambers[iE][iS][iR][iC] = true;
895  }
896  }
897  }
898  }
899  }
900 
901  //
902  if (printalot) {
903  printf(" The size of the segment collection is %i\n", int(segments->size()));
904  //printf("\t...start loop over segments...\n");
905  }
906  segmentsPerEvent->Fill(segments->size());
907  for (CSCSegmentCollection::const_iterator it = segments->begin(); it != segments->end(); it++) {
908  CSCDetId id = (CSCDetId)(*it).cscDetId();
909  StHist[id.endcap() - 1][id.station() - 1].segmentChi2_ndf->Fill((*it).chi2() / (*it).degreesOfFreedom());
910  StHist[id.endcap() - 1][id.station() - 1].hitsInSegment->Fill((*it).nRecHits());
911  if (printalot) {
912  printf("\tendcap/station/ring/chamber: %i %i %i %i\n", id.endcap(), id.station(), id.ring(), id.chamber());
913  std::cout << "\tposition(loc) = " << (*it).localPosition() << " error(loc) = " << (*it).localPositionError()
914  << std::endl;
915  std::cout << "\t chi2/ndf = " << (*it).chi2() / (*it).degreesOfFreedom() << " nhits = " << (*it).nRecHits()
916  << std::endl;
917  }
918  allSegments[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh].push_back(
919  make_pair((*it).localPosition(), (*it).localDirection()));
920 
921  //---- try to get the CSC recHits that contribute to this segment.
922  //if (printalot) printf("\tGet the recHits for this segment.\t");
923  std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
924  int nRH = (*it).nRecHits();
925  if (printalot) {
926  printf("\tGet the recHits for this segment.\t");
927  printf(" nRH = %i\n", nRH);
928  }
929  //---- Find which of the rechits in the chamber is in the segment
930  int layerRH = 0;
931  for (vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
932  ++layerRH;
933  CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
934  if (printalot) {
935  printf("\t%i RH\tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",
936  layerRH,
937  idRH.endcap(),
938  idRH.station(),
939  idRH.ring(),
940  idRH.chamber(),
941  idRH.layer());
942  }
943  for (size_t jRH = 0;
944  jRH <
945  allRechits[idRH.endcap() - 1][idRH.station() - 1][idRH.ring() - 1][idRH.chamber() - FirstCh][idRH.layer() - 1]
946  .size();
947  ++jRH) {
948  float xDiff = iRH->localPosition().x() - allRechits[idRH.endcap() - 1][idRH.station() - 1][idRH.ring() - 1]
949  [idRH.chamber() - FirstCh][idRH.layer() - 1][jRH]
950  .first.x();
951  float yDiff = iRH->localPosition().y() - allRechits[idRH.endcap() - 1][idRH.station() - 1][idRH.ring() - 1]
952  [idRH.chamber() - FirstCh][idRH.layer() - 1][jRH]
953  .first.y();
954  if (fabs(xDiff) < 0.0001 && fabs(yDiff) < 0.0001) {
955  std::pair<LocalPoint, bool> recHitPos(allRechits[idRH.endcap() - 1][idRH.station() - 1][idRH.ring() - 1]
956  [idRH.chamber() - FirstCh][idRH.layer() - 1][jRH]
957  .first,
958  true);
959  allRechits[idRH.endcap() - 1][idRH.station() - 1][idRH.ring() - 1][idRH.chamber() - FirstCh][idRH.layer() - 1]
960  [jRH] = recHitPos;
961  if (printalot) {
962  std::cout << " number of the rechit (from zero) in the segment = " << jRH << std::endl;
963  }
964  }
965  }
966  }
967  }
968 }
969 //
970 
971 void CSCEfficiency::ringCandidates(int station, float feta, std::map<std::string, bool> &chamberTypes) {
972  // yeah, hardcoded again...
973  switch (station) {
974  case 1:
975  if (feta > 0.85 && feta < 1.18) { //ME13
976  chamberTypes["ME13"] = true;
977  }
978  if (feta > 1.18 && feta < 1.7) { //ME12
979  chamberTypes["ME12"] = true;
980  }
981  if (feta > 1.5 && feta < 2.45) { //ME11
982  chamberTypes["ME11"] = true;
983  }
984  break;
985  case 2:
986  if (feta > 0.95 && feta < 1.6) { //ME22
987  chamberTypes["ME22"] = true;
988  }
989  if (feta > 1.55 && feta < 2.45) { //ME21
990  chamberTypes["ME21"] = true;
991  }
992  break;
993  case 3:
994  if (feta > 1.08 && feta < 1.72) { //ME32
995  chamberTypes["ME32"] = true;
996  }
997  if (feta > 1.69 && feta < 2.45) { //ME31
998  chamberTypes["ME31"] = true;
999  }
1000  break;
1001  case 4:
1002  if (feta > 1.78 && feta < 2.45) { //ME41
1003  chamberTypes["ME41"] = true;
1004  }
1005  break;
1006  default:
1007  break;
1008  }
1009 }
1010 //
1011 void CSCEfficiency::chamberCandidates(int station, int ring, float phi, std::vector<int> &coupleOfChambers) {
1012  coupleOfChambers.clear();
1013  // -pi< phi<+pi
1014  float phi_zero = 0.; // check! the phi at the "edge" of Ch 1
1015  float phi_const = 2. * M_PI / 36.;
1016  int last_chamber = 36;
1017  int first_chamber = 1;
1018  if (1 != station && 1 == ring) { // 18 chambers in the ring
1019  phi_const *= 2;
1020  last_chamber /= 2;
1021  }
1022  if (phi < 0.) {
1023  if (printalot)
1024  std::cout << " info: negative phi = " << phi << std::endl;
1025  phi += 2 * M_PI;
1026  }
1027  float chamber_float = (phi - phi_zero) / phi_const;
1028  int chamber_int = int(chamber_float);
1029  if (chamber_float - float(chamber_int) - 0.5 < 0.) {
1030  if (0 != chamber_int) {
1031  coupleOfChambers.push_back(chamber_int);
1032  } else {
1033  coupleOfChambers.push_back(last_chamber);
1034  }
1035  coupleOfChambers.push_back(chamber_int + 1);
1036 
1037  } else {
1038  coupleOfChambers.push_back(chamber_int + 1);
1039  if (last_chamber != chamber_int + 1) {
1040  coupleOfChambers.push_back(chamber_int + 2);
1041  } else {
1042  coupleOfChambers.push_back(first_chamber);
1043  }
1044  }
1045  if (printalot)
1046  std::cout << " phi = " << phi << " phi_zero = " << phi_zero << " phi_const = " << phi_const
1047  << " candidate chambers: first ch = " << coupleOfChambers[0] << " second ch = " << coupleOfChambers[1]
1048  << std::endl;
1049 }
1050 
1051 //
1053  const CSCChamber *cscChamber,
1054  FreeTrajectoryState &ftsChamber) {
1055  int ec, st, rg, ch, secondRing;
1056  returnTypes(id, ec, st, rg, ch, secondRing);
1057 
1058  LocalVector localDir = cscChamber->toLocal(ftsChamber.momentum());
1059  if (printalot) {
1060  std::cout << " global dir = " << ftsChamber.momentum() << std::endl;
1061  std::cout << " local dir = " << localDir << std::endl;
1062  std::cout << " local theta = " << localDir.theta() << std::endl;
1063  }
1064  float dxdz = localDir.x() / localDir.z();
1065  float dydz = localDir.y() / localDir.z();
1066  if (2 == st || 3 == st) {
1067  if (printalot) {
1068  std::cout << "st 3 or 4 ... flip dy/dz" << std::endl;
1069  }
1070  dydz = -dydz;
1071  }
1072  if (printalot) {
1073  std::cout << "dy/dz = " << dydz << std::endl;
1074  }
1075  // Apply angle cut
1076  bool out = true;
1077  if (applyIPangleCuts) {
1078  if (dydz > local_DY_DZ_Max || dydz < local_DY_DZ_Min || fabs(dxdz) > local_DX_DZ_Max) {
1079  out = false;
1080  }
1081  }
1082 
1083  // Segments
1084  bool firstCondition = !allSegments[ec][st][rg][ch].empty() ? true : false;
1085  bool secondCondition = false;
1086  //---- ME1 is special as usual - ME1a and ME1b are actually one chamber
1087  if (secondRing > -1) {
1088  secondCondition = !allSegments[ec][st][secondRing][ch].empty() ? true : false;
1089  }
1090  if (firstCondition || secondCondition) {
1091  if (out) {
1092  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(1);
1093  }
1094  } else {
1095  if (out) {
1096  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(0);
1097  }
1098  }
1099 
1100  if (useDigis) {
1101  // ALCTs
1102  firstCondition = allALCT[ec][st][rg][ch];
1103  secondCondition = false;
1104  if (secondRing > -1) {
1105  secondCondition = allALCT[ec][st][secondRing][ch];
1106  }
1107  if (firstCondition || secondCondition) {
1108  if (out) {
1109  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(3);
1110  }
1111  // always apply partial angle cuts for this kind of histos
1112  if (fabs(dxdz) < local_DX_DZ_Max) {
1113  StHist[ec][st].EfficientALCT_momTheta->Fill(ftsChamber.momentum().theta());
1114  ChHist[ec][st][rg][ch].EfficientALCT_dydz->Fill(dydz);
1115  }
1116  } else {
1117  if (out) {
1118  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(2);
1119  }
1120  if (fabs(dxdz) < local_DX_DZ_Max) {
1121  StHist[ec][st].InefficientALCT_momTheta->Fill(ftsChamber.momentum().theta());
1122  ChHist[ec][st][rg][ch].InefficientALCT_dydz->Fill(dydz);
1123  }
1124  if (printalot) {
1125  std::cout << " missing ALCT (dy/dz = " << dydz << ")";
1126  printf("\t\tendcap/station/ring/chamber: %i/%i/%i/%i\n", ec + 1, st + 1, rg + 1, ch + 1);
1127  }
1128  }
1129 
1130  // CLCTs
1131  firstCondition = allCLCT[ec][st][rg][ch];
1132  secondCondition = false;
1133  if (secondRing > -1) {
1134  secondCondition = allCLCT[ec][st][secondRing][ch];
1135  }
1136  if (firstCondition || secondCondition) {
1137  if (out) {
1138  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(5);
1139  }
1140  if (dydz < local_DY_DZ_Max && dydz > local_DY_DZ_Min) {
1141  StHist[ec][st].EfficientCLCT_momPhi->Fill(ftsChamber.momentum().phi()); // - phi chamber...
1142  ChHist[ec][st][rg][ch].EfficientCLCT_dxdz->Fill(dxdz);
1143  }
1144  } else {
1145  if (out) {
1146  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(4);
1147  }
1148  if (dydz < local_DY_DZ_Max && dydz > local_DY_DZ_Min) {
1149  StHist[ec][st].InefficientCLCT_momPhi->Fill(ftsChamber.momentum().phi()); // - phi chamber...
1150  ChHist[ec][st][rg][ch].InefficientCLCT_dxdz->Fill(dxdz);
1151  }
1152  if (printalot) {
1153  std::cout << " missing CLCT (dx/dz = " << dxdz << ")";
1154  printf("\t\tendcap/station/ring/chamber: %i/%i/%i/%i\n", ec + 1, st + 1, rg + 1, ch + 1);
1155  }
1156  }
1157  if (out) {
1158  // CorrLCTs
1159  firstCondition = allCorrLCT[ec][st][rg][ch];
1160  secondCondition = false;
1161  if (secondRing > -1) {
1162  secondCondition = allCorrLCT[ec][st][secondRing][ch];
1163  }
1164  if (firstCondition || secondCondition) {
1165  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(7);
1166  } else {
1167  ChHist[ec][st][rg][ch].digiAppearanceCount->Fill(6);
1168  }
1169  }
1170  }
1171  return out;
1172 }
1173 
1174 //
1176  int ec, st, rg, ch, secondRing;
1177  returnTypes(id, ec, st, rg, ch, secondRing);
1178 
1179  bool firstCondition, secondCondition;
1180  int missingLayers_s = 0;
1181  int missingLayers_wg = 0;
1182  for (int iLayer = 0; iLayer < 6; iLayer++) {
1183  //----Strips
1184  if (printalot) {
1185  printf("\t%i swEff: \tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",
1186  iLayer + 1,
1187  id.endcap(),
1188  id.station(),
1189  id.ring(),
1190  id.chamber(),
1191  iLayer + 1);
1192  std::cout << " size S = "
1193  << allStrips[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh][iLayer].size()
1194  << "size W = "
1195  << allWG[id.endcap() - 1][id.station() - 1][id.ring() - 1][id.chamber() - FirstCh][iLayer].size()
1196  << std::endl;
1197  }
1198  firstCondition = !allStrips[ec][st][rg][ch][iLayer].empty() ? true : false;
1199  //allSegments[ec][st][rg][ch].size() ? true : false;
1200  secondCondition = false;
1201  if (secondRing > -1) {
1202  secondCondition = !allStrips[ec][st][secondRing][ch][iLayer].empty() ? true : false;
1203  }
1204  if (firstCondition || secondCondition) {
1205  ChHist[ec][st][rg][ch].EfficientStrips->Fill(iLayer + 1);
1206  } else {
1207  if (printalot) {
1208  std::cout << "missing strips ";
1209  printf("\t\tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",
1210  id.endcap(),
1211  id.station(),
1212  id.ring(),
1213  id.chamber(),
1214  iLayer + 1);
1215  }
1216  }
1217  // Wires
1218  firstCondition = !allWG[ec][st][rg][ch][iLayer].empty() ? true : false;
1219  secondCondition = false;
1220  if (secondRing > -1) {
1221  secondCondition = !allWG[ec][st][secondRing][ch][iLayer].empty() ? true : false;
1222  }
1223  if (firstCondition || secondCondition) {
1224  ChHist[ec][st][rg][ch].EfficientWireGroups->Fill(iLayer + 1);
1225  } else {
1226  if (printalot) {
1227  std::cout << "missing wires ";
1228  printf("\t\tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",
1229  id.endcap(),
1230  id.station(),
1231  id.ring(),
1232  id.chamber(),
1233  iLayer + 1);
1234  }
1235  }
1236  }
1237  // Normalization
1238  if (6 != missingLayers_s) {
1239  ChHist[ec][st][rg][ch].EfficientStrips->Fill(8);
1240  }
1241  if (6 != missingLayers_wg) {
1242  ChHist[ec][st][rg][ch].EfficientWireGroups->Fill(8);
1243  }
1244  ChHist[ec][st][rg][ch].EfficientStrips->Fill(9);
1245  ChHist[ec][st][rg][ch].EfficientWireGroups->Fill(9);
1246  //
1247  ChHist[ec][st][rg][ch].StripWiresCorrelations->Fill(1);
1248  if (missingLayers_s != missingLayers_wg) {
1249  ChHist[ec][st][rg][ch].StripWiresCorrelations->Fill(2);
1250  if (6 == missingLayers_wg) {
1251  ChHist[ec][st][rg][ch].StripWiresCorrelations->Fill(3);
1252  ChHist[ec][st][rg][ch].NoWires_momTheta->Fill(ftsChamber.momentum().theta());
1253  }
1254  if (6 == missingLayers_s) {
1255  ChHist[ec][st][rg][ch].StripWiresCorrelations->Fill(4);
1256  ChHist[ec][st][rg][ch].NoStrips_momPhi->Fill(ftsChamber.momentum().theta());
1257  }
1258  } else if (6 == missingLayers_s) {
1259  ChHist[ec][st][rg][ch].StripWiresCorrelations->Fill(5);
1260  }
1261 
1262  return true;
1263 }
1264 //
1266  int ec, st, rg, ch, secondRing;
1267  returnTypes(id, ec, st, rg, ch, secondRing);
1268  bool firstCondition, secondCondition;
1269  for (int iLayer = 0; iLayer < 6; iLayer++) {
1270  firstCondition = !allSimhits[ec][st][rg][ch][iLayer].empty() ? true : false;
1271  secondCondition = false;
1272  int thisRing = rg;
1273  if (secondRing > -1) {
1274  secondCondition = !allSimhits[ec][st][secondRing][ch][iLayer].empty() ? true : false;
1275  if (secondCondition) {
1276  thisRing = secondRing;
1277  }
1278  }
1279  if (firstCondition || secondCondition) {
1280  for (size_t iSH = 0; iSH < allSimhits[ec][st][thisRing][ch][iLayer].size(); ++iSH) {
1281  if (13 == fabs(allSimhits[ec][st][thisRing][ch][iLayer][iSH].second)) {
1282  ChHist[ec][st][rg][ch].SimSimhits->Fill(iLayer + 1);
1283  if (!allRechits[ec][st][thisRing][ch][iLayer].empty()) {
1284  ChHist[ec][st][rg][ch].SimRechits->Fill(iLayer + 1);
1285  }
1286  break;
1287  }
1288  }
1289  //---- Next is not too usefull...
1290  /*
1291  for(unsigned int iSimHits=0;
1292  iSimHits<allSimhits[id.endcap()-1][id.station()-1][id.ring()-1][id.chamber()-FirstCh][iLayer].size();
1293  iSimHits++){
1294  ChHist[ec][st][rg][id.chamber()-FirstCh].SimSimhits_each->Fill(iLayer+1);
1295  }
1296  for(unsigned int iRecHits=0;
1297  iRecHits<allRechits[id.endcap()-1][id.station()-1][id.ring()-1][id.chamber()-FirstCh][iLayer].size();
1298  iRecHits++){
1299  ChHist[ec][st][rg][id.chamber()-FirstCh].SimRechits_each->Fill(iLayer+1);
1300  }
1301  */
1302  //
1303  }
1304  }
1305  return true;
1306 }
1307 
1308 //
1310  const CSCChamber *cscChamber,
1311  FreeTrajectoryState &ftsChamber) {
1312  int ec, st, rg, ch, secondRing;
1313  returnTypes(id, ec, st, rg, ch, secondRing);
1314  bool firstCondition, secondCondition;
1315 
1316  std::vector<bool> missingLayers_rh(6);
1317  std::vector<int> usedInSegment(6);
1318  // Rechits
1319  if (printalot)
1320  std::cout << "RecHits eff" << std::endl;
1321  for (int iLayer = 0; iLayer < 6; ++iLayer) {
1322  firstCondition = !allRechits[ec][st][rg][ch][iLayer].empty() ? true : false;
1323  secondCondition = false;
1324  int thisRing = rg;
1325  if (secondRing > -1) {
1326  secondCondition = !allRechits[ec][st][secondRing][ch][iLayer].empty() ? true : false;
1327  if (secondCondition) {
1328  thisRing = secondRing;
1329  }
1330  }
1331  if (firstCondition || secondCondition) {
1332  ChHist[ec][st][rg][ch].EfficientRechits_good->Fill(iLayer + 1);
1333  for (size_t iR = 0; iR < allRechits[ec][st][thisRing][ch][iLayer].size(); ++iR) {
1334  if (allRechits[ec][st][thisRing][ch][iLayer][iR].second) {
1335  usedInSegment[iLayer] = 1;
1336  break;
1337  } else {
1338  usedInSegment[iLayer] = -1;
1339  }
1340  }
1341  } else {
1342  missingLayers_rh[iLayer] = true;
1343  if (printalot) {
1344  std::cout << "missing rechits ";
1345  printf("\t\tendcap/station/ring/chamber/layer: %i/%i/%i/%i/%i\n",
1346  id.endcap(),
1347  id.station(),
1348  id.ring(),
1349  id.chamber(),
1350  iLayer + 1);
1351  }
1352  }
1353  }
1354  GlobalVector globalDir;
1355  GlobalPoint globalPos;
1356  // Segments
1357  firstCondition = !allSegments[ec][st][rg][ch].empty() ? true : false;
1358  secondCondition = false;
1359  int secondSize = 0;
1360  int thisRing = rg;
1361  if (secondRing > -1) {
1362  secondCondition = !allSegments[ec][st][secondRing][ch].empty() ? true : false;
1363  secondSize = allSegments[ec][st][secondRing][ch].size();
1364  if (secondCondition) {
1365  thisRing = secondRing;
1366  }
1367  }
1368  if (firstCondition || secondCondition) {
1369  if (printalot)
1370  std::cout << "segments - start ec = " << ec << " st = " << st << " rg = " << rg << " ch = " << ch << std::endl;
1371  StHist[ec][st].EfficientSegments_XY->Fill(ftsChamber.position().x(), ftsChamber.position().y());
1372  if (1 == allSegments[ec][st][rg][ch].size() + secondSize) {
1373  globalDir = cscChamber->toGlobal(allSegments[ec][st][thisRing][ch][0].second);
1374  globalPos = cscChamber->toGlobal(allSegments[ec][st][thisRing][ch][0].first);
1375  StHist[ec][st].EfficientSegments_eta->Fill(fabs(ftsChamber.position().eta()));
1376  double residual =
1377  sqrt(pow(ftsChamber.position().x() - globalPos.x(), 2) + pow(ftsChamber.position().y() - globalPos.y(), 2) +
1378  pow(ftsChamber.position().z() - globalPos.z(), 2));
1379  if (printalot)
1380  std::cout << " fts.position() = " << ftsChamber.position() << " segPos = " << globalPos << " res = " << residual
1381  << std::endl;
1382  StHist[ec][st].ResidualSegments->Fill(residual);
1383  }
1384  for (int iLayer = 0; iLayer < 6; ++iLayer) {
1385  if (printalot)
1386  std::cout << " iLayer = " << iLayer << " usedInSegment = " << usedInSegment[iLayer] << std::endl;
1387  if (0 != usedInSegment[iLayer]) {
1388  if (-1 == usedInSegment[iLayer]) {
1389  ChHist[ec][st][rg][ch].InefficientSingleHits->Fill(iLayer + 1);
1390  }
1391  ChHist[ec][st][rg][ch].AllSingleHits->Fill(iLayer + 1);
1392  }
1393  firstCondition = !allRechits[ec][st][rg][ch][iLayer].empty() ? true : false;
1394  secondCondition = false;
1395  if (secondRing > -1) {
1396  secondCondition = !allRechits[ec][st][secondRing][ch][iLayer].empty() ? true : false;
1397  }
1398  float stripAngle = 99999.;
1399  std::vector<float> posXY(2);
1400  bool oneSegment = false;
1401  if (1 == allSegments[ec][st][rg][ch].size() + secondSize) {
1402  oneSegment = true;
1403  const BoundPlane bp = cscChamber->layer(iLayer + 1)->surface();
1404  linearExtrapolation(globalPos, globalDir, bp.position().z(), posXY);
1405  GlobalPoint gp_extrapol(posXY.at(0), posXY.at(1), bp.position().z());
1406  const LocalPoint lp_extrapol = cscChamber->layer(iLayer + 1)->toLocal(gp_extrapol);
1407  posXY.at(0) = lp_extrapol.x();
1408  posXY.at(1) = lp_extrapol.y();
1409  int nearestStrip = cscChamber->layer(iLayer + 1)->geometry()->nearestStrip(lp_extrapol);
1410  stripAngle = cscChamber->layer(iLayer + 1)->geometry()->stripAngle(nearestStrip) - M_PI / 2.;
1411  }
1412  if (firstCondition || secondCondition) {
1413  ChHist[ec][st][rg][ch].EfficientRechits_inSegment->Fill(iLayer + 1);
1414  if (oneSegment) {
1415  ChHist[ec][st][rg][ch].Y_EfficientRecHits_inSegment[iLayer]->Fill(posXY.at(1));
1416  ChHist[ec][st][rg][ch].Phi_EfficientRecHits_inSegment[iLayer]->Fill(stripAngle);
1417  }
1418  } else {
1419  if (oneSegment) {
1420  ChHist[ec][st][rg][ch].Y_InefficientRecHits_inSegment[iLayer]->Fill(posXY.at(1));
1421  ChHist[ec][st][rg][ch].Phi_InefficientRecHits_inSegment[iLayer]->Fill(stripAngle);
1422  }
1423  }
1424  }
1425  } else {
1426  StHist[ec][st].InefficientSegments_XY->Fill(ftsChamber.position().x(), ftsChamber.position().y());
1427  if (printalot) {
1428  std::cout << "missing segment " << std::endl;
1429  printf("\t\tendcap/station/ring/chamber: %i/%i/%i/%i\n", id.endcap(), id.station(), id.ring(), id.chamber());
1430  std::cout << " fts.position() = " << ftsChamber.position() << std::endl;
1431  }
1432  }
1433  // Normalization
1434  ChHist[ec][st][rg][ch].EfficientRechits_good->Fill(8);
1435  if (allSegments[ec][st][rg][ch].size() + secondSize < 2) {
1436  StHist[ec][st].AllSegments_eta->Fill(fabs(ftsChamber.position().eta()));
1437  }
1438  ChHist[ec][st][rg][id.chamber() - FirstCh].EfficientRechits_inSegment->Fill(9);
1439 
1440  return true;
1441 }
1442 //
1443 void CSCEfficiency::returnTypes(CSCDetId &id, int &ec, int &st, int &rg, int &ch, int &secondRing) {
1444  ec = id.endcap() - 1;
1445  st = id.station() - 1;
1446  rg = id.ring() - 1;
1447  secondRing = -1;
1448  if (1 == id.station() && (4 == id.ring() || 1 == id.ring())) {
1449  rg = 0;
1450  secondRing = 3;
1451  }
1452  ch = id.chamber() - FirstCh;
1453 }
1454 
1455 //
1457  CLHEP::Hep3Vector &p3,
1458  CLHEP::Hep3Vector &r3,
1459  int &charge,
1460  AlgebraicSymMatrix66 &cov) {
1461  GlobalVector p3GV = fts.momentum();
1462  GlobalPoint r3GP = fts.position();
1463 
1464  p3.set(p3GV.x(), p3GV.y(), p3GV.z());
1465  r3.set(r3GP.x(), r3GP.y(), r3GP.z());
1466 
1467  charge = fts.charge();
1468  cov = fts.hasError() ? fts.cartesianError().matrix() : AlgebraicSymMatrix66();
1469 }
1470 
1472  const CLHEP::Hep3Vector &r3,
1473  int charge,
1474  const AlgebraicSymMatrix66 &cov,
1475  const MagneticField *field) {
1476  GlobalVector p3GV(p3.x(), p3.y(), p3.z());
1477  GlobalPoint r3GP(r3.x(), r3.y(), r3.z());
1478  GlobalTrajectoryParameters tPars(r3GP, p3GV, charge, field);
1479 
1480  CartesianTrajectoryError tCov(cov);
1481 
1482  return cov.kRows == 6 ? FreeTrajectoryState(tPars, tCov) : FreeTrajectoryState(tPars);
1483 }
1484 
1486  GlobalVector initialDirection,
1487  float zSurface,
1488  std::vector<float> &posZY) {
1489  double paramLine = lineParameter(initialPosition.z(), zSurface, initialDirection.z());
1490  double xPosition = extrapolate1D(initialPosition.x(), initialDirection.x(), paramLine);
1491  double yPosition = extrapolate1D(initialPosition.y(), initialDirection.y(), paramLine);
1492  posZY.clear();
1493  posZY.push_back(xPosition);
1494  posZY.push_back(yPosition);
1495 }
1496 //
1497 double CSCEfficiency::extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine) {
1498  double extrapolatedPosition = initPosition + initDirection * parameterOfTheLine;
1499  return extrapolatedPosition;
1500 }
1501 //
1502 double CSCEfficiency::lineParameter(double initZPosition, double destZPosition, double initZDirection) {
1503  double paramLine = (destZPosition - initZPosition) / initZDirection;
1504  return paramLine;
1505 }
1506 //
1507 void CSCEfficiency::chooseDirection(CLHEP::Hep3Vector &innerPosition, CLHEP::Hep3Vector &outerPosition) {
1508  //---- Be careful with trigger conditions too
1509  if (!isIPdata) {
1510  float dy = outerPosition.y() - innerPosition.y();
1511  float dz = outerPosition.z() - innerPosition.z();
1512  if (isBeamdata) {
1513  if (dz > 0) {
1514  alongZ = true;
1515  } else {
1516  alongZ = false;
1517  }
1518  } else { //cosmics
1519  if (dy / dz > 0) {
1520  alongZ = false;
1521  } else {
1522  alongZ = true;
1523  }
1524  }
1525  }
1526 }
1527 //
1529  return &*theService->propagator(propagatorName);
1530 }
1531 
1532 //
1534  TrajectoryStateOnSurface tSOSDest;
1536  /*
1537 // it would work if cosmic muons had properly assigned direction...
1538  bool dzPositive = bpDest.position().z() - ftsStart.position().z() > 0 ? true : false;
1539  //---- Be careful with trigger conditions too
1540  if(!isIPdata){
1541  bool rightDirection = !(alongZ^dzPositive);
1542  if(rightDirection){
1543  if(printalot) std::cout<<" propagate along momentum"<<std::endl;
1544  propagatorName = "SteppingHelixPropagatorAlong";
1545  }
1546  else{
1547  if(printalot) std::cout<<" propagate opposite momentum"<<std::endl;
1548  propagatorName = "SteppingHelixPropagatorOpposite";
1549  }
1550  }
1551  else{
1552  if(printalot) std::cout<<" propagate any (momentum)"<<std::endl;
1553  propagatorName = "SteppingHelixPropagatorAny";
1554  }
1555 */
1556  propagatorName = "SteppingHelixPropagatorAny";
1557  tSOSDest = propagator(propagatorName)->propagate(ftsStart, bpDest);
1558  return tSOSDest;
1559 }
1560 //
1562  bool triggerPassed = true;
1563  std::vector<std::string> hlNames = triggerNames.triggerNames();
1564  pointToTriggers.clear();
1565  for (size_t imyT = 0; imyT < myTriggers.size(); ++imyT) {
1566  for (size_t iT = 0; iT < hlNames.size(); ++iT) {
1567  //std::cout<<" iT = "<<iT<<" hlNames[iT] = "<<hlNames[iT]<<
1568  //" : wasrun = "<<hltR->wasrun(iT)<<" accept = "<<
1569  // hltR->accept(iT)<<" !error = "<<
1570  // !hltR->error(iT)<<std::endl;
1571  if (!imyT) {
1572  if (hltR->wasrun(iT) && hltR->accept(iT) && !hltR->error(iT)) {
1573  TriggersFired->Fill(iT);
1574  }
1575  }
1576  if (hlNames[iT] == myTriggers[imyT]) {
1577  pointToTriggers.push_back(iT);
1578  if (imyT) {
1579  break;
1580  }
1581  }
1582  }
1583  }
1584  if (pointToTriggers.size() != myTriggers.size()) {
1585  pointToTriggers.clear();
1586  if (printalot) {
1587  std::cout << " Not all trigger names found - all trigger specifications will be ignored. Check your cfg file!"
1588  << std::endl;
1589  }
1590  } else {
1591  if (!pointToTriggers.empty()) {
1592  if (printalot) {
1593  std::cout << "The following triggers will be required in the event: " << std::endl;
1594  for (size_t imyT = 0; imyT < pointToTriggers.size(); ++imyT) {
1595  std::cout << " " << hlNames[pointToTriggers[imyT]];
1596  }
1597  std::cout << std::endl;
1598  std::cout << " in condition (AND/OR) : " << !andOr << "/" << andOr << std::endl;
1599  }
1600  }
1601  }
1602 
1603  if (hltR.isValid()) {
1604  if (pointToTriggers.empty()) {
1605  if (printalot) {
1606  std::cout
1607  << " No triggers specified in the configuration or all ignored - no trigger information will be considered"
1608  << std::endl;
1609  }
1610  }
1611  for (size_t imyT = 0; imyT < pointToTriggers.size(); ++imyT) {
1612  if (hltR->wasrun(pointToTriggers[imyT]) && hltR->accept(pointToTriggers[imyT]) &&
1613  !hltR->error(pointToTriggers[imyT])) {
1614  triggerPassed = true;
1615  if (andOr) {
1616  break;
1617  }
1618  } else {
1619  triggerPassed = false;
1620  if (!andOr) {
1621  triggerPassed = false;
1622  break;
1623  }
1624  }
1625  }
1626  } else {
1627  if (printalot) {
1628  std::cout << " TriggerResults handle returns invalid state?! No trigger information will be considered"
1629  << std::endl;
1630  }
1631  }
1632  if (printalot) {
1633  std::cout << " Trigger passed: " << triggerPassed << std::endl;
1634  }
1635  return triggerPassed;
1636 }
1637 //
1638 
1639 // Constructor
1641  // const float Xmin = -70;
1642  //const float Xmax = 70;
1643  //const int nXbins = int(4.*(Xmax - Xmin));
1644  const float Ymin = -165;
1645  const float Ymax = 165;
1646  const int nYbins = int((Ymax - Ymin) / 2);
1647  const float Layer_min = -0.5;
1648  const float Layer_max = 9.5;
1649  const int nLayer_bins = int(Layer_max - Layer_min);
1650  //
1651 
1652  //---- Get the input parameters
1653  printout_NEvents = pset.getUntrackedParameter<unsigned int>("printout_NEvents", 0);
1654  rootFileName = pset.getUntrackedParameter<string>("rootFileName", "cscHists.root");
1655 
1656  isData = pset.getUntrackedParameter<bool>("runOnData", true); //
1657  isIPdata = pset.getUntrackedParameter<bool>("IPdata", false); //
1658  isBeamdata = pset.getUntrackedParameter<bool>("Beamdata", false); //
1659  getAbsoluteEfficiency = pset.getUntrackedParameter<bool>("getAbsoluteEfficiency", true); //
1660  useDigis = pset.getUntrackedParameter<bool>("useDigis", true); //
1661  distanceFromDeadZone = pset.getUntrackedParameter<double>("distanceFromDeadZone", 10.); //
1662  minP = pset.getUntrackedParameter<double>("minP", 20.); //
1663  maxP = pset.getUntrackedParameter<double>("maxP", 100.); //
1664  maxNormChi2 = pset.getUntrackedParameter<double>("maxNormChi2", 3.); //
1665  minTrackHits = pset.getUntrackedParameter<unsigned int>("minTrackHits", 10); //
1666 
1667  applyIPangleCuts = pset.getUntrackedParameter<bool>("applyIPangleCuts", false); //
1668  local_DY_DZ_Max = pset.getUntrackedParameter<double>("local_DY_DZ_Max", -0.1); //
1669  local_DY_DZ_Min = pset.getUntrackedParameter<double>("local_DY_DZ_Min", -0.8); //
1670  local_DX_DZ_Max = pset.getUntrackedParameter<double>("local_DX_DZ_Max", 0.2); //
1671 
1672  sd_token = consumes<CSCStripDigiCollection>(pset.getParameter<edm::InputTag>("stripDigiTag"));
1673  wd_token = consumes<CSCWireDigiCollection>(pset.getParameter<edm::InputTag>("wireDigiTag"));
1674  al_token = consumes<CSCALCTDigiCollection>(pset.getParameter<edm::InputTag>("alctDigiTag"));
1675  cl_token = consumes<CSCCLCTDigiCollection>(pset.getParameter<edm::InputTag>("clctDigiTag"));
1676  co_token = consumes<CSCCorrelatedLCTDigiCollection>(pset.getParameter<edm::InputTag>("corrlctDigiTag"));
1677  rh_token = consumes<CSCRecHit2DCollection>(pset.getParameter<edm::InputTag>("rechitTag"));
1678  se_token = consumes<CSCSegmentCollection>(pset.getParameter<edm::InputTag>("segmentTag"));
1679  tk_token = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("tracksTag"));
1680  sh_token = consumes<edm::PSimHitContainer>(pset.getParameter<edm::InputTag>("simHitTag"));
1681 
1682  geomToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
1683 
1684  edm::ParameterSet serviceParameters = pset.getParameter<edm::ParameterSet>("ServiceParameters");
1685  // maybe use the service for getting magnetic field, propagators, etc. ...
1686  theService = new MuonServiceProxy(serviceParameters, consumesCollector());
1687 
1688  // Trigger
1689  useTrigger = pset.getUntrackedParameter<bool>("useTrigger", false);
1690 
1691  ht_token = consumes<edm::TriggerResults>(pset.getParameter<edm::InputTag>("HLTriggerResults"));
1692 
1693  myTriggers = pset.getParameter<std::vector<std::string> >("myTriggers");
1694  andOr = pset.getUntrackedParameter<bool>("andOr");
1695  pointToTriggers.clear();
1696 
1697  //---- set counter to zero
1698  nEventsAnalyzed = 0;
1699  //---- set presence of magnetic field
1700  magField = true;
1701  //
1702  std::string Path = "AllChambers/";
1703  std::string FullName;
1704  //---- File with output histograms
1705  theFile = new TFile(rootFileName.c_str(), "RECREATE");
1706  theFile->cd();
1707  //---- Book histograms for the analysis
1708  char SpecName[60];
1709 
1710  sprintf(SpecName, "DataFlow");
1711  DataFlow = new TH1F(SpecName, "Data flow;condition number;entries", 40, -0.5, 39.5);
1712  //
1713  sprintf(SpecName, "TriggersFired");
1714  TriggersFired = new TH1F(SpecName, "Triggers fired;trigger number;entries", 140, -0.5, 139.5);
1715  //
1716  int Chan = 50;
1717  float minChan = -0.5;
1718  float maxChan = 49.5;
1719  //
1720  sprintf(SpecName, "ALCTPerEvent");
1721  ALCTPerEvent = new TH1F(SpecName, "ALCTs per event;N digis;entries", Chan, minChan, maxChan);
1722  //
1723  sprintf(SpecName, "CLCTPerEvent");
1724  CLCTPerEvent = new TH1F(SpecName, "CLCTs per event;N digis;entries", Chan, minChan, maxChan);
1725  //
1726  sprintf(SpecName, "recHitsPerEvent");
1727  recHitsPerEvent = new TH1F(SpecName, "RecHits per event;N digis;entries", 150, -0.5, 149.5);
1728  //
1729  sprintf(SpecName, "segmentsPerEvent");
1730  segmentsPerEvent = new TH1F(SpecName, "segments per event;N digis;entries", Chan, minChan, maxChan);
1731  //
1732  //---- Book groups of histograms (for any chamber)
1733 
1734  map<std::string, bool>::iterator iter;
1735  for (int ec = 0; ec < 2; ++ec) {
1736  for (int st = 0; st < 4; ++st) {
1737  theFile->cd();
1738  sprintf(SpecName, "Stations__E%d_S%d", ec + 1, st + 1);
1739  theFile->mkdir(SpecName);
1740  theFile->cd(SpecName);
1741 
1742  //
1743  sprintf(SpecName, "segmentChi2_ndf_St%d", st + 1);
1744  StHist[ec][st].segmentChi2_ndf = new TH1F(SpecName, "Chi2/ndf of a segment;chi2/ndf;entries", 100, 0., 20.);
1745  //
1746  sprintf(SpecName, "hitsInSegment_St%d", st + 1);
1747  StHist[ec][st].hitsInSegment = new TH1F(SpecName, "Number of hits in a segment;nHits;entries", 7, -0.5, 6.5);
1748  //
1749  Chan = 170;
1750  minChan = 0.85;
1751  maxChan = 2.55;
1752  //
1753  sprintf(SpecName, "AllSegments_eta_St%d", st + 1);
1754  StHist[ec][st].AllSegments_eta = new TH1F(SpecName, "All segments in eta;eta;entries", Chan, minChan, maxChan);
1755  //
1756  sprintf(SpecName, "EfficientSegments_eta_St%d", st + 1);
1757  StHist[ec][st].EfficientSegments_eta =
1758  new TH1F(SpecName, "Efficient segments in eta;eta;entries", Chan, minChan, maxChan);
1759  //
1760  sprintf(SpecName, "ResidualSegments_St%d", st + 1);
1761  StHist[ec][st].ResidualSegments = new TH1F(SpecName, "Residual (segments);residual,cm;entries", 75, 0., 15.);
1762  //
1763  Chan = 200;
1764  minChan = -800.;
1765  maxChan = 800.;
1766  int Chan2 = 200;
1767  float minChan2 = -800.;
1768  float maxChan2 = 800.;
1769 
1770  sprintf(SpecName, "EfficientSegments_XY_St%d", st + 1);
1771  StHist[ec][st].EfficientSegments_XY =
1772  new TH2F(SpecName, "Efficient segments in XY;X;Y", Chan, minChan, maxChan, Chan2, minChan2, maxChan2);
1773  sprintf(SpecName, "InefficientSegments_XY_St%d", st + 1);
1774  StHist[ec][st].InefficientSegments_XY =
1775  new TH2F(SpecName, "Inefficient segments in XY;X;Y", Chan, minChan, maxChan, Chan2, minChan2, maxChan2);
1776  //
1777  Chan = 80;
1778  minChan = 0;
1779  maxChan = 3.2;
1780  sprintf(SpecName, "EfficientALCT_momTheta_St%d", st + 1);
1781  StHist[ec][st].EfficientALCT_momTheta =
1782  new TH1F(SpecName, "Efficient ALCT in theta (momentum);theta, rad;entries", Chan, minChan, maxChan);
1783  //
1784  sprintf(SpecName, "InefficientALCT_momTheta_St%d", st + 1);
1785  StHist[ec][st].InefficientALCT_momTheta =
1786  new TH1F(SpecName, "Inefficient ALCT in theta (momentum);theta, rad;entries", Chan, minChan, maxChan);
1787  //
1788  Chan = 160;
1789  minChan = -3.2;
1790  maxChan = 3.2;
1791  sprintf(SpecName, "EfficientCLCT_momPhi_St%d", st + 1);
1792  StHist[ec][st].EfficientCLCT_momPhi =
1793  new TH1F(SpecName, "Efficient CLCT in phi (momentum);phi, rad;entries", Chan, minChan, maxChan);
1794  //
1795  sprintf(SpecName, "InefficientCLCT_momPhi_St%d", st + 1);
1796  StHist[ec][st].InefficientCLCT_momPhi =
1797  new TH1F(SpecName, "Inefficient CLCT in phi (momentum);phi, rad;entries", Chan, minChan, maxChan);
1798  //
1799  theFile->cd();
1800  for (int rg = 0; rg < 3; ++rg) {
1801  if (0 != st && rg > 1) {
1802  continue;
1803  } else if (1 == rg && 3 == st) {
1804  continue;
1805  }
1806  for (int iChamber = FirstCh; iChamber < FirstCh + NumCh; iChamber++) {
1807  if (0 != st && 0 == rg && iChamber > 18) {
1808  continue;
1809  }
1810  theFile->cd();
1811  sprintf(SpecName, "Chambers__E%d_S%d_R%d_Chamber_%d", ec + 1, st + 1, rg + 1, iChamber);
1812  theFile->mkdir(SpecName);
1813  theFile->cd(SpecName);
1814  //
1815 
1816  sprintf(SpecName, "EfficientRechits_inSegment_Ch%d", iChamber);
1817  ChHist[ec][st][rg][iChamber - FirstCh].EfficientRechits_inSegment = new TH1F(
1818  SpecName, "Existing RecHit given a segment;layers (1-6);entries", nLayer_bins, Layer_min, Layer_max);
1819  //
1820  sprintf(SpecName, "InefficientSingleHits_Ch%d", iChamber);
1821  ChHist[ec][st][rg][iChamber - FirstCh].InefficientSingleHits = new TH1F(
1822  SpecName, "Single RecHits not in the segment;layers (1-6);entries ", nLayer_bins, Layer_min, Layer_max);
1823  //
1824  sprintf(SpecName, "AllSingleHits_Ch%d", iChamber);
1825  ChHist[ec][st][rg][iChamber - FirstCh].AllSingleHits = new TH1F(
1826  SpecName, "Single RecHits given a segment; layers (1-6);entries", nLayer_bins, Layer_min, Layer_max);
1827  //
1828  sprintf(SpecName, "digiAppearanceCount_Ch%d", iChamber);
1829  ChHist[ec][st][rg][iChamber - FirstCh].digiAppearanceCount =
1830  new TH1F(SpecName,
1831  "Digi appearance (no-yes): segment(0,1), ALCT(2,3), CLCT(4,5), CorrLCT(6,7); digi type;entries",
1832  8,
1833  -0.5,
1834  7.5);
1835  //
1836  Chan = 100;
1837  minChan = -1.1;
1838  maxChan = 0.9;
1839  sprintf(SpecName, "EfficientALCT_dydz_Ch%d", iChamber);
1840  ChHist[ec][st][rg][iChamber - FirstCh].EfficientALCT_dydz =
1841  new TH1F(SpecName, "Efficient ALCT; local dy/dz (ME 3 and 4 flipped);entries", Chan, minChan, maxChan);
1842  //
1843  sprintf(SpecName, "InefficientALCT_dydz_Ch%d", iChamber);
1844  ChHist[ec][st][rg][iChamber - FirstCh].InefficientALCT_dydz =
1845  new TH1F(SpecName, "Inefficient ALCT; local dy/dz (ME 3 and 4 flipped);entries", Chan, minChan, maxChan);
1846  //
1847  Chan = 100;
1848  minChan = -1.;
1849  maxChan = 1.0;
1850  sprintf(SpecName, "EfficientCLCT_dxdz_Ch%d", iChamber);
1851  ChHist[ec][st][rg][iChamber - FirstCh].EfficientCLCT_dxdz =
1852  new TH1F(SpecName, "Efficient CLCT; local dxdz;entries", Chan, minChan, maxChan);
1853  //
1854  sprintf(SpecName, "InefficientCLCT_dxdz_Ch%d", iChamber);
1855  ChHist[ec][st][rg][iChamber - FirstCh].InefficientCLCT_dxdz =
1856  new TH1F(SpecName, "Inefficient CLCT; local dxdz;entries", Chan, minChan, maxChan);
1857  //
1858  sprintf(SpecName, "EfficientRechits_good_Ch%d", iChamber);
1859  ChHist[ec][st][rg][iChamber - FirstCh].EfficientRechits_good = new TH1F(
1860  SpecName, "Existing RecHit - sensitive area only;layers (1-6);entries", nLayer_bins, Layer_min, Layer_max);
1861  //
1862  sprintf(SpecName, "EfficientStrips_Ch%d", iChamber);
1863  ChHist[ec][st][rg][iChamber - FirstCh].EfficientStrips =
1864  new TH1F(SpecName, "Existing strip;layer (1-6); entries", nLayer_bins, Layer_min, Layer_max);
1865  //
1866  sprintf(SpecName, "EfficientWireGroups_Ch%d", iChamber);
1867  ChHist[ec][st][rg][iChamber - FirstCh].EfficientWireGroups =
1868  new TH1F(SpecName, "Existing WireGroups;layer (1-6); entries ", nLayer_bins, Layer_min, Layer_max);
1869  //
1870  sprintf(SpecName, "StripWiresCorrelations_Ch%d", iChamber);
1871  ChHist[ec][st][rg][iChamber - FirstCh].StripWiresCorrelations =
1872  new TH1F(SpecName, "StripWire correlations;; entries ", 5, 0.5, 5.5);
1873  //
1874  Chan = 80;
1875  minChan = 0;
1876  maxChan = 3.2;
1877  sprintf(SpecName, "NoWires_momTheta_Ch%d", iChamber);
1878  ChHist[ec][st][rg][iChamber - FirstCh].NoWires_momTheta =
1879  new TH1F(SpecName,
1880  "No wires (all strips present) - in theta (momentum);theta, rad;entries",
1881  Chan,
1882  minChan,
1883  maxChan);
1884  //
1885  Chan = 160;
1886  minChan = -3.2;
1887  maxChan = 3.2;
1888  sprintf(SpecName, "NoStrips_momPhi_Ch%d", iChamber);
1889  ChHist[ec][st][rg][iChamber - FirstCh].NoStrips_momPhi = new TH1F(
1890  SpecName, "No strips (all wires present) - in phi (momentum);phi, rad;entries", Chan, minChan, maxChan);
1891  //
1892  for (int iLayer = 0; iLayer < 6; iLayer++) {
1893  sprintf(SpecName, "Y_InefficientRecHits_inSegment_Ch%d_L%d", iChamber, iLayer);
1894  ChHist[ec][st][rg][iChamber - FirstCh].Y_InefficientRecHits_inSegment.push_back(
1895  new TH1F(SpecName,
1896  "Missing RecHit/layer in a segment (local system, whole chamber);Y, cm; entries",
1897  nYbins,
1898  Ymin,
1899  Ymax));
1900  //
1901  sprintf(SpecName, "Y_EfficientRecHits_inSegment_Ch%d_L%d", iChamber, iLayer);
1902  ChHist[ec][st][rg][iChamber - FirstCh].Y_EfficientRecHits_inSegment.push_back(
1903  new TH1F(SpecName,
1904  "Efficient (extrapolated from the segment) RecHit/layer in a segment (local system, whole "
1905  "chamber);Y, cm; entries",
1906  nYbins,
1907  Ymin,
1908  Ymax));
1909  //
1910  Chan = 200;
1911  minChan = -0.2;
1912  maxChan = 0.2;
1913  sprintf(SpecName, "Phi_InefficientRecHits_inSegment_Ch%d_L%d", iChamber, iLayer);
1914  ChHist[ec][st][rg][iChamber - FirstCh].Phi_InefficientRecHits_inSegment.push_back(
1915  new TH1F(SpecName,
1916  "Missing RecHit/layer in a segment (local system, whole chamber);Phi, rad; entries",
1917  Chan,
1918  minChan,
1919  maxChan));
1920  //
1921  sprintf(SpecName, "Phi_EfficientRecHits_inSegment_Ch%d_L%d", iChamber, iLayer);
1922  ChHist[ec][st][rg][iChamber - FirstCh].Phi_EfficientRecHits_inSegment.push_back(
1923  new TH1F(SpecName,
1924  "Efficient (extrapolated from the segment) in a segment (local system, whole chamber);Phi, "
1925  "rad; entries",
1926  Chan,
1927  minChan,
1928  maxChan));
1929  }
1930  //
1931  sprintf(SpecName, "Sim_Rechits_Ch%d", iChamber);
1932  ChHist[ec][st][rg][iChamber - FirstCh].SimRechits =
1933  new TH1F(SpecName, "Existing RecHit (Sim);layers (1-6);entries", nLayer_bins, Layer_min, Layer_max);
1934  //
1935  sprintf(SpecName, "Sim_Simhits_Ch%d", iChamber);
1936  ChHist[ec][st][rg][iChamber - FirstCh].SimSimhits =
1937  new TH1F(SpecName, "Existing SimHit (Sim);layers (1-6);entries", nLayer_bins, Layer_min, Layer_max);
1938  //
1939  /*
1940  sprintf(SpecName,"Sim_Rechits_each_Ch%d",iChamber);
1941  ChHist[ec][st][rg][iChamber-FirstCh].SimRechits_each =
1942  new TH1F(SpecName,"Existing RecHit (Sim), each;layers (1-6);entries",nLayer_bins,Layer_min,Layer_max);
1943  //
1944  sprintf(SpecName,"Sim_Simhits_each_Ch%d",iChamber);
1945  ChHist[ec][st][rg][iChamber-FirstCh].SimSimhits_each =
1946  new TH1F(SpecName,"Existing SimHit (Sim), each;layers (1-6);entries",nLayer_bins,Layer_min,Layer_max);
1947  */
1948  theFile->cd();
1949  }
1950  }
1951  }
1952  }
1953 }
1954 
1955 // Destructor
1957  if (theService)
1958  delete theService;
1959  // Write the histos to a file
1960  theFile->cd();
1961  //
1962  char SpecName[60];
1963  std::vector<float> bins, Efficiency, EffError;
1964  std::vector<float> eff(2);
1965 
1966  //---- loop over chambers
1967  std::map<std::string, bool> chamberTypes;
1968  chamberTypes["ME11"] = false;
1969  chamberTypes["ME12"] = false;
1970  chamberTypes["ME13"] = false;
1971  chamberTypes["ME21"] = false;
1972  chamberTypes["ME22"] = false;
1973  chamberTypes["ME31"] = false;
1974  chamberTypes["ME32"] = false;
1975  chamberTypes["ME41"] = false;
1976 
1977  map<std::string, bool>::iterator iter;
1978  std::cout << " Writing proper histogram structure (patience)..." << std::endl;
1979  for (int ec = 0; ec < 2; ++ec) {
1980  for (int st = 0; st < 4; ++st) {
1981  snprintf(SpecName, sizeof(SpecName), "Stations__E%d_S%d", ec + 1, st + 1);
1982  theFile->cd(SpecName);
1983  StHist[ec][st].segmentChi2_ndf->Write();
1984  StHist[ec][st].hitsInSegment->Write();
1985  StHist[ec][st].AllSegments_eta->Write();
1986  StHist[ec][st].EfficientSegments_eta->Write();
1987  StHist[ec][st].ResidualSegments->Write();
1988  StHist[ec][st].EfficientSegments_XY->Write();
1989  StHist[ec][st].InefficientSegments_XY->Write();
1990  StHist[ec][st].EfficientALCT_momTheta->Write();
1991  StHist[ec][st].InefficientALCT_momTheta->Write();
1992  StHist[ec][st].EfficientCLCT_momPhi->Write();
1993  StHist[ec][st].InefficientCLCT_momPhi->Write();
1994  for (int rg = 0; rg < 3; ++rg) {
1995  if (0 != st && rg > 1) {
1996  continue;
1997  } else if (1 == rg && 3 == st) {
1998  continue;
1999  }
2000  for (int iChamber = FirstCh; iChamber < FirstCh + NumCh; iChamber++) {
2001  if (0 != st && 0 == rg && iChamber > 18) {
2002  continue;
2003  }
2004  snprintf(SpecName, sizeof(SpecName), "Chambers__E%d_S%d_R%d_Chamber_%d", ec + 1, st + 1, rg + 1, iChamber);
2005  theFile->cd(SpecName);
2006 
2007  ChHist[ec][st][rg][iChamber - FirstCh].EfficientRechits_inSegment->Write();
2008  ChHist[ec][st][rg][iChamber - FirstCh].AllSingleHits->Write();
2009  ChHist[ec][st][rg][iChamber - FirstCh].digiAppearanceCount->Write();
2010  ChHist[ec][st][rg][iChamber - FirstCh].EfficientALCT_dydz->Write();
2011  ChHist[ec][st][rg][iChamber - FirstCh].InefficientALCT_dydz->Write();
2012  ChHist[ec][st][rg][iChamber - FirstCh].EfficientCLCT_dxdz->Write();
2013  ChHist[ec][st][rg][iChamber - FirstCh].InefficientCLCT_dxdz->Write();
2014  ChHist[ec][st][rg][iChamber - FirstCh].InefficientSingleHits->Write();
2015  ChHist[ec][st][rg][iChamber - FirstCh].EfficientRechits_good->Write();
2016  ChHist[ec][st][rg][iChamber - FirstCh].EfficientStrips->Write();
2017  ChHist[ec][st][rg][iChamber - FirstCh].StripWiresCorrelations->Write();
2018  ChHist[ec][st][rg][iChamber - FirstCh].NoWires_momTheta->Write();
2019  ChHist[ec][st][rg][iChamber - FirstCh].NoStrips_momPhi->Write();
2020  ChHist[ec][st][rg][iChamber - FirstCh].EfficientWireGroups->Write();
2021  for (unsigned int iLayer = 0; iLayer < 6; iLayer++) {
2022  ChHist[ec][st][rg][iChamber - FirstCh].Y_InefficientRecHits_inSegment[iLayer]->Write();
2023  ChHist[ec][st][rg][iChamber - FirstCh].Y_EfficientRecHits_inSegment[iLayer]->Write();
2024  ChHist[ec][st][rg][iChamber - FirstCh].Phi_InefficientRecHits_inSegment[iLayer]->Write();
2025  ChHist[ec][st][rg][iChamber - FirstCh].Phi_EfficientRecHits_inSegment[iLayer]->Write();
2026  }
2027  ChHist[ec][st][rg][iChamber - FirstCh].SimRechits->Write();
2028  ChHist[ec][st][rg][iChamber - FirstCh].SimSimhits->Write();
2029  /*
2030  ChHist[ec][st][rg][iChamber-FirstCh].SimRechits_each->Write();
2031  ChHist[ec][st][rg][iChamber-FirstCh].SimSimhits_each->Write();
2032  */
2033  //
2034  theFile->cd(SpecName);
2035  theFile->cd();
2036  }
2037  }
2038  }
2039  }
2040  //
2041  snprintf(SpecName, sizeof(SpecName), "AllChambers");
2042  theFile->mkdir(SpecName);
2043  theFile->cd(SpecName);
2044  DataFlow->Write();
2045  TriggersFired->Write();
2046  ALCTPerEvent->Write();
2047  CLCTPerEvent->Write();
2048  recHitsPerEvent->Write();
2049  segmentsPerEvent->Write();
2050  //
2051  theFile->cd(SpecName);
2052  //---- Close the file
2053  theFile->Close();
2054 }
2055 
2056 // ------------ method called once each job just before starting event loop ------------
2058 
2059 // ------------ method called once each job just after ending the event loop ------------
2061 
reco::Track::outerPosition
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
Vector3DBase< float, LocalTag >
CSCEfficiency::propagate
TrajectoryStateOnSurface propagate(FreeTrajectoryState &ftsStart, const BoundPlane &bp)
Definition: CSCEfficiency.cc:1533
change_name.diff
diff
Definition: change_name.py:13
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
CSCEfficiency::beginJob
void beginJob() override
Definition: CSCEfficiency.cc:2057
mps_fire.i
i
Definition: mps_fire.py:428
NumCh
#define NumCh
Definition: CSCEfficiency.h:82
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
Muon.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
CSCChamber::layer
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
reco::TrackBase::tight
Definition: TrackBase.h:153
SteppingHelixPropagator.h
reco::TrackBase::loose
Definition: TrackBase.h:152
edm::Handle::product
T const * product() const
Definition: Handle.h:70
FreeTrajectoryState::hasError
bool hasError() const
Definition: FreeTrajectoryState.h:77
reco::Muon::SegmentAndTrackArbitration
Definition: Muon.h:190
CSCEfficiency::recSimHitEfficiency
bool recSimHitEfficiency(CSCDetId &id, FreeTrajectoryState &ftsChamber)
Definition: CSCEfficiency.cc:1265
reco::TrackBase::goodIterative
Definition: TrackBase.h:156
CSCEfficiency::inSensitiveLocalRegion
bool inSensitiveLocalRegion(double xLocal, double yLocal, int station, int ring)
Definition: CSCEfficiency.cc:546
LocalError::xy
float xy() const
Definition: LocalError.h:23
CSCEfficiency::chamberCandidates
void chamberCandidates(int station, int ring, float phi, std::vector< int > &coupleOfChambers)
Definition: CSCEfficiency.cc:1011
muon
Definition: MuonCocktails.h:17
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
reco::TrackBase::confirmed
Definition: TrackBase.h:155
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
DigiDM_cff.wires
wires
Definition: DigiDM_cff.py:33
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
CSCGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
reco::TrackBase::undefQuality
Definition: TrackBase.h:151
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RunLumiEventNumber.h
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
edm::HLTGlobalStatus::wasrun
bool wasrun() const
Was at least one path run?
Definition: HLTGlobalStatus.h:47
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
CSCEfficiency::stripWire_Efficiencies
bool stripWire_Efficiencies(CSCDetId &cscDetId, FreeTrajectoryState &ftsChamber)
Definition: CSCEfficiency.cc:1175
CSCLayer
Definition: CSCLayer.h:24
edm::HLTGlobalStatus::error
bool error() const
Has any path encountered an error (exception)
Definition: HLTGlobalStatus.h:51
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
edm::Handle< CSCALCTDigiCollection >
CSCEfficiency::CSCEfficiency
CSCEfficiency(const edm::ParameterSet &pset)
Constructor.
Definition: CSCEfficiency.cc:1640
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:14
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
CSCEfficiency
Definition: CSCEfficiency.h:95
PixelTestBeamValidation_cfi.Efficiency
Efficiency
Definition: PixelTestBeamValidation_cfi.py:79
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
dqmdumpme.last
last
Definition: dqmdumpme.py:56
debug
#define debug
Definition: HDRShower.cc:19
CSCEfficiency::returnTypes
void returnTypes(CSCDetId &id, int &ec, int &st, int &rg, int &ch, int &secondRing)
Definition: CSCEfficiency.cc:1443
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
FreeTrajectoryState::cartesianError
CartesianTrajectoryError cartesianError() const
Definition: FreeTrajectoryState.h:81
RecoMuonValidator_cfi.maxP
maxP
Definition: RecoMuonValidator_cfi.py:34
interactiveExample.theFile
theFile
Definition: interactiveExample.py:17
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
BeamSpot.h
MuonPatternRecoDumper
Definition: MuonPatternRecoDumper.h:18
CSCEfficiency::lineParameter
double lineParameter(double initZPosition, double destZPosition, double initZDirection)
Definition: CSCEfficiency.cc:1502
LocalError::xx
float xx() const
Definition: LocalError.h:22
CSCEfficiency::linearExtrapolation
void linearExtrapolation(GlobalPoint initialPosition, GlobalVector initialDirection, float zSurface, std::vector< float > &posZY)
Definition: CSCEfficiency.cc:1485
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
L1TEGammaOffline_cfi.triggerNames
triggerNames
Definition: L1TEGammaOffline_cfi.py:40
MuonSelectors.h
MuonFwd.h
CSCLayerGeometry
Definition: CSCLayerGeometry.h:25
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
muon::caloCompatibility
float caloCompatibility(const reco::Muon &muon)
Definition: MuonSelectors.cc:58
HLTBitAnalyser_cfi.isData
isData
Definition: HLTBitAnalyser_cfi.py:29
reco::BeamSpot
Definition: BeamSpot.h:21
CSCDetId::layer
int layer() const
Definition: CSCDetId.h:56
AlgebraicSymMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Definition: AlgebraicROOTObjects.h:24
edm::ESHandle< CSCGeometry >
CSCEfficiency::fillDigiInfo
void fillDigiInfo(edm::Handle< CSCALCTDigiCollection > &alcts, edm::Handle< CSCCLCTDigiCollection > &clcts, edm::Handle< CSCCorrelatedLCTDigiCollection > &correlatedlcts, edm::Handle< CSCWireDigiCollection > &wires, edm::Handle< CSCStripDigiCollection > &strips, edm::Handle< edm::PSimHitContainer > &simhits, edm::Handle< CSCRecHit2DCollection > &rechits, edm::Handle< CSCSegmentCollection > &segments, edm::ESHandle< CSCGeometry > &cscGeom)
Definition: CSCEfficiency.cc:683
CSCChamber
Definition: CSCChamber.h:22
BeamSpotPI::dxdz
Definition: BeamSpotPayloadInspectorHelper.h:37
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
CSCLayer::geometry
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
Point3DBase< float, GlobalTag >
GeomDet::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
CSCEfficiency::getFromCLHEP
FreeTrajectoryState getFromCLHEP(const CLHEP::Hep3Vector &p3, const CLHEP::Hep3Vector &r3, int charge, const AlgebraicSymMatrix66 &cov, const MagneticField *field)
Definition: CSCEfficiency.cc:1471
reco::TrackBase::qualitySize
Definition: TrackBase.h:160
CSCEfficiency::fillLCT_info
void fillLCT_info(edm::Handle< CSCALCTDigiCollection > &alcts, edm::Handle< CSCCLCTDigiCollection > &clcts, edm::Handle< CSCCorrelatedLCTDigiCollection > &correlatedlcts)
Definition: CSCEfficiency.cc:720
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
CSCEfficiency.h
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCLayerGeometry::nearestStrip
int nearestStrip(const LocalPoint &lp) const
Definition: CSCLayerGeometry.h:96
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
MuonMETValueMapProducer_cff.maxNormChi2
maxNormChi2
Definition: MuonMETValueMapProducer_cff.py:17
edm::View
Definition: CaloClusterFwd.h:14
funct::true
true
Definition: Factorize.h:173
HLT_FULL_cff.propagatorName
propagatorName
Definition: HLT_FULL_cff.py:9521
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
JetMETHLTOfflineSource_cfi.feta
feta
Definition: JetMETHLTOfflineSource_cfi.py:30
FirstCh
#define FirstCh
Definition: CSCEfficiency.h:81
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
CSCEfficiency::fillSimhit_info
void fillSimhit_info(edm::Handle< edm::PSimHitContainer > &simHits)
Definition: CSCEfficiency.cc:826
HLTBitAnalyser_cfi.simhits
simhits
SIM objects.
Definition: HLTBitAnalyser_cfi.py:21
CSCEfficiency::propagator
const Propagator * propagator(std::string propagatorName) const
Definition: CSCEfficiency.cc:1528
edm::ParameterSet
Definition: ParameterSet.h:47
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
LocalError
Definition: LocalError.h:12
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCEfficiency::extrapolate1D
double extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine)
Definition: CSCEfficiency.cc:1497
CSCDetId
Definition: CSCDetId.h:26
BeamSpotPI::dydz
Definition: BeamSpotPayloadInspectorHelper.h:38
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
createfilelist.int
int
Definition: createfilelist.py:10
TriggerNames.h
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
CSCEfficiency::fillWG_info
void fillWG_info(edm::Handle< CSCWireDigiCollection > &wires, edm::ESHandle< CSCGeometry > &cscGeom)
Definition: CSCEfficiency.cc:766
PVValHelper::dy
Definition: PVValidationHelpers.h:50
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
CSCEfficiency::chooseDirection
void chooseDirection(CLHEP::Hep3Vector &innerPosition, CLHEP::Hep3Vector &outerPosition)
Definition: CSCEfficiency.cc:1507
CSCEfficiency::applyTrigger
bool applyTrigger(edm::Handle< edm::TriggerResults > &hltR, const edm::TriggerNames &triggerNames)
Definition: CSCEfficiency.cc:1561
edm::EventSetup
Definition: EventSetup.h:58
CSCLayerGeometry::stripAngle
float stripAngle(int strip) const
Definition: CSCLayerGeometry.cc:147
get
#define get
HLT_FULL_cff.minTrackHits
minTrackHits
Definition: HLT_FULL_cff.py:32618
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:27
CartesianTrajectoryError::matrix
const AlgebraicSymMatrix66 & matrix() const
Definition: CartesianTrajectoryError.h:28
CSCEfficiency::getFromFTS
void getFromFTS(const FreeTrajectoryState &fts, CLHEP::Hep3Vector &p3, CLHEP::Hep3Vector &r3, int &charge, AlgebraicSymMatrix66 &cov)
Definition: CSCEfficiency.cc:1456
CartesianTrajectoryError
Definition: CartesianTrajectoryError.h:15
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
mps_fire.Path
Path
Definition: mps_fire.py:298
std
Definition: JetResolutionObject.h:76
CSCGeometry::layer
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
CSCEfficiency::fillRechitsSegments_info
void fillRechitsSegments_info(edm::Handle< CSCRecHit2DCollection > &rechits, edm::Handle< CSCSegmentCollection > &segments, edm::ESHandle< CSCGeometry > &cscGeom)
Definition: CSCEfficiency.cc:838
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
CSCEfficiency::recHitSegment_Efficiencies
bool recHitSegment_Efficiencies(CSCDetId &cscDetId, const CSCChamber *cscChamber, FreeTrajectoryState &ftsChamber)
Definition: CSCEfficiency.cc:1309
PVValHelper::dz
Definition: PVValidationHelpers.h:51
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
TrackingComponentsRecord.h
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
CSCEfficiency::checkLocal
bool checkLocal(double yLocal, double yBoundary, int station, int ring)
Definition: CSCEfficiency.cc:605
BoundPlane
edm::TriggerNames
Definition: TriggerNames.h:55
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
CSCEfficiency::endJob
void endJob() override
Definition: CSCEfficiency.cc:2060
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
edm::RefToBase< reco::Track >
p3
double p3[4]
Definition: TauolaWrapper.h:91
CSCSkim_cfi.rootFileName
rootFileName
Definition: CSCSkim_cfi.py:9
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
CSCEfficiency::fillStrips_info
void fillStrips_info(edm::Handle< CSCStripDigiCollection > &strips)
Definition: CSCEfficiency.cc:792
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
CSCLayerGeometry::yOfWireGroup
float yOfWireGroup(int wireGroup, float x=0.) const
Definition: CSCLayerGeometry.h:201
CSCEfficiency::~CSCEfficiency
~CSCEfficiency() override
Destructor.
Definition: CSCEfficiency.cc:1956
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CSCEfficiency::efficienciesPerChamber
bool efficienciesPerChamber(CSCDetId &id, const CSCChamber *cscChamber, FreeTrajectoryState &ftsChamber)
Definition: CSCEfficiency.cc:1052
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::Event
Definition: Event.h:73
CSCEfficiency::filter
bool filter(edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: CSCEfficiency.cc:22
MagneticField
Definition: MagneticField.h:19
PA_MinBiasSkim_cff.andOr
andOr
Definition: PA_MinBiasSkim_cff.py:8
CSCEfficiency::ringCandidates
void ringCandidates(int station, float absEta, std::map< std::string, bool > &chamberTypes)
Definition: CSCEfficiency.cc:971
LocalError::yy
float yy() const
Definition: LocalError.h:24
alignBH_cfg.minP
minP
Definition: alignBH_cfg.py:15
edm::InputTag
Definition: InputTag.h:15
DigiDM_cff.strips
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers....
Definition: DigiDM_cff.py:32
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
CSCGeometry::chamber
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
edm::View::size_type
unsigned int size_type
Definition: View.h:90
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
reco::TrackBase::highPurity
Definition: TrackBase.h:154