CMS 3D CMS Logo

CSCSkim.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CSCSkim
4 // Class: CSCSkim
5 //
13 //
14 // Original Author: Michael Schmitt
15 // Created: Sat Jul 12 17:43:33 CEST 2008
16 //
17 //
18 //======================================================================
19 //
20 // CSCSkim:
21 //
22 // A simple skim module for extracting generally useful events from
23 // the cosmic-ray runs (CRUZET-n and CRAFT). The selected events
24 // should be useful for most CSC-DPG and muon-POG studies. However,
25 // the selection requirements may bias the sample with respect to
26 // trigger requirements and certain noise and efficiency-related
27 // studies.
28 //
29 // Types of skims: (typeOfSkim control word)
30 // 1 = loose skim demanding hit chambers and/or segments
31 // 2 = ask for hit chambers in both endcaps
32 // 3 = segments in neighboring chambers - good for alignment
33 // 4 = messy events
34 // 5 = select events with DIGIs from one particular chamber
35 // 6 = overlap with DT
36 // 7 = nearly horizontal track going through ME1/1,2/1,3/1,4/1
37 // 8 = ask for one long cosmic stand-alone muon track
38 // 9 = selection for magnetic field studies
39 //
40 //
41 //======================================================================
42 
44 
45 using namespace std;
46 using namespace edm;
47 
48 //===================
49 // CONSTRUCTOR
50 //===================
52  // tokens from tags
53 
54  // Really should define the wire and digi tags in config, but for now, to avoid having to modify
55  // multiple config files, just hard-code those tags, to be equivalent to the pre-consumes code
56 
57  // wds_token = consumes<CSCWireDigiCollection>(pset.getParameter<InputTag>("simWireDigiTag"));
58  // sds_token = consumes<CSCStripDigiCollection>(pset.getParameter<InputTag>("simStripDigiTag"));
59  // wdr_token = consumes<CSCWireDigiCollection>(pset.getParameter<InputTag>("wireDigiTag"));
60  // sdr_token = consumes<CSCStripDigiCollection>(pset.getParameter<InputTag>("stripDigiTag"));
61 
62  wds_token = consumes<CSCWireDigiCollection>(edm::InputTag("simMuonCSCDigis", "MuonCSCWireDigi"));
63  sds_token = consumes<CSCStripDigiCollection>(edm::InputTag("simMuonCSCDigis", "MuonCSCStripDigi"));
64  wdr_token = consumes<CSCWireDigiCollection>(edm::InputTag("muonCSCDigis", "MuonCSCWireDigi"));
65  sdr_token = consumes<CSCStripDigiCollection>(edm::InputTag("muonCSCDigis", "MuonCSCStripDigi"));
66 
67  rh_token = consumes<CSCRecHit2DCollection>(pset.getParameter<InputTag>("cscRecHitTag"));
68  seg_token = consumes<CSCSegmentCollection>(pset.getParameter<InputTag>("cscSegmentTag"));
69 
70  sam_token = consumes<reco::TrackCollection>(pset.getParameter<InputTag>("SAMuonTag"));
71  trk_token = consumes<reco::TrackCollection>(pset.getParameter<InputTag>("trackTag"));
72  glm_token = consumes<reco::MuonCollection>(pset.getParameter<InputTag>("GLBMuonTag"));
73 
74  // Get the various input parameters
75  outputFileName = pset.getUntrackedParameter<std::string>("outputFileName", "outputSkim.root");
76  histogramFileName = pset.getUntrackedParameter<std::string>("histogramFileName", "histos.root");
77  typeOfSkim = pset.getUntrackedParameter<int>("typeOfSkim", 1);
78  nLayersWithHitsMinimum = pset.getUntrackedParameter<int>("nLayersWithHitsMinimum", 3);
79  minimumHitChambers = pset.getUntrackedParameter<int>("minimumHitChambers", 1);
80  minimumSegments = pset.getUntrackedParameter<int>("minimumSegments", 3);
81  demandChambersBothSides = pset.getUntrackedParameter<bool>("demandChambersBothSides", false);
82  makeHistograms = pset.getUntrackedParameter<bool>("makeHistograms", false);
83  makeHistogramsForMessyEvents = pset.getUntrackedParameter<bool>("makeHistogramsForMessyEvebts", false);
84  whichEndcap = pset.getUntrackedParameter<int>("whichEndcap", 2);
85  whichStation = pset.getUntrackedParameter<int>("whichStation", 3);
86  whichRing = pset.getUntrackedParameter<int>("whichRing", 2);
87  whichChamber = pset.getUntrackedParameter<int>("whichChamber", 24);
88 
89  // for BStudy selection (skim type 9)
90  pMin = pset.getUntrackedParameter<double>("pMin", 3.);
91  zLengthMin = pset.getUntrackedParameter<double>("zLengthMin", 200.);
92  nCSCHitsMin = pset.getUntrackedParameter<int>("nCSCHitsMin", 9);
93  zInnerMax = pset.getUntrackedParameter<double>("zInnerMax", 9000.);
94  nTrHitsMin = pset.getUntrackedParameter<int>("nTrHitsMin", 8);
95  zLengthTrMin = pset.getUntrackedParameter<double>("zLengthTrMin", 180.);
96  rExtMax = pset.getUntrackedParameter<double>("rExtMax", 3000.);
97  redChiSqMax = pset.getUntrackedParameter<double>("redChiSqMax", 20.);
98  nValidHitsMin = pset.getUntrackedParameter<int>("nValidHitsMin", 8);
99 
100  LogInfo("[CSCSkim] Setup") << "\n\t===== CSCSkim =====\n"
101  << "\t\ttype of skim ...............................\t" << typeOfSkim
102  << "\t\tminimum number of layers with hits .........\t" << nLayersWithHitsMinimum
103  << "\n\t\tminimum number of chambers w/ hit layers..\t" << minimumHitChambers
104  << "\n\t\tminimum number of segments ...............\t" << minimumSegments
105  << "\n\t\tdemand chambers on both sides.............\t" << demandChambersBothSides
106  << "\n\t\tmake histograms...........................\t" << makeHistograms
107  << "\n\t\t..for messy events........................\t" << makeHistogramsForMessyEvents
108  << "\n\t===================\n\n";
109 }
110 
111 //===================
112 // DESTRUCTOR
113 //===================
115 
116 //================
117 // BEGIN JOB
118 //================
120  // set counters to zero
121  nEventsAnalyzed = 0;
122  nEventsSelected = 0;
123  nEventsChambersBothSides = 0;
124  nEventsOverlappingChambers = 0;
125  nEventsMessy = 0;
126  nEventsCertainChamber = 0;
127  nEventsDTOverlap = 0;
128  nEventsHaloLike = 0;
129  nEventsLongSATrack = 0;
130  nEventsForBFieldStudies = 0;
131  iRun = 0;
132  iEvent = 0;
133 
134  if (makeHistograms || makeHistogramsForMessyEvents) {
135  // Create the root file for the histograms
136  theHistogramFile = new TFile(histogramFileName.c_str(), "RECREATE");
137  theHistogramFile->cd();
138 
139  if (makeHistograms) {
140  // book histograms for the skimming module
141  hxnRecHits = new TH1F("hxnRecHits", "n RecHits", 61, -0.5, 60.5);
142  hxnSegments = new TH1F("hxnSegments", "n Segments", 11, -0.5, 10.5);
143  hxnHitChambers = new TH1F("hxnHitsChambers", "n chambers with hits", 11, -0.5, 10.5);
144  hxnRecHitsSel = new TH1F("hxnRecHitsSel", "n RecHits selected", 61, -0.5, 60.5);
145 
146  xxP = new TH1F("xxP", "P global", 100, 0., 200.);
147  xxnValidHits = new TH1F("xxnValidHits", "n valid hits global", 61, -0.5, 60.5);
148  xxnTrackerHits = new TH1F("xxnTrackerHits", "n tracker hits global", 61, -0.5, 60.5);
149  xxnCSCHits = new TH1F("xxnCSCHits", "n CSC hits global", 41, -0.5, 40.5);
150  xxredChiSq = new TH1F("xxredChiSq", "red chisq global", 100, 0., 100.);
151  }
152  if (makeHistogramsForMessyEvents) {
153  // book histograms for the messy event skimming module
154  mevnRecHits0 = new TH1F("mevnRecHits0", "n RecHits", 121, -0.5, 120.5);
155  mevnChambers0 = new TH1F("mevnChambers0", "n chambers with hits", 21, -0.5, 20.5);
156  mevnSegments0 = new TH1F("mevnSegments0", "n Segments", 21, -0.5, 20.5);
157  mevnRecHits1 = new TH1F("mevnRecHits1", "n RecHits", 100, 0., 300.);
158  mevnChambers1 = new TH1F("mevnChambers1", "n chambers with hits", 50, 0., 50.);
159  mevnSegments1 = new TH1F("mevnSegments1", "n Segments", 30, 0., 30.);
160  }
161  }
162 }
163 
164 //================
165 // END JOB
166 //================
168  // Write out results
169 
170  float fraction = 0.;
171  if (nEventsAnalyzed > 0) {
172  fraction = (float)nEventsSelected / (float)nEventsAnalyzed;
173  }
174 
175  LogInfo("[CSCSkim] Summary") << "\n\n\t====== CSCSkim ==========================================================\n"
176  << "\t\ttype of skim ...............................\t" << typeOfSkim << "\n"
177  << "\t\tevents analyzed ..............\t" << nEventsAnalyzed << "\n"
178  << "\t\tevents selected ..............\t" << nEventsSelected
179  << "\tfraction= " << fraction << std::endl
180  << "\t\tevents chambers both sides ...\t" << nEventsChambersBothSides << "\n"
181  << "\t\tevents w/ overlaps .......... \t" << nEventsOverlappingChambers << "\n"
182  << "\t\tevents lots of hit chambers . \t" << nEventsMessy << "\n"
183  << "\t\tevents from certain chamber . \t" << nEventsCertainChamber << "\n"
184  << "\t\tevents in DT-CSC overlap .... \t" << nEventsDTOverlap << "\n"
185  << "\t\tevents halo-like ............ \t" << nEventsHaloLike << "\n"
186  << "\t\tevents w/ long SA track ..... \t" << nEventsLongSATrack << "\n"
187  << "\t\tevents good for BField ..... \t" << nEventsForBFieldStudies << "\n"
188  << "\t=========================================================================\n\n";
189 
190  if (makeHistograms || makeHistogramsForMessyEvents) {
191  // Write the histos to file
192  LogDebug("[CSCSkim]") << "======= write out my histograms ====\n";
193  theHistogramFile->cd();
194  if (makeHistograms) {
195  hxnRecHits->Write();
196  hxnSegments->Write();
197  hxnHitChambers->Write();
198  hxnRecHitsSel->Write();
199  }
200  if (makeHistogramsForMessyEvents) {
201  mevnRecHits0->Write();
202  mevnChambers0->Write();
203  mevnSegments0->Write();
204  mevnRecHits1->Write();
205  mevnChambers1->Write();
206  mevnSegments1->Write();
207  }
208  theHistogramFile->Close();
209  }
210 }
211 
212 //================
213 // FILTER MAIN
214 //================
215 bool CSCSkim::filter(edm::Event& event, const edm::EventSetup& eventSetup) {
216  // increment counter
217  nEventsAnalyzed++;
218 
219  iRun = event.id().run();
220  iEvent = event.id().event();
221 
222  LogDebug("[CSCSkim] EventInfo") << "Run: " << iRun << "\tEvent: " << iEvent << "\tn Analyzed: " << nEventsAnalyzed;
223 
224  // Get the CSC Geometry :
225  ESHandle<CSCGeometry> cscGeom;
226  eventSetup.get<MuonGeometryRecord>().get(cscGeom);
227 
228  // Get the DIGI collections
231 
232  if (event.eventAuxiliary().isRealData()) {
233  event.getByToken(wdr_token, wires);
234  event.getByToken(sdr_token, strips);
235  } else {
236  event.getByToken(wds_token, wires);
237  event.getByToken(sds_token, strips);
238  }
239 
240  // Get the RecHits collection :
242  event.getByToken(rh_token, cscRecHits);
243 
244  // get CSC segment collection
246  event.getByToken(seg_token, cscSegments);
247 
248  // get the cosmic muons collection
250  if (typeOfSkim == 8) {
251  event.getByToken(sam_token, saMuons);
252  }
253 
254  // get the stand-alone muons collection
257  if (typeOfSkim == 9) {
258  event.getByToken(sam_token, saMuons);
259  event.getByToken(trk_token, tracks);
260  event.getByToken(glm_token, gMuons);
261  }
262 
263  //======================================
264  // evaluate the skimming routines
265  //======================================
266 
267  // basic skimming
268  bool basicEvent = false;
269  if (typeOfSkim == 1 || typeOfSkim == 2) {
270  basicEvent = doCSCSkimming(cscRecHits, cscSegments);
271  }
272 
273  // overlapping chamber skim
274  bool goodOverlapEvent = false;
275  if (typeOfSkim == 3) {
276  goodOverlapEvent = doOverlapSkimming(cscSegments);
277  if (goodOverlapEvent) {
278  nEventsOverlappingChambers++;
279  }
280  }
281 
282  // messy events skim
283  bool messyEvent = false;
284  if (typeOfSkim == 4) {
285  messyEvent = doMessyEventSkimming(cscRecHits, cscSegments);
286  if (messyEvent) {
287  nEventsMessy++;
288  }
289  }
290 
291  // select events with DIGIs in a certain chamber
292  bool hasChamber = false;
293  if (typeOfSkim == 5) {
294  hasChamber = doCertainChamberSelection(wires, strips);
295  if (hasChamber) {
296  nEventsCertainChamber++;
297  }
298  }
299 
300  // select events in the DT-CSC overlap region
301  bool DTOverlapCandidate = false;
302  if (typeOfSkim == 6) {
303  DTOverlapCandidate = doDTOverlap(cscSegments);
304  if (DTOverlapCandidate) {
305  nEventsDTOverlap++;
306  }
307  }
308 
309  // select halo-like events
310  bool HaloLike = false;
311  if (typeOfSkim == 7) {
312  HaloLike = doHaloLike(cscSegments);
313  if (HaloLike) {
314  nEventsHaloLike++;
315  }
316  }
317 
318  // select long cosmic tracks
319  bool LongSATrack = false;
320  if (typeOfSkim == 8) {
321  LongSATrack = doLongSATrack(saMuons);
322  if (LongSATrack) {
323  nEventsLongSATrack++;
324  }
325  }
326 
327  // select events suitable for a B-field study. They have tracks in the tracker.
328  bool GoodForBFieldStudy = false;
329  if (typeOfSkim == 9) {
330  GoodForBFieldStudy = doBFieldStudySelection(saMuons, tracks, gMuons);
331  if (GoodForBFieldStudy) {
332  nEventsForBFieldStudies++;
333  }
334  }
335 
336  // set filter flag
337  bool selectThisEvent = false;
338  if (typeOfSkim == 1 || typeOfSkim == 2) {
339  selectThisEvent = basicEvent;
340  }
341  if (typeOfSkim == 3) {
342  selectThisEvent = goodOverlapEvent;
343  }
344  if (typeOfSkim == 4) {
345  selectThisEvent = messyEvent;
346  }
347  if (typeOfSkim == 5) {
348  selectThisEvent = hasChamber;
349  }
350  if (typeOfSkim == 6) {
351  selectThisEvent = DTOverlapCandidate;
352  }
353  if (typeOfSkim == 7) {
354  selectThisEvent = HaloLike;
355  }
356  if (typeOfSkim == 8) {
357  selectThisEvent = LongSATrack;
358  }
359  if (typeOfSkim == 9) {
360  selectThisEvent = GoodForBFieldStudy;
361  }
362 
363  if (selectThisEvent) {
364  nEventsSelected++;
365  }
366 
367  return selectThisEvent;
368 }
369 
370 // ==============================================
371 //
372 // CSC Skimming
373 //
374 // ==============================================
375 
378  // how many RecHits in the collection?
379  int nRecHits = cscRecHits->size();
380 
381  // zero the recHit counter
382  int cntRecHit[600];
383  for (int i = 0; i < 600; i++) {
384  cntRecHit[i] = 0;
385  }
386 
387  // ---------------------
388  // Loop over rechits
389  // ---------------------
390 
392  for (recIt = cscRecHits->begin(); recIt != cscRecHits->end(); recIt++) {
393  // which chamber is it?
394  CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
395  int kEndcap = idrec.endcap();
396  int kRing = idrec.ring();
397  int kStation = idrec.station();
398  int kChamber = idrec.chamber();
399  int kLayer = idrec.layer();
400 
401  // compute chamber serial number
402  int kSerial = chamberSerial(kEndcap, kStation, kRing, kChamber);
403 
404  // increment recHit counter
405  // (each layer is represented by a different power of 10)
406  int kDigit = (int)pow((float)10., (float)(kLayer - 1));
407  cntRecHit[kSerial] += kDigit;
408 
409  } //end rechit loop
410 
411  // ------------------------------------------------------
412  // Are there chambers with the minimum number of hits?
413  // ------------------------------------------------------
414 
415  int nChambersWithMinimalHits = 0;
416  int nChambersWithMinimalHitsPOS = 0;
417  int nChambersWithMinimalHitsNEG = 0;
418  if (nRecHits > 0) {
419  for (int i = 0; i < 600; i++) {
420  if (cntRecHit[i] > 0) {
421  int nLayersWithHits = 0;
422  float dummy = (float)cntRecHit[i];
423  for (int j = 5; j > -1; j--) {
424  float digit = dummy / pow((float)10., (float)j);
425  int kCount = (int)digit;
426  if (kCount > 0)
427  nLayersWithHits++;
428  dummy = dummy - ((float)kCount) * pow((float)10., (float)j);
429  }
430  if (nLayersWithHits > nLayersWithHitsMinimum) {
431  if (i < 300) {
432  nChambersWithMinimalHitsPOS++;
433  } else {
434  nChambersWithMinimalHitsNEG++;
435  }
436  }
437  }
438  }
439  nChambersWithMinimalHits = nChambersWithMinimalHitsPOS + nChambersWithMinimalHitsNEG;
440  }
441 
442  // how many Segments?
443  int nSegments = cscSegments->size();
444 
445  // ----------------------
446  // fill histograms
447  // ----------------------
448 
449  if (makeHistograms) {
450  hxnRecHits->Fill(nRecHits);
451  if (nRecHits > 0) {
452  hxnSegments->Fill(nSegments);
453  hxnHitChambers->Fill(nChambersWithMinimalHits);
454  }
455  if (nChambersWithMinimalHits > 0) {
456  hxnRecHitsSel->Fill(nRecHits);
457  }
458  }
459 
460  // ----------------------
461  // set the filter flag
462  // ----------------------
463  bool basicEvent = (nChambersWithMinimalHits >= minimumHitChambers) && (nSegments >= minimumSegments);
464 
465  bool chambersOnBothSides =
466  ((nChambersWithMinimalHitsPOS >= minimumHitChambers) && (nChambersWithMinimalHitsNEG >= minimumHitChambers));
467 
468  if (chambersOnBothSides) {
469  nEventsChambersBothSides++;
470  }
471 
472  bool selectEvent = false;
473  if (typeOfSkim == 1) {
474  selectEvent = basicEvent;
475  }
476  if (typeOfSkim == 2) {
477  selectEvent = chambersOnBothSides;
478  }
479 
480  // debug
481  LogDebug("[CSCSkim]") << "----- nRecHits = " << nRecHits
482  << "\tnChambersWithMinimalHits = " << nChambersWithMinimalHits << "\tnSegments = " << nSegments
483  << "\tselect? " << selectEvent << std::endl;
484 
485  /*
486  if ((nChambersWithMinimalHitsPOS >= minimumHitChambers) && (nChambersWithMinimalHitsNEG >= minimumHitChambers)) {
487  std::cout << "\n==========================================================================\n"
488  << "\tinteresting event - chambers hit on both sides\n"
489  << "\t " << nEventsAnalyzed
490  << "\trun " << iRun << "\tevent " << iEvent << std::endl;
491  std::cout << "----- nRecHits = " << nRecHits
492  << "\tnChambersWithMinimalHits = " << nChambersWithMinimalHits
493  << "\tnSegments = " << nSegments
494  << "\tselect? " << selectEvent << std::endl;
495  for (int i = 0; i < 600; i++) {
496  if (cntRecHit[i] > 0) {
497  cout << "\t\t" << i << "\tcntRecHit= " << cntRecHit[i] << std::endl;
498  }
499  }
500  std::cout << "==========================================================================\n\n" ;
501  }
502  */
503 
504  return selectEvent;
505 }
506 
507 //-------------------------------------------------------------------------------
508 // A module to select events useful in aligning chambers relative to each other
509 // using the overlap regions at the edges (in Xlocal) of the chamber.
510 //-------------------------------------------------------------------------------
512  const int nhitsMinimum = 4;
513  const float chisqMaximum = 100.;
514  const int nAllMaximum = 3;
515 
516  // how many Segments?
517  // int nSegments = cscSegments->size();
518 
519  // zero arrays
520  int nAll[600];
521  int nGood[600];
522  for (int i = 0; i < 600; i++) {
523  nAll[i] = 0;
524  nGood[i] = 0;
525  }
526 
527  // -----------------------
528  // loop over segments
529  // -----------------------
530  for (CSCSegmentCollection::const_iterator it = cscSegments->begin(); it != cscSegments->end(); it++) {
531  // which chamber?
532  CSCDetId id = (CSCDetId)(*it).cscDetId();
533  int kEndcap = id.endcap();
534  int kStation = id.station();
535  int kRing = id.ring();
536  int kChamber = id.chamber();
537  int kSerial = chamberSerial(kEndcap, kStation, kRing, kChamber);
538 
539  // segment information
540  float chisq = (*it).chi2();
541  int nhits = (*it).nRecHits();
542 
543  // is this a good segment?
544  bool goodSegment = (nhits >= nhitsMinimum) && (chisq < chisqMaximum);
545 
546  /*
547  LocalPoint localPos = (*it).localPosition();
548  float segX = localPos.x();
549  float segY = localPos.y();
550  std::cout << "E/S/R/Ch: " << kEndcap << "/" << kStation << "/" << kRing << "/" << kChamber
551  << "\tnhits/chisq: " << nhits << "/" << chisq
552  << "\tX/Y: " << segX << "/" << segY
553  << "\tgood? " << goodSegment << std::endl;
554  */
555 
556  // count
557  nAll[kSerial - 1]++;
558  if (goodSegment)
559  nGood[kSerial]++;
560 
561  } // end loop over segments
562 
563  //----------------------
564  // select the event
565  //----------------------
566 
567  // does any chamber have too many segments?
568  bool messyChamber = false;
569  for (int i = 0; i < 600; i++) {
570  if (nAll[i] > nAllMaximum)
571  messyChamber = true;
572  }
573 
574  // are there consecutive chambers with good segments
575  // (This is a little sloppy but is probably fine for skimming...)
576  bool consecutiveChambers = false;
577  for (int i = 0; i < 599; i++) {
578  if ((nGood[i] > 0) && (nGood[i + 1] > 0))
579  consecutiveChambers = true;
580  }
581 
582  bool selectThisEvent = !messyChamber && consecutiveChambers;
583 
584  return selectThisEvent;
585 }
586 
587 //============================================================
588 //
589 // This module selects events with a large numbere
590 // of recHits and larger number of chambers with hits.
591 //
592 //============================================================
595  // how many RecHits in the collection?
596  int nRecHits = cscRecHits->size();
597 
598  // zero the recHit counter
599  int cntRecHit[600];
600  for (int i = 0; i < 600; i++) {
601  cntRecHit[i] = 0;
602  }
603 
604  // ---------------------
605  // Loop over rechits
606  // ---------------------
607 
609  for (recIt = cscRecHits->begin(); recIt != cscRecHits->end(); recIt++) {
610  // which chamber is it?
611  CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
612  int kEndcap = idrec.endcap();
613  int kRing = idrec.ring();
614  int kStation = idrec.station();
615  int kChamber = idrec.chamber();
616  int kLayer = idrec.layer();
617 
618  // compute chamber serial number
619  int kSerial = chamberSerial(kEndcap, kStation, kRing, kChamber);
620 
621  // increment recHit counter
622  // (each layer is represented by a different power of 10)
623  int kDigit = (int)pow((float)10., (float)(kLayer - 1));
624  cntRecHit[kSerial] += kDigit;
625 
626  } //end rechit loop
627 
628  // ------------------------------------------------------
629  // Are there chambers with the minimum number of hits?
630  // ------------------------------------------------------
631 
632  int nChambersWithMinimalHits = 0;
633  int nChambersWithMinimalHitsPOS = 0;
634  int nChambersWithMinimalHitsNEG = 0;
635  if (nRecHits > 0) {
636  for (int i = 0; i < 600; i++) {
637  if (cntRecHit[i] > 0) {
638  int nLayersWithHits = 0;
639  float dummy = (float)cntRecHit[i];
640  for (int j = 5; j > -1; j--) {
641  float digit = dummy / pow((float)10., (float)j);
642  int kCount = (int)digit;
643  if (kCount > 0)
644  nLayersWithHits++;
645  dummy = dummy - ((float)kCount) * pow((float)10., (float)j);
646  }
647  if (nLayersWithHits > nLayersWithHitsMinimum) {
648  if (i < 300) {
649  nChambersWithMinimalHitsPOS++;
650  } else {
651  nChambersWithMinimalHitsNEG++;
652  }
653  }
654  }
655  }
656  nChambersWithMinimalHits = nChambersWithMinimalHitsPOS + nChambersWithMinimalHitsNEG;
657  }
658 
659  // how many Segments?
660  int nSegments = cscSegments->size();
661 
662  // ----------------------
663  // fill histograms
664  // ----------------------
665 
666  if (makeHistogramsForMessyEvents) {
667  if (nRecHits > 8) {
668  mevnRecHits0->Fill(nRecHits);
669  mevnChambers0->Fill(nChambersWithMinimalHits);
670  mevnSegments0->Fill(nSegments);
671  }
672  if (nRecHits > 54) {
673  double dummy = (double)nRecHits;
674  if (dummy > 299.9)
675  dummy = 299.9;
676  mevnRecHits1->Fill(dummy);
677  dummy = (double)nChambersWithMinimalHits;
678  if (dummy > 49.9)
679  dummy = 49.9;
680  mevnChambers1->Fill(dummy);
681  dummy = (double)nSegments;
682  if (dummy > 29.9)
683  dummy = 29.9;
684  mevnSegments1->Fill(dummy);
685  }
686  }
687 
688  // ----------------------
689  // set the filter flag
690  // ----------------------
691 
692  bool selectEvent = false;
693  if ((nRecHits > 54) && (nChambersWithMinimalHits > 5)) {
694  selectEvent = true;
695  }
696 
697  // debug
698  LogDebug("[CSCSkim]") << "----- nRecHits = " << nRecHits
699  << "\tnChambersWithMinimalHits = " << nChambersWithMinimalHits << "\tnSegments = " << nSegments
700  << "\tselect? " << selectEvent << std::endl;
701 
702  /*
703  if (selectEvent) {
704  std::cout << "\n==========================================================================\n"
705  << "\tmessy event!\n"
706  << "\t " << nEventsAnalyzed
707  << "\trun " << iRun << "\tevent " << iEvent << std::endl;
708  std::cout << "----- nRecHits = " << nRecHits
709  << "\tnChambersWithMinimalHits = " << nChambersWithMinimalHits
710  << "\tnSegments = " << nSegments
711  << "\tselect? " << selectEvent << std::endl;
712  for (int i = 0; i < 600; i++) {
713  if (cntRecHit[i] > 0) {
714  cout << "\t\t" << i << "\tcntRecHit= " << cntRecHit[i] << std::endl;
715  }
716  }
717  std::cout << "==========================================================================\n\n" ;
718  }
719  */
720 
721  return selectEvent;
722 }
723 
724 //============================================================
725 //
726 // Select events with DIGIs are a particular chamber.
727 //
728 //============================================================
731  // Loop through the wire DIGIs, looking for a match
732  bool certainChamberIsPresentInWires = false;
733  for (CSCWireDigiCollection::DigiRangeIterator jw = wires->begin(); jw != wires->end(); jw++) {
734  CSCDetId id = (CSCDetId)(*jw).first;
735  int kEndcap = id.endcap();
736  int kRing = id.ring();
737  int kStation = id.station();
738  int kChamber = id.chamber();
739  if ((kEndcap == whichEndcap) && (kStation == whichStation) && (kRing == whichRing) && (kChamber == whichChamber)) {
740  certainChamberIsPresentInWires = true;
741  }
742  } // end wire loop
743 
744  // Loop through the strip DIGIs, looking for a match
745  bool certainChamberIsPresentInStrips = false;
746  for (CSCStripDigiCollection::DigiRangeIterator js = strips->begin(); js != strips->end(); js++) {
747  CSCDetId id = (CSCDetId)(*js).first;
748  int kEndcap = id.endcap();
749  int kRing = id.ring();
750  int kStation = id.station();
751  int kChamber = id.chamber();
752  if ((kEndcap == whichEndcap) && (kStation == whichStation) && (kRing == whichRing) && (kChamber == whichChamber)) {
753  certainChamberIsPresentInStrips = true;
754  }
755  }
756 
757  bool certainChamberIsPresent = certainChamberIsPresentInWires || certainChamberIsPresentInStrips;
758 
759  return certainChamberIsPresent;
760 }
761 
762 //============================================================
763 //
764 // Select events which *might* probe the DT-CSC overlap region.
765 //
766 //============================================================
768  const float chisqMax = 100.;
769  const int nhitsMin = 5;
770  const int maxNSegments = 3;
771 
772  // initialize
773  bool DTOverlapCandidate = false;
774  int cntMEP13[36];
775  int cntMEN13[36];
776  int cntMEP22[36];
777  int cntMEN22[36];
778  int cntMEP32[36];
779  int cntMEN32[36];
780  for (int i = 0; i < 36; ++i) {
781  cntMEP13[i] = 0;
782  cntMEN13[i] = 0;
783  cntMEP22[i] = 0;
784  cntMEN22[i] = 0;
785  cntMEP32[i] = 0;
786  cntMEN32[i] = 0;
787  }
788 
789  // -----------------------
790  // loop over segments
791  // -----------------------
792 
793  int nSegments = cscSegments->size();
794  if (nSegments < 2)
795  return DTOverlapCandidate;
796 
797  for (CSCSegmentCollection::const_iterator it = cscSegments->begin(); it != cscSegments->end(); it++) {
798  // which chamber?
799  CSCDetId id = (CSCDetId)(*it).cscDetId();
800  int kEndcap = id.endcap();
801  int kStation = id.station();
802  int kRing = id.ring();
803  int kChamber = id.chamber();
804  // segment information
805  float chisq = (*it).chi2();
806  int nhits = (*it).nRecHits();
807  bool goodSegment = (chisq < chisqMax) && (nhits >= nhitsMin);
808  if (goodSegment) {
809  if ((kStation == 1) && (kRing == 3)) {
810  if (kEndcap == 1) {
811  cntMEP13[kChamber - 1]++;
812  }
813  if (kEndcap == 2) {
814  cntMEN13[kChamber - 1]++;
815  }
816  }
817  if ((kStation == 2) && (kRing == 2)) {
818  if (kEndcap == 1) {
819  cntMEP22[kChamber - 1]++;
820  }
821  if (kEndcap == 2) {
822  cntMEN22[kChamber - 1]++;
823  }
824  }
825  if ((kStation == 3) && (kRing == 2)) {
826  if (kEndcap == 1) {
827  cntMEP32[kChamber - 1]++;
828  }
829  if (kEndcap == 2) {
830  cntMEN32[kChamber - 1]++;
831  }
832  }
833  } // this is a good segment
834  } // end loop over segments
835 
836  // ---------------------------------------------
837  // veto messy events
838  // ---------------------------------------------
839  bool tooManySegments = false;
840  for (int i = 0; i < 36; ++i) {
841  if ((cntMEP13[i] > maxNSegments) || (cntMEN13[i] > maxNSegments) || (cntMEP22[i] > maxNSegments) ||
842  (cntMEN22[i] > maxNSegments) || (cntMEP32[i] > maxNSegments) || (cntMEN32[i] > maxNSegments))
843  tooManySegments = true;
844  }
845  if (tooManySegments) {
846  return DTOverlapCandidate;
847  }
848 
849  // ---------------------------------------------
850  // check for relevant matchup of segments
851  // ---------------------------------------------
852  bool matchup = false;
853  for (int i = 0; i < 36; ++i) {
854  if ((cntMEP13[i] > 0) && (cntMEP22[i] + cntMEP32[i] > 0)) {
855  matchup = true;
856  }
857  if ((cntMEN13[i] > 0) && (cntMEN22[i] + cntMEN32[i] > 0)) {
858  matchup = true;
859  }
860  }
861  /*
862  if (matchup) {
863  std::cout << "\tYYY looks like a good event. Select!\n";
864  std::cout << "-- pos endcap --\n"
865  << "ME1/3: ";
866  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP13[k];}
867  std::cout << "\nME2/2: ";
868  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP22[k];}
869  std::cout << "\nME3/2: ";
870  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP32[k];}
871  std::cout << std::endl;
872  }
873  */
874 
875  // set the selection flag
876  DTOverlapCandidate = matchup;
877  return DTOverlapCandidate;
878 }
879 
880 //============================================================
881 //
882 // Select events which register in the inner parts of
883 // stations 1, 2, 3 and 4.
884 //
885 //============================================================
887  const float chisqMax = 100.;
888  const int nhitsMin = 5; // on a segment
889  const int maxNSegments = 3; // in a chamber
890 
891  // initialize
892  bool HaloLike = false;
893  int cntMEP11[36];
894  int cntMEN11[36];
895  int cntMEP12[36];
896  int cntMEN12[36];
897  int cntMEP21[36];
898  int cntMEN21[36];
899  int cntMEP31[36];
900  int cntMEN31[36];
901  int cntMEP41[36];
902  int cntMEN41[36];
903  for (int i = 0; i < 36; ++i) {
904  cntMEP11[i] = 0;
905  cntMEN11[i] = 0;
906  cntMEP12[i] = 0;
907  cntMEN12[i] = 0;
908  cntMEP21[i] = 0;
909  cntMEN21[i] = 0;
910  cntMEP31[i] = 0;
911  cntMEN31[i] = 0;
912  cntMEP41[i] = 0;
913  cntMEN41[i] = 0;
914  }
915 
916  // -----------------------
917  // loop over segments
918  // -----------------------
919  int nSegments = cscSegments->size();
920  if (nSegments < 4)
921  return HaloLike;
922 
923  for (CSCSegmentCollection::const_iterator it = cscSegments->begin(); it != cscSegments->end(); it++) {
924  // which chamber?
925  CSCDetId id = (CSCDetId)(*it).cscDetId();
926  int kEndcap = id.endcap();
927  int kStation = id.station();
928  int kRing = id.ring();
929  int kChamber = id.chamber();
930  // segment information
931  float chisq = (*it).chi2();
932  int nhits = (*it).nRecHits();
933  bool goodSegment = (chisq < chisqMax) && (nhits >= nhitsMin);
934  if (goodSegment) {
935  if ((kStation == 1) && (kRing == 1)) {
936  if (kEndcap == 1) {
937  cntMEP11[kChamber - 1]++;
938  }
939  if (kEndcap == 2) {
940  cntMEN11[kChamber - 1]++;
941  }
942  }
943  if ((kStation == 1) && (kRing == 2)) {
944  if (kEndcap == 1) {
945  cntMEP12[kChamber - 1]++;
946  }
947  if (kEndcap == 2) {
948  cntMEN12[kChamber - 1]++;
949  }
950  }
951  if ((kStation == 2) && (kRing == 1)) {
952  if (kEndcap == 1) {
953  cntMEP21[kChamber - 1]++;
954  }
955  if (kEndcap == 2) {
956  cntMEN21[kChamber - 1]++;
957  }
958  }
959  if ((kStation == 3) && (kRing == 1)) {
960  if (kEndcap == 1) {
961  cntMEP31[kChamber - 1]++;
962  }
963  if (kEndcap == 2) {
964  cntMEN31[kChamber - 1]++;
965  }
966  }
967  if ((kStation == 4) && (kRing == 1)) {
968  if (kEndcap == 1) {
969  cntMEP41[kChamber - 1]++;
970  }
971  if (kEndcap == 2) {
972  cntMEN41[kChamber - 1]++;
973  }
974  }
975  } // this is a good segment
976  } // end loop over segments
977 
978  // ---------------------------------------------
979  // veto messy events
980  // ---------------------------------------------
981  bool tooManySegments = false;
982  for (int i = 0; i < 36; ++i) {
983  if ((cntMEP11[i] > 3 * maxNSegments) || (cntMEN11[i] > 3 * maxNSegments) || (cntMEP12[i] > maxNSegments) ||
984  (cntMEN12[i] > maxNSegments) || (cntMEP21[i] > maxNSegments) || (cntMEN21[i] > maxNSegments) ||
985  (cntMEP31[i] > maxNSegments) || (cntMEN31[i] > maxNSegments) || (cntMEP41[i] > maxNSegments) ||
986  (cntMEN41[i] > maxNSegments))
987  tooManySegments = true;
988  }
989  if (tooManySegments) {
990  return HaloLike;
991  }
992 
993  // ---------------------------------------------
994  // check for relevant matchup of segments
995  // ---------------------------------------------
996  bool matchup = false;
997  for (int i = 0; i < 36; ++i) {
998  if ((cntMEP11[i] + cntMEP12[i] > 0) && (cntMEP21[i] > 0) && (cntMEP31[i] > 0) && (cntMEP41[i] > 0)) {
999  matchup = true;
1000  }
1001  if ((cntMEN11[i] + cntMEN12[i] > 0) && (cntMEN21[i] > 0) && (cntMEN31[i] > 0) && (cntMEN41[i] > 0)) {
1002  matchup = true;
1003  }
1004  }
1005  /*
1006  if (matchup) {
1007  std::cout << "\tYYY looks like a good event. Select!\n";
1008  std::cout << "-- pos endcap --\n"
1009  << "ME1/1: ";
1010  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP11[k];}
1011  std::cout << "\nME1/2: ";
1012  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP12[k];}
1013  std::cout << "\nME2/1: ";
1014  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP21[k];}
1015  std::cout << "\nME3/1: ";
1016  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP31[k];}
1017  std::cout << "\nME4/1: ";
1018  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEP41[k];}
1019  std::cout << std::endl;
1020  std::cout << "-- neg endcap --\n"
1021  << "ME1/1: ";
1022  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEN11[k];}
1023  std::cout << "\nME1/2: ";
1024  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEN12[k];}
1025  std::cout << "\nME2/1: ";
1026  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEN21[k];}
1027  std::cout << "\nME3/1: ";
1028  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEN31[k];}
1029  std::cout << "\nME4/1: ";
1030  for (int k=0; k<36; ++k) {std::cout << " " << setw(3) << cntMEN41[k];}
1031  std::cout << std::endl;
1032  std::cout << "\tn Analyzed = " << nEventsAnalyzed << "\tn Halo-like = " << nEventsHaloLike << std::endl;
1033  }
1034  */
1035 
1036  // set the selection flag
1037  HaloLike = matchup;
1038  return HaloLike;
1039 }
1040 
1041 //--------------------------------------------------------------
1042 // select events with at least one "long" stand-alone muon
1043 //--------------------------------------------------------------
1045  const float zDistanceMax = 2500.;
1046  const float zDistanceMin = 700.;
1047  const int nCSCHitsMin = 25;
1048  const int nCSCHitsMax = 50;
1049  const float zInnerMax = 80000.;
1050 
1051  const int nNiceMuonsMin = 1;
1052 
1053  //
1054  // Loop through the track collection and test each one
1055  //
1056 
1057  int nNiceMuons = 0;
1058 
1059  for (reco::TrackCollection::const_iterator muon = saMuons->begin(); muon != saMuons->end(); ++muon) {
1060  // basic information
1061  math::XYZVector innerMo = muon->innerMomentum();
1062  GlobalVector im(innerMo.x(), innerMo.y(), innerMo.z());
1063  math::XYZPoint innerPo = muon->innerPosition();
1064  GlobalPoint ip(innerPo.x(), innerPo.y(), innerPo.z());
1065  math::XYZPoint outerPo = muon->outerPosition();
1066  GlobalPoint op(outerPo.x(), outerPo.y(), outerPo.z());
1067  float zInner = ip.z();
1068  float zOuter = op.z();
1069  float zDistance = fabs(zOuter - zInner);
1070 
1071  // loop over hits
1072  int nDTHits = 0;
1073  int nCSCHits = 0;
1074  for (trackingRecHit_iterator hit = muon->recHitsBegin(); hit != muon->recHitsEnd(); ++hit) {
1075  const DetId detId((*hit)->geographicalId());
1076  if (detId.det() == DetId::Muon) {
1077  if (detId.subdetId() == MuonSubdetId::DT) {
1078  //DTChamberId dtId(detId.rawId());
1079  //int chamberId = dtId.sector();
1080  nDTHits++;
1081  } else if (detId.subdetId() == MuonSubdetId::CSC) {
1082  //CSCDetId cscId(detId.rawId());
1083  //int chamberId = cscId.chamber();
1084  nCSCHits++;
1085  }
1086  }
1087  }
1088 
1089  // is this a nice muon?
1090  if ((zDistance < zDistanceMax) && (zDistance > zDistanceMin) && (nCSCHits > nCSCHitsMin) &&
1091  (nCSCHits < nCSCHitsMax) && (min(fabs(zInner), fabs(zOuter)) < zInnerMax) &&
1092  (fabs(innerMo.z()) > 0.000000001)) {
1093  nNiceMuons++;
1094  }
1095  }
1096 
1097  bool select = (nNiceMuons >= nNiceMuonsMin);
1098 
1099  return select;
1100 }
1101 
1102 //============================================================
1103 //
1104 // Select events which are good for B-field studies.
1105 //
1106 // These events have a good track in the tracker.
1107 //
1108 // D.Dibur and M.Schmitt
1109 //============================================================
1113  bool acceptThisEvent = false;
1114 
1115  //-----------------------------------
1116  // examine the stand-alone tracks
1117  //-----------------------------------
1118  int nGoodSAMuons = 0;
1119  for (reco::TrackCollection::const_iterator muon = saMuons->begin(); muon != saMuons->end(); ++muon) {
1120  float preco = muon->p();
1121 
1122  math::XYZPoint innerPo = muon->innerPosition();
1123  GlobalPoint iPnt(innerPo.x(), innerPo.y(), innerPo.z());
1124  math::XYZPoint outerPo = muon->outerPosition();
1125  GlobalPoint oPnt(outerPo.x(), outerPo.y(), outerPo.z());
1126  float zLength = abs(iPnt.z() - oPnt.z());
1127 
1128  math::XYZVector innerMom = muon->innerMomentum();
1129  GlobalVector iP(innerMom.x(), innerMom.y(), innerMom.z());
1130  math::XYZVector outerMom = muon->outerMomentum();
1131  GlobalVector oP(outerMom.x(), outerMom.y(), outerMom.z());
1132 
1133  const float zRef = 300.;
1134  float xExt = 10000.;
1135  float yExt = 10000.;
1136  if (abs(oPnt.z()) < abs(iPnt.z())) {
1137  float deltaZ = 0.;
1138  if (oPnt.z() > 0) {
1139  deltaZ = zRef - oPnt.z();
1140  } else {
1141  deltaZ = -zRef - oPnt.z();
1142  }
1143  xExt = oPnt.x() + deltaZ * oP.x() / oP.z();
1144  yExt = oPnt.y() + deltaZ * oP.y() / oP.z();
1145  } else {
1146  float deltaZ = 0.;
1147  if (iPnt.z() > 0) {
1148  deltaZ = zRef - iPnt.z();
1149  } else {
1150  deltaZ = -zRef - iPnt.z();
1151  }
1152  xExt = iPnt.x() + deltaZ * iP.x() / iP.z();
1153  yExt = iPnt.y() + deltaZ * iP.y() / iP.z();
1154  }
1155  float rExt = sqrt(xExt * xExt + yExt * yExt);
1156 
1157  int kHit = 0;
1158  int nDTHits = 0;
1159  int nCSCHits = 0;
1160  for (trackingRecHit_iterator hit = muon->recHitsBegin(); hit != muon->recHitsEnd(); ++hit) {
1161  ++kHit;
1162  const DetId detId((*hit)->geographicalId());
1163  if (detId.det() == DetId::Muon) {
1164  if (detId.subdetId() == MuonSubdetId::DT) {
1165  nDTHits++;
1166  } else if (detId.subdetId() == MuonSubdetId::CSC) {
1167  nCSCHits++;
1168  }
1169  }
1170  } // end loop over hits
1171 
1172  float zInner = -1.;
1173  if (nCSCHits >= nCSCHitsMin) {
1174  if (abs(iPnt.z()) < abs(iPnt.z())) {
1175  zInner = iPnt.z();
1176  } else {
1177  zInner = oPnt.z();
1178  }
1179  }
1180 
1181  bool goodSAMuon = (preco > pMin) && (zLength > zLengthMin) && (nCSCHits >= nCSCHitsMin) && (zInner < zInnerMax) &&
1182  (rExt < rExtMax);
1183 
1184  if (goodSAMuon) {
1185  nGoodSAMuons++;
1186  }
1187 
1188  } // end loop over stand-alone muon collection
1189 
1190  //-----------------------------------
1191  // examine the tracker tracks
1192  //-----------------------------------
1193  int nGoodTracks = 0;
1194  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
1195  float preco = track->p();
1196  int n = track->recHitsSize();
1197 
1198  math::XYZPoint innerPo = track->innerPosition();
1199  GlobalPoint iPnt(innerPo.x(), innerPo.y(), innerPo.z());
1200  math::XYZPoint outerPo = track->outerPosition();
1201  GlobalPoint oPnt(outerPo.x(), outerPo.y(), outerPo.z());
1202  float zLength = abs(iPnt.z() - oPnt.z());
1203 
1204  math::XYZVector innerMom = track->innerMomentum();
1205  GlobalVector iP(innerMom.x(), innerMom.y(), innerMom.z());
1206  math::XYZVector outerMom = track->outerMomentum();
1207  GlobalVector oP(outerMom.x(), outerMom.y(), outerMom.z());
1208 
1209  const float zRef = 300.;
1210  float xExt = 10000.;
1211  float yExt = 10000.;
1212  if (abs(oPnt.z()) > abs(iPnt.z())) {
1213  float deltaZ = 0.;
1214  if (oPnt.z() > 0) {
1215  deltaZ = zRef - oPnt.z();
1216  } else {
1217  deltaZ = -zRef - oPnt.z();
1218  }
1219  xExt = oPnt.x() + deltaZ * oP.x() / oP.z();
1220  yExt = oPnt.y() + deltaZ * oP.y() / oP.z();
1221  } else {
1222  float deltaZ = 0.;
1223  if (iPnt.z() > 0) {
1224  deltaZ = zRef - iPnt.z();
1225  } else {
1226  deltaZ = -zRef - iPnt.z();
1227  }
1228  xExt = iPnt.x() + deltaZ * iP.x() / iP.z();
1229  yExt = iPnt.y() + deltaZ * iP.y() / iP.z();
1230  }
1231  float rExt = sqrt(xExt * xExt + yExt * yExt);
1232 
1233  bool goodTrack = (preco > pMin) && (n >= nTrHitsMin) && (zLength > zLengthTrMin) && (rExt < rExtMax);
1234 
1235  if (goodTrack) {
1236  nGoodTracks++;
1237  }
1238 
1239  } // end loop over tracker tracks
1240 
1241  //-----------------------------------
1242  // examine the global muons
1243  //-----------------------------------
1244  int nGoodGlobalMuons = 0;
1245  for (reco::MuonCollection::const_iterator global = gMuons->begin(); global != gMuons->end(); ++global) {
1246  if (global->isGlobalMuon()) {
1247  float pDef = global->p();
1248  float redChiSq = global->globalTrack()->normalizedChi2();
1249  const reco::HitPattern& hp = (global->globalTrack())->hitPattern();
1250  // int nTotalHits = hp.numberOfHits();
1251  // int nValidHits = hp.numberOfValidHits();
1252  int nTrackerHits = hp.numberOfValidTrackerHits();
1253  // int nPixelHits = hp.numberOfValidPixelHits();
1254  // int nStripHits = hp.numberOfValidStripHits();
1255 
1256  int nDTHits = 0;
1257  int nCSCHits = 0;
1258  for (trackingRecHit_iterator hit = (global->globalTrack())->recHitsBegin();
1259  hit != (global->globalTrack())->recHitsEnd();
1260  ++hit) {
1261  const DetId detId((*hit)->geographicalId());
1262  if (detId.det() == DetId::Muon) {
1263  if (detId.subdetId() == MuonSubdetId::DT) {
1264  nDTHits++;
1265  } else if (detId.subdetId() == MuonSubdetId::CSC) {
1266  nCSCHits++;
1267  }
1268  }
1269  } // end loop over hits
1270 
1271  bool goodGlobalMuon =
1272  (pDef > pMin) && (nTrackerHits >= nValidHitsMin) && (nCSCHits >= nCSCHitsMin) && (redChiSq < redChiSqMax);
1273 
1274  if (goodGlobalMuon) {
1275  nGoodGlobalMuons++;
1276  }
1277 
1278  } // this is a global muon
1279  } // end loop over stand-alone muon collection
1280 
1281  //-----------------------------------
1282  // do we accept this event?
1283  //-----------------------------------
1284 
1285  acceptThisEvent = ((nGoodSAMuons > 0) && (nGoodTracks > 0)) || (nGoodGlobalMuons > 0);
1286 
1287  return acceptThisEvent;
1288 }
1289 
1290 //--------------------------------------------------------------
1291 // Compute a serial number for the chamber.
1292 // This is useful when filling histograms and working with arrays.
1293 //--------------------------------------------------------------
1294 int CSCSkim::chamberSerial(int kEndcap, int kStation, int kRing, int kChamber) {
1295  int kSerial = kChamber;
1296  if (kStation == 1 && kRing == 1) {
1297  kSerial = kChamber;
1298  }
1299  if (kStation == 1 && kRing == 2) {
1300  kSerial = kChamber + 36;
1301  }
1302  if (kStation == 1 && kRing == 3) {
1303  kSerial = kChamber + 72;
1304  }
1305  if (kStation == 1 && kRing == 4) {
1306  kSerial = kChamber;
1307  }
1308  if (kStation == 2 && kRing == 1) {
1309  kSerial = kChamber + 108;
1310  }
1311  if (kStation == 2 && kRing == 2) {
1312  kSerial = kChamber + 126;
1313  }
1314  if (kStation == 3 && kRing == 1) {
1315  kSerial = kChamber + 162;
1316  }
1317  if (kStation == 3 && kRing == 2) {
1318  kSerial = kChamber + 180;
1319  }
1320  if (kStation == 4 && kRing == 1) {
1321  kSerial = kChamber + 216;
1322  }
1323  if (kStation == 4 && kRing == 2) {
1324  kSerial = kChamber + 234;
1325  } // one day...
1326  if (kEndcap == 2) {
1327  kSerial = kSerial + 300;
1328  }
1329  return kSerial;
1330 }
1331 
1332 //define this as a plug-in
Vector3DBase
Definition: Vector3DBase.h:8
CSCSkim::beginJob
void beginJob() override
Definition: CSCSkim.cc:119
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
CSCSkim_cfi.whichEndcap
whichEndcap
Definition: CSCSkim_cfi.py:16
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CSCSkim::doMessyEventSkimming
bool doMessyEventSkimming(edm::Handle< CSCRecHit2DCollection > cscRecHits, edm::Handle< CSCSegmentCollection > cscSegments)
Definition: CSCSkim.cc:593
CommPDSkim_cfg.minimumSegments
minimumSegments
CSC Filter ############################.
Definition: CommPDSkim_cfg.py:145
CSCSkim::doBFieldStudySelection
bool doBFieldStudySelection(edm::Handle< reco::TrackCollection > saTracks, edm::Handle< reco::TrackCollection > Tracks, edm::Handle< reco::MuonCollection > gMuons)
Definition: CSCSkim.cc:1110
muon
Definition: MuonCocktails.h:17
min
T min(T a, T b)
Definition: MathUtil.h:58
edm
HLT enums.
Definition: AlignableModifier.h:19
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
DigiDM_cff.wires
wires
Definition: DigiDM_cff.py:33
singleTopDQM_cfi.select
select
Definition: singleTopDQM_cfi.py:50
CSCSkim_cfi.whichRing
whichRing
Definition: CSCSkim_cfi.py:18
CSCSkim::endJob
void endJob() override
Definition: CSCSkim.cc:167
dtChamberEfficiency_cfi.cscSegments
cscSegments
Definition: dtChamberEfficiency_cfi.py:15
spr::goodTrack
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
Definition: TrackSelection.cc:10
CSCSkim_cfi.whichStation
whichStation
Definition: CSCSkim_cfi.py:17
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< CSCWireDigiCollection >
CSCSkim::~CSCSkim
~CSCSkim() override
Definition: CSCSkim.cc:114
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
CommPDSkim_cfg.minimumHitChambers
minimumHitChambers
Definition: CommPDSkim_cfg.py:146
DetId
Definition: DetId.h:17
reco::HitPattern
Definition: HitPattern.h:147
CSCSkim.h
trackingPlots.hp
hp
Definition: trackingPlots.py:1248
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52795
CSCSkim::filter
bool filter(edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: CSCSkim.cc:215
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CSCDetId::layer
int layer() const
Definition: CSCDetId.h:56
edm::ESHandle< CSCGeometry >
CSCSkim::doDTOverlap
bool doDTOverlap(edm::Handle< CSCSegmentCollection > cscSegments)
Definition: CSCSkim.cc:767
reco_skim_cfg_mod.outputFileName
outputFileName
Definition: reco_skim_cfg_mod.py:15
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
Point3DBase< float, GlobalTag >
nhits
Definition: HIMultiTrackSelector.h:42
CSCSkim_cfi.makeHistograms
makeHistograms
Definition: CSCSkim_cfi.py:15
CSCSkim_cfi.histogramFileName
histogramFileName
Definition: CSCSkim_cfi.py:10
CSCSkim::doHaloLike
bool doHaloLike(edm::Handle< CSCSegmentCollection > cscSegments)
Definition: CSCSkim.cc:886
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
CosmicsPD_Skims.typeOfSkim
typeOfSkim
Definition: CosmicsPD_Skims.py:109
ALCARECOTkAlMinBias_cff.pMin
pMin
GeV.
Definition: ALCARECOTkAlMinBias_cff.py:35
CSCSkim::CSCSkim
CSCSkim(const edm::ParameterSet &pset)
Definition: CSCSkim.cc:51
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
CSCSkim_cfi.nLayersWithHitsMinimum
nLayersWithHitsMinimum
Definition: CSCSkim_cfi.py:11
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
CSCSkim::doOverlapSkimming
bool doOverlapSkimming(edm::Handle< CSCSegmentCollection > cscSegments)
Definition: CSCSkim.cc:511
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
CSCSkim_cfi.whichChamber
whichChamber
Definition: CSCSkim_cfi.py:19
CSCSkim::doCSCSkimming
bool doCSCSkimming(edm::Handle< CSCRecHit2DCollection > cscRecHits, edm::Handle< CSCSegmentCollection > cscSegments)
Definition: CSCSkim.cc:376
std
Definition: JetResolutionObject.h:76
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
DetId::Muon
Definition: DetId.h:26
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CSCSkim
Definition: CSCSkim.h:72
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
dummy
Definition: DummySelector.h:38
CSCSkim::doCertainChamberSelection
bool doCertainChamberSelection(edm::Handle< CSCWireDigiCollection > wires, edm::Handle< CSCStripDigiCollection > strips)
Definition: CSCSkim.cc:729
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CSCSkim_cfi.demandChambersBothSides
demandChambersBothSides
Definition: CSCSkim_cfi.py:14
event
Definition: event.py:1
CSCSkim::doLongSATrack
bool doLongSATrack(edm::Handle< reco::TrackCollection > saTracks)
Definition: CSCSkim.cc:1044
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
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
hit
Definition: SiStripHitEffFromCalibTree.cc:88
kLayer
static const std::string kLayer("layer")
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
CSCSkim::chamberSerial
int chamberSerial(int kE, int kS, int kR, int kCh)
Definition: CSCSkim.cc:1294