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 
26  dbe = NULL;
27  if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
28  {
30  dbe->setVerbose(0);
31  }
32 
33  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
34  if ( outputFile_.size() != 0 ) {
35  cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
36  }
37 
38  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
39  if(disable){
40  outputFile_="";
41  }
42 
43 
44  if ( dbe !=NULL ) {
45  dbe->setCurrentFolder("L1T/L1TRPCTPG");
46  }
47 
48 
49 }
50 
52 {
53 }
54 
56 {
57  nev_ = 0;
58 }
59 
60 void L1TRPCTPG::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup)
61 {
62  if ( dbe ) {
63  dbe->setCurrentFolder("L1T/L1TRPCTPG");
64  dbe->rmdir("L1T/L1TRPCTPG");
65  }
66 
67 
68  if ( dbe )
69  {
70  dbe->setCurrentFolder("L1T/L1TRPCTPG");
71  rpctpgbx = dbe->book1D("RPCTPG_bx",
72  "RPC digis bx - all events", 9, -4.5, 4.5 ) ;
73 
74  rpctpgndigi[1] = dbe->book1D("RPCTPG_ndigi",
75  "RPCTPG nDigi bx 0", 100, -0.5, 99.5 ) ;
76  rpctpgndigi[2] = dbe->book1D("RPCTPG_ndigi_+1",
77  "RPCTPG nDigi bx +1", 100, -0.5, 99.5 ) ;
78  rpctpgndigi[0] = dbe->book1D("RPCTPG_ndigi_-1",
79  "RPCTPG nDigi bx -1", 100, -0.5, 99.5 ) ;
80 
81 
82 
83  m_digiBxRPCBar = dbe->book1D("RPCDigiRPCBmu_noDTmu_bx",
84  "RPC digis bx - RPC, !DT", 9, -4.5, 4.5 ) ;
85 
86  m_digiBxRPCEnd = dbe->book1D("RPCDigiRPCEmu_noCSCmu_bx",
87  "RPC digis bx - RPC, !CSC", 9, -4.5, 4.5 ) ;
88 
89  m_digiBxDT = dbe->book1D("RPCDigiDTmu_noRPCBmu_bx",
90  "RPC digis bx - !RPC, DT", 9, -4.5, 4.5 ) ;
91 
92  m_digiBxCSC = dbe->book1D("RPCDigiCSCmu_noRPCEmu_bx",
93  "RPC digis bx - !RPC, CSC", 9, -4.5, 4.5 ) ;
94  }
95 }
96 
97 
99 {
100  if(verbose_) cout << "L1TRPCTPG: end job...." << endl;
101  LogInfo("EndJob") << "analyzed " << nev_ << " events";
102 
103  if ( outputFile_.size() != 0 && dbe ) dbe->save(outputFile_);
104 
105  return;
106 }
107 
108 void L1TRPCTPG::analyze(const Event& e, const EventSetup& c)
109 {
110  nev_++;
111  if(verbose_) cout << "L1TRPCTPG: analyze...." << endl;
112 
113 
116  c.get<MuonGeometryRecord>().get(rpcGeo);
117  if (!rpcGeo.isValid()) {
118  edm::LogInfo("DataNotFound") << "can't find RPCGeometry" << endl;
119  return;
120  }
121 // char layerLabel[328];
122 // char meId [328];
123 
124 
127  e.getByToken(rpctpgSource_token_,rpcdigis);
128 
129  if (!rpcdigis.isValid()) {
130  edm::LogInfo("DataNotFound") << "can't find RPCDigiCollection with label "<< rpctpgSource_ << endl;
131  return;
132  }
133 
134  // Calculate the number of DT and CSC cands present
136  e.getByToken(rpctfSource_token_,pCollection);
137 
138  if (!pCollection.isValid()) {
139  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label "
140  << rpctfSource_.label() ;
141  return;
142  }
143 
144  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
145  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
146  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
147 
148  static int nRPCTrackBarrel, nRPCTrackEndcap , nDTTrack, nCSCTrack;
149  nRPCTrackBarrel = 0;
150  nRPCTrackEndcap = 0;
151  nDTTrack = 0;
152  nCSCTrack = 0;
153 
154  for( RRItr = gmt_records.begin() ;
155  RRItr != gmt_records.end() ;
156  RRItr++ )
157  {
158  // DTs
159  vector<L1MuRegionalCand> DTCands = RRItr->getDTBXCands();
160  for( vector<L1MuRegionalCand>::const_iterator
161  ECItr = DTCands.begin() ;
162  ECItr != DTCands.end() ;
163  ++ECItr )
164  {
165  if (!ECItr->empty()) { ++nDTTrack; }
166  }
167  // CSCs
168  vector<L1MuRegionalCand> CSCCands = RRItr->getCSCCands();
169  for( vector<L1MuRegionalCand>::const_iterator
170  ECItr = CSCCands.begin() ;
171  ECItr != CSCCands.end() ;
172  ++ECItr )
173  {
174  if (!ECItr->empty()) { ++nCSCTrack; }
175  }
176 
177  //RPC barrel
178  vector<L1MuRegionalCand> RPCBCands = RRItr->getBrlRPCCands();
179  for( vector<L1MuRegionalCand>::const_iterator
180  ECItr = RPCBCands.begin() ;
181  ECItr != RPCBCands.end() ;
182  ++ECItr )
183  {
184  if (!ECItr->empty()) { ++nRPCTrackBarrel; }
185  }
186 
187  //RPC endcap
188  vector<L1MuRegionalCand> RPCECands = RRItr->getFwdRPCCands();
189  for( vector<L1MuRegionalCand>::const_iterator
190  ECItr = RPCECands.begin() ;
191  ECItr != RPCECands.end() ;
192  ++ECItr )
193  {
194  if (!ECItr->empty()) { ++nRPCTrackEndcap; }
195  }
196  }
197 
198  int numberofDigi[3] = {0,0,0};
199 
200 
202  for(collectionItr=rpcdigis->begin(); collectionItr!=rpcdigis->end(); ++collectionItr){
203 
204  /*RPCDetId detId=(*collectionItr ).first;
205 
206 
207  uint32_t id=detId();
208  char detUnitLabel[328];
209  RPCGeomServ RPCname(detId);
210  std::string nameRoll = RPCname.name();
211  sprintf(detUnitLabel ,"%s",nameRoll.c_str());
212  sprintf(layerLabel ,"%s",nameRoll.c_str());
213  std::map<uint32_t, std::map<std::string,MonitorElement*> >::iterator meItr = rpctpgmeCollection.find(id);
214  if (meItr == rpctpgmeCollection.end() || (rpctpgmeCollection.size()==0)) {
215  rpctpgmeCollection[id]=L1TRPCBookME(detId);
216  }
217  std::map<std::string, MonitorElement*> meMap=rpctpgmeCollection[id];*/
218 
219 
220 // std::vector<int> strips;
221 // std::vector<int> bxs;
222 // strips.clear();
223 // bxs.clear();
225  for (digiItr = ((*collectionItr ).second).first;
226  digiItr!=((*collectionItr).second).second; ++digiItr){
227 
228  // strips is a list of hit strips (regardless of bx) for this roll
229 // int strip= (*digiItr).strip();
230 // strips.push_back(strip);
231  int bx=(*digiItr).bx();
232  rpctpgbx->Fill(bx);
233  //
234 
235  if ( nRPCTrackBarrel == 0 && nDTTrack != 0) {
236  m_digiBxDT->Fill(bx);
237  } else if ( nRPCTrackBarrel != 0 && nDTTrack == 0) {
238  m_digiBxRPCBar->Fill(bx);
239  }
240 
241  if ( nRPCTrackEndcap == 0 && nCSCTrack != 0) {
242  m_digiBxCSC->Fill(bx);
243  } else if ( nRPCTrackEndcap != 0 && nCSCTrack == 0) {
244  m_digiBxRPCEnd->Fill(bx);
245  }
246 
247 
248 
249 
250 
251  if (bx == -1)
252  {
253  numberofDigi[0]++;
254  }
255  if (bx == 0)
256  {
257 // sprintf(meId,"Occupancy_%s",detUnitLabel);
258 // meMap[meId]->Fill(strip);
259  numberofDigi[1]++;
260  }
261  if (bx == 2)
262  {
263  numberofDigi[2]++;
264  }
265 
266 // sprintf(meId,"BXN_%s",detUnitLabel);
267 // meMap[meId]->Fill(bx);
268 // sprintf(meId,"BXN_vs_strip_%s",detUnitLabel);
269 // meMap[meId]->Fill(strip,bx);
270 
271  }
272  }
273 
274  rpctpgndigi[0]->Fill(numberofDigi[0]);
275  rpctpgndigi[1]->Fill(numberofDigi[1]);
276  rpctpgndigi[2]->Fill(numberofDigi[2]);
277 
278 }
279 
edm::EDGetTokenT< RPCDigiCollection > rpctpgSource_token_
Definition: L1TRPCTPG.h:106
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup)
Definition: L1TRPCTPG.cc:60
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1TRPCTPG.cc:108
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define NULL
Definition: scimark2.h:8
MonitorElement * m_digiBxCSC
Definition: L1TRPCTPG.h:96
void Fill(long long x)
U second(std::pair< T, U > const &p)
L1TRPCTPG(const edm::ParameterSet &ps)
Definition: L1TRPCTPG.cc:13
int nev_
Definition: L1TRPCTPG.h:100
std::string outputFile_
Definition: L1TRPCTPG.h:101
DQMStore * dbe
Definition: L1TRPCTPG.h:85
virtual ~L1TRPCTPG()
Definition: L1TRPCTPG.cc:51
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
void setVerbose(unsigned level)
Definition: DQMStore.cc:548
bool isValid() const
Definition: HandleBase.h:76
MonitorElement * rpctpgndigi[3]
Definition: L1TRPCTPG.h:87
const T & get() const
Definition: EventSetup.h:55
void endJob(void)
Definition: L1TRPCTPG.cc:98
edm::EDGetTokenT< L1MuGMTReadoutCollection > rpctfSource_token_
Definition: L1TRPCTPG.h:108
std::vector< RPCDigi >::const_iterator const_iterator
edm::InputTag rpctpgSource_
Definition: L1TRPCTPG.h:105
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:42
MonitorElement * m_digiBxRPCBar
Definition: L1TRPCTPG.h:90
bool verbose_
Definition: L1TRPCTPG.h:102
MonitorElement * m_digiBxRPCEnd
Definition: L1TRPCTPG.h:92
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
edm::InputTag rpctfSource_
Definition: L1TRPCTPG.h:107
tuple cout
Definition: gather_cfg.py:121
MonitorElement * rpctpgbx
Definition: L1TRPCTPG.h:88
bool isValid() const
Definition: ESHandle.h:37
void beginJob(void)
Definition: L1TRPCTPG.cc:55
MonitorElement * m_digiBxDT
Definition: L1TRPCTPG.h:94
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41