CMS 3D CMS Logo

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