CMS 3D CMS Logo

CSCTFAnalyzer.cc
Go to the documentation of this file.
4 
5 #include <strings.h>
6 #include <cerrno>
7 #include <iostream>
8 #include <iomanip>
9 
10 CSCTFAnalyzer::CSCTFAnalyzer(const edm::ParameterSet& conf) : edm::EDAnalyzer() {
11  mbProducer = conf.getUntrackedParameter<edm::InputTag>("mbProducer", edm::InputTag("csctfunpacker"));
12  lctProducer = conf.getUntrackedParameter<edm::InputTag>("lctProducer", edm::InputTag("csctfunpacker"));
13  trackProducer = conf.getUntrackedParameter<edm::InputTag>("trackProducer", edm::InputTag("csctfunpacker"));
14  statusProducer = conf.getUntrackedParameter<edm::InputTag>("statusProducer", edm::InputTag("csctfunpacker"));
15  file = new TFile("ewq.root", "RECREATE");
16  tree = new TTree("dy", "QWE");
17  tree->Branch("dtPhi_1_plus", &dtPhi[0][0], "dtPhi_1_plus/I");
18  tree->Branch("dtPhi_2_plus", &dtPhi[1][0], "dtPhi_2_plus/I");
19  tree->Branch("dtPhi_3_plus", &dtPhi[2][0], "dtPhi_3_plus/I");
20  tree->Branch("dtPhi_4_plus", &dtPhi[3][0], "dtPhi_4_plus/I");
21  tree->Branch("dtPhi_5_plus", &dtPhi[4][0], "dtPhi_5_plus/I");
22  tree->Branch("dtPhi_6_plus", &dtPhi[5][0], "dtPhi_6_plus/I");
23  tree->Branch("dtPhi_7_plus", &dtPhi[6][0], "dtPhi_7_plus/I");
24  tree->Branch("dtPhi_8_plus", &dtPhi[7][0], "dtPhi_8_plus/I");
25  tree->Branch("dtPhi_9_plus", &dtPhi[8][0], "dtPhi_9_plus/I");
26  tree->Branch("dtPhi_10_plus", &dtPhi[9][0], "dtPhi_10_plus/I");
27  tree->Branch("dtPhi_11_plus", &dtPhi[10][0], "dtPhi_11_plus/I");
28  tree->Branch("dtPhi_12_plus", &dtPhi[11][0], "dtPhi_12_plus/I");
29  tree->Branch("dtPhi_1_minus", &dtPhi[0][1], "dtPhi_1_minus/I");
30  tree->Branch("dtPhi_2_minus", &dtPhi[1][1], "dtPhi_2_minus/I");
31  tree->Branch("dtPhi_3_minus", &dtPhi[2][1], "dtPhi_3_minus/I");
32  tree->Branch("dtPhi_4_minus", &dtPhi[3][1], "dtPhi_4_minus/I");
33  tree->Branch("dtPhi_5_minus", &dtPhi[4][1], "dtPhi_5_minus/I");
34  tree->Branch("dtPhi_6_minus", &dtPhi[5][1], "dtPhi_6_minus/I");
35  tree->Branch("dtPhi_7_minus", &dtPhi[6][1], "dtPhi_7_minus/I");
36  tree->Branch("dtPhi_8_minus", &dtPhi[7][1], "dtPhi_8_minus/I");
37  tree->Branch("dtPhi_9_minus", &dtPhi[8][1], "dtPhi_9_minus/I");
38  tree->Branch("dtPhi_10_minus", &dtPhi[9][1], "dtPhi_10_minus/I");
39  tree->Branch("dtPhi_11_minus", &dtPhi[10][1], "dtPhi_11_minus/I");
40  tree->Branch("dtPhi_12_minus", &dtPhi[11][1], "dtPhi_12_minus/I");
41 
42  L1CSCS_Tok = consumes<L1CSCStatusDigiCollection>(edm::InputTag(statusProducer.label(), statusProducer.instance()));
43  CSCTC_Tok =
44  consumes<CSCTriggerContainer<csctf::TrackStub> >(edm::InputTag(mbProducer.label(), mbProducer.instance()));
45  CSCCDC_Tok = consumes<CSCCorrelatedLCTDigiCollection>(edm::InputTag(lctProducer.label(), lctProducer.instance()));
46  L1CST_Tok = consumes<L1CSCTrackCollection>(edm::InputTag(trackProducer.label(), trackProducer.instance()));
47 }
48 
50  /* edm::Handle<FEDRawDataCollection> rawdata;
51  e.getByToken("source","",rawdata);
52 
53  const FEDRawData& fedData = rawdata->FEDData(750);
54  if( fedData.size()==0 ) return;
55  unsigned short *data = (unsigned short *)fedData.data();
56  unsigned int size = fedData.size()/2;
57  std::cout<<"New event:"<<std::endl;
58  for(unsigned i=0; i<size/4; i++)
59  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;
60  std::cout<<"End of event"<<std::endl;
61  return;
62 */
63  if (statusProducer.label() != "null") {
65  e.getByToken(L1CSCS_Tok, status);
66  if (status.isValid()) {
67  edm::LogInfo("CSCTFAnalyzer") << " Unpacking Errors: " << status->first;
68  for (std::vector<L1CSCSPStatusDigi>::const_iterator stat = status->second.begin(); stat != status->second.end();
69  stat++) {
70  //edm::LogInfo("CSCTFAnalyzer") << " Status: SP in slot "<<stat->slot()<<" FMM: "<<stat->FMM()<<" SE: 0x"<<std::hex<<stat->SEs()<<" VP: 0x"<<stat->VPs()<<std::dec;
71  }
72  } else
73  edm::LogInfo("CSCTFAnalyzer") << " No valid L1CSCStatusDigiCollection products found";
74  }
75 
76  if (mbProducer.label() != "null") {
77  bzero(dtPhi, sizeof(dtPhi));
79  e.getByToken(CSCTC_Tok, dtStubs);
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: ")
90  << " dtSector=" << dtSector << " dtEndcap=" << dtEndcap;
91  }
92  edm::LogInfo("CSCTFAnalyzer") << " DT data: tbin=" << stub->BX() << " CSC sector=" << stub->sector()
93  << " CSC subsector=" << stub->subsector() << " station=" << stub->station()
94  << " endcap=" << stub->endcap() << " phi=" << stub->phiPacked()
95  << " phiBend=" << stub->getBend() << " quality=" << stub->getQuality()
96  << " mb_bxn=" << stub->cscid();
97  }
98  } else
99  edm::LogInfo("CSCTFAnalyzer") << " No valid CSCTriggerContainer<csctf::TrackStub> products found";
100  tree->Fill();
101  }
102 
103  if (lctProducer.label() != "null") {
105  e.getByToken(CSCCDC_Tok, corrlcts);
106  if (corrlcts.isValid()) {
108  csc != corrlcts.product()->end();
109  csc++) {
110  int lctId = 0;
111  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
112  for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range1.first; lct != range1.second; lct++, lctId++) {
113  int station = (*csc).first.station() - 1;
114  int cscId = (*csc).first.triggerCscId() - 1;
115  int sector = (*csc).first.triggerSector() - 1; // + ( (*csc).first.endcap()==1 ? 0 : 6 );
116  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
117  int tbin = lct->getBX();
118  int fpga = (subSector ? subSector - 1 : station + 1);
119  // If Det Id is within range
120  if (sector < 0 || sector > 11 || station < 0 || station > 3 || cscId < 0 || cscId > 8 || lctId < 0 ||
121  lctId > 1) {
122  edm::LogInfo("CSCTFAnalyzer: CSC digi are out of range: ");
123  continue;
124  }
125  edm::LogInfo("CSCTFAnalyzer") << " Front data endcap: " << (*csc).first.endcap()
126  << " station: " << (station + 1) << " sector: " << (sector + 1)
127  << " subSector: " << subSector << " tbin: " << tbin
128  << " cscId: " << (cscId + 1) << " fpga: " << (fpga + 1) << " "
129  << "LCT(vp=" << lct->isValid() << ",qual=" << lct->getQuality()
130  << ",wg=" << lct->getKeyWG() << ",strip=" << lct->getStrip()
131  << ",link=" << lct->getMPCLink() << ")";
132  }
133  }
134  } else
135  edm::LogInfo("CSCTFAnalyzer") << " No valid CSCCorrelatedLCTDigiCollection products found";
136  }
137 
138  if (trackProducer.label() != "null") {
140  e.getByToken(L1CST_Tok, tracks);
141  if (tracks.isValid()) {
142  int nTrk = 0;
143  for (L1CSCTrackCollection::const_iterator trk = tracks->begin(); trk < tracks->end(); trk++, nTrk++) {
144  int sector = 6 * (trk->first.endcap() - 1) + trk->first.sector() - 1;
145  int tbin = trk->first.BX();
146  edm::LogInfo("CSCTFAnalyzer") << " Track sector: " << (sector + 1) << " tbin: " << tbin << " "
147  << "TRK(mode=" << ((trk->first.ptLUTAddress() >> 16) & 0xF)
148  << ",eta=" << trk->first.eta_packed() << ",phi=" << trk->first.localPhi()
149  << ") IDs:"
150  << " me1D=" << trk->first.me1ID() << " t1=" << trk->first.me1Tbin()
151  << " me2D=" << trk->first.me2ID() << " t2=" << trk->first.me2Tbin()
152  << " me3D=" << trk->first.me3ID() << " t3=" << trk->first.me3Tbin()
153  << " me4D=" << trk->first.me4ID() << " t4=" << trk->first.me4Tbin()
154  << " mb1D=" << trk->first.mb1ID() << " tb=" << trk->first.mb1Tbin();
155 
156  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc = trk->second.begin(); csc != trk->second.end();
157  csc++) {
158  int lctId = 0;
159  CSCCorrelatedLCTDigiCollection::Range range1 = trk->second.get((*csc).first);
160  for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range1.first; lct != range1.second;
161  lct++, lctId++) {
162  int station = (*csc).first.station() - 1;
163  int cscId = (*csc).first.triggerCscId() - 1;
164  int sector = (*csc).first.triggerSector() - 1; // + ( (*csc).first.endcap()==1 ? 0 : 6 );
165  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
166  int tbin = lct->getBX();
167  int fpga = (subSector ? subSector - 1 : station + 1);
168  // If Det Id is within range
169  if (sector < 0 || sector > 11 || station < 0 || station > 3 || cscId < 0 || cscId > 8 || lctId < 0 ||
170  lctId > 1) {
171  edm::LogInfo("CSCTFAnalyzer: Digi are out of range: ");
172  continue;
173  }
174  if (lct->getQuality() < 100)
175  edm::LogInfo("CSCTFAnalyzer")
176  << " Linked LCT: " << (*csc).first.endcap() << " station: " << (station + 1)
177  << " sector: " << (sector + 1) << " subSector: " << subSector << " tbin: " << tbin
178  << " cscId: " << (cscId + 1) << " fpga: " << (fpga + 1) << " LCT(vp=" << lct->isValid()
179  << ",qual=" << lct->getQuality() << ",wg=" << lct->getKeyWG() << ",strip=" << lct->getStrip() << ")";
180  else
181  edm::LogInfo("CSCTFAnalyzer")
182  << " Linked MB stub: " << (*csc).first.endcap() << " sector: " << (sector + 1)
183  << " subSector: " << subSector << " tbin: " << tbin << " MB(vp=" << lct->isValid()
184  << ",qual=" << (lct->getQuality() - 100) << ",cal=" << lct->getKeyWG() << ",flag=" << lct->getStrip()
185  << ",bc0=" << lct->getPattern() << ",phiBend=" << lct->getBend() << ",tbin=" << lct->getBX()
186  << ",id=" << lct->getMPCLink() << ",bx0=" << lct->getBX0() << ",se=" << lct->getSyncErr()
187  << ",bxn=" << lct->getCSCID() << ",phi=" << lct->getTrknmb() << ")";
188  }
189  }
190  }
191  } else
192  edm::LogInfo("CSCTFAnalyzer") << " No valid L1CSCTrackCollection products found";
193  }
194 }
CSCTFAnalyzer::L1CST_Tok
edm::EDGetTokenT< L1CSCTrackCollection > L1CST_Tok
Definition: CSCTFAnalyzer.h:31
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CSCTFAnalyzer::mbProducer
edm::InputTag mbProducer
Definition: CSCTFAnalyzer.h:23
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
mps_update.status
status
Definition: mps_update.py:69
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCTFAnalyzer.h
edm
HLT enums.
Definition: AlignableModifier.h:19
tree
Definition: tree.py:1
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
CSCTriggerNumbering::triggerSubSectorFromLabels
static int triggerSubSectorFromLabels(int station, int chamber)
Definition: CSCTriggerNumbering.cc:105
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
CSCTFAnalyzer::trackProducer
edm::InputTag trackProducer
Definition: CSCTFAnalyzer.h:23
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
csc
Definition: L1Track.h:19
CSCTFAnalyzer::dtPhi
int dtPhi[12][2]
Definition: CSCTFAnalyzer.h:26
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
edm::ParameterSet
Definition: ParameterSet.h:47
CSCTFAnalyzer::statusProducer
edm::InputTag statusProducer
Definition: CSCTFAnalyzer.h:23
CSCTFAnalyzer::L1CSCS_Tok
edm::EDGetTokenT< L1CSCStatusDigiCollection > L1CSCS_Tok
Definition: CSCTFAnalyzer.h:28
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
CSCTFAnalyzer::file
TFile * file
Definition: CSCTFAnalyzer.h:25
CSCTFAnalyzer::CSCTFAnalyzer
CSCTFAnalyzer(const edm::ParameterSet &conf)
Definition: CSCTFAnalyzer.cc:10
CSCTFAnalyzer::CSCCDC_Tok
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > CSCCDC_Tok
Definition: CSCTFAnalyzer.h:30
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
CSCTFAnalyzer::lctProducer
edm::InputTag lctProducer
Definition: CSCTFAnalyzer.h:23
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::Event
Definition: Event.h:73
CSCTFAnalyzer::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: CSCTFAnalyzer.cc:49
edm::Log
Definition: MessageLogger.h:70
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
CSCTFAnalyzer::CSCTC_Tok
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > CSCTC_Tok
Definition: CSCTFAnalyzer.h:29