CMS 3D CMS Logo

ME0DigisValidation.cc
Go to the documentation of this file.
2 #include <TMath.h>
3 
5 {
6  InputTagToken_ = consumes<edm::PSimHitContainer>(cfg.getParameter<edm::InputTag>("simInputLabel"));
7  InputTagToken_Digi = consumes<ME0DigiPreRecoCollection>(cfg.getParameter<edm::InputTag>("digiInputLabel"));
8  sigma_x_ = cfg.getParameter<double>("sigma_x");
9  sigma_y_ = cfg.getParameter<double>("sigma_y");
10 }
11 
13 
14  LogDebug("MuonME0DigisValidation")<<"Info: Loading Geometry information\n";
15  ibooker.setCurrentFolder("MuonME0DigisV/ME0DigisTask");
16 
17  unsigned int nregion = 2;
18 
19  edm::LogInfo("MuonME0DigisValidation")<<"+++ Info : # of region: "<<nregion<<std::endl;
20 
21  LogDebug("MuonME0DigisValidation")<<"+++ Info : finish to get geometry information from ES.\n";
22 
23  num_evts = ibooker.book1D( "num_evts", "Number of events; ; Number of events", 1, 0, 2);
24 
25  me0_strip_dg_x_local_tot = ibooker.book1D( "me0_strip_dg_x_local_tot", "Local X; X_{local} [cm]; Entries", 60, -30.0, +30.0);
26  me0_strip_dg_y_local_tot = ibooker.book1D( "me0_strip_dg_y_local_tot", "Local Y; Y_{local} [cm]; Entries", 100, -50.0, +50.0);
27  me0_strip_dg_time_tot = ibooker.book1D( "me0_strip_dg_time_tot", "ToF; ToF [ns]; Entries", 400, -200, +200);
28 
29  me0_strip_dg_dx_local_tot_Muon = ibooker.book1D( "me0_strip_dg_dx_local_tot", "Local DeltaX; #Delta X_{local} [cm]; Entries", 50, -0.1, +0.1);
30  me0_strip_dg_dy_local_tot_Muon = ibooker.book1D( "me0_strip_dg_dy_local_tot", "Local DeltaY; #Delta Y_{local} [cm]; Entries", 500, -10.0, +10.0);
31  me0_strip_dg_dphi_global_tot_Muon = ibooker.book1D( "me0_strip_dg_dphi_global_tot", "Global DeltaPhi; #Delta #phi_{global} [rad]; Entries", 50, -0.01, +0.01);
32  me0_strip_dg_dtime_tot_Muon = ibooker.book1D( "me0_strip_dg_dtime_tot", "DeltaToF; #Delta ToF [ns]; Entries", 50, -5, +5);
33 
34  me0_strip_dg_dphi_vs_phi_global_tot_Muon = ibooker.book2D( "me0_strip_dg_dphi_vs_phi_global_tot", "Global DeltaPhi vs. Phi; #phi_{global} [rad]; #Delta #phi_{global} [rad]", 72,-M_PI,+M_PI,50,-0.01,+0.01);
35 
36  me0_strip_dg_den_eta_tot = ibooker.book1D( "me0_strip_dg_den_eta_tot", "Denominator; #eta; Entries", 12, 1.8, 3.0);
37  me0_strip_dg_num_eta_tot = ibooker.book1D( "me0_strip_dg_num_eta_tot", "Numerator; #eta; Entries", 12, 1.8, 3.0);
38 
39  float bins[] = {62.3, 70.0, 77.7, 87.1, 96.4, 108.2, 119.9, 134.7, 149.5};
40  int binnum = sizeof(bins)/sizeof(float) - 1;
41 
42  me0_strip_dg_bkg_rad_tot = ibooker.book1D( "me0_strip_dg_bkg_radius_tot", "Total neutron background; Radius [cm]; Entries", binnum, bins);
43  me0_strip_dg_bkgElePos_rad = ibooker.book1D( "me0_strip_dg_bkgElePos_radius", "Neutron background: electrons+positrons; Radius [cm]; Entries", binnum, bins);
44  me0_strip_dg_bkgNeutral_rad = ibooker.book1D( "me0_strip_dg_bkgNeutral_radius", "Neutron background: gammas+neutrons; Radius [cm]; Entries", binnum, bins);
45 
46  me0_strip_exp_bkg_rad_tot = ibooker.book1D( "me0_strip_exp_bkg_radius_tot", "Total expected neutron background; Radius [cm]; Hit Rate [Hz/cm^{2}]", binnum, bins);
47  me0_strip_exp_bkgElePos_rad = ibooker.book1D( "me0_strip_exp_bkgElePos_radius", "Expected neutron background: electrons+positrons; Radius [cm]; Hit Rate [Hz/cm^{2}]", binnum, bins);
48  me0_strip_exp_bkgNeutral_rad = ibooker.book1D( "me0_strip_exp_bkgNeutral_radius", "Expected neutron background: gammas+neutrons; Radius [cm]; Hit Rate [Hz/cm^{2}]", binnum, bins);
49 
50  std::vector<double> neuBkg, eleBkg;
51  neuBkg.push_back(899644.0); neuBkg.push_back(-30841.0); neuBkg.push_back(441.28);
52  neuBkg.push_back(-3.3405); neuBkg.push_back(0.0140588); neuBkg.push_back(-3.11473e-05); neuBkg.push_back(2.83736e-08);
53  eleBkg.push_back(4.68590e+05); eleBkg.push_back(-1.63834e+04); eleBkg.push_back(2.35700e+02);
54  eleBkg.push_back(-1.77706e+00); eleBkg.push_back(7.39960e-03); eleBkg.push_back(-1.61448e-05); eleBkg.push_back(1.44368e-08);
55 
56  for(int i = 1; i < me0_strip_exp_bkgNeutral_rad->getTH1F()->GetSize(); i++){
57 
58  double pos = me0_strip_exp_bkgNeutral_rad->getTH1F()->GetBinCenter(i);
59  double neutral = 0;
60  double charged = 0;
61 
62  double pos_helper = 1.0;
63  for(int j = 0; j < 7; ++j) {
64 
65  neutral += neuBkg[j]*pos_helper;
66  charged += eleBkg[j]*pos_helper;
67  pos_helper *= pos;
68 
69  }
70 
73  me0_strip_exp_bkg_rad_tot->setBinContent(i, neutral+charged);
74 
75  }
76 
77  for( unsigned int region_num = 0 ; region_num < nregion ; region_num++ ) {
78  me0_strip_dg_zr_tot[region_num] = BookHistZR(ibooker,"me0_strip_dg_tot","Digi",region_num);
79  me0_strip_dg_zr_tot_Muon[region_num] = BookHistZR(ibooker,"me0_strip_dg_tot_Muon","Digi Muon",region_num);
80  for( unsigned int layer_num = 0 ; layer_num < 6 ; layer_num++) {
81 
82  std::string hist_name_for_dx_local = std::string("me0_strip_dg_dx_local")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
83  std::string hist_name_for_dy_local = std::string("me0_strip_dg_dy_local")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
84  std::string hist_name_for_dphi_global = std::string("me0_strip_dg_dphi_global")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
85 
86  std::string hist_name_for_den_eta = std::string("me0_strip_dg_den_eta")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
87  std::string hist_name_for_num_eta = std::string("me0_strip_dg_num_eta")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
88 
89  std::string hist_label_for_dx_local = "Local DeltaX: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #Delta X_{local} [cm]; Entries";
90  std::string hist_label_for_dy_local = "Local DeltaY: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #Delta Y_{local} [cm]; Entries";
91  std::string hist_label_for_dphi_global = "Global DeltaPhi: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #Delta #phi_{global} [rad]; Entries";
92 
93  std::string hist_label_for_den_eta = "Denominator: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #eta; Entries";
94  std::string hist_label_for_num_eta = "Numerator: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #eta; Entries";
95 
96  me0_strip_dg_xy[region_num][layer_num] = BookHistXY(ibooker,"me0_strip_dg","Digi",region_num,layer_num);
97  me0_strip_dg_xy_Muon[region_num][layer_num] = BookHistXY(ibooker,"me0_strip_dg_Muon","Digi Muon",region_num,layer_num);
98 
99  me0_strip_dg_dx_local_Muon[region_num][layer_num] = ibooker.book1D( hist_name_for_dx_local.c_str(), hist_label_for_dx_local.c_str(), 50, -0.1, +0.1);
100  me0_strip_dg_dy_local_Muon[region_num][layer_num] = ibooker.book1D( hist_name_for_dy_local.c_str(), hist_label_for_dy_local.c_str(), 500, -10.0, +10.0);
101  me0_strip_dg_dphi_global_Muon[region_num][layer_num] = ibooker.book1D( hist_name_for_dphi_global.c_str(), hist_label_for_dphi_global.c_str(), 50, -0.01, +0.01);
102 
103  me0_strip_dg_den_eta[region_num][layer_num] = ibooker.book1D( hist_name_for_den_eta, hist_label_for_den_eta, 12, 1.8, 3.0);
104  me0_strip_dg_num_eta[region_num][layer_num] = ibooker.book1D( hist_name_for_num_eta, hist_label_for_num_eta, 12, 1.8, 3.0);
105 
106  }
107  }
108 }
109 
111 }
112 
113 
115  const edm::EventSetup& iSetup)
116 {
118  iSetup.get<MuonGeometryRecord>().get(hGeom);
119  const ME0Geometry* ME0Geometry_ =( &*hGeom);
120 
122  e.getByToken(InputTagToken_, ME0Hits);
123 
125  e.getByToken(InputTagToken_Digi, ME0Digis);
126 
127  if (!ME0Hits.isValid() | !ME0Digis.isValid() ) {
128  edm::LogError("ME0DigisValidation") << "Cannot get ME0Hits/ME0Digis by Token simInputTagToken";
129  return ;
130  }
131 
132  num_evts->Fill(1);
133  bool toBeCounted1 = true;
134 
135  for (ME0DigiPreRecoCollection::DigiRangeIterator cItr=ME0Digis->begin(); cItr!=ME0Digis->end(); cItr++) {
136  ME0DetId id = (*cItr).first;
137 
138  const GeomDet* gdet = ME0Geometry_->idToDet(id);
139  if ( gdet == nullptr) {
140  edm::LogWarning("ME0DigisValidation")<<"Getting DetId failed. Discard this gem strip hit. Maybe it comes from unmatched geometry.";
141  continue;
142  }
143  const BoundPlane & surface = gdet->surface();
144 
145  int region = (int) id.region();
146  int layer = (int) id.layer();
147  int chamber = (int) id.chamber();
148  int roll = (int) id.roll();
149 
151  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
152  {
153 
154  LocalPoint lp(digiItr->x(), digiItr->y(), 0);
155 
156  GlobalPoint gp = surface.toGlobal(lp);
157 
158  float g_r = (float) gp.perp();
159  float g_x = (float) gp.x();
160  float g_y = (float) gp.y();
161  float g_z = (float) gp.z();
162 
163  int particleType = digiItr->pdgid();
164  int isPrompt = digiItr->prompt();
165 
166  float timeOfFlight = digiItr->tof();
167 
170  me0_strip_dg_time_tot->Fill(timeOfFlight);
171 
172  // fill hist
173  int region_num = 0 ;
174  if ( region == -1 ) region_num = 0 ;
175  else if ( region == 1) region_num = 1;
176  int layer_num = layer-1;
177 
178  bool toBeCounted2 = true;
179 
180  if (isPrompt == 1 && abs(particleType) == 13) {
181 
182  me0_strip_dg_zr_tot_Muon[region_num]->Fill(g_z,g_r);
183  me0_strip_dg_xy_Muon[region_num][layer_num]->Fill(g_x,g_y);
184 
185  for (auto hits=ME0Hits->begin(); hits!=ME0Hits->end(); hits++) {
186 
187  int particleType_sh = hits->particleType();
188  int evtId_sh = hits->eventId().event();
189  int bx_sh = hits->eventId().bunchCrossing();
190  int procType_sh = hits->processType();
191 
192  if(!(abs(particleType_sh) == 13 && evtId_sh == 0 && bx_sh == 0 && procType_sh == 0)) continue;
193 
194  const ME0DetId id(hits->detUnitId());
195  int region_sh = id.region();
196  int layer_sh = id.layer();
197  int chamber_sh = id.chamber();
198  int roll_sh = id.roll();
199 
200  int region_sh_num = 0 ;
201  if ( region_sh == -1 ) region_sh_num = 0 ;
202  else if ( region_sh == 1) region_sh_num = 1;
203  int layer_sh_num = layer_sh - 1;
204 
205  LocalPoint lp_sh = hits->localPosition();
206  GlobalPoint gp_sh = ME0Geometry_->idToDet(id)->surface().toGlobal(lp_sh);
207 
208  if(toBeCounted1){
209 
210  me0_strip_dg_den_eta[region_sh_num][layer_sh_num]->Fill(fabs(gp_sh.eta()));
211  me0_strip_dg_den_eta_tot->Fill(fabs(gp_sh.eta()));
212  }
213 
214  if(!(region == region_sh && layer == layer_sh && chamber == chamber_sh && roll == roll_sh)) continue;
215 
216  float dx_loc = lp_sh.x()-lp.x();
217  float dy_loc = lp_sh.y()-lp.y();
218  float dphi_glob = gp_sh.phi()-gp.phi();
219  float deta_glob = gp_sh.eta()-gp.eta();
220 
221  if(!(fabs(dphi_glob) < 3*sigma_x_ && fabs(deta_glob) < 3*sigma_y_)) continue;
222 
223  float timeOfFlight_sh = hits->tof();
224  const LocalPoint centralLP(0., 0., 0.);
225  const GlobalPoint centralGP(ME0Geometry_->idToDet(id)->surface().toGlobal(centralLP));
226  float centralTOF(centralGP.mag() / 29.98); //speed of light
227  float timeOfFlight_sh_corr = timeOfFlight_sh - centralTOF;
228 
229  me0_strip_dg_dx_local_Muon[region_num][layer_num]->Fill(dx_loc);
230  me0_strip_dg_dy_local_Muon[region_num][layer_num]->Fill(dy_loc);
231  me0_strip_dg_dphi_global_Muon[region_num][layer_num]->Fill(dphi_glob);
232 
236 
238  me0_strip_dg_dtime_tot_Muon->Fill(timeOfFlight - timeOfFlight_sh_corr);
239 
240  if(toBeCounted2){
241 
242  me0_strip_dg_num_eta[region_num][layer_num]->Fill(fabs(gp_sh.eta()));
243  me0_strip_dg_num_eta_tot->Fill(fabs(gp_sh.eta()));
244 
245  }
246  toBeCounted2 = false;
247 
248  }//loop SH
249 
250  toBeCounted1 = false;
251 
252  }
253  else {
254  me0_strip_dg_zr_tot[region_num]->Fill(g_z,g_r);
255  me0_strip_dg_xy[region_num][layer_num]->Fill(g_x,g_y);
256  }
257 
258  if ((abs(particleType) == 11 || abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
259  me0_strip_dg_bkg_rad_tot->Fill(fabs(gp.perp()));
260  if ((abs(particleType) == 11) && isPrompt == 0)
261  me0_strip_dg_bkgElePos_rad->Fill(fabs(gp.perp()));
262  if ((abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
263  me0_strip_dg_bkgNeutral_rad->Fill(fabs(gp.perp()));
264 
265  }//loop DG
266  }
267 
268 }
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
T getParameter(std::string const &) const
MonitorElement * me0_strip_dg_num_eta[2][6]
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * me0_strip_dg_den_eta_tot
MonitorElement * me0_strip_exp_bkgElePos_rad
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
TH1F * getTH1F() const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< std::string > layerLabel
T y() const
Definition: PV3DBase.h:63
MonitorElement * me0_strip_dg_num_eta_tot
MonitorElement * me0_strip_dg_x_local_tot
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
MonitorElement * me0_strip_dg_dphi_global_Muon[2][6]
MonitorElement * me0_strip_dg_y_local_tot
return((rh^lh)&mask)
void Fill(long long x)
MonitorElement * BookHistXY(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
MonitorElement * num_evts
MonitorElement * me0_strip_dg_zr_tot_Muon[2]
MonitorElement * me0_strip_dg_dtime_tot_Muon
MonitorElement * me0_strip_dg_xy[2][6]
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * me0_strip_dg_dphi_global_tot_Muon
MonitorElement * me0_strip_dg_xy_Muon[2][6]
MonitorElement * me0_strip_dg_dy_local_tot_Muon
ME0DigisValidation(const edm::ParameterSet &)
std::vector< std::string > regionLabel
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * me0_strip_dg_dy_local_Muon[2][6]
#define M_PI
MonitorElement * me0_strip_dg_bkgNeutral_rad
MonitorElement * me0_strip_exp_bkgNeutral_rad
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * me0_strip_dg_dx_local_tot_Muon
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
edm::EDGetToken InputTagToken_Digi
std::vector< ME0DigiPreReco >::const_iterator const_iterator
const GeomDet * idToDet(DetId) const override
Definition: ME0Geometry.cc:42
MonitorElement * me0_strip_dg_time_tot
edm::EDGetToken InputTagToken_
T eta() const
Definition: PV3DBase.h:76
MonitorElement * me0_strip_dg_bkg_rad_tot
MonitorElement * me0_strip_dg_den_eta[2][6]
MonitorElement * me0_strip_dg_bkgElePos_rad
T get() const
Definition: EventSetup.h:63
MonitorElement * me0_strip_exp_bkg_rad_tot
MonitorElement * me0_strip_dg_dphi_vs_phi_global_tot_Muon
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void analyze(const edm::Event &e, const edm::EventSetup &) override
T x() const
Definition: PV3DBase.h:62
MonitorElement * me0_strip_dg_zr_tot[2]
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:17
Definition: Run.h:44
MonitorElement * me0_strip_dg_dx_local_Muon[2][6]