CMS 3D CMS Logo

CTPPSRandomDQMSource.cc
Go to the documentation of this file.
1 /******************************************
2  *
3  * This is a part of CTPPSDQM software.
4  * Authors:
5  * A. Bellora (Universita' e INFN Torino)
6  *
7  *******************************************/
8 
15 
18 
20 
28 
29 #include <string>
30 
31 //-----------------------------------------------------------------------------
32 
34 public:
36  ~CTPPSRandomDQMSource() override = default;
37  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
38 
39 protected:
40  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
41  void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override;
42 
43 private:
45 
46  static constexpr int kNArms_ = 2;
47  static constexpr int kNStationMAX_ = 3; // in an arm
48  static constexpr int kNRPotsMAX_ = 6; // per station
49  static constexpr int kNplaneMAX_ = 6; // per RPot
50  static constexpr int kFirstRPn_ = 3, kLastRPn_ = 4;
51  static constexpr int kStationIDMAX_ = 4; // possible range of ID
52  static constexpr int kRPotsIDMAX_ = 8; // possible range of ID
53 
54  const std::string folderName_ = "PPSRANDOM/RandomPixel";
55 
56  unsigned int rpStatusWord_ = 0x8008; // 220_fr_hr(stn2rp3)+ 210_fr_hr
57  int rpStatus_[kStationIDMAX_][kRPotsIDMAX_]; // symmetric in both arms
58  int stationStatus_[kStationIDMAX_]; // symmetric in both arms
59  const int kIndexNotValid = 0;
60 
62 
64 
67 
68  int getRPindex(int arm, int station, int rp) const {
69  if (arm < 0 || station < 0 || rp < 0)
70  return (kIndexNotValid);
71  if (arm > 1 || station >= kNStationMAX_ || rp >= kNRPotsMAX_)
72  return (kIndexNotValid);
73  int rc = (arm * kNStationMAX_ + station) * kNRPotsMAX_ + rp;
74  return (rc);
75  }
76 };
77 
78 //-------------------------------------------------------------------------------
79 
81  : tokenDigi_(consumes<edm::DetSetVector<CTPPSPixelDigi>>(ps.getParameter<edm::InputTag>("tagRPixDigi"))),
82  folderName_(ps.getUntrackedParameter<std::string>("folderName", "PPSRANDOM/RandomPixel")),
83  rpStatusWord_(ps.getUntrackedParameter<unsigned int>("RPStatusWord", 0x8008)) {
84  for (int stn = 0; stn < kStationIDMAX_; stn++) {
85  stationStatus_[stn] = 0;
86  for (int rp = 0; rp < kRPotsIDMAX_; rp++)
87  rpStatus_[stn][rp] = 0;
88  }
89 
90  unsigned int rpSts = rpStatusWord_ << 1;
91  for (int stn = 0; stn < kNStationMAX_; stn++) {
92  int stns = 0;
93  for (int rp = 0; rp < kNRPotsMAX_; rp++) {
94  rpSts = (rpSts >> 1);
95  rpStatus_[stn][rp] = rpSts & 1;
96  if (rpStatus_[stn][rp] > 0)
97  stns = 1;
98  }
99  stationStatus_[stn] = stns;
100  }
101 
102  for (int index = 0; index < 2 * 3 * kNRPotsMAX_; index++)
103  RPindexValid_[index] = 0;
104 }
105 
106 //--------------------------------------------------------------------------
107 
109  ibooker.cd();
110  ibooker.setCurrentFolder(folderName_);
111 
112  hBX_ = ibooker.book1D("events per BX", "ctpps_pixel;Event.BX", 4002, -1.5, 4000. + 0.5);
113 
114  for (int arm = 0; arm < kNArms_; arm++) {
116  std::string sd;
117  ID.armName(sd, CTPPSDetId::nShort);
118  sd = folderName_ + "/sector " + sd;
119 
120  ibooker.setCurrentFolder(sd);
121 
122  for (int stn = 0; stn < kNStationMAX_; stn++) {
123  if (stationStatus_[stn] == 0)
124  continue;
125  ID.setStation(stn);
126  std::string stnd;
127  CTPPSDetId(ID.stationId()).stationName(stnd, CTPPSDetId::nShort);
128  stnd = sd + "/station " + stnd;
129 
130  ibooker.setCurrentFolder(stnd);
131 
132  for (int rp = kFirstRPn_; rp < kLastRPn_; rp++) { // only installed pixel pots
133  ID.setRP(rp);
134  std::string rpd, rpTitle;
135  CTPPSDetId(ID.rpId()).rpName(rpTitle, CTPPSDetId::nFull);
136  CTPPSDetId(ID.rpId()).rpName(rpd, CTPPSDetId::nShort);
137  rpd = stnd + "/" + rpd;
138 
139  ibooker.setCurrentFolder(rpd);
140 
141  int indexP = getRPindex(arm, stn, rp);
142  RPindexValid_[indexP] = 1;
143 
144  h2HitsVsBXRandoms_[indexP] = ibooker.book2D("Digi per plane per BX - random triggers",
145  rpTitle + ";Event.BX;Plane",
146  4002,
147  -1.5,
148  4000. + 0.5,
149  kNplaneMAX_,
150  0,
151  kNplaneMAX_);
152  h2HitsVsBXRandoms_[indexP]->getTH2F()->SetOption("colz");
153 
154  } // end for(int rp=0; rp<kNRPotsMAX_;...
155  } // end of for(int stn=0; stn<
156  } // end of for(int arm=0; arm<2;...
157 
158  return;
159 }
160 
161 //-------------------------------------------------------------------------------
162 
164  auto const pixDigi = event.getHandle(tokenDigi_);
165 
166  if (!pixDigi.isValid())
167  return;
168 
169  hBX_->Fill(event.bunchCrossing());
170 
171  for (int arm = 0; arm < 2; arm++) {
172  for (int stn = 0; stn < kNStationMAX_; stn++) {
173  if (!stationStatus_[stn])
174  continue;
175  for (int rp = 0; rp < kNRPotsMAX_; rp++) {
176  if (!rpStatus_[stn][rp])
177  continue;
178  int index = getRPindex(arm, stn, rp);
179  if (RPindexValid_[index] == 0)
180  continue;
181 
182  for (int p = 0; p < kNplaneMAX_; p++) {
183  CTPPSPixelDetId planeId(arm, stn, rp, p);
184  auto pix_d = pixDigi->find(planeId.rawId());
185  if (pix_d != pixDigi->end()) {
186  int n_digis = pix_d->size();
187  h2HitsVsBXRandoms_[index]->Fill(event.bunchCrossing(), p, n_digis);
188  }
189  }
190  } // end for (int rp=0; rp<kNRPotsMAX_; rp++) {
191  } // end for (int stn = 0; stn < kNStationMAX_; stn++) {
192  } // end for (int arm=0; arm<2; arm++) {
193 }
194 
195 //---------------------------------------------------------------------------
196 
199  desc.add<edm::InputTag>("tagRPixDigi", edm::InputTag("ctppsPixelDigisAlCaRecoProducer"));
200  desc.addUntracked<std::string>("folderName", "PPSRANDOM/RandomPixel");
201  desc.addUntracked<unsigned int>("RPStatusWord", 0x8008);
202  descriptions.add("ctppsRandomDQMSource", desc);
203 }
204 
205 //---------------------------------------------------------------------------
int rpStatus_[kStationIDMAX_][kRPotsIDMAX_]
static constexpr int kNStationMAX_
static constexpr int kFirstRPn_
static constexpr int kLastRPn_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int RPindexValid_[kRPotsTotalNumber_]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
static constexpr int kNplaneMAX_
uint32_t ID
Definition: Definitions.h:24
static constexpr int kRPotsIDMAX_
CTPPSRandomDQMSource(const edm::ParameterSet &ps)
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDigi > > const tokenDigi_
static constexpr int kStationIDMAX_
void Fill(long long x)
static constexpr int kNRPotsMAX_
int getRPindex(int arm, int station, int rp) const
static constexpr int kNArms_
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
~CTPPSRandomDQMSource() override=default
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * h2HitsVsBXRandoms_[kRPotsTotalNumber_]
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
HLT enums.
int stationStatus_[kStationIDMAX_]
const std::string folderName_
static constexpr int kRPotsTotalNumber_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: event.py:1
Definition: Run.h:45