CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCTFAnalyzer.cc
Go to the documentation of this file.
4 
5 
6 #include <strings.h>
7 #include <errno.h>
8 #include <iostream>
9 #include <iomanip>
10 
16 
18  mbProducer = conf.getUntrackedParameter<edm::InputTag>("mbProducer",edm::InputTag("csctfunpacker"));
19  lctProducer = conf.getUntrackedParameter<edm::InputTag>("lctProducer",edm::InputTag("csctfunpacker"));
20  trackProducer = conf.getUntrackedParameter<edm::InputTag>("trackProducer",edm::InputTag("csctfunpacker"));
21  statusProducer= conf.getUntrackedParameter<edm::InputTag>("statusProducer",edm::InputTag("csctfunpacker"));
22  file = new TFile("ewq.root","RECREATE");
23  tree = new TTree("dy","QWE");
24  tree->Branch("dtPhi_1_plus",&dtPhi[0][0],"dtPhi_1_plus/I");
25  tree->Branch("dtPhi_2_plus",&dtPhi[1][0],"dtPhi_2_plus/I");
26  tree->Branch("dtPhi_3_plus",&dtPhi[2][0],"dtPhi_3_plus/I");
27  tree->Branch("dtPhi_4_plus",&dtPhi[3][0],"dtPhi_4_plus/I");
28  tree->Branch("dtPhi_5_plus",&dtPhi[4][0],"dtPhi_5_plus/I");
29  tree->Branch("dtPhi_6_plus",&dtPhi[5][0],"dtPhi_6_plus/I");
30  tree->Branch("dtPhi_7_plus",&dtPhi[6][0],"dtPhi_7_plus/I");
31  tree->Branch("dtPhi_8_plus",&dtPhi[7][0],"dtPhi_8_plus/I");
32  tree->Branch("dtPhi_9_plus",&dtPhi[8][0],"dtPhi_9_plus/I");
33  tree->Branch("dtPhi_10_plus",&dtPhi[9][0],"dtPhi_10_plus/I");
34  tree->Branch("dtPhi_11_plus",&dtPhi[10][0],"dtPhi_11_plus/I");
35  tree->Branch("dtPhi_12_plus",&dtPhi[11][0],"dtPhi_12_plus/I");
36  tree->Branch("dtPhi_1_minus",&dtPhi[0][1],"dtPhi_1_minus/I");
37  tree->Branch("dtPhi_2_minus",&dtPhi[1][1],"dtPhi_2_minus/I");
38  tree->Branch("dtPhi_3_minus",&dtPhi[2][1],"dtPhi_3_minus/I");
39  tree->Branch("dtPhi_4_minus",&dtPhi[3][1],"dtPhi_4_minus/I");
40  tree->Branch("dtPhi_5_minus",&dtPhi[4][1],"dtPhi_5_minus/I");
41  tree->Branch("dtPhi_6_minus",&dtPhi[5][1],"dtPhi_6_minus/I");
42  tree->Branch("dtPhi_7_minus",&dtPhi[6][1],"dtPhi_7_minus/I");
43  tree->Branch("dtPhi_8_minus",&dtPhi[7][1],"dtPhi_8_minus/I");
44  tree->Branch("dtPhi_9_minus",&dtPhi[8][1],"dtPhi_9_minus/I");
45  tree->Branch("dtPhi_10_minus",&dtPhi[9][1],"dtPhi_10_minus/I");
46  tree->Branch("dtPhi_11_minus",&dtPhi[10][1],"dtPhi_11_minus/I");
47  tree->Branch("dtPhi_12_minus",&dtPhi[11][1],"dtPhi_12_minus/I");
48 }
49 
51 /* edm::Handle<FEDRawDataCollection> rawdata;
52  e.getByLabel("source","",rawdata);
53 
54  const FEDRawData& fedData = rawdata->FEDData(750);
55  if( fedData.size()==0 ) return;
56  unsigned short *data = (unsigned short *)fedData.data();
57  unsigned int size = fedData.size()/2;
58  std::cout<<"New event:"<<std::endl;
59  for(unsigned i=0; i<size/4; i++)
60  std::cout<<std::hex<<" "<<std::setw(6)<<data[i*4+0]<<" "<<std::setw(6)<<data[i*4+1]<<" "<<std::setw(6)<<data[i*4+2]<<" "<<std::setw(6)<<data[i*4+3]<<std::dec<<std::endl;
61  std::cout<<"End of event"<<std::endl;
62  return;
63 */
64  if( statusProducer.label() != "null" ){
67  if( status.isValid() ){
68  edm::LogInfo("CSCTFAnalyzer") << " Unpacking Errors: "<<status->first;
69  for(std::vector<L1CSCSPStatusDigi>::const_iterator stat=status->second.begin();
70  stat!=status->second.end(); stat++){
71  //edm::LogInfo("CSCTFAnalyzer") << " Status: SP in slot "<<stat->slot()<<" FMM: "<<stat->FMM()<<" SE: 0x"<<std::hex<<stat->SEs()<<" VP: 0x"<<stat->VPs()<<std::dec;
72  }
73  } else edm::LogInfo("CSCTFAnalyzer")<<" No valid L1CSCStatusDigiCollection products found";
74  }
75 
76  if( mbProducer.label() != "null" ){
77  bzero(dtPhi,sizeof(dtPhi));
80  if( dtStubs.isValid() ){
81  std::vector<csctf::TrackStub> vstubs = dtStubs->get();
82  std::cout<<"DT size="<<vstubs.end()-vstubs.begin()<<std::endl;
83  for(std::vector<csctf::TrackStub>::const_iterator stub=vstubs.begin(); stub!=vstubs.end(); stub++){
84  int dtSector =(stub->sector()-1)*2 + stub->subsector()-1;
85  int dtEndcap = stub->endcap()-1;
86  if( dtSector>=0 && dtSector<12 && dtEndcap>=0 && dtEndcap<2 ){
87  dtPhi[dtSector][dtEndcap] = stub->phiPacked();
88  } else {
89  edm::LogInfo("CSCTFAnalyzer: DT digi are out of range: ")<<" dtSector="<<dtSector<<" dtEndcap="<<dtEndcap;
90  }
91  edm::LogInfo("CSCTFAnalyzer")<<" DT data: tbin="<<stub->BX()<<" CSC sector="<<stub->sector()<<" CSC subsector="<<stub->subsector()<<" station="<<stub->station()<<" endcap="<<stub->endcap()
92  <<" phi="<<stub->phiPacked()<<" phiBend="<<stub->getBend()<<" quality="<<stub->getQuality()<<" mb_bxn="<<stub->cscid();
93  }
94  } else edm::LogInfo("CSCTFAnalyzer")<<" No valid CSCTriggerContainer<csctf::TrackStub> products found";
95  tree->Fill();
96  }
97 
98  if( lctProducer.label() != "null" ){
101  if( corrlcts.isValid() ){
102  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++){
103  int lctId=0;
104  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
105  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++,lctId++){
106  int station = (*csc).first.station()-1;
107  int cscId = (*csc).first.triggerCscId()-1;
108  int sector = (*csc).first.triggerSector()-1;// + ( (*csc).first.endcap()==1 ? 0 : 6 );
109  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
110  int tbin = lct->getBX();
111  int fpga = ( subSector ? subSector-1 : station+1 );
112  // If Det Id is within range
113  if( sector<0 || sector>11 || station<0 || station>3 || cscId<0 || cscId>8 || lctId<0 || lctId>1){
114  edm::LogInfo("CSCTFAnalyzer: CSC digi are out of range: ");
115  continue;
116  }
117  edm::LogInfo("CSCTFAnalyzer")<<" Front data endcap: "<<(*csc).first.endcap()<<" station: "<<(station+1)<<" sector: "<<(sector+1)<<" subSector: "<<subSector<<" tbin: "<<tbin<<" cscId: "<<(cscId+1)<<" fpga: "<<(fpga+1)<<" "<<
118  "LCT(vp="<<lct->isValid()<<",qual="<<lct->getQuality()<<",wg="<<lct->getKeyWG()<<",strip="<<lct->getStrip()<<",link="<<lct->getMPCLink()<<")";
119  }
120  }
121  } else edm::LogInfo("CSCTFAnalyzer")<<" No valid CSCCorrelatedLCTDigiCollection products found";
122  }
123 
124  if( trackProducer.label() != "null" ){
127  if( tracks.isValid() ){
128  int nTrk=0;
129  for(L1CSCTrackCollection::const_iterator trk=tracks->begin(); trk<tracks->end(); trk++,nTrk++){
130  int sector = 6*(trk->first.endcap()-1)+trk->first.sector()-1;
131  int tbin = trk->first.BX();
132  edm::LogInfo("CSCTFAnalyzer") << " Track sector: "<<(sector+1)<<" tbin: "<<tbin<<" "<<
133  "TRK(mode="<<((trk->first.ptLUTAddress()>>16)&0xF)<<",eta="<<trk->first.eta_packed()<<",phi="<<trk->first.localPhi()<<") IDs:"
134  <<" me1D="<<trk->first.me1ID()<<" t1="<<trk->first.me1Tbin()
135  <<" me2D="<<trk->first.me2ID()<<" t2="<<trk->first.me2Tbin()
136  <<" me3D="<<trk->first.me3ID()<<" t3="<<trk->first.me3Tbin()
137  <<" me4D="<<trk->first.me4ID()<<" t4="<<trk->first.me4Tbin()
138  <<" mb1D="<<trk->first.mb1ID()<<" tb="<<trk->first.mb1Tbin();
139 
140  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=trk->second.begin(); csc!=trk->second.end(); csc++){
141  int lctId=0;
142  CSCCorrelatedLCTDigiCollection::Range range1 = trk->second.get((*csc).first);
143  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++,lctId++){
144  int station = (*csc).first.station()-1;
145  int cscId = (*csc).first.triggerCscId()-1;
146  int sector = (*csc).first.triggerSector()-1;// + ( (*csc).first.endcap()==1 ? 0 : 6 );
147  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
148  int tbin = lct->getBX();
149  int fpga = ( subSector ? subSector-1 : station+1 );
150  // If Det Id is within range
151  if( sector<0 || sector>11 || station<0 || station>3 || cscId<0 || cscId>8 || lctId<0 || lctId>1){
152  edm::LogInfo("CSCTFAnalyzer: Digi are out of range: ");
153  continue;
154  }
155  if( lct->getQuality() < 100 )
156  edm::LogInfo("CSCTFAnalyzer")<<" Linked LCT: "<<(*csc).first.endcap()<<" station: "<<(station+1)<<" sector: "<<(sector+1)<<" subSector: "<<subSector<<" tbin: "<<tbin
157  <<" cscId: "<<(cscId+1)<<" fpga: "<<(fpga+1)<<" LCT(vp="<<lct->isValid()<<",qual="<<lct->getQuality()<<",wg="<<lct->getKeyWG()<<",strip="<<lct->getStrip()<<")";
158  else
159  edm::LogInfo("CSCTFAnalyzer")<<" Linked MB stub: "<<(*csc).first.endcap()<<" sector: "<<(sector+1)<<" subSector: "<<subSector<<" tbin: "<<tbin
160  <<" MB(vp="<<lct->isValid()<<",qual="<<(lct->getQuality()-100)<<",cal="<<lct->getKeyWG()<<",flag="<<lct->getStrip()<<",bc0="<<lct->getPattern()<<",phiBend="<<lct->getBend()
161  <<",tbin="<<lct->getBX()<<",id="<<lct->getMPCLink()<<",bx0="<<lct->getBX0()<<",se="<<lct->getSyncErr()<<",bxn="<<lct->getCSCID()<<",phi="<<lct->getTrknmb()<<")";
162  }
163  }
164  }
165  } else edm::LogInfo("CSCTFAnalyzer")<<" No valid L1CSCTrackCollection products found";
166  }
167 }
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag mbProducer
Definition: CSCTFAnalyzer.h:14
CSCTFAnalyzer(const edm::ParameterSet &conf)
void analyze(const edm::Event &e, const edm::EventSetup &c)
edm::InputTag lctProducer
Definition: CSCTFAnalyzer.h:14
edm::InputTag statusProducer
Definition: CSCTFAnalyzer.h:14
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple conf
Definition: dbtoconf.py:185
edm::InputTag trackProducer
Definition: CSCTFAnalyzer.h:14
tuple tracks
Definition: testEve_cfg.py:39
std::vector< CSCCorrelatedLCTDigi >::const_iterator const_iterator
static int triggerSubSectorFromLabels(int station, int chamber)
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:42
int dtPhi[12][2]
Definition: CSCTFAnalyzer.h:17
std::pair< const_iterator, const_iterator > Range
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
std::string const & instance() const
Definition: InputTag.h:43