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