CMS 3D CMS Logo

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 
127  // Fill timing information
128  const double digiTime = digiIt->hasTime() ? digiIt->time() : digiIt->bx()*25;
129  hDigiTimeAll->Fill(digiTime);
130  if ( digiIt->hasTime() ) {
131  hDigiTime->Fill(digiTime);
132  if ( roll->isIRPC() ) hDigiTimeIRPC->Fill(digiTime);
133  else hDigiTimeNoIRPC->Fill(digiTime);
134  }
135  }
136 
137  if (sims.size() == 1 && ndigi == 1)
138  {
139  double dis = roll->centreOfStrip(range.first->strip()).x() - sims[0];
140  Res->Fill(dis);
141 
142  if (Rsid.region() == 0)
143  {
144  if (Rsid.ring() == -2)
145  ResWmin2->Fill(dis);
146  else if (Rsid.ring() == -1)
147  ResWmin1->Fill(dis);
148  else if (Rsid.ring() == 0)
149  ResWzer0->Fill(dis);
150  else if (Rsid.ring() == 1)
151  ResWplu1->Fill(dis);
152  else if (Rsid.ring() == 2)
153  ResWplu2->Fill(dis);
154  //barrel layers
155  if (Rsid.station() == 1 && Rsid.layer() == 1)
156  ResLayer1_barrel->Fill(dis);
157  if (Rsid.station() == 1 && Rsid.layer() == 2)
158  ResLayer2_barrel->Fill(dis);
159  if (Rsid.station() == 2 && Rsid.layer() == 1)
160  ResLayer3_barrel->Fill(dis);
161  if (Rsid.station() == 2 && Rsid.layer() == 2)
162  ResLayer4_barrel->Fill(dis);
163  if (Rsid.station() == 3)
164  ResLayer5_barrel->Fill(dis);
165  if (Rsid.station() == 4)
166  ResLayer6_barrel->Fill(dis);
167  }
168  //endcap layers residuals
169  if (Rsid.region() != 0)
170  {
171  if (Rsid.ring() == 2)
172  {
173  if (abs(Rsid.station()) == 1)
174  {
175  if (Rsid.roll() == 1)
176  Res_Endcap1_Ring2_A->Fill(dis);
177  if (Rsid.roll() == 2)
178  Res_Endcap1_Ring2_B->Fill(dis);
179  if (Rsid.roll() == 3)
180  Res_Endcap1_Ring2_C->Fill(dis);
181  }
182  if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3)
183  {
184  if (Rsid.roll() == 1)
185  Res_Endcap23_Ring2_A->Fill(dis);
186  if (Rsid.roll() == 2)
187  Res_Endcap23_Ring2_B->Fill(dis);
188  if (Rsid.roll() == 3)
189  Res_Endcap23_Ring2_C->Fill(dis);
190  }
191  }
192  if (Rsid.ring() == 3)
193  {
194  if (Rsid.roll() == 1)
195  Res_Endcap123_Ring3_A->Fill(dis);
196  if (Rsid.roll() == 2)
197  Res_Endcap123_Ring3_B->Fill(dis);
198  if (Rsid.roll() == 3)
199  Res_Endcap123_Ring3_C->Fill(dis);
200  }
201  }
202 
203  if (Rsid.region() == (+1))
204  {
205 
206  if (Rsid.station() == 1)
207  ResDplu1->Fill(dis);
208  else if (Rsid.station() == 2)
209  ResDplu2->Fill(dis);
210  else if (Rsid.station() == 3)
211  ResDplu3->Fill(dis);
212  else if (Rsid.station() == 4)
213  ResDplu4->Fill(dis);
214  }
215  if (Rsid.region() == (-1))
216  {
217 
218  if (Rsid.station() == 1)
219  ResDmin1->Fill(dis);
220  else if (Rsid.station() == 2)
221  ResDmin2->Fill(dis);
222  else if (Rsid.station() == 3)
223  ResDmin3->Fill(dis);
224  else if (Rsid.station() == 4)
225  ResDmin4->Fill(dis);
226  }
227  }
228  }
229 }
230 
232 {
233  booker.setCurrentFolder("RPCDigisV/RPCDigis");
234 
235  xyview = booker.book2D("X_Vs_Y_View", "X_Vs_Y_View", 155, -775., 775., 155, -775., 775.);
236 
237  xyvDplu4 = booker.book2D("Dplu4_XvsY", "Dplu4_XvsY", 155, -775., 775., 155, -775., 775.);
238  xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.);
239 
240  rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.);
241  Res = booker.book1D("Digi_SimHit_difference", "Digi_SimHit_difference", 300, -8, 8);
242  ResWmin2 = booker.book1D("W_Min2_Residuals", "W_Min2_Residuals", 400, -8, 8);
243  ResWmin1 = booker.book1D("W_Min1_Residuals", "W_Min1_Residuals", 400, -8, 8);
244  ResWzer0 = booker.book1D("W_Zer0_Residuals", "W_Zer0_Residuals", 400, -8, 8);
245  ResWplu1 = booker.book1D("W_Plu1_Residuals", "W_Plu1_Residuals", 400, -8, 8);
246  ResWplu2 = booker.book1D("W_Plu2_Residuals", "W_Plu2_Residuals", 400, -8, 8);
247 
248  ResLayer1_barrel = booker.book1D("ResLayer1_barrel", "ResLayer1_barrel", 400, -8, 8);
249  ResLayer2_barrel = booker.book1D("ResLayer2_barrel", "ResLayer2_barrel", 400, -8, 8);
250  ResLayer3_barrel = booker.book1D("ResLayer3_barrel", "ResLayer3_barrel", 400, -8, 8);
251  ResLayer4_barrel = booker.book1D("ResLayer4_barrel", "ResLayer4_barrel", 400, -8, 8);
252  ResLayer5_barrel = booker.book1D("ResLayer5_barrel", "ResLayer5_barrel", 400, -8, 8);
253  ResLayer6_barrel = booker.book1D("ResLayer6_barrel", "ResLayer6_barrel", 400, -8, 8);
254 
255  BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.);
256  StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100);
257 
258  BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.);
259  BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.);
260 
261  //endcap residuals
262  ResDmin1 = booker.book1D("Disk_Min1_Residuals", "Disk_Min1_Residuals", 400, -8, 8);
263  ResDmin2 = booker.book1D("Disk_Min2_Residuals", "Disk_Min2_Residuals", 400, -8, 8);
264  ResDmin3 = booker.book1D("Disk_Min3_Residuals", "Disk_Min3_Residuals", 400, -8, 8);
265  ResDplu1 = booker.book1D("Disk_Plu1_Residuals", "Disk_Plu1_Residuals", 400, -8, 8);
266  ResDplu2 = booker.book1D("Disk_Plu2_Residuals", "Disk_Plu2_Residuals", 400, -8, 8);
267  ResDplu3 = booker.book1D("Disk_Plu3_Residuals", "Disk_Plu3_Residuals", 400, -8, 8);
268 
269  ResDmin4 = booker.book1D("Disk_Min4_Residuals", "Disk_Min4_Residuals", 400, -8, 8);
270  ResDplu4 = booker.book1D("Disk_Plu4_Residuals", "Disk_Plu4_Residuals", 400, -8, 8);
271 
272  Res_Endcap1_Ring2_A = booker.book1D("Res_Endcap1_Ring2_A", "Res_Endcap1_Ring2_A", 400, -8, 8);
273  Res_Endcap1_Ring2_B = booker.book1D("Res_Endcap1_Ring2_B", "Res_Endcap1_Ring2_B", 400, -8, 8);
274  Res_Endcap1_Ring2_C = booker.book1D("Res_Endcap1_Ring2_C", "Res_Endcap1_Ring2_C", 400, -8, 8);
275 
276  Res_Endcap23_Ring2_A = booker.book1D("Res_Endcap23_Ring2_A", "Res_Endcap23_Ring2_A", 400, -8, 8);
277  Res_Endcap23_Ring2_B = booker.book1D("Res_Endcap23_Ring2_B", "Res_Endcap23_Ring2_B", 400, -8, 8);
278  Res_Endcap23_Ring2_C = booker.book1D("Res_Endcap23_Ring2_C", "Res_Endcap23_Ring2_C", 400, -8, 8);
279 
280  Res_Endcap123_Ring3_A = booker.book1D("Res_Endcap123_Ring3_A", "Res_Endcap123_Ring3_A", 400, -8, 8);
281  Res_Endcap123_Ring3_B = booker.book1D("Res_Endcap123_Ring3_B", "Res_Endcap123_Ring3_B", 400, -8, 8);
282  Res_Endcap123_Ring3_C = booker.book1D("Res_Endcap123_Ring3_C", "Res_Endcap123_Ring3_C", 400, -8, 8);
283 
284  // Timing informations
285  hDigiTimeAll = booker.book1D("DigiTimeAll" , "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5);
286  hDigiTime = booker.book1D("DigiTime" , "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5);
287  hDigiTimeIRPC = booker.book1D("DigiTimeIRPC" , "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5);
288  hDigiTimeNoIRPC = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5);
289 }
290 
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:54
T y() const
Definition: PV3DBase.h:63
RPCDigiValid(const edm::ParameterSet &ps)
Definition: RPCDigiValid.cc:18
bool isIRPC() const
Definition: RPCRoll.h:38
T x() const
Cartesian x coordinate.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
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
int layer() const
Definition: RPCDetId.h:108
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
std::vector< RPCDigi >::const_iterator const_iterator
HLT enums.
std::pair< const_iterator, const_iterator > Range
T x() const
Definition: PV3DBase.h:62
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:75
Definition: event.py:1
Definition: Run.h:42
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96