CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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, 68.2, 74.1, 81.1, 88.2, 96.6, 104.9, 115.1, 125.2, 137.3, 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; Entries", binnum, bins);
43  me0_strip_dg_bkgElePos_rad = ibooker.book1D( "me0_strip_dg_bkgElePos_radius", "Neutron background: electrons+positrons; Radius; Entries", binnum, bins);
44  me0_strip_dg_bkgNeutral_rad = ibooker.book1D( "me0_strip_dg_bkgNeutral_radius", "Neutron background: gammas+neutrons; Radius; Entries", binnum, bins);
45 
46  for( unsigned int region_num = 0 ; region_num < nregion ; region_num++ ) {
47  me0_strip_dg_zr_tot[region_num] = BookHistZR(ibooker,"me0_strip_dg_tot","Digi",region_num);
48  me0_strip_dg_zr_tot_Muon[region_num] = BookHistZR(ibooker,"me0_strip_dg_tot_Muon","Digi Muon",region_num);
49  for( unsigned int layer_num = 0 ; layer_num < 6 ; layer_num++) {
50 
51  std::string hist_name_for_dx_local = std::string("me0_strip_dg_dx_local")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
52  std::string hist_name_for_dy_local = std::string("me0_strip_dg_dy_local")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
53  std::string hist_name_for_dphi_global = std::string("me0_strip_dg_dphi_global")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
54 
55  std::string hist_name_for_den_eta = std::string("me0_strip_dg_den_eta")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
56  std::string hist_name_for_num_eta = std::string("me0_strip_dg_num_eta")+regionLabel[region_num]+"_l"+layerLabel[layer_num];
57 
58  std::string hist_label_for_dx_local = "Local DeltaX: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #Delta X_{local} [cm]; Entries";
59  std::string hist_label_for_dy_local = "Local DeltaY: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #Delta Y_{local} [cm]; Entries";
60  std::string hist_label_for_dphi_global = "Global DeltaPhi: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #Delta #phi_{global} [rad]; Entries";
61 
62  std::string hist_label_for_den_eta = "Denominator: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #eta; Entries";
63  std::string hist_label_for_num_eta = "Numerator: region"+regionLabel[region_num]+" layer "+layerLabel[layer_num]+" ; #eta; Entries";
64 
65  me0_strip_dg_xy[region_num][layer_num] = BookHistXY(ibooker,"me0_strip_dg","Digi",region_num,layer_num);
66  me0_strip_dg_xy_Muon[region_num][layer_num] = BookHistXY(ibooker,"me0_strip_dg_Muon","Digi Muon",region_num,layer_num);
67 
68  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);
69  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);
70  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);
71 
72  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);
73  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);
74 
75  }
76  }
77 }
78 
80 }
81 
82 
84  const edm::EventSetup& iSetup)
85 {
87  iSetup.get<MuonGeometryRecord>().get(hGeom);
88  const ME0Geometry* ME0Geometry_ =( &*hGeom);
89 
91  e.getByToken(InputTagToken_, ME0Hits);
92 
94  e.getByToken(InputTagToken_Digi, ME0Digis);
95 
96  if (!ME0Hits.isValid() | !ME0Digis.isValid() ) {
97  edm::LogError("ME0DigisValidation") << "Cannot get ME0Hits/ME0Digis by Token simInputTagToken";
98  return ;
99  }
100 
101  num_evts->Fill(1);
102  bool toBeCounted1 = true;
103 
104  for (ME0DigiPreRecoCollection::DigiRangeIterator cItr=ME0Digis->begin(); cItr!=ME0Digis->end(); cItr++) {
105  ME0DetId id = (*cItr).first;
106 
107  const GeomDet* gdet = ME0Geometry_->idToDet(id);
108  if ( gdet == nullptr) {
109  edm::LogWarning("ME0DigisValidation")<<"Getting DetId failed. Discard this gem strip hit. Maybe it comes from unmatched geometry.";
110  continue;
111  }
112  const BoundPlane & surface = gdet->surface();
113 
114  int region = (int) id.region();
115  int layer = (int) id.layer();
116  int chamber = (int) id.chamber();
117 // int roll = (int) id.roll();
118 
120  for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
121  {
122 
123  LocalPoint lp(digiItr->x(), digiItr->y(), 0);
124 
125  GlobalPoint gp = surface.toGlobal(lp);
126 
127  float g_r = (float) gp.perp();
128  float g_x = (float) gp.x();
129  float g_y = (float) gp.y();
130  float g_z = (float) gp.z();
131 
132  int particleType = digiItr->pdgid();
133  int isPrompt = digiItr->prompt();
134 
135  float timeOfFlight = digiItr->tof();
136 
139  me0_strip_dg_time_tot->Fill(timeOfFlight);
140 
141  // fill hist
142  int region_num = 0 ;
143  if ( region == -1 ) region_num = 0 ;
144  else if ( region == 1) region_num = 1;
145  int layer_num = layer-1;
146 
147  bool toBeCounted2 = true;
148 
149  if (isPrompt == 1 && abs(particleType) == 13) {
150 
151  me0_strip_dg_zr_tot_Muon[region_num]->Fill(g_z,g_r);
152  me0_strip_dg_xy_Muon[region_num][layer_num]->Fill(g_x,g_y);
153 
154  for (auto hits=ME0Hits->begin(); hits!=ME0Hits->end(); hits++) {
155 
156  int particleType_sh = hits->particleType();
157  int evtId_sh = hits->eventId().event();
158  int bx_sh = hits->eventId().bunchCrossing();
159  int procType_sh = hits->processType();
160 
161  if(!(abs(particleType_sh) == 13 && evtId_sh == 0 && bx_sh == 0 && procType_sh == 0)) continue;
162 
163  const ME0DetId id(hits->detUnitId());
164  int region_sh = id.region();
165  int layer_sh = id.layer();
166  int chamber_sh = id.chamber();
167 // int roll_sh = id.roll();
168 
169  int region_sh_num = 0 ;
170  if ( region_sh == -1 ) region_sh_num = 0 ;
171  else if ( region_sh == 1) region_sh_num = 1;
172  int layer_sh_num = layer_sh - 1;
173 
174  LocalPoint lp_sh = hits->localPosition();
175  GlobalPoint gp_sh = ME0Geometry_->idToDet(id)->surface().toGlobal(lp_sh);
176 
177  if(toBeCounted1){
178 
179  me0_strip_dg_den_eta[region_sh_num][layer_sh_num]->Fill(fabs(gp_sh.eta()));
180  me0_strip_dg_den_eta_tot->Fill(fabs(gp_sh.eta()));
181  }
182 
183  if(!(region == region_sh && layer == layer_sh && chamber == chamber_sh /*&& roll == roll_sh*/)) continue;
184 
185  float dx_loc = lp_sh.x()-lp.x();
186  float dy_loc = lp_sh.y()-lp.y();
187 
188  if(!(fabs(dx_loc) < 3*sigma_x_ && fabs(dy_loc) < 3*sigma_y_)) continue;
189 
190  float timeOfFlight_sh = hits->tof();
191  const LocalPoint centralLP(0., 0., 0.);
192  const GlobalPoint centralGP(ME0Geometry_->idToDet(id)->surface().toGlobal(centralLP));
193  float centralTOF(centralGP.mag() / 29.98); //speed of light
194  float timeOfFlight_sh_corr = timeOfFlight_sh - centralTOF;
195 
196  float dphi_glob = gp_sh.phi()-gp.phi();
197 
198  me0_strip_dg_dx_local_Muon[region_num][layer_num]->Fill(dx_loc);
199  me0_strip_dg_dy_local_Muon[region_num][layer_num]->Fill(dy_loc);
200  me0_strip_dg_dphi_global_Muon[region_num][layer_num]->Fill(dphi_glob);
201 
205 
207  me0_strip_dg_dtime_tot_Muon->Fill(timeOfFlight - timeOfFlight_sh_corr);
208 
209  if(toBeCounted2){
210 
211  me0_strip_dg_num_eta[region_num][layer_num]->Fill(fabs(gp_sh.eta()));
212  me0_strip_dg_num_eta_tot->Fill(fabs(gp_sh.eta()));
213 
214  }
215  toBeCounted2 = false;
216 
217  }//loop SH
218 
219  toBeCounted1 = false;
220 
221  }
222  else {
223  me0_strip_dg_zr_tot[region_num]->Fill(g_z,g_r);
224  me0_strip_dg_xy[region_num][layer_num]->Fill(g_x,g_y);
225  }
226 
227  if ((abs(particleType) == 11 || abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
228  me0_strip_dg_bkg_rad_tot->Fill(fabs(gp.perp()));
229  if ((abs(particleType) == 11) && isPrompt == 0)
230  me0_strip_dg_bkgElePos_rad->Fill(fabs(gp.perp()));
231  if ((abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
232  me0_strip_dg_bkgNeutral_rad->Fill(fabs(gp.perp()));
233 
234  }//loop DG
235  }
236 
237 }
#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]
tuple cfg
Definition: looper.py:293
MonitorElement * me0_strip_dg_den_eta_tot
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual const GeomDet * idToDet(DetId) const
Definition: ME0Geometry.cc:42
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
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]
T phi() const
Definition: Phi.h:41
MonitorElement * me0_strip_dg_dtime_tot_Muon
MonitorElement * me0_strip_dg_xy[2][6]
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
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:75
MonitorElement * me0_strip_dg_dy_local_Muon[2][6]
#define M_PI
MonitorElement * me0_strip_dg_bkgNeutral_rad
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * me0_strip_dg_dx_local_tot_Muon
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
edm::EDGetToken InputTagToken_Digi
const T & get() const
Definition: EventSetup.h:56
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: ME0DetId.h:46
std::vector< ME0DigiPreReco >::const_iterator const_iterator
MonitorElement * me0_strip_dg_time_tot
edm::EDGetToken InputTagToken_
return(e1-e2)*(e1-e2)+dp *dp
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
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:13
tuple particleType
Definition: Run.h:42
MonitorElement * me0_strip_dg_dx_local_Muon[2][6]