CMS 3D CMS Logo

CTPPSCommonDQMSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TotemDQM and TOTEM offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
15 
19 
21 
23 
24 #include <string>
25 
26 //----------------------------------------------------------------------------------------------------
27 
29 {
30  public:
31 
33 
34  ~CTPPSCommonDQMSource() override;
35 
36  protected:
37 
38  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
39 
40  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
41 
42  private:
43  unsigned int verbosity;
44 
46 
48  struct GlobalPlots
49  {
52 
53  void Init(DQMStore::IBooker &ibooker);
54  };
55 
57 
59  struct ArmPlots
60  {
61  int id;
62 
63  MonitorElement *h_numRPWithTrack_top=nullptr, *h_numRPWithTrack_hor=nullptr, *h_numRPWithTrack_bot=nullptr;
64  MonitorElement *h_trackCorr=nullptr, *h_trackCorr_overlap=nullptr;
65 
67 
68  ArmPlots(DQMStore::IBooker &ibooker, int _id);
69  };
70 
71  std::map<unsigned int, ArmPlots> armPlots;
72 };
73 
74 //----------------------------------------------------------------------------------------------------
75 //----------------------------------------------------------------------------------------------------
76 
77 using namespace std;
78 using namespace edm;
79 
80 //----------------------------------------------------------------------------------------------------
81 
83 {
84  ibooker.setCurrentFolder("CTPPS/common");
85 
86  events_per_bx = ibooker.book1D("events per BX", "rp;Event.BX", 4002, -1.5, 4000. + 0.5);
87  events_per_bx_short = ibooker.book1D("events per BX (short)", "rp;Event.BX", 102, -1.5, 100. + 0.5);
88 
89  h_trackCorr_hor = ibooker.book2D("track correlation hor", "ctpps_common_rp_hor", 6, -0.5, 5.5, 6, -0.5, 5.5);
90  {
91  TH2F* hist = h_trackCorr_hor->getTH2F();
92  TAxis* xa = hist->GetXaxis(), *ya = hist->GetYaxis();
93  xa->SetBinLabel(1, "45, 210, far"); ya->SetBinLabel(1, "45, 210, far");
94  xa->SetBinLabel(2, "45, 220, far"); ya->SetBinLabel(2, "45, 220, far");
95  xa->SetBinLabel(3, "45, 220, cyl"); ya->SetBinLabel(3, "45, 220, cyl");
96  xa->SetBinLabel(4, "56, 210, far"); ya->SetBinLabel(4, "56, 210, far");
97  xa->SetBinLabel(5, "56, 220, far"); ya->SetBinLabel(5, "56, 220, far");
98  xa->SetBinLabel(6, "56, 220, cyl"); ya->SetBinLabel(6, "56, 220, cyl");
99  }
100 
101  h_trackCorr_vert = ibooker.book2D("track correlation vert", "ctpps_common_rp_vert", 8, -0.5, 7.5, 8, -0.5, 7.5);
102  {
103  TH2F* hist = h_trackCorr_vert->getTH2F();
104  TAxis* xa = hist->GetXaxis(), *ya = hist->GetYaxis();
105  xa->SetBinLabel(1, "45, 210, far, top"); ya->SetBinLabel(1, "45, 210, far, top");
106  xa->SetBinLabel(2, "45, 210, far, bot"); ya->SetBinLabel(2, "45, 210, far, bot");
107  xa->SetBinLabel(3, "45, 220, far, top"); ya->SetBinLabel(3, "45, 220, far, top");
108  xa->SetBinLabel(4, "45, 220, far, bot"); ya->SetBinLabel(4, "45, 220, far, bot");
109  xa->SetBinLabel(5, "56, 210, far, top"); ya->SetBinLabel(5, "56, 210, far, top");
110  xa->SetBinLabel(6, "56, 210, far, bot"); ya->SetBinLabel(6, "56, 210, far, bot");
111  xa->SetBinLabel(7, "56, 220, far, top"); ya->SetBinLabel(7, "56, 220, far, top");
112  xa->SetBinLabel(8, "56, 220, far, bot"); ya->SetBinLabel(8, "56, 220, far, bot");
113  }
114 }
115 
116 //----------------------------------------------------------------------------------------------------
117 
119 {
120  string name;
122 
123  ibooker.setCurrentFolder("CTPPS/common/sector " + name);
124 
125  string title = "ctpps_common_sector_" + name;
126 
127  h_numRPWithTrack_top = ibooker.book1D("number of top RPs with tracks", title+";number of top RPs with tracks", 5, -0.5, 4.5);
128  h_numRPWithTrack_hor = ibooker.book1D("number of hor RPs with tracks", title+";number of hor RPs with tracks", 5, -0.5, 4.5);
129  h_numRPWithTrack_bot = ibooker.book1D("number of bot RPs with tracks", title+";number of bot RPs with tracks", 5, -0.5, 4.5);
130 
131  h_trackCorr = ibooker.book2D("track correlation", title, 7, -0.5, 6.5, 7, -0.5, 6.5);
132  TH2F *h_trackCorr_h = h_trackCorr->getTH2F();
133  TAxis *xa = h_trackCorr_h->GetXaxis(), *ya = h_trackCorr_h->GetYaxis();
134  xa->SetBinLabel( 1, "210, far, hor"); ya->SetBinLabel( 1, "210, far, hor");
135  xa->SetBinLabel( 2, "210, far, top"); ya->SetBinLabel( 2, "210, far, top");
136  xa->SetBinLabel( 3, "210, far, bot"); ya->SetBinLabel( 3, "210, far, bot");
137  xa->SetBinLabel( 4, "220, cyl" ); ya->SetBinLabel( 4, "220, cyl" );
138  xa->SetBinLabel( 5, "220, far, hor"); ya->SetBinLabel( 5, "220, far, hor");
139  xa->SetBinLabel( 6, "220, far, top"); ya->SetBinLabel( 6, "220, far, top");
140  xa->SetBinLabel( 7, "220, far, bot"); ya->SetBinLabel( 7, "220, far, bot");
141 
142  h_trackCorr_overlap = ibooker.book2D("track correlation hor-vert overlaps", title, 7, -0.5, 6.5, 7, -0.5, 6.5);
143  h_trackCorr_h = h_trackCorr_overlap->getTH2F();
144  xa = h_trackCorr_h->GetXaxis(); ya = h_trackCorr_h->GetYaxis();
145  xa->SetBinLabel( 1, "210, far, hor"); ya->SetBinLabel( 1, "210, far, hor");
146  xa->SetBinLabel( 2, "210, far, top"); ya->SetBinLabel( 2, "210, far, top");
147  xa->SetBinLabel( 3, "210, far, bot"); ya->SetBinLabel( 3, "210, far, bot");
148  xa->SetBinLabel( 4, "220, cyl" ); ya->SetBinLabel( 4, "220, cyl" );
149  xa->SetBinLabel( 5, "220, far, hor"); ya->SetBinLabel( 5, "220, far, hor");
150  xa->SetBinLabel( 6, "220, far, top"); ya->SetBinLabel( 6, "220, far, top");
151  xa->SetBinLabel( 7, "220, far, bot"); ya->SetBinLabel( 7, "220, far, bot");
152 }
153 
154 //----------------------------------------------------------------------------------------------------
155 //----------------------------------------------------------------------------------------------------
156 
158  verbosity(ps.getUntrackedParameter<unsigned int>("verbosity", 0))
159 {
160  tokenLocalTrackLite = consumes< vector<CTPPSLocalTrackLite> >(ps.getParameter<edm::InputTag>("tagLocalTrackLite"));
161 }
162 
163 //----------------------------------------------------------------------------------------------------
164 
166 {
167 }
168 
169 //----------------------------------------------------------------------------------------------------
170 
172 {
173  // global plots
174  globalPlots.Init(ibooker);
175 
176  // loop over arms
177  for (unsigned int arm = 0; arm < 2; arm++)
178  {
179  armPlots[arm] = ArmPlots(ibooker, arm);
180  }
181 }
182 
183 //----------------------------------------------------------------------------------------------------
184 
186 {
187  // get event data
189  event.getByToken(tokenLocalTrackLite, tracks);
190 
191  // check validity
192  bool valid = true;
193  valid &= tracks.isValid();
194 
195  if (!valid)
196  {
197  if (verbosity)
198  {
199  LogProblem("CTPPSCommonDQMSource")
200  << " trackLites.isValid = " << tracks.isValid();
201  }
202 
203  return;
204  }
205 
206  //------------------------------
207  // collect indeces of RP with tracks, for each correlation plot
208  set<signed int> s_rp_idx_global_hor, s_rp_idx_global_vert;
209  map<unsigned int, set<signed int>> ms_rp_idx_arm;
210 
211  for (auto &tr : *tracks)
212  {
213  const CTPPSDetId rpId(tr.getRPId());
214  const unsigned int arm = rpId.arm();
215  const unsigned int stNum = rpId.station();
216  const unsigned int rpNum = rpId.rp();
217  const unsigned int stRPNum = stNum * 10 + rpNum;
218 
219  {
220  signed int idx = -1;
221  if (stRPNum == 3) idx = 0;
222  if (stRPNum == 23) idx = 1;
223  if (stRPNum == 16) idx = 2;
224 
225  if (idx >= 0)
226  s_rp_idx_global_hor.insert(3*arm + idx);
227  }
228 
229  {
230  signed int idx = -1;
231  if (stRPNum == 4) idx = 0;
232  if (stRPNum == 5) idx = 1;
233  if (stRPNum == 24) idx = 2;
234  if (stRPNum == 25) idx = 3;
235 
236  if (idx >= 0)
237  s_rp_idx_global_vert.insert(4*arm + idx);
238  }
239 
240  {
241  signed int idx = -1;
242  if (stRPNum == 3) idx = 0;
243  if (stRPNum == 4) idx = 1;
244  if (stRPNum == 5) idx = 2;
245  if (stRPNum == 16) idx = 3;
246  if (stRPNum == 23) idx = 4;
247  if (stRPNum == 24) idx = 5;
248  if (stRPNum == 25) idx = 6;
249 
250  const signed int hor = ((rpNum == 2) || (rpNum == 3) || (rpNum == 6)) ? 1 : 0;
251 
252  if (idx >= 0)
253  ms_rp_idx_arm[arm].insert(idx * 10 + hor);
254  }
255  }
256 
257  //------------------------------
258  // Global Plots
259 
262 
263  for (const auto &idx1 : s_rp_idx_global_hor)
264  for (const auto &idx2 : s_rp_idx_global_hor)
265  globalPlots.h_trackCorr_hor->Fill(idx1, idx2);
266 
267  for (const auto &idx1 : s_rp_idx_global_vert)
268  for (const auto &idx2 : s_rp_idx_global_vert)
269  globalPlots.h_trackCorr_vert->Fill(idx1, idx2);
270 
271  //------------------------------
272  // Arm Plots
273 
274  map<unsigned int, set<unsigned int>> mTop, mHor, mBot;
275 
276  for (auto &tr : *tracks)
277  {
278  CTPPSDetId rpId(tr.getRPId());
279  const unsigned int rpNum = rpId.rp();
280  const unsigned int armIdx = rpId.arm();
281 
282  if (rpNum == 0 || rpNum == 4)
283  mTop[armIdx].insert(rpId);
284  if (rpNum == 2 || rpNum == 3 || rpNum == 6)
285  mHor[armIdx].insert(rpId);
286  if (rpNum == 1 || rpNum == 5)
287  mBot[armIdx].insert(rpId);
288  }
289 
290  for (auto &p : armPlots)
291  {
292  p.second.h_numRPWithTrack_top->Fill(mTop[p.first].size());
293  p.second.h_numRPWithTrack_hor->Fill(mHor[p.first].size());
294  p.second.h_numRPWithTrack_bot->Fill(mBot[p.first].size());
295  }
296 
297  // track RP correlation
298  for (const auto &ap : ms_rp_idx_arm)
299  {
300  auto &plots = armPlots[ap.first];
301 
302  for (const auto &idx1 : ap.second)
303  {
304  for (const auto &idx2 : ap.second)
305  {
306  plots.h_trackCorr->Fill(idx1/10, idx2/10);
307 
308  if ((idx1 % 10) != (idx2 % 10))
309  plots.h_trackCorr_overlap->Fill(idx1/10, idx2/10);
310  }
311  }
312  }
313 }
314 
315 //----------------------------------------------------------------------------------------------------
316 
T getParameter(std::string const &) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< std::vector< CTPPSLocalTrackLite > > tokenLocalTrackLite
int bunchCrossing() const
Definition: EventBase.h:66
CTPPSCommonDQMSource(const edm::ParameterSet &ps)
void Fill(long long x)
std::map< unsigned int, ArmPlots > armPlots
void Init(DQMStore::IBooker &ibooker)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
uint32_t arm() const
Definition: CTPPSDetId.h:52
bool isValid() const
Definition: HandleBase.h:74
void armName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:115
TH2F * getTH2F() const
plots related to the whole system
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
HLT enums.
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Definition: event.py:1
Definition: Run.h:43
uint32_t rp() const
Definition: CTPPSDetId.h:74