CMS 3D CMS Logo

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