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