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