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  // verbosity switch
19  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
20 
21  if (verbose_)
22  cout << "L1TRPCTPG: constructor...." << endl;
23 
24  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
25  if (!outputFile_.empty()) {
26  cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
27  }
28 
29  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
30  if (disable) {
31  outputFile_ = "";
32  }
34 }
35 
37 
39  //
40 }
41 
43  nev_ = 0;
44 
45  ibooker.setCurrentFolder("L1T/L1TRPCTPG");
46 
47  rpctpgbx = ibooker.book1D("RPCTPG_bx", "RPC digis bx - all events", 9, -4.5, 4.5);
48 
49  rpctpgndigi[1] = ibooker.book1D("RPCTPG_ndigi", "RPCTPG nDigi bx 0", 100, -0.5, 99.5);
50  rpctpgndigi[2] = ibooker.book1D("RPCTPG_ndigi_+1", "RPCTPG nDigi bx +1", 100, -0.5, 99.5);
51  rpctpgndigi[0] = ibooker.book1D("RPCTPG_ndigi_-1", "RPCTPG nDigi bx -1", 100, -0.5, 99.5);
52 
53  m_digiBxRPCBar = ibooker.book1D("RPCDigiRPCBmu_noDTmu_bx", "RPC digis bx - RPC, !DT", 9, -4.5, 4.5);
54 
55  m_digiBxRPCEnd = ibooker.book1D("RPCDigiRPCEmu_noCSCmu_bx", "RPC digis bx - RPC, !CSC", 9, -4.5, 4.5);
56 
57  m_digiBxDT = ibooker.book1D("RPCDigiDTmu_noRPCBmu_bx", "RPC digis bx - !RPC, DT", 9, -4.5, 4.5);
58 
59  m_digiBxCSC = ibooker.book1D("RPCDigiCSCmu_noRPCEmu_bx", "RPC digis bx - !RPC, CSC", 9, -4.5, 4.5);
60 }
61 
62 void L1TRPCTPG::analyze(const Event& e, const EventSetup& c) {
63  nev_++;
64  if (verbose_)
65  cout << "L1TRPCTPG: analyze...." << endl;
66 
68  const auto& rpcGeo = c.getHandle(rpcgeomToken_);
69  if (!rpcGeo.isValid()) {
70  edm::LogInfo("DataNotFound") << "can't find RPCGeometry" << endl;
71  return;
72  }
73  // char layerLabel[328];
74  // char meId [328];
75 
78  e.getByToken(rpctpgSource_token_, rpcdigis);
79 
80  if (!rpcdigis.isValid()) {
81  edm::LogInfo("DataNotFound") << "can't find RPCDigiCollection with label " << rpctpgSource_ << endl;
82  return;
83  }
84 
85  // Calculate the number of DT and CSC cands present
87  e.getByToken(rpctfSource_token_, pCollection);
88 
89  if (!pCollection.isValid()) {
90  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label " << rpctfSource_.label();
91  return;
92  }
93 
94  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
95  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
96  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
97 
98  int nRPCTrackBarrel, nRPCTrackEndcap, nDTTrack, nCSCTrack;
99  nRPCTrackBarrel = 0;
100  nRPCTrackEndcap = 0;
101  nDTTrack = 0;
102  nCSCTrack = 0;
103 
104  for (RRItr = gmt_records.begin(); RRItr != gmt_records.end(); RRItr++) {
105  // DTs
106  vector<L1MuRegionalCand> DTCands = RRItr->getDTBXCands();
107  for (vector<L1MuRegionalCand>::const_iterator ECItr = DTCands.begin(); ECItr != DTCands.end(); ++ECItr) {
108  if (!ECItr->empty()) {
109  ++nDTTrack;
110  }
111  }
112  // CSCs
113  vector<L1MuRegionalCand> CSCCands = RRItr->getCSCCands();
114  for (vector<L1MuRegionalCand>::const_iterator ECItr = CSCCands.begin(); ECItr != CSCCands.end(); ++ECItr) {
115  if (!ECItr->empty()) {
116  ++nCSCTrack;
117  }
118  }
119 
120  //RPC barrel
121  vector<L1MuRegionalCand> RPCBCands = RRItr->getBrlRPCCands();
122  for (vector<L1MuRegionalCand>::const_iterator ECItr = RPCBCands.begin(); ECItr != RPCBCands.end(); ++ECItr) {
123  if (!ECItr->empty()) {
124  ++nRPCTrackBarrel;
125  }
126  }
127 
128  //RPC endcap
129  vector<L1MuRegionalCand> RPCECands = RRItr->getFwdRPCCands();
130  for (vector<L1MuRegionalCand>::const_iterator ECItr = RPCECands.begin(); ECItr != RPCECands.end(); ++ECItr) {
131  if (!ECItr->empty()) {
132  ++nRPCTrackEndcap;
133  }
134  }
135  }
136 
137  int numberofDigi[3] = {0, 0, 0};
138 
140  for (collectionItr = rpcdigis->begin(); collectionItr != rpcdigis->end(); ++collectionItr) {
142  for (digiItr = ((*collectionItr).second).first; digiItr != ((*collectionItr).second).second; ++digiItr) {
143  // strips is a list of hit strips (regardless of bx) for this roll
144  // int strip= (*digiItr).strip();
145  // strips.push_back(strip);
146  int bx = (*digiItr).bx();
147  rpctpgbx->Fill(bx);
148  //
149 
150  if (nRPCTrackBarrel == 0 && nDTTrack != 0) {
151  m_digiBxDT->Fill(bx);
152  } else if (nRPCTrackBarrel != 0 && nDTTrack == 0) {
154  }
155 
156  if (nRPCTrackEndcap == 0 && nCSCTrack != 0) {
157  m_digiBxCSC->Fill(bx);
158  } else if (nRPCTrackEndcap != 0 && nCSCTrack == 0) {
160  }
161 
162  if (bx == -1) {
163  numberofDigi[0]++;
164  }
165  if (bx == 0) {
166  // sprintf(meId,"Occupancy_%s",detUnitLabel);
167  // meMap[meId]->Fill(strip);
168  numberofDigi[1]++;
169  }
170  if (bx == 2) {
171  numberofDigi[2]++;
172  }
173 
174  // sprintf(meId,"BXN_%s",detUnitLabel);
175  // meMap[meId]->Fill(bx);
176  // sprintf(meId,"BXN_vs_strip_%s",detUnitLabel);
177  // meMap[meId]->Fill(strip,bx);
178  }
179  }
180 
181  rpctpgndigi[0]->Fill(numberofDigi[0]);
182  rpctpgndigi[1]->Fill(numberofDigi[1]);
183  rpctpgndigi[2]->Fill(numberofDigi[2]);
184 
185  if (verbose_)
186  cout << "L1TRPCTPG: end job...." << endl;
187  LogInfo("EndJob") << "analyzed " << nev_ << " events";
188 }
edm::EDGetTokenT< RPCDigiCollection > rpctpgSource_token_
Definition: L1TRPCTPG.h:89
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
T const * product() const
Definition: Handle.h:70
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: L1TRPCTPG.cc:38
std::string const & label() const
Definition: InputTag.h:36
MonitorElement * m_digiBxCSC
Definition: L1TRPCTPG.h:79
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcgeomToken_
Definition: L1TRPCTPG.h:92
T getUntrackedParameter(std::string const &, T const &) const
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:42
L1TRPCTPG(const edm::ParameterSet &ps)
Definition: L1TRPCTPG.cc:13
int nev_
Definition: L1TRPCTPG.h:83
std::string outputFile_
Definition: L1TRPCTPG.h:84
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: L1TRPCTPG.cc:62
MonitorElement * rpctpgndigi[3]
Definition: L1TRPCTPG.h:74
Log< level::Info, false > LogInfo
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
~L1TRPCTPG() override
Definition: L1TRPCTPG.cc:36
edm::EDGetTokenT< L1MuGMTReadoutCollection > rpctfSource_token_
Definition: L1TRPCTPG.h:91
std::vector< RPCDigi >::const_iterator const_iterator
edm::InputTag rpctpgSource_
Definition: L1TRPCTPG.h:88
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * m_digiBxRPCBar
Definition: L1TRPCTPG.h:76
bool verbose_
Definition: L1TRPCTPG.h:85
MonitorElement * m_digiBxRPCEnd
Definition: L1TRPCTPG.h:77
HLT enums.
edm::InputTag rpctfSource_
Definition: L1TRPCTPG.h:90
MonitorElement * rpctpgbx
Definition: L1TRPCTPG.h:75
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * m_digiBxDT
Definition: L1TRPCTPG.h:78
Definition: Run.h:45