CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCDigiValid.cc
Go to the documentation of this file.
4 
12 
13 #include <cmath>
14 
15 using namespace std;
16 using namespace edm;
17 
19 {
20 
21 // Init the tokens for run data retrieval - stanislav
22 // ps.getUntackedParameter<InputTag> retrieves a InputTag from the configuration. The second param is default value
23 // module, instance and process labels may be passed in a single string if separated by colon ':'
24 // (@see the edm::InputTag constructor documentation)
25  simHitToken = consumes<PSimHitContainer>(ps.getUntrackedParameter<edm::InputTag >("simHitTag", edm::InputTag("g4SimHits:MuonRPCHits")));
26  rpcDigiToken = consumes<RPCDigiCollection>(ps.getUntrackedParameter<edm::InputTag>("rpcDigiTag", edm::InputTag("simMuonRPCDigis")));
27 
28  outputFile_ = ps.getUntrackedParameter<string> ("outputFile", "rpcDigiValidPlots.root");
29 }
30 
32 {
33 }
34 
35 
36 void RPCDigiValid::analyze(const Event& event, const EventSetup& eventSetup)
37 {
38 
39  // Get the RPC Geometry
41  eventSetup.get<MuonGeometryRecord> ().get(rpcGeom);
42 
45  event.getByToken(simHitToken, simHit);
46  event.getByToken(rpcDigiToken, rpcDigis);
47 
48  // Loop on simhits
49  PSimHitContainer::const_iterator simIt;
50 
51  //loop over Simhit
52  std::map<RPCDetId, std::vector<double> > allsims;
53 
54  for (simIt = simHit->begin(); simIt != simHit->end(); simIt++)
55  {
56  RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId();
57  const RPCRoll* soll = dynamic_cast<const RPCRoll*> (rpcGeom->roll(Rsid));
58  int ptype = simIt->particleType();
59 
60  if (ptype == 13 || ptype == -13)
61  {
62 
63  std::vector<double> buff;
64  if (allsims.find(Rsid) != allsims.end())
65  {
66  buff = allsims[Rsid];
67  }
68 
69  buff.push_back(simIt->localPosition().x());
70 
71  allsims[Rsid] = buff;
72  }
73  GlobalPoint p = soll->toGlobal(simIt->localPosition());
74 
75  double sim_x = p.x();
76  double sim_y = p.y();
77 
78  xyview->Fill(sim_x, sim_y);
79 
80  if (Rsid.region() == (+1))
81  {
82  if (Rsid.station() == 4)
83  {
84  xyvDplu4->Fill(sim_x, sim_y);
85  }
86  }
87  else if (Rsid.region() == (-1))
88  {
89  if (Rsid.station() == 4)
90  {
91  xyvDmin4->Fill(sim_x, sim_y);
92  }
93  }
94  rzview->Fill(p.z(), p.perp());
95  }
96  //loop over Digis
98  for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt)
99  {
100  const RPCDetId Rsid = (*detUnitIt).first;
101  const RPCRoll* roll = dynamic_cast<const RPCRoll*> (rpcGeom->roll(Rsid));
102 
103  const RPCDigiCollection::Range& range = (*detUnitIt).second;
104  std::vector<double> sims;
105  if (allsims.find(Rsid) != allsims.end())
106  {
107  sims = allsims[Rsid];
108  }
109 
110  int ndigi=0;
111  for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt)
112  {
113  StripProf->Fill(digiIt->strip());
114  BxDist->Fill(digiIt->bx());
115  //bx for 4 endcaps
116  if (Rsid.region() == (+1))
117  {
118  if (Rsid.station() == 4)
119  BxDisc_4Plus->Fill(digiIt->bx());
120  }
121  else if (Rsid.region() == (-1))
122  {
123  if (Rsid.station() == 4)
124  BxDisc_4Min->Fill(digiIt->bx());
125  }
126  ndigi++;
127  }
128 
129  if (sims.size() == 0)
130  {
131  noiseCLS->Fill(ndigi);
132  if (Rsid.region() == 0)
133  {
134  noiseCLSBarrel->Fill(ndigi);
135  }
136  if (Rsid.region() == +1 || Rsid.region() == 1)
137  {
138  noiseCLSEndcaps->Fill(ndigi);
139  }
140  }
141  //CLS histos
142  if (Rsid.region() == 0)
143  {
144  clsBarrel->Fill(ndigi);
145  }
146  //endcap
147  if (Rsid.region() != 0)
148  {
149  if (Rsid.ring() == 2)
150  {
151  if (abs(Rsid.station()) == 1)
152  {
153  if (Rsid.roll() == 1)
154  CLS_Endcap_1_Ring2_A->Fill(ndigi);
155  if (Rsid.roll() == 2)
156  CLS_Endcap_1_Ring2_B->Fill(ndigi);
157  if (Rsid.roll() == 3)
158  CLS_Endcap_1_Ring2_C->Fill(ndigi);
159  }
160  if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3)
161  {
162  if (Rsid.roll() == 1)
163  CLS_Endcap_23_Ring2_A->Fill(ndigi);
164  if (Rsid.roll() == 2)
165  CLS_Endcap_23_Ring2_B->Fill(ndigi);
166  if (Rsid.roll() == 3)
167  CLS_Endcap_23_Ring2_C->Fill(ndigi);
168  }
169  }
170  if (Rsid.ring() == 3)
171  {
172  if (Rsid.roll() == 1)
173  CLS_Endcap_123_Ring3_A->Fill(ndigi);
174  if (Rsid.roll() == 2)
175  CLS_Endcap_123_Ring3_B->Fill(ndigi);
176  if (Rsid.roll() == 3)
177  CLS_Endcap_123_Ring3_C->Fill(ndigi);
178  }
179  if (abs(Rsid.station()) == 4)
180  CLS_Endcap_4->Fill(ndigi);
181  }
182 
183  if (sims.size() == 1 && ndigi == 1)
184  {
185  double dis = roll->centreOfStrip(range.first->strip()).x() - sims[0];
186  Res->Fill(dis);
187 
188  if (Rsid.region() == 0)
189  {
190  if (Rsid.ring() == -2)
191  ResWmin2->Fill(dis);
192  else if (Rsid.ring() == -1)
193  ResWmin1->Fill(dis);
194  else if (Rsid.ring() == 0)
195  ResWzer0->Fill(dis);
196  else if (Rsid.ring() == 1)
197  ResWplu1->Fill(dis);
198  else if (Rsid.ring() == 2)
199  ResWplu2->Fill(dis);
200  //barrel layers
201  if (Rsid.station() == 1 && Rsid.layer() == 1)
202  ResLayer1_barrel->Fill(dis);
203  if (Rsid.station() == 1 && Rsid.layer() == 2)
204  ResLayer2_barrel->Fill(dis);
205  if (Rsid.station() == 2 && Rsid.layer() == 1)
206  ResLayer3_barrel->Fill(dis);
207  if (Rsid.station() == 2 && Rsid.layer() == 2)
208  ResLayer4_barrel->Fill(dis);
209  if (Rsid.station() == 3)
210  ResLayer5_barrel->Fill(dis);
211  if (Rsid.station() == 4)
212  ResLayer6_barrel->Fill(dis);
213  }
214  //endcap layers residuals
215  if (Rsid.region() != 0)
216  {
217  if (Rsid.ring() == 2)
218  {
219  if (abs(Rsid.station()) == 1)
220  {
221  if (Rsid.roll() == 1)
222  Res_Endcap1_Ring2_A->Fill(dis);
223  if (Rsid.roll() == 2)
224  Res_Endcap1_Ring2_B->Fill(dis);
225  if (Rsid.roll() == 3)
226  Res_Endcap1_Ring2_C->Fill(dis);
227  }
228  if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3)
229  {
230  if (Rsid.roll() == 1)
231  Res_Endcap23_Ring2_A->Fill(dis);
232  if (Rsid.roll() == 2)
233  Res_Endcap23_Ring2_B->Fill(dis);
234  if (Rsid.roll() == 3)
235  Res_Endcap23_Ring2_C->Fill(dis);
236  }
237  }
238  if (Rsid.ring() == 3)
239  {
240  if (Rsid.roll() == 1)
241  Res_Endcap123_Ring3_A->Fill(dis);
242  if (Rsid.roll() == 2)
243  Res_Endcap123_Ring3_B->Fill(dis);
244  if (Rsid.roll() == 3)
245  Res_Endcap123_Ring3_C->Fill(dis);
246  }
247  }
248 
249  if (Rsid.region() == (+1))
250  {
251 
252  if (Rsid.station() == 1)
253  ResDplu1->Fill(dis);
254  else if (Rsid.station() == 2)
255  ResDplu2->Fill(dis);
256  else if (Rsid.station() == 3)
257  ResDplu3->Fill(dis);
258  else if (Rsid.station() == 4)
259  ResDplu4->Fill(dis);
260  }
261  if (Rsid.region() == (-1))
262  {
263 
264  if (Rsid.station() == 1)
265  ResDmin1->Fill(dis);
266  else if (Rsid.station() == 2)
267  ResDmin2->Fill(dis);
268  else if (Rsid.station() == 3)
269  ResDmin3->Fill(dis);
270  else if (Rsid.station() == 4)
271  ResDmin4->Fill(dis);
272  }
273  }
274  }
275 }
276 
278 {
279  booker.setCurrentFolder("RPCDigisV/RPCDigis");
280 
281  xyview = booker.book2D("X_Vs_Y_View", "X_Vs_Y_View", 155, -775., 775., 155, -775., 775.);
282 
283  xyvDplu4 = booker.book2D("Dplu4_XvsY", "Dplu4_XvsY", 155, -775., 775., 155, -775., 775.);
284  xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.);
285 
286  rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.);
287  Res = booker.book1D("Digi_SimHit_difference", "Digi_SimHit_difference", 300, -8, 8);
288  ResWmin2 = booker.book1D("W_Min2_Residuals", "W_Min2_Residuals", 400, -8, 8);
289  ResWmin1 = booker.book1D("W_Min1_Residuals", "W_Min1_Residuals", 400, -8, 8);
290  ResWzer0 = booker.book1D("W_Zer0_Residuals", "W_Zer0_Residuals", 400, -8, 8);
291  ResWplu1 = booker.book1D("W_Plu1_Residuals", "W_Plu1_Residuals", 400, -8, 8);
292  ResWplu2 = booker.book1D("W_Plu2_Residuals", "W_Plu2_Residuals", 400, -8, 8);
293 
294  ResLayer1_barrel = booker.book1D("ResLayer1_barrel", "ResLayer1_barrel", 400, -8, 8);
295  ResLayer2_barrel = booker.book1D("ResLayer2_barrel", "ResLayer2_barrel", 400, -8, 8);
296  ResLayer3_barrel = booker.book1D("ResLayer3_barrel", "ResLayer3_barrel", 400, -8, 8);
297  ResLayer4_barrel = booker.book1D("ResLayer4_barrel", "ResLayer4_barrel", 400, -8, 8);
298  ResLayer5_barrel = booker.book1D("ResLayer5_barrel", "ResLayer5_barrel", 400, -8, 8);
299  ResLayer6_barrel = booker.book1D("ResLayer6_barrel", "ResLayer6_barrel", 400, -8, 8);
300 
301  BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.);
302  StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100);
303 
304  BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.);
305  BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.);
306 
307  //cls histos
308  noiseCLS = booker.book1D("noiseCLS", "noiseCLS", 10, 0.5, 10.5);
309  noiseCLSBarrel = booker.book1D("noiseCLSBarrel", "noiseCLSBarrel", 10, 0.5, 10.5);
310  noiseCLSEndcaps = booker.book1D("noiseCLSEndcaps", "noiseCLSEndcaps", 10, 0.5, 10.5);
311 
312  clsBarrel = booker.book1D("clsBarrel", "clsBarrel", 10, 0.5, 10.5);
313 
314  //endcap CLS
315  CLS_Endcap_1_Ring2_A = booker.book1D("CLS_Endcap_1_1Ring2_A", "CLS_Endcap_1_Ring2_A", 10, 0.5, 10.5);
316  CLS_Endcap_1_Ring2_B = booker.book1D("CLS_Endcap_1_1Ring2_B", "CLS_Endcap_1_Ring2_B", 10, 0.5, 10.5);
317  CLS_Endcap_1_Ring2_C = booker.book1D("CLS_Endcap_1_1Ring2_C", "CLS_Endcap_1_Ring2_C", 10, 0.5, 10.5);
318 
319  CLS_Endcap_23_Ring2_A = booker.book1D("CLS_Endcap_23_Ring2_A", "CLS_Endcap_23_Ring2_A", 10, 0.5, 10.5);
320  CLS_Endcap_23_Ring2_B = booker.book1D("CLS_Endcap_23_Ring2_B", "CLS_Endcap_23_Ring2_B", 10, 0.5, 10.5);
321  CLS_Endcap_23_Ring2_C = booker.book1D("CLS_Endcap_23_Ring2_C", "CLS_Endcap_23_Ring2_C", 10, 0.5, 10.5);
322 
323  CLS_Endcap_123_Ring3_A = booker.book1D("CLS_Endcap_123_Ring3_A", "CLS_Endcap_123_Ring3_A", 10, 0.5, 10.5);
324  CLS_Endcap_123_Ring3_B = booker.book1D("CLS_Endcap_123_Ring3_B", "CLS_Endcap_123_Ring3_B", 10, 0.5, 10.5);
325  CLS_Endcap_123_Ring3_C = booker.book1D("CLS_Endcap_123_Ring3_C", "CLS_Endcap_123_Ring3_C", 10, 0.5, 10.5);
326 
327  CLS_Endcap_4 = booker.book1D("CLS_Endcap_4", "CLS_Endcap_4", 10, 0.5, 10.5);
328 
329  //endcap residuals
330  ResDmin1 = booker.book1D("Disk_Min1_Residuals", "Disk_Min1_Residuals", 400, -8, 8);
331  ResDmin2 = booker.book1D("Disk_Min2_Residuals", "Disk_Min2_Residuals", 400, -8, 8);
332  ResDmin3 = booker.book1D("Disk_Min3_Residuals", "Disk_Min3_Residuals", 400, -8, 8);
333  ResDplu1 = booker.book1D("Disk_Plu1_Residuals", "Disk_Plu1_Residuals", 400, -8, 8);
334  ResDplu2 = booker.book1D("Disk_Plu2_Residuals", "Disk_Plu2_Residuals", 400, -8, 8);
335  ResDplu3 = booker.book1D("Disk_Plu3_Residuals", "Disk_Plu3_Residuals", 400, -8, 8);
336 
337  ResDmin4 = booker.book1D("Disk_Min4_Residuals", "Disk_Min4_Residuals", 400, -8, 8);
338  ResDplu4 = booker.book1D("Disk_Plu4_Residuals", "Disk_Plu4_Residuals", 400, -8, 8);
339 
340  Res_Endcap1_Ring2_A = booker.book1D("Res_Endcap1_Ring2_A", "Res_Endcap1_Ring2_A", 400, -8, 8);
341  Res_Endcap1_Ring2_B = booker.book1D("Res_Endcap1_Ring2_B", "Res_Endcap1_Ring2_B", 400, -8, 8);
342  Res_Endcap1_Ring2_C = booker.book1D("Res_Endcap1_Ring2_C", "Res_Endcap1_Ring2_C", 400, -8, 8);
343 
344  Res_Endcap23_Ring2_A = booker.book1D("Res_Endcap23_Ring2_A", "Res_Endcap23_Ring2_A", 400, -8, 8);
345  Res_Endcap23_Ring2_B = booker.book1D("Res_Endcap23_Ring2_B", "Res_Endcap23_Ring2_B", 400, -8, 8);
346  Res_Endcap23_Ring2_C = booker.book1D("Res_Endcap23_Ring2_C", "Res_Endcap23_Ring2_C", 400, -8, 8);
347 
348  Res_Endcap123_Ring3_A = booker.book1D("Res_Endcap123_Ring3_A", "Res_Endcap123_Ring3_A", 400, -8, 8);
349  Res_Endcap123_Ring3_B = booker.book1D("Res_Endcap123_Ring3_B", "Res_Endcap123_Ring3_B", 400, -8, 8);
350  Res_Endcap123_Ring3_C = booker.book1D("Res_Endcap123_Ring3_C", "Res_Endcap123_Ring3_C", 400, -8, 8);
351 }
352 
T getUntrackedParameter(std::string const &, T const &) const
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:52
T perp() const
Definition: PV3DBase.h:72
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
T y() const
Definition: PV3DBase.h:63
RPCDigiValid(const edm::ParameterSet &ps)
Definition: RPCDigiValid.cc:18
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: RPCDigiValid.cc:36
int roll() const
Definition: RPCDetId.h:120
int ring() const
Definition: RPCDetId.h:72
T z() const
Definition: PV3DBase.h:64
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int layer() const
Definition: RPCDetId.h:108
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
std::vector< RPCDigi >::const_iterator const_iterator
std::pair< const_iterator, const_iterator > Range
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
Definition: Run.h:41
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96