CMS 3D CMS Logo

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