CMS 3D CMS Logo

RPCDigiValid.cc
Go to the documentation of this file.
4 
10 
11 #include <cmath>
12 
13 using namespace std;
14 using namespace edm;
15 
17  // Init the tokens for run data retrieval - stanislav
18  // ps.getUntackedParameter<InputTag> retrieves a InputTag from the
19  // configuration. The second param is default value module, instance and
20  // process labels may be passed in a single string if separated by colon ':'
21  // (@see the edm::InputTag constructor documentation)
22  simHitToken = consumes<PSimHitContainer>(
23  ps.getUntrackedParameter<edm::InputTag>("simHitTag", edm::InputTag("g4SimHits:MuonRPCHits")));
24  rpcDigiToken = consumes<RPCDigiCollection>(
25  ps.getUntrackedParameter<edm::InputTag>("rpcDigiTag", edm::InputTag("simMuonRPCDigis")));
26 
27  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "rpcDigiValidPlots.root");
28 
29  rpcGeomToken_ = esConsumes();
30 }
31 
33 
35  // Get the RPC Geometry
36  auto rpcGeom = eventSetup.getHandle(rpcGeomToken_);
37 
40  event.getByToken(simHitToken, simHit);
41  event.getByToken(rpcDigiToken, rpcDigis);
42 
43  // Loop on simhits
44  PSimHitContainer::const_iterator simIt;
45 
46  // loop over Simhit
47  std::map<RPCDetId, std::vector<double>> allsims;
48 
49  for (simIt = simHit->begin(); simIt != simHit->end(); simIt++) {
50  RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId();
51  const RPCRoll *soll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(Rsid));
52  int ptype = simIt->particleType();
53 
54  if (ptype == 13 || ptype == -13) {
55  std::vector<double> buff;
56  if (allsims.find(Rsid) != allsims.end()) {
57  buff = allsims[Rsid];
58  }
59 
60  buff.push_back(simIt->localPosition().x());
61 
62  allsims[Rsid] = buff;
63  }
64  GlobalPoint p = soll->toGlobal(simIt->localPosition());
65 
66  double sim_x = p.x();
67  double sim_y = p.y();
68 
69  xyview->Fill(sim_x, sim_y);
70 
71  if (Rsid.region() == (+1)) {
72  if (Rsid.station() == 4) {
73  xyvDplu4->Fill(sim_x, sim_y);
74  }
75  } else if (Rsid.region() == (-1)) {
76  if (Rsid.station() == 4) {
77  xyvDmin4->Fill(sim_x, sim_y);
78  }
79  }
80  rzview->Fill(p.z(), p.perp());
81  }
82  // loop over Digis
84  for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt) {
85  const RPCDetId Rsid = (*detUnitIt).first;
86  const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(Rsid));
87 
88  const RPCDigiCollection::Range &range = (*detUnitIt).second;
89  std::vector<double> sims;
90  if (allsims.find(Rsid) != allsims.end()) {
91  sims = allsims[Rsid];
92  }
93 
94  int ndigi = 0;
95  for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
96  StripProf->Fill(digiIt->strip());
97  BxDist->Fill(digiIt->bx());
98  // bx for 4 endcaps
99  if (Rsid.region() == (+1)) {
100  if (Rsid.station() == 4)
101  BxDisc_4Plus->Fill(digiIt->bx());
102  } else if (Rsid.region() == (-1)) {
103  if (Rsid.station() == 4)
104  BxDisc_4Min->Fill(digiIt->bx());
105  }
106 
107  // Fill timing information
108  const double digiTime = digiIt->hasTime() ? digiIt->time() : digiIt->bx() * 25;
109  hDigiTimeAll->Fill(digiTime);
110  if (digiIt->hasTime()) {
111  hDigiTime->Fill(digiTime);
112  if (roll->isIRPC())
113  hDigiTimeIRPC->Fill(digiTime);
114  else
115  hDigiTimeNoIRPC->Fill(digiTime);
116  }
117  }
118 
119  if (sims.size() == 1 && ndigi == 1) {
120  double dis = roll->centreOfStrip(range.first->strip()).x() - sims[0];
121  Res->Fill(dis);
122 
123  if (Rsid.region() == 0) {
124  if (Rsid.ring() == -2)
125  ResWmin2->Fill(dis);
126  else if (Rsid.ring() == -1)
127  ResWmin1->Fill(dis);
128  else if (Rsid.ring() == 0)
129  ResWzer0->Fill(dis);
130  else if (Rsid.ring() == 1)
131  ResWplu1->Fill(dis);
132  else if (Rsid.ring() == 2)
133  ResWplu2->Fill(dis);
134  // barrel layers
135  if (Rsid.station() == 1 && Rsid.layer() == 1)
136  ResLayer1_barrel->Fill(dis);
137  if (Rsid.station() == 1 && Rsid.layer() == 2)
138  ResLayer2_barrel->Fill(dis);
139  if (Rsid.station() == 2 && Rsid.layer() == 1)
140  ResLayer3_barrel->Fill(dis);
141  if (Rsid.station() == 2 && Rsid.layer() == 2)
142  ResLayer4_barrel->Fill(dis);
143  if (Rsid.station() == 3)
144  ResLayer5_barrel->Fill(dis);
145  if (Rsid.station() == 4)
146  ResLayer6_barrel->Fill(dis);
147  }
148  // endcap layers residuals
149  if (Rsid.region() != 0) {
150  if (Rsid.ring() == 2) {
151  if (abs(Rsid.station()) == 1) {
152  if (Rsid.roll() == 1)
153  Res_Endcap1_Ring2_A->Fill(dis);
154  if (Rsid.roll() == 2)
155  Res_Endcap1_Ring2_B->Fill(dis);
156  if (Rsid.roll() == 3)
157  Res_Endcap1_Ring2_C->Fill(dis);
158  }
159  if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3) {
160  if (Rsid.roll() == 1)
161  Res_Endcap23_Ring2_A->Fill(dis);
162  if (Rsid.roll() == 2)
163  Res_Endcap23_Ring2_B->Fill(dis);
164  if (Rsid.roll() == 3)
165  Res_Endcap23_Ring2_C->Fill(dis);
166  }
167  }
168  if (Rsid.ring() == 3) {
169  if (Rsid.roll() == 1)
170  Res_Endcap123_Ring3_A->Fill(dis);
171  if (Rsid.roll() == 2)
172  Res_Endcap123_Ring3_B->Fill(dis);
173  if (Rsid.roll() == 3)
174  Res_Endcap123_Ring3_C->Fill(dis);
175  }
176  }
177 
178  if (Rsid.region() == (+1)) {
179  if (Rsid.station() == 1)
180  ResDplu1->Fill(dis);
181  else if (Rsid.station() == 2)
182  ResDplu2->Fill(dis);
183  else if (Rsid.station() == 3)
184  ResDplu3->Fill(dis);
185  else if (Rsid.station() == 4)
186  ResDplu4->Fill(dis);
187  }
188  if (Rsid.region() == (-1)) {
189  if (Rsid.station() == 1)
190  ResDmin1->Fill(dis);
191  else if (Rsid.station() == 2)
192  ResDmin2->Fill(dis);
193  else if (Rsid.station() == 3)
194  ResDmin3->Fill(dis);
195  else if (Rsid.station() == 4)
196  ResDmin4->Fill(dis);
197  }
198  }
199  }
200 }
201 
203  booker.setCurrentFolder("RPCDigisV/RPCDigis");
204 
205  xyview = booker.book2D("X_Vs_Y_View", "X_Vs_Y_View", 155, -775., 775., 155, -775., 775.);
206 
207  xyvDplu4 = booker.book2D("Dplu4_XvsY", "Dplu4_XvsY", 155, -775., 775., 155, -775., 775.);
208  xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.);
209 
210  rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.);
211  Res = booker.book1D("Digi_SimHit_difference", "Digi_SimHit_difference", 300, -8, 8);
212  ResWmin2 = booker.book1D("W_Min2_Residuals", "W_Min2_Residuals", 400, -8, 8);
213  ResWmin1 = booker.book1D("W_Min1_Residuals", "W_Min1_Residuals", 400, -8, 8);
214  ResWzer0 = booker.book1D("W_Zer0_Residuals", "W_Zer0_Residuals", 400, -8, 8);
215  ResWplu1 = booker.book1D("W_Plu1_Residuals", "W_Plu1_Residuals", 400, -8, 8);
216  ResWplu2 = booker.book1D("W_Plu2_Residuals", "W_Plu2_Residuals", 400, -8, 8);
217 
218  ResLayer1_barrel = booker.book1D("ResLayer1_barrel", "ResLayer1_barrel", 400, -8, 8);
219  ResLayer2_barrel = booker.book1D("ResLayer2_barrel", "ResLayer2_barrel", 400, -8, 8);
220  ResLayer3_barrel = booker.book1D("ResLayer3_barrel", "ResLayer3_barrel", 400, -8, 8);
221  ResLayer4_barrel = booker.book1D("ResLayer4_barrel", "ResLayer4_barrel", 400, -8, 8);
222  ResLayer5_barrel = booker.book1D("ResLayer5_barrel", "ResLayer5_barrel", 400, -8, 8);
223  ResLayer6_barrel = booker.book1D("ResLayer6_barrel", "ResLayer6_barrel", 400, -8, 8);
224 
225  BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.);
226  StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100);
227 
228  BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.);
229  BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.);
230 
231  // endcap residuals
232  ResDmin1 = booker.book1D("Disk_Min1_Residuals", "Disk_Min1_Residuals", 400, -8, 8);
233  ResDmin2 = booker.book1D("Disk_Min2_Residuals", "Disk_Min2_Residuals", 400, -8, 8);
234  ResDmin3 = booker.book1D("Disk_Min3_Residuals", "Disk_Min3_Residuals", 400, -8, 8);
235  ResDplu1 = booker.book1D("Disk_Plu1_Residuals", "Disk_Plu1_Residuals", 400, -8, 8);
236  ResDplu2 = booker.book1D("Disk_Plu2_Residuals", "Disk_Plu2_Residuals", 400, -8, 8);
237  ResDplu3 = booker.book1D("Disk_Plu3_Residuals", "Disk_Plu3_Residuals", 400, -8, 8);
238 
239  ResDmin4 = booker.book1D("Disk_Min4_Residuals", "Disk_Min4_Residuals", 400, -8, 8);
240  ResDplu4 = booker.book1D("Disk_Plu4_Residuals", "Disk_Plu4_Residuals", 400, -8, 8);
241 
242  Res_Endcap1_Ring2_A = booker.book1D("Res_Endcap1_Ring2_A", "Res_Endcap1_Ring2_A", 400, -8, 8);
243  Res_Endcap1_Ring2_B = booker.book1D("Res_Endcap1_Ring2_B", "Res_Endcap1_Ring2_B", 400, -8, 8);
244  Res_Endcap1_Ring2_C = booker.book1D("Res_Endcap1_Ring2_C", "Res_Endcap1_Ring2_C", 400, -8, 8);
245 
246  Res_Endcap23_Ring2_A = booker.book1D("Res_Endcap23_Ring2_A", "Res_Endcap23_Ring2_A", 400, -8, 8);
247  Res_Endcap23_Ring2_B = booker.book1D("Res_Endcap23_Ring2_B", "Res_Endcap23_Ring2_B", 400, -8, 8);
248  Res_Endcap23_Ring2_C = booker.book1D("Res_Endcap23_Ring2_C", "Res_Endcap23_Ring2_C", 400, -8, 8);
249 
250  Res_Endcap123_Ring3_A = booker.book1D("Res_Endcap123_Ring3_A", "Res_Endcap123_Ring3_A", 400, -8, 8);
251  Res_Endcap123_Ring3_B = booker.book1D("Res_Endcap123_Ring3_B", "Res_Endcap123_Ring3_B", 400, -8, 8);
252  Res_Endcap123_Ring3_C = booker.book1D("Res_Endcap123_Ring3_C", "Res_Endcap123_Ring3_C", 400, -8, 8);
253 
254  // Timing informations
255  hDigiTimeAll =
256  booker.book1D("DigiTimeAll", "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5);
257  hDigiTime = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5);
258  hDigiTimeIRPC = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5);
259  hDigiTimeNoIRPC = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5);
260 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int ring() const
Definition: RPCDetId.h:59
RPCDigiValid(const edm::ParameterSet &ps)
Definition: RPCDigiValid.cc:16
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: RPCDigiValid.cc:34
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
~RPCDigiValid() override
Definition: RPCDigiValid.cc:32
int roll() const
Definition: RPCDetId.h:92
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::pair< const_iterator, const_iterator > Range
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
std::vector< RPCDigi >::const_iterator const_iterator
int station() const
Definition: RPCDetId.h:78
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
HLT enums.
float x
int layer() const
Definition: RPCDetId.h:85
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: event.py:1
Definition: Run.h:45