CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1AnalysisCSCTF.cc
Go to the documentation of this file.
2 
3 
4 
6 {
7 }
8 
10 {
11 }
12 
13 
14 
16  const L1MuTriggerScales *ts, const L1MuTriggerPtScale *tpts,
17  CSCSectorReceiverLUT* srLUTs_[5][2],
18  CSCTFPtLUT* ptLUTs_)
19 {
20 
21  //for (int i =0; i<MAXCSCTFTR; i++) csctf_.trSector[i]=0;
22 
23  csctf_.trSize = csctfTrks->size();
24  //cout << " csctf_.trSize: " << csctf_.trSize << endl;
25 
26  int nTrk=0;
27  for(L1CSCTrackCollection::const_iterator trk=csctfTrks->begin();
28  trk<csctfTrks->end(); trk++){
29 
30  nTrk++;
31 
32  // trk->first.endcap() = 2 for - endcap
33  // = 1 for + endcap
34  csctf_.trEndcap.push_back(trk->first.endcap()==2 ? trk->first.endcap()-3 : trk->first.endcap());
35  //sectors: 1->6 (plus endcap), 7->12 (minus endcap)
36  csctf_.trSector.push_back(6* (trk->first.endcap()-1) + trk->first.sector());
37  csctf_.trBx.push_back(trk->first.BX());
38 
39  csctf_.trME1ID.push_back(trk->first.me1ID());
40  csctf_.trME2ID.push_back(trk->first.me2ID());
41  csctf_.trME3ID.push_back(trk->first.me3ID());
42  csctf_.trME4ID.push_back(trk->first.me4ID());
43  csctf_.trMB1ID.push_back(trk->first.mb1ID());
44 
45  csctf_.trME1TBin.push_back(trk->first.me1Tbin());
46  csctf_.trME2TBin.push_back(trk->first.me2Tbin());
47  csctf_.trME3TBin.push_back(trk->first.me3Tbin());
48  csctf_.trME4TBin.push_back(trk->first.me4Tbin());
49  csctf_.trMB1TBin.push_back(trk->first.mb1Tbin());
50 
51  // output link of the track
52  csctf_.trOutputLink.push_back(trk->first.outputLink());
53 
54  // PtAddress gives an handle on other parameters
55  ptadd thePtAddress(trk->first.ptLUTAddress());
56 
57  csctf_.trPhiSign.push_back(thePtAddress.delta_phi_sign);
58  csctf_.trPhi12.push_back(thePtAddress.delta_phi_12);
59  csctf_.trPhi23.push_back(thePtAddress.delta_phi_23);
60  csctf_.trMode.push_back(thePtAddress.track_mode);
61  csctf_.trForR.push_back(thePtAddress.track_fr);
62  csctf_.trCharge.push_back(trk->first.chargeValue());
63 
64 
65  //Pt needs some more workaround since it is not in the unpacked data
67  ptdat thePtData = ptLUTs_->Pt(thePtAddress);
68 
69  // front or rear bit?
70  if (thePtAddress.track_fr) {
71  csctf_.trPtBit.push_back(thePtData.front_rank&0x1f);
72  csctf_.trQuality.push_back((thePtData.front_rank>>5)&0x3);
73  csctf_.trChargeValid.push_back(thePtData.charge_valid_front);
74  } else {
75  csctf_.trPtBit.push_back(thePtData.rear_rank&0x1f);
76  csctf_.trQuality.push_back((thePtData.rear_rank>>5)&0x3);
77  csctf_.trChargeValid.push_back(thePtData.charge_valid_rear);
78  }
79 
80 
81  // convert the Pt in human readable values (GeV/c)
82  csctf_.trPt.push_back(tpts->getPtScale()->getLowEdge(csctf_.trPtBit.back()));
83 
84  // track's Eta and Phi in bit...
85  csctf_.trEtaBit.push_back(trk->first.eta_packed());
86  csctf_.trPhiBit.push_back(trk->first.localPhi());
87 
88  //... in radians
89  // Type 2 is CSC
90  //csctf_.trEta.push_back(theTriggerScales->getRegionalEtaScale(2)->getCenter(trk->first.eta_packed()));
91  //csctf_.trPhi.push_back(theTriggerScales->getPhiScale()->getLowEdge(trk->first.localPhi()));
92  csctf_.trEta.push_back(ts->getRegionalEtaScale(2)->getCenter(trk->first.eta_packed()));
93  csctf_.trPhi.push_back(ts->getPhiScale()->getLowEdge(trk->first.localPhi()));
94  //Phi in one sector varies from [0,62] degrees -> Rescale manually to global coords.
95  csctf_.trPhi_02PI.push_back(fmod(csctf_.trPhi[nTrk-1] +
96  ((trk->first.sector()-1)*TMath::Pi()/3) + //sector 1 starts at 15 degrees
97  (TMath::Pi()/12) , 2*TMath::Pi()));
98 
99 
100  // //csctf lcts of tracks
101  // if( csctfLCTSource_.label() != "none" ){
102 
103  // For each trk, get the list of its LCTs
104  CSCCorrelatedLCTDigiCollection lctsOfTracks = trk -> second;
105 
106  int LctTrkId_ = 0;
107 
108  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator lctOfTrks = lctsOfTracks.begin();
109  lctOfTrks != lctsOfTracks.end() ; lctOfTrks++){
110 
111  int lctTrkId = 0;
112 
114  lctsOfTracks.get((*lctOfTrks).first);
115 
117  lctTrk = lctRange.first ;
118  lctTrk != lctRange.second; lctTrk++, lctTrkId++){
119 
120 
121  csctf_.trLctEndcap[nTrk-1][LctTrkId_] = (*lctOfTrks).first.zendcap();
122  if ((*lctOfTrks).first.zendcap() > 0)
123  csctf_.trLctSector[nTrk-1][LctTrkId_] = (*lctOfTrks).first.triggerSector();
124  else
125  csctf_.trLctSector[nTrk-1][LctTrkId_] = 6+(*lctOfTrks).first.triggerSector();
126  csctf_.trLctSubSector[nTrk-1][LctTrkId_] = CSCTriggerNumbering::triggerSubSectorFromLabels((*lctOfTrks).first);;
127  csctf_.trLctBx[nTrk-1][LctTrkId_] = lctTrk -> getBX();
128  csctf_.trLctBx0[nTrk-1][LctTrkId_] = lctTrk -> getBX0();
129 
130  csctf_.trLctStation[nTrk-1][LctTrkId_] = (*lctOfTrks).first.station();
131  csctf_.trLctRing[nTrk-1][LctTrkId_] = (*lctOfTrks).first.ring();
132  csctf_.trLctChamber[nTrk-1][LctTrkId_] = (*lctOfTrks).first.chamber();
133  csctf_.trLctTriggerCSCID[nTrk-1][LctTrkId_] = (*lctOfTrks).first.triggerCscId();
134  csctf_.trLctFpga[nTrk-1][LctTrkId_] =
135  ( csctf_.trLctSubSector[nTrk-1][LctTrkId_] ? csctf_.trLctSubSector[nTrk-1][LctTrkId_] : (*lctOfTrks).first.station()+1);
136 
137 
138  // Check if DetId is within range
139  if( csctf_.trLctSector[nTrk-1][LctTrkId_] < 1 || csctf_.trLctSector[nTrk-1][LctTrkId_] > 12 ||
140  csctf_.trLctStation[nTrk-1][LctTrkId_] < 1 || csctf_.trLctStation[nTrk-1][LctTrkId_] > 4 ||
141  csctf_.trLctTriggerCSCID[nTrk-1][LctTrkId_] < 1 || csctf_.trLctTriggerCSCID[nTrk-1][LctTrkId_] > 9 ||
142  lctTrkId < 0 || lctTrkId > 1 ){
143 
144  edm::LogInfo("L1NtupleProducer")<<" TRACK ERROR: CSC digi are out of range: ";
145 
146  continue;
147  }
148 
149  // handles not to overload the method: mostly for readability
150  int endcap = (*lctOfTrks).first.zendcap();
151  if (endcap < 0) endcap = 0;
152 
153  int StationLctTrk = (*lctOfTrks).first.station();
154  int CscIdLctTrk = (*lctOfTrks).first.triggerCscId();
155  int SubSectorLctTrk =
157 
158  int FPGALctTrk =
159  ( SubSectorLctTrk ? SubSectorLctTrk-1 : StationLctTrk );
160 
161 
162  // local Phi
163  lclphidat lclPhi;
164 
165  try {
166 
167  csctf_.trLctstripNum[nTrk-1][LctTrkId_] = lctTrk->getStrip();
168  lclPhi = srLUTs_[FPGALctTrk][endcap] -> localPhi(lctTrk->getStrip(),
169  lctTrk->getPattern(),
170  lctTrk->getQuality(),
171  lctTrk->getBend() );
172 
173  csctf_.trLctlocalPhi[nTrk-1][LctTrkId_] = lclPhi.phi_local;
174  //csctf_.trLctlocalPhi_bend[nTrk-1][LctTrkId_] = lclPhi.phi_bend_local;
175  //csctf_.trLctCLCT_pattern[nTrk-1][LctTrkId_] = lctTrk->getPattern();
176  csctf_.trLctQuality[nTrk-1][LctTrkId_] = lctTrk->getQuality();
177 
178  //std::cout <<"lctTrk->getPattern() = " << lctTrk->getPattern() << std::endl;
179  }
180  catch(...) {
181  bzero(&lclPhi,sizeof(lclPhi));
182  csctf_.trLctlocalPhi[nTrk-1][LctTrkId_] = -999;
183  //csctf_.trLctlocalPhi_bend[nTrk-1][LctTrkId_] = -999;
184  //csctf_.trLctCLCT_pattern[nTrk-1][LctTrkId_] = -999;
185  csctf_.trLctQuality[nTrk-1][LctTrkId_] = -999;
186  }
187  // clct pattern
188  lclphiadd lclPattern;
189  try{
190  //std::cout <<"lclPattern.clct_pattern = " << lclPattern.clct_pattern << std::endl;
191  //std::cout <<"lclPattern.pattern_type = " << lclPattern.pattern_type << std::endl;
192 
193  }
194  catch(...){
195  }
196 
197 
198  // Global Phi
199  gblphidat gblPhi;
200 
201  try {
202 
203  csctf_.trLctwireGroup[nTrk-1][LctTrkId_] = lctTrk->getKeyWG();
204  gblPhi = srLUTs_[FPGALctTrk][endcap] -> globalPhiME(lclPhi.phi_local ,
205  lctTrk->getKeyWG(),
206  CscIdLctTrk);
207 
208  csctf_.trLctglobalPhi[nTrk-1][LctTrkId_] = gblPhi.global_phi;
209 
210  } catch(...) {
211  bzero(&gblPhi,sizeof(gblPhi));
212  csctf_.trLctglobalPhi[nTrk-1][LctTrkId_] = -999;
213  }
214 
215  // Global Eta
216  gbletadat gblEta;
217 
218  try {
219  gblEta = srLUTs_[FPGALctTrk][endcap] -> globalEtaME(lclPhi.phi_bend_local,
220  lclPhi.phi_local ,
221  lctTrk->getKeyWG() ,
222  CscIdLctTrk);
223  csctf_.trLctglobalEta[nTrk-1][LctTrkId_] = gblEta.global_eta;
224  csctf_.trLctCLCT_pattern[nTrk-1][LctTrkId_] = gblEta.global_bend;
225  }
226  catch(...) {
227  bzero(&gblEta,sizeof(gblEta));
228  csctf_.trLctglobalEta[nTrk-1][LctTrkId_] = -999;
229  csctf_.trLctCLCT_pattern[nTrk-1][LctTrkId_] = -999;
230  }
231 
232  ++LctTrkId_;
233 
234  } // for(CSCCorrelatedLCTDigiCollection::const_iterator lctTrk
235  } // for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator lctOfTrks
236 
237  csctf_.trNumLCTs.push_back(LctTrkId_);
238  //}
239  //else
240  // edm::LogInfo("L1NtupleProducer")<<" No valid CSCCorrelatedLCTDigiCollection products found";
241 
243 
244  } //for(L1CSCTrackCollection::const_iterator trk=csctfTrks->begin(); trk<csctfTrks->end(); trk++,nTrk++){
245 }
246 
247 
248 
249 //ALL csctf lcts
251 {
252 
253  int nLCT=0;
255  corrLct = corrlcts.product()->begin();
256  corrLct != corrlcts.product()->end() ; corrLct++){
257 
258  nLCT++;
259 
260  int lctId = 0;
261 
263  corrlcts.product()->get((*corrLct).first);
264 
266  lct = lctRange.first ;
267  lct != lctRange.second; lct++, lctId++){
268 
269  csctf_.lctEndcap.push_back((*corrLct).first.zendcap());
270  if ((*corrLct).first.zendcap() > 0)
271  csctf_.lctSector.push_back((*corrLct).first.triggerSector());
272  else
273  csctf_.lctSector.push_back(6+(*corrLct).first.triggerSector());
274 
275  csctf_.lctSubSector.push_back(CSCTriggerNumbering::triggerSubSectorFromLabels((*corrLct).first));
276  csctf_.lctBx.push_back(lct->getBX());
277  csctf_.lctBx0.push_back(lct->getBX0());
278 
279  csctf_.lctStation.push_back((*corrLct).first.station());
280  csctf_.lctRing.push_back((*corrLct).first.ring());
281  csctf_.lctChamber.push_back((*corrLct).first.chamber());
282  csctf_.lctTriggerCSCID.push_back((*corrLct).first.triggerCscId());
283  csctf_.lctFpga.push_back((csctf_.lctSubSector.back() ? csctf_.lctSubSector.back() : (*corrLct).first.station()+1));
284 
285 
286  // Check if DetId is within range
287  if( csctf_.lctSector.back() < 1 || csctf_.lctSector.back() > 12 ||
288  csctf_.lctStation.back() < 1 || csctf_.lctStation.back() > 4 ||
289  csctf_.lctTriggerCSCID.back() < 1 || csctf_.lctTriggerCSCID.back() > 9 ||
290  lctId < 0 || lctId > 1 ){
291 
292  edm::LogInfo("L1NtupleProducer")<<" LCT ERROR: CSC digi are out of range: ";
293 
294  continue;
295  }
296 
297  // handles not to overload the method: mostly for readability
298  int endcap = (*corrLct).first.zendcap();
299  if (endcap < 0) endcap = 0;
300 
301  int StationLct = (*corrLct).first.station();
302  int CscIdLct = (*corrLct).first.triggerCscId();
303  int SubSectorLct =
305 
306  int FPGALct = ( SubSectorLct ? SubSectorLct-1 : StationLct );
307 
308 
309  // local Phi
310  lclphidat lclPhi;
311 
312 /*
313  try {
314 
315  csctf_.lctstripNum.push_back(lct->getStrip());
316 
317 
318  csctf_.lctlocalPhi.push_back(lclPhi.phi_local);
319  }
320  catch(...) {
321  bzero(&lclPhi,sizeof(lclPhi));
322  csctf_.lctlocalPhi.push_back(-999);
323  }
324 
325 */
326  try {
327 
328  csctf_.lctstripNum.push_back(lct->getStrip());
329  lclPhi = srLUTs_[FPGALct][endcap] -> localPhi(lct->getStrip(),
330  lct->getPattern(),
331  lct->getQuality(),
332  lct->getBend() );
333 
334  csctf_.lctlocalPhi.push_back(lclPhi.phi_local);
335  //csctf_.lctlocalPhi_bend.push_back(lclPhi.phi_bend_local);
336  //csctf_.lctCLCT_pattern.push_back(lct->getPattern());
337  csctf_.lctQuality.push_back(lct->getQuality());
338  //std::cout <<"localPhi: lclPhi.phi_bend_local = " << lclPhi.phi_bend_local << std::endl;
339  //std::cout <<"localPhi: lct->getBend() = " << lct->getBend() << std::endl;
340 
341  }
342  catch(...) {
343  bzero(&lclPhi,sizeof(lclPhi));
344  csctf_.lctlocalPhi.push_back(-999);
345  //csctf_.lctlocalPhi_bend.push_back(-999);
346  //csctf_.lctCLCT_pattern.push_back(-999);
347  csctf_.lctQuality.push_back(-999);
348  }
349 
350  // Global Phi
351  gblphidat gblPhi;
352 
353  try {
354 
355  csctf_.lctwireGroup.push_back(lct->getKeyWG());
356 
357  //std::cout << "lclPhi.phi_local: " << lclPhi.phi_local << std::endl;
358  //std::cout << "lct->getKeyWG(): " << lct->getKeyWG() << std::endl;
359  //std::cout << "CscIdLct: " << CscIdLct << std::endl;
360 
361  gblPhi = srLUTs_[FPGALct][endcap] -> globalPhiME(lclPhi.phi_local ,
362  lct->getKeyWG(),
363  CscIdLct);
364  csctf_.lctglobalPhi.push_back(gblPhi.global_phi);
365 
366 
367  } catch(...) {
368  bzero(&gblPhi,sizeof(gblPhi));
369  csctf_.lctglobalPhi.push_back(-999);
370  }
371 
372  // Global Eta
373  gbletadat gblEta;
374 
375  try {
376  gblEta = srLUTs_[FPGALct][endcap] -> globalEtaME(lclPhi.phi_bend_local,
377  lclPhi.phi_local ,
378  lct->getKeyWG() ,
379  CscIdLct);
380  //std::cout <<"gblEta: lclPhi.phi_bend_local = " << lclPhi.phi_bend_local << std::endl;
381  csctf_.lctglobalEta.push_back(gblEta.global_eta);
382  csctf_.lctCLCT_pattern.push_back(gblEta.global_bend);
383  }
384  catch(...) {
385  bzero(&gblEta,sizeof(gblEta));
386  csctf_.lctglobalEta.push_back(-999);
387  csctf_.lctCLCT_pattern.push_back(-999);
388  }
389 
390  } // for(CSCCorrelatedLCTDigiCollection::const_iterator lct
391  } // for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator lct
392 
393  csctf_.lctSize = nLCT;
394 
395 }
396 
397 
399 {
400  int nStat=0;
401  for(std::vector<L1CSCSPStatusDigi>::const_iterator stat=status->second.begin();
402  stat!=status->second.end(); stat++){
403 
404  // fill the Ntuple
405  if (stat->VPs() != 0) {
406 
407  csctf_.stSPslot.push_back(stat->slot());
408  csctf_.stL1A_BXN.push_back(stat->BXN());
409  csctf_.stTrkCounter.push_back((const_cast<L1CSCSPStatusDigi*>(&(*stat)))->track_counter());
410  csctf_.stOrbCounter.push_back((const_cast<L1CSCSPStatusDigi*>(&(*stat)))->orbit_counter());
411 
412  nStat++;
413  }
414  }
415 
416  csctf_.nsp = nStat;
417 }
418 
419 //DT Stubs added by Alex Ji
420 //Code modeled from DQM/L1TMonitor/src/L1TCSCTF.cc, v1.36
422  //get the vector of DT Stubs
423  std::vector<csctf::TrackStub> vstubs = dtStubs->get();
424  //iterate through DT Stubs
425  for (std::vector<csctf::TrackStub>::const_iterator stub = vstubs.begin();
426  stub != vstubs.end(); stub++) {
427  csctf_.dtBXN.push_back(stub->BX());
428  csctf_.dtFLAG.push_back(stub->getStrip()); //getStrip() is actually the "FLAG" bit
429  csctf_.dtCAL.push_back(stub->getKeyWG()); //getKeyWG() is actually the "CAL" bit
430 
431  csctf_.dtSector.push_back( 6*(stub->endcap()-1) + stub->sector() );
432  csctf_.dtSubSector.push_back(stub->subsector());
433 
434  csctf_.dtBX0.push_back(stub->getBX0()); //it is unclear what this variable is...
435  csctf_.dtPhiBend.push_back(stub->getBend());
436  csctf_.dtPhiPacked.push_back(stub->phiPacked());
437  csctf_.dtQuality.push_back(stub->getQuality());
438  }
439 
440  csctf_.dtSize = vstubs.size();
441 }
const double Pi
ptdat Pt(const ptadd &) const
Definition: CSCTFPtLUT.cc:183
const L1MuScale * getPtScale() const
get the Pt scale
void SetStatus(const edm::Handle< L1CSCStatusDigiCollection > status)
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
virtual float getCenter(unsigned packed) const =0
get the center of bin represented by packed
U second(std::pair< T, U > const &p)
void SetTracks(const edm::Handle< L1CSCTrackCollection > csctfTrks, const L1MuTriggerScales *ts, const L1MuTriggerPtScale *tpts, CSCSectorReceiverLUT *srLUTs_[5][2], CSCTFPtLUT *ptLUTs_)
const L1MuScale * getPhiScale() const
get the phi scale
T const * product() const
Definition: Handle.h:81
class pt_address ptadd
class pt_data ptdat
class global_phi_data gblphidat
class local_phi_address lclphiadd
std::vector< CSCCorrelatedLCTDigi >::const_iterator const_iterator
class local_phi_data lclphidat
Data Types.
static int triggerSubSectorFromLabels(int station, int chamber)
const L1MuScale * getRegionalEtaScale(int isys) const
get the regioanl muon trigger eta scale, isys = 0(DT), 1(bRPC), 2(CSC), 3(fwdRPC) ...
void SetLCTs(const edm::Handle< CSCCorrelatedLCTDigiCollection > corrlcts, CSCSectorReceiverLUT *srLUTs_[5][2])
std::pair< const_iterator, const_iterator > Range
void SetDTStubs(const edm::Handle< CSCTriggerContainer< csctf::TrackStub > > dtStubs)
tuple status
Definition: ntuplemaker.py:245
class global_eta_data gbletadat