CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCRecHitValid.cc
Go to the documentation of this file.
1  /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2008/10/21 10:48:14 $
5  * $Revision: 1.2 $
6  * \author D. Pagano - Dip. Fis. Nucl. e Teo. & INFN Pavia
7  */
8 
10 
12 
17 
23 
24 using namespace std;
25 using namespace edm;
26 
27 
29  rootFileName = pset.getUntrackedParameter<string>("rootFileName", "rpcRecHitValidPlots.root");
30  //simHitLabel = pset.getUntrackedParameter<string>("g4SimHits", "MuonRPCHits");
31  //recHitLabel = pset.getUntrackedParameter<string>("recHitLabel", "RPCRecHitProducer");
33 
34  if ( dbe_ ) {
35 
36  Rechisto = dbe_->book1D("RecHits", "RPC RecHits", 300, -150, 150);
37  Simhisto = dbe_->book1D("SimHits", "Simulated Hits", 300, -150, 150);
38  Pulls = dbe_->book1D("Global Pulls", "RPC Global Pulls", 100, -4,4);
39  ClSize = dbe_->book1D("Global ClSize", "Global Cluster Size", 10, 0, 10);
40  res1cl = dbe_->book1D("Residuals CS = 1", "Residuals for ClSize = 1", 300, -8, 8);
41 
42 // dbe_->setCurrentFolder("Residuals");
43 // Res = dbe_->book1D("Global Residuals", "Global Residuals", 300, -8, 8);
44 // ResWmin2 = dbe_->book1D("W-2 Residuals", "Residuals for Wheel -2", 300, -8, 8);
45 // ResWmin1 = dbe_->book1D("W-1 Residuals", "Residuals for Wheel -1", 300, -8, 8);
46 // ResWzer0 = dbe_->book1D("W 0 Residuals", "Residuals for Wheel 0", 300, -8, 8);
47 // ResWplu1 = dbe_->book1D("W+1 Residuals", "Residuals for Wheel +1", 300, -8, 8);
48 // ResWplu2 = dbe_->book1D("W+2 Residuals", "Residuals for Wheel +2", 300, -8, 8);
49 // ResS1 = dbe_->book1D("Sector 1 Residuals", "Sector 1 Residuals", 300, -8, 8);
50 // ResS3 = dbe_->book1D("Sector 3 Residuals", "Sector 3 Residuals", 300, -8, 8);
51 
52  dbe_->setCurrentFolder("Residuals and Occupancy");
53  occRB1IN = dbe_->book1D("RB1 IN Occupancy", "RB1 IN Occupancy", 100, 0, 100);
54  occRB1OUT = dbe_->book1D("RB1 OUT Occupancy", "RB1 OUT Occupancy", 100, 0, 100);
55 
56  // dbe_->setCurrentFolder("Residuals");
57  Res = dbe_->book1D("Global Residuals", "Global Residuals", 300, -8, 8);
58  ResWmin2 = dbe_->book1D("W-2 Residuals", "Residuals for Wheel -2", 300, -8, 8);
59  ResWmin1 = dbe_->book1D("W-1 Residuals", "Residuals for Wheel -1", 300, -8, 8);
60  ResWzer0 = dbe_->book1D("W 0 Residuals", "Residuals for Wheel 0", 300, -8, 8);
61  ResWplu1 = dbe_->book1D("W+1 Residuals", "Residuals for Wheel +1", 300, -8, 8);
62  ResWplu2 = dbe_->book1D("W+2 Residuals", "Residuals for Wheel +2", 300, -8, 8);
63  ResS1 = dbe_->book1D("Sector 1 Residuals", "Sector 1 Residuals", 300, -8, 8);
64  ResS3 = dbe_->book1D("Sector 3 Residuals", "Sector 3 Residuals", 300, -8, 8);
65 
66 
67 
68 
69  }
70 }
71 
73 
74 // Destructor
76 }
77 
79  if ( rootFileName.size() != 0 && dbe_ ) dbe_->save(rootFileName);
80 }
81 
82 
83 
84 void RPCRecHitValid::analyze(const Event & event, const EventSetup& eventSetup){
85 
86  // Get the RPC Geometry
87  ESHandle<RPCGeometry> rpcGeom;
88  eventSetup.get<MuonGeometryRecord>().get(rpcGeom);
89 
91  event.getByLabel("g4SimHits", "MuonRPCHits", simHit);
92  std::map<double, int> mapsim;
93  std::map<int, double> nmapsim;
94  std::map<double, int> simWmin2;
95  std::map<double, int> simWmin1;
96  std::map<double, int> simWzer0;
97  std::map<double, int> simWplu1;
98  std::map<double, int> simWplu2;
99  std::map<double, int> simS1;
100  std::map<double, int> simS3;
101  std::map<int, double> nsimWmin2;
102  std::map<int, double> nsimWmin1;
103  std::map<int, double> nsimWzer0;
104  std::map<int, double> nsimWplu1;
105  std::map<int, double> nsimWplu2;
106  std::map<int, double> nsimS1;
107  std::map<int, double> nsimS3;
108 
110  event.getByLabel("rpcRecHits", recHit);
111  std::map<double, int> maprec;
112  std::map<int, double> nmaprec;
113  std::map<double, double> nmaperr;
114  std::map<int, double> nmapres;
115 
116  std::map<double, int> maprecCL1;
117  std::map<int, double> nmaprecCL1;
118 
119  std::map<double, int> recWmin2;
120  std::map<double, int> recWmin1;
121  std::map<double, int> recWzer0;
122  std::map<double, int> recWplu1;
123  std::map<double, int> recWplu2;
124  std::map<double, int> recS1;
125  std::map<double, int> recS3;
126  std::map<int, double> nrecWmin2;
127  std::map<int, double> nrecWmin1;
128  std::map<int, double> nrecWzer0;
129  std::map<int, double> nrecWplu1;
130  std::map<int, double> nrecWplu2;
131  std::map<int, double> nrecS1;
132  std::map<int, double> nrecS3;
133  std::map<double, double> errWmin2;
134  std::map<double, double> errWmin1;
135  std::map<double, double> errWzer0;
136  std::map<double, double> errWplu1;
137  std::map<double, double> errWplu2;
138 
139 
140  // Loop on rechits
142  int nrec = 0;
143  int nrecCL1 = 0;
144  int nrecmin2 = 0;
145  int nrecmin1 = 0;
146  int nreczer0 = 0;
147  int nrecplu1 = 0;
148  int nrecplu2 = 0;
149  int nrecS1c = 0;
150  int nrecS3c = 0;
151 
152  for (recIt = recHit->begin(); recIt != recHit->end(); recIt++) {
153  RPCDetId Rid = (RPCDetId)(*recIt).rpcId();
154  const RPCRoll* roll = dynamic_cast<const RPCRoll* >( rpcGeom->roll(Rid));
155  if((roll->isForward())) return;
156  int clsize = (*recIt).clusterSize();
157  int fstrip = (*recIt).firstClusterStrip();
158 
159  nrec = nrec + 1;
160  LocalPoint rhitlocal = (*recIt).localPosition();
161  LocalError locerr = (*recIt).localPositionError();
162  double rhitlocalx = rhitlocal.x();
163  double rhiterrx = locerr.xx();
164  Rechisto->Fill(rhitlocalx);
165  int wheel = roll->id().ring();
166  int sector = roll->id().sector();
167  int station = roll->id().station();
168  int k = roll->id().layer();
169  // int s = roll->id().subsector();
170 
171  //-----CLSIZE = 1------------
172  if (clsize == 1) {
173  maprecCL1[rhitlocalx] = nrec;
174  nrecCL1 = nrecCL1 + 1;
175  }
176  //-----------------------------
177 
178  ClSize->Fill(clsize); //Global Cluster Size
179 
180 
181  // occupancy
182  for (int occ = 0; occ < clsize; occ++) {
183  int occup = fstrip + occ;
184  if (station == 1 && k == 1) {
185  occRB1IN->Fill(occup);
186  }
187  if (station == 1 && k == 2) {
188  occRB1OUT->Fill(occup);
189  }
190  }
191 
192 
193  maprec[rhitlocalx] = nrec;
194  nmaperr[rhitlocalx] = rhiterrx;
195 
196  //-------PHI-------------------
197  if(sector == 1) {
198  recS1[rhitlocalx] = nrec;
199  nrecS1c = nrecS1c + 1;
200  }
201  if(sector == 3) {
202  recS3[rhitlocalx] = nrec;
203  nrecS3c = nrecS3c + 1;
204  }
205  //----------------------------
206 
207  if(wheel == -2) {
208  recWmin2[rhitlocalx] = nrec;
209  errWmin2[rhitlocalx] = rhiterrx;
210  nrecmin2 = nrecmin2 + 1;
211  }
212  if(wheel == -1) {
213  recWmin1[rhitlocalx] = nrec;
214  errWmin1[rhitlocalx] = rhiterrx;
215  nrecmin1 = nrecmin1 + 1;
216  }
217  if(wheel == 0) {
218  recWzer0[rhitlocalx] = nrec;
219  errWzer0[rhitlocalx] = rhiterrx;
220  nreczer0 = nreczer0 + 1;
221  }
222  if(wheel == 1) {
223  recWplu1[rhitlocalx] = nrec;
224  errWplu1[rhitlocalx] = rhiterrx;
225  nrecplu1 = nrecplu1 + 1;
226  }
227  if(wheel == 2) {
228  recWplu2[rhitlocalx] = nrec;
229  errWplu2[rhitlocalx] = rhiterrx;
230  nrecplu2 = nrecplu2 + 1;
231  }
232  }
233  //cout << " --> Found " << nrec << " rechit in event " << event.id().event() << endl;
234 
235  // Global rechit mapping
236  int i = 0;
237  for (map<double, int>::iterator iter = maprec.begin(); iter != maprec.end(); iter++) {
238  i = i + 1;
239  nmaprec[i] = (*iter).first;
240  }
241  // CL = 1 rechit mapping
242  i = 0;
243  for (map<double, int>::iterator iter = maprecCL1.begin(); iter != maprecCL1.end(); iter++) {
244  i = i + 1;
245  nmaprecCL1[i] = (*iter).first;
246  }
247  // Wheel -2 rechit mapping
248  i = 0;
249  for (map<double, int>::iterator iter = recWmin2.begin(); iter != recWmin2.end(); iter++) {
250  i = i + 1;
251  nrecWmin2[i] = (*iter).first;
252  }
253  // Wheel -1 rechit mapping
254  i = 0;
255  for (map<double, int>::iterator iter = recWmin1.begin(); iter != recWmin1.end(); iter++) {
256  i = i + 1;
257  nrecWmin1[i] = (*iter).first;
258  }
259  // Wheel 0 rechit mapping
260  i = 0;
261  for (map<double, int>::iterator iter = recWzer0.begin(); iter != recWzer0.end(); iter++) {
262  i = i + 1;
263  nrecWzer0[i] = (*iter).first;
264  }
265  // Wheel +1 rechit mapping
266  i = 0;
267  for (map<double, int>::iterator iter = recWplu1.begin(); iter != recWplu1.end(); iter++) {
268  i = i + 1;
269  nrecWplu1[i] = (*iter).first;
270  }
271  // Wheel +2 rechit mapping
272  i = 0;
273  for (map<double, int>::iterator iter = recWplu2.begin(); iter != recWplu2.end(); iter++) {
274  i = i + 1;
275  nrecWplu2[i] = (*iter).first;
276  }
277  // Sector 1 rechit mapping
278  i = 0;
279  for (map<double, int>::iterator iter = recS1.begin(); iter != recS1.end(); iter++) {
280  i = i + 1;
281  nrecS1[i] = (*iter).first;
282  }
283  // Sector 3 rechit mapping
284  i = 0;
285  for (map<double, int>::iterator iter = recS3.begin(); iter != recS3.end(); iter++) {
286  i = i + 1;
287  nrecS3[i] = (*iter).first;
288  }
289 
290 
291  // Loop on simhits
292  PSimHitContainer::const_iterator simIt;
293  int nsim = 0;
294  int nsimmin2 = 0;
295  int nsimmin1 = 0;
296  int nsimzer0 = 0;
297  int nsimplu1 = 0;
298  int nsimplu2 = 0;
299  int nsimS1c = 0;
300  int nsimS3c = 0;
301 
302  for (simIt = simHit->begin(); simIt != simHit->end(); simIt++) {
303  int ptype = (*simIt).particleType();
304  RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId();
305  const RPCRoll* roll = dynamic_cast<const RPCRoll* >( rpcGeom->roll(Rsid));
306  int Swheel = roll->id().ring();
307  int Ssector = roll->id().sector();
308 
309  // selection of muon hits
310  if (ptype == 13 || ptype == -13) {
311  nsim = nsim + 1;
312  LocalPoint shitlocal = (*simIt).localPosition();
313  double shitlocalx = shitlocal.x();
314  Simhisto->Fill(shitlocalx);
315 
316  mapsim[shitlocalx] = nsim;
317 
318  //----PHI------------------------
319  if(Ssector == 1) {
320  simS1[shitlocalx] = nsim;
321  nsimS1c = nsimS1c + 1;
322  }
323  if(Ssector == 3) {
324  simS3[shitlocalx] = nsim;
325  nsimS3c = nsimS3c + 1;
326  }
327  //--------------------------------
328 
329 
330  if(Swheel == -2) {
331  simWmin2[shitlocalx] = nsim;
332  nsimmin2 = nsimmin2 + 1;
333  }
334  if(Swheel == -1) {
335  simWmin1[shitlocalx] = nsim;
336  nsimmin1 = nsimmin1 + 1;
337  }
338  if(Swheel == 0) {
339  simWzer0[shitlocalx] = nsim;
340  nsimzer0 = nsimzer0 + 1;
341  }
342  if(Swheel == 1) {
343  simWplu1[shitlocalx] = nsim;
344  nsimplu1 = nsimplu1 + 1;
345  }
346  if(Swheel == 2) {
347  simWplu2[shitlocalx] = nsim;
348  nsimplu2 = nsimplu2 + 1;
349  }
350 
351  }
352  }
353  //cout << " --> Found " << nsim <<" simhits in event " << event.id().event() << endl;
354 
355  // Global simhit mapping
356  i = 0;
357  for (map<double, int>::iterator iter = mapsim.begin(); iter != mapsim.end(); iter++) {
358  i = i + 1;
359  nmapsim[i] = (*iter).first;
360  }
361  // Wheel -2 simhit mapping
362  i = 0;
363  for (map<double, int>::iterator iter = simWmin2.begin(); iter != simWmin2.end(); iter++) {
364  i = i + 1;
365  nsimWmin2[i] = (*iter).first;
366  }
367  // Wheel -1 simhit mapping
368  i = 0;
369  for (map<double, int>::iterator iter = simWmin1.begin(); iter != simWmin1.end(); iter++) {
370  i = i + 1;
371  nsimWmin1[i] = (*iter).first;
372  }
373  // Wheel 0 simhit mapping
374  i = 0;
375  for (map<double, int>::iterator iter = simWzer0.begin(); iter != simWzer0.end(); iter++) {
376  i = i + 1;
377  nsimWzer0[i] = (*iter).first;
378  }
379  // Wheel +1 simhit mapping
380  i = 0;
381  for (map<double, int>::iterator iter = simWplu1.begin(); iter != simWplu1.end(); iter++) {
382  i = i + 1;
383  nsimWplu1[i] = (*iter).first;
384  }
385  // Wheel +2 simhit mapping
386  i = 0;
387  for (map<double, int>::iterator iter = simWplu2.begin(); iter != simWplu2.end(); iter++) {
388  i = i + 1;
389  nsimWplu2[i] = (*iter).first;
390  }
391  // Sector 1 simhit mapping
392  i = 0;
393  for (map<double, int>::iterator iter = simS1.begin(); iter != simS1.end(); iter++) {
394  i = i + 1;
395  nsimS1[i] = (*iter).first;
396  }
397  // Sector 3 simhit mapping
398  i = 0;
399  for (map<double, int>::iterator iter = simS3.begin(); iter != simS3.end(); iter++) {
400  i = i + 1;
401  nsimS3[i] = (*iter).first;
402  }
403 
404  // Compute residuals
405  double res,resmin2,resmin1,reszer0,resplu1,resplu2,resS1,resS3;
406  if (nsim == nrec) {
407  for (int r=0; r<nsim; r++) {
408  res = nmapsim[r+1] - nmaprec[r+1];
409  nmapres[r+1] = res;
410  Res->Fill(res);
411  }
412  }
413  if (nsim == nrecCL1) {
414  for (int r=0; r<nsim; r++) {
415  res = nmapsim[r+1] - nmaprecCL1[r+1];
416  //cout << nmapsim[r+1] << " " << nmaprecCL1[r+1] << endl;
417  if (abs(res) < 3) {
418  res1cl->Fill(res);
419  }
420  }
421  }
422  if (nsimmin2 == nrecmin2) {
423  for (int r=0; r<nsimmin2; r++) {
424  resmin2 = nsimWmin2[r+1] - nrecWmin2[r+1];
425  ResWmin2->Fill(resmin2);
426  }
427  }
428  if (nsimmin1 == nrecmin1) {
429  for (int r=0; r<nsimmin1; r++) {
430  resmin1 = nsimWmin1[r+1] - nrecWmin1[r+1];
431  ResWmin1->Fill(resmin1);
432  }
433  }
434  if (nsimzer0 == nreczer0) {
435  for (int r=0; r<nsimzer0; r++) {
436  reszer0 = nsimWzer0[r+1] - nrecWzer0[r+1];
437  ResWzer0->Fill(reszer0);
438  }
439  }
440  if (nsimplu1 == nrecplu1) {
441  for (int r=0; r<nsimplu1; r++) {
442  resplu1 = nsimWplu1[r+1] - nrecWplu1[r+1];
443  ResWplu1->Fill(resplu1);
444  }
445  }
446  if (nsimplu2 == nrecplu2) {
447  for (int r=0; r<nsimplu2; r++) {
448  resplu2 = nsimWplu2[r+1] - nrecWplu2[r+1];
449  ResWplu2->Fill(resplu2);
450  }
451  }
452  if (nsimS1c == nrecS1c) {
453  for (int r=0; r<nsimS1c; r++) {
454  resS1 = nsimS1[r+1] - nrecS1[r+1];
455  ResS1->Fill(resS1);
456  }
457  }
458  if (nsimS3c == nrecS3c) {
459  for (int r=0; r<nsimS3c; r++) {
460  resS3 = nsimS3[r+1] - nrecS3[r+1];
461  ResS3->Fill(resS3);
462  }
463  }
464 
465 
466  // compute Pulls
467  double pull;
468  if (nsim == nrec) {
469  for (int r=0; r<nsim; r++) {
470  pull = nmapres[r+1] / nmaperr[nmaprec[r+1]];
471  Pulls->Fill(pull);
472  }
473  }
474 }
475 
476 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void endJob(void)
float xx() const
Definition: LocalError.h:19
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1883
#define abs(x)
Definition: mlp_lapack.h:159
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
RPCDetId id() const
Definition: RPCRoll.cc:24
void analyze(const edm::Event &e, const edm::EventSetup &c)
int ring() const
Definition: RPCDetId.h:74
tuple pset
Definition: CrabTask.py:85
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
DQMStore * dbe_
int k[5][pyjets_maxn]
int layer() const
Definition: RPCDetId.h:110
static const char * Res
Definition: FitHist_fwd.h:7
const T & get() const
Definition: EventSetup.h:55
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:104
RPCRecHitValid(const edm::ParameterSet &ps)
T x() const
Definition: PV3DBase.h:56
bool isForward() const
Definition: RPCRoll.cc:98
int station() const
Definition: RPCDetId.h:98