CMS 3D CMS Logo

L1TRPCTPG.cc
Go to the documentation of this file.
1 /*
2  * \file L1TRPCTPG.cc
3  *
4  * \author J. Berryhill
5  *
6  */
7 
9 
10 using namespace std;
11 using namespace edm;
12 
14  : rpctpgSource_( ps.getParameter< InputTag >("rpctpgSource") ),
15  rpctpgSource_token_( consumes<RPCDigiCollection>(ps.getParameter< InputTag >("rpctpgSource") )),
16  rpctfSource_( ps.getParameter< InputTag >("rpctfSource") ),
17  rpctfSource_token_( consumes<L1MuGMTReadoutCollection>(ps.getParameter< InputTag >("rpctfSource") ))
18 {
19 
20  // verbosity switch
21  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
22 
23  if(verbose_) cout << "L1TRPCTPG: constructor...." << endl;
24 
25  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
26  if ( !outputFile_.empty() ) {
27  cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
28  }
29 
30  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
31  if(disable){
32  outputFile_="";
33  }
34 }
35 
37 {
38 }
39 
41  //
42 }
43 
44 
45 
47 {
48 
49  nev_ = 0;
50 
51  ibooker.setCurrentFolder("L1T/L1TRPCTPG");
52 
53  rpctpgbx = ibooker.book1D("RPCTPG_bx",
54  "RPC digis bx - all events", 9, -4.5, 4.5 ) ;
55 
56  rpctpgndigi[1] = ibooker.book1D("RPCTPG_ndigi",
57  "RPCTPG nDigi bx 0", 100, -0.5, 99.5 ) ;
58  rpctpgndigi[2] = ibooker.book1D("RPCTPG_ndigi_+1",
59  "RPCTPG nDigi bx +1", 100, -0.5, 99.5 ) ;
60  rpctpgndigi[0] = ibooker.book1D("RPCTPG_ndigi_-1",
61  "RPCTPG nDigi bx -1", 100, -0.5, 99.5 ) ;
62 
63 
64 
65  m_digiBxRPCBar = ibooker.book1D("RPCDigiRPCBmu_noDTmu_bx",
66  "RPC digis bx - RPC, !DT", 9, -4.5, 4.5 ) ;
67 
68  m_digiBxRPCEnd = ibooker.book1D("RPCDigiRPCEmu_noCSCmu_bx",
69  "RPC digis bx - RPC, !CSC", 9, -4.5, 4.5 ) ;
70 
71  m_digiBxDT = ibooker.book1D("RPCDigiDTmu_noRPCBmu_bx",
72  "RPC digis bx - !RPC, DT", 9, -4.5, 4.5 ) ;
73 
74  m_digiBxCSC = ibooker.book1D("RPCDigiCSCmu_noRPCEmu_bx",
75  "RPC digis bx - !RPC, CSC", 9, -4.5, 4.5 ) ;
76 }
77 
78 
79 void L1TRPCTPG::analyze(const Event& e, const EventSetup& c)
80 {
81  nev_++;
82  if(verbose_) cout << "L1TRPCTPG: analyze...." << endl;
83 
84 
87  c.get<MuonGeometryRecord>().get(rpcGeo);
88  if (!rpcGeo.isValid()) {
89  edm::LogInfo("DataNotFound") << "can't find RPCGeometry" << endl;
90  return;
91  }
92 // char layerLabel[328];
93 // char meId [328];
94 
95 
98  e.getByToken(rpctpgSource_token_,rpcdigis);
99 
100  if (!rpcdigis.isValid()) {
101  edm::LogInfo("DataNotFound") << "can't find RPCDigiCollection with label "<< rpctpgSource_ << endl;
102  return;
103  }
104 
105  // Calculate the number of DT and CSC cands present
107  e.getByToken(rpctfSource_token_,pCollection);
108 
109  if (!pCollection.isValid()) {
110  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label "
111  << rpctfSource_.label() ;
112  return;
113  }
114 
115  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
116  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
117  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
118 
119  int nRPCTrackBarrel, nRPCTrackEndcap , nDTTrack, nCSCTrack;
120  nRPCTrackBarrel = 0;
121  nRPCTrackEndcap = 0;
122  nDTTrack = 0;
123  nCSCTrack = 0;
124 
125  for( RRItr = gmt_records.begin() ;
126  RRItr != gmt_records.end() ;
127  RRItr++ )
128  {
129  // DTs
130  vector<L1MuRegionalCand> DTCands = RRItr->getDTBXCands();
131  for( vector<L1MuRegionalCand>::const_iterator
132  ECItr = DTCands.begin() ;
133  ECItr != DTCands.end() ;
134  ++ECItr )
135  {
136  if (!ECItr->empty()) { ++nDTTrack; }
137  }
138  // CSCs
139  vector<L1MuRegionalCand> CSCCands = RRItr->getCSCCands();
140  for( vector<L1MuRegionalCand>::const_iterator
141  ECItr = CSCCands.begin() ;
142  ECItr != CSCCands.end() ;
143  ++ECItr )
144  {
145  if (!ECItr->empty()) { ++nCSCTrack; }
146  }
147 
148  //RPC barrel
149  vector<L1MuRegionalCand> RPCBCands = RRItr->getBrlRPCCands();
150  for( vector<L1MuRegionalCand>::const_iterator
151  ECItr = RPCBCands.begin() ;
152  ECItr != RPCBCands.end() ;
153  ++ECItr )
154  {
155  if (!ECItr->empty()) { ++nRPCTrackBarrel; }
156  }
157 
158  //RPC endcap
159  vector<L1MuRegionalCand> RPCECands = RRItr->getFwdRPCCands();
160  for( vector<L1MuRegionalCand>::const_iterator
161  ECItr = RPCECands.begin() ;
162  ECItr != RPCECands.end() ;
163  ++ECItr )
164  {
165  if (!ECItr->empty()) { ++nRPCTrackEndcap; }
166  }
167  }
168 
169  int numberofDigi[3] = {0,0,0};
170 
171 
173  for(collectionItr=rpcdigis->begin(); collectionItr!=rpcdigis->end(); ++collectionItr){
174 
176  for (digiItr = ((*collectionItr ).second).first;
177  digiItr!=((*collectionItr).second).second; ++digiItr){
178 
179  // strips is a list of hit strips (regardless of bx) for this roll
180 // int strip= (*digiItr).strip();
181 // strips.push_back(strip);
182  int bx=(*digiItr).bx();
183  rpctpgbx->Fill(bx);
184  //
185 
186  if ( nRPCTrackBarrel == 0 && nDTTrack != 0) {
187  m_digiBxDT->Fill(bx);
188  } else if ( nRPCTrackBarrel != 0 && nDTTrack == 0) {
189  m_digiBxRPCBar->Fill(bx);
190  }
191 
192  if ( nRPCTrackEndcap == 0 && nCSCTrack != 0) {
193  m_digiBxCSC->Fill(bx);
194  } else if ( nRPCTrackEndcap != 0 && nCSCTrack == 0) {
195  m_digiBxRPCEnd->Fill(bx);
196  }
197 
198 
199 
200 
201 
202  if (bx == -1)
203  {
204  numberofDigi[0]++;
205  }
206  if (bx == 0)
207  {
208 // sprintf(meId,"Occupancy_%s",detUnitLabel);
209 // meMap[meId]->Fill(strip);
210  numberofDigi[1]++;
211  }
212  if (bx == 2)
213  {
214  numberofDigi[2]++;
215  }
216 
217 // sprintf(meId,"BXN_%s",detUnitLabel);
218 // meMap[meId]->Fill(bx);
219 // sprintf(meId,"BXN_vs_strip_%s",detUnitLabel);
220 // meMap[meId]->Fill(strip,bx);
221 
222  }
223  }
224 
225  rpctpgndigi[0]->Fill(numberofDigi[0]);
226  rpctpgndigi[1]->Fill(numberofDigi[1]);
227  rpctpgndigi[2]->Fill(numberofDigi[2]);
228 
229 
230  if(verbose_) cout << "L1TRPCTPG: end job...." << endl;
231  LogInfo("EndJob") << "analyzed " << nev_ << " events";
232 }
233 
edm::EDGetTokenT< RPCDigiCollection > rpctpgSource_token_
Definition: L1TRPCTPG.h:94
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: L1TRPCTPG.cc:40
MonitorElement * m_digiBxCSC
Definition: L1TRPCTPG.h:84
void Fill(long long x)
U second(std::pair< T, U > const &p)
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override
Definition: L1TRPCTPG.cc:46
L1TRPCTPG(const edm::ParameterSet &ps)
Definition: L1TRPCTPG.cc:13
int nev_
Definition: L1TRPCTPG.h:88
std::string outputFile_
Definition: L1TRPCTPG.h:89
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
bool isValid() const
Definition: HandleBase.h:74
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: L1TRPCTPG.cc:79
MonitorElement * rpctpgndigi[3]
Definition: L1TRPCTPG.h:79
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: Handle.h:81
~L1TRPCTPG() override
Definition: L1TRPCTPG.cc:36
edm::EDGetTokenT< L1MuGMTReadoutCollection > rpctfSource_token_
Definition: L1TRPCTPG.h:96
std::vector< RPCDigi >::const_iterator const_iterator
edm::InputTag rpctpgSource_
Definition: L1TRPCTPG.h:93
std::string const & label() const
Definition: InputTag.h:36
MonitorElement * m_digiBxRPCBar
Definition: L1TRPCTPG.h:81
bool verbose_
Definition: L1TRPCTPG.h:90
MonitorElement * m_digiBxRPCEnd
Definition: L1TRPCTPG.h:82
HLT enums.
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
T get() const
Definition: EventSetup.h:63
edm::InputTag rpctfSource_
Definition: L1TRPCTPG.h:95
MonitorElement * rpctpgbx
Definition: L1TRPCTPG.h:80
bool isValid() const
Definition: ESHandle.h:47
MonitorElement * m_digiBxDT
Definition: L1TRPCTPG.h:83
Definition: Run.h:44