CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSimHitsValidAnalyzer.cc
Go to the documentation of this file.
2 
3 #include "TFile.h"
4 #include "TTree.h"
5 #include "TBranch.h"
6 #include "TH1F.h"
7 
8 #include <iostream>
9 #include <string>
10 
11 using namespace edm;
12 using namespace std;
13 
14 
16  fName(""), verbosity(0), label(""), getAllProvenances(false),
17  printProvenanceInfo(false), nRawGenPart(0), count(0)
18 
19 {
21  fName = iPSet.getUntrackedParameter<std::string>("Name");
22  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
23  label = iPSet.getParameter<std::string>("Label");
24  edm::ParameterSet m_Prov =
25  iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
27  m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
29  m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
30 
31  nRawGenPart = 0;
32  // ROOT Histos output files
33  DToutputFile_ = iPSet.getUntrackedParameter<std::string>("DT_outputFile", "");
34  // CSCoutputFile_ = iPSet.getUntrackedParameter<std::string>("CSC_outputFile", "");
35  // RPCoutputFile_ = iPSet.getUntrackedParameter<std::string>("RPC_outputFile", "");
36 
37 
39  CSCHitsToken_ = consumes<edm::PSimHitContainer>(
40  iPSet.getParameter<edm::InputTag>("CSCHitsSrc"));
41  DTHitsToken_ = consumes<edm::PSimHitContainer>(
42  iPSet.getParameter<edm::InputTag>("DTHitsSrc"));
43  RPCHitsToken_ = consumes<edm::PSimHitContainer>(
44  iPSet.getParameter<edm::InputTag>("RPCHitsSrc"));
45 
47 
48  if (verbosity) {
49  Labels l;
51  edm::LogInfo ("MuonSimHitsValidAnalyzer::MuonSimHitsValidAnalyzer")
52  << "\n===============================\n"
53  << "Initialized as EDAnalyzer with parameter values:\n"
54  << " Name = " << fName << "\n"
55  << " Verbosity = " << verbosity << "\n"
56  << " Label = " << label << "\n"
57  << " GetProv = " << getAllProvenances << "\n"
58  << " PrintProv = " << printProvenanceInfo << "\n"
59  // << " CSCHitsSrc= " <<CSCHitsSrc_.label()
60  // << ":" << CSCHitsSrc_.instance() << "\n"
61  << " DTHitsSrc = " << l.module
62  << ":" << l.productInstance << "\n"
63  // << " RPCHitsSrc= " <<RPCHitsSrc_.label()
64  // << ":" << RPCHitsSrc_.instance() << "\n"
65  << "===============================\n";
66  }
67 
68  // ----------------------
69  // get hold of back-end interface DT
70  dbeDT_ = 0;
72  if ( dbeDT_ ) {
73  if ( verbosity ) {
74  dbeDT_->setVerbose(1);
75  } else {
76  dbeDT_->setVerbose(0);
77  }
78  }
79  if ( dbeDT_ ) {
80  if ( verbosity ) dbeDT_->showDirStructure();
81  }
82 
83  // ----------------------
84 
85  bookHistos_DT();
86 
87  /*
88  // get hold of back-end interface CSC
89  dbeCSC_ = 0;
90  dbeCSC_ = Service<DQMStore>().operator->();
91  if ( dbeCSC_ ) {
92  if ( verbosity ) {
93  dbeCSC_->setVerbose(1);
94  } else {
95  dbeCSC_->setVerbose(0);
96  }
97  }
98  if ( dbeCSC_ ) {
99  if ( verbosity ) dbeCSC_->showDirStructure();
100  }
101 
102  // ----------------------
103 
104  bookHistos_CSC();
105 
106  // get hold of back-end interface RPC
107  dbeRPC_ = 0;
108  dbeRPC_ = Service<DQMStore>().operator->();
109  if ( dbeRPC_ ) {
110  if ( verbosity ) {
111  dbeRPC_->setVerbose(1);
112  } else {
113  dbeRPC_->setVerbose(0);
114  }
115  }
116  if ( dbeRPC_ ) {
117  if ( verbosity ) dbeRPC_->showDirStructure();
118  }
119 
120  // ----------------------
121 
122  bookHistos_RPC();
123  */
124 
125  pow6=1000000.0;
126  mom4 =0.;
127  mom1 = 0;
128  costeta = 0.;
129  radius = 0;
130  sinteta = 0.;
131  globposx = 0.;
132  globposy = 0;
133  nummu_DT = 0;
134  nummu_CSC =0;
135  nummu_RPC=0;
136 
137 }
138 
140 {
141  if ( DToutputFile_.size() != 0 )
142  {
143  LogInfo("OutputInfo") << " DT MuonHits histos file is closed " ;
144  theDTFile->Close();
145  }
146 
147 // theCSCFile->Close();
148 // theRPCFile->Close();
149 }
150 
152 {
153  return;
154 }
155 
157 {
158  meAllDTHits =0 ;
159  meMuDTHits =0 ;
160  meToF =0 ;
161  meEnergyLoss =0 ;
162  meMomentumMB1 =0 ;
163  meMomentumMB4 =0 ;
164  meLossMomIron =0 ;
165  meLocalXvsZ =0 ;
166  meLocalXvsY =0 ;
167  meGlobalXvsZ =0 ;
168  meGlobalXvsY =0 ;
169  meGlobalXvsZWm2 =0 ;
170  meGlobalXvsZWm1 =0 ;
171  meGlobalXvsZW0 =0 ;
172  meGlobalXvsZWp1 =0 ;
173  meGlobalXvsZWp2 =0 ;
174  meGlobalXvsYWm2 =0 ;
175  meGlobalXvsYWm1 =0 ;
176  meGlobalXvsYW0 =0 ;
177  meGlobalXvsYWp1 =0 ;
178  meGlobalXvsYWp2 =0 ;
179  meWheelOccup =0 ;
180  meStationOccup =0 ;
181  meSectorOccup =0 ;
182  meSuperLOccup =0 ;
183  meLayerOccup =0 ;
184  meWireOccup =0 ;
185  mePathMuon =0 ;
186  meChamberOccup =0 ;
187  meHitRadius =0 ;
188  meCosTheta =0 ;
189  meGlobalEta =0 ;
190  meGlobalPhi =0 ;
191 
192  if ( DToutputFile_.size() != 0 ) {
193  theDTFile = new TFile(DToutputFile_.c_str(),"RECREATE");
194  theDTFile->cd();
195  LogInfo("OutputInfo") << " DT MuonHits histograms will be saved to '" << DToutputFile_.c_str() << "'";
196  } else {
197  LogInfo("OutputInfo") << " DT MuonHits histograms will NOT be saved";
198  }
199 
200 
201  Char_t histo_n[100];
202  Char_t histo_t[100];
203 
204  if ( dbeDT_ ) {
205  dbeDT_->setCurrentFolder("MuonDTHitsV/DTHitsValidationTask");
206 
207  sprintf (histo_n, "Number_of_all_DT_hits" );
208  sprintf (histo_t, "Number_of_all_DT_hits" );
209  meAllDTHits = dbeDT_->book1D(histo_n, histo_t, 200, 1.0, 201.0) ;
210 
211  sprintf (histo_n, "Number_of_muon_DT_hits" );
212  sprintf (histo_t, "Number_of_muon_DT_hits" );
213  meMuDTHits = dbeDT_->book1D(histo_n, histo_t, 150, 1.0, 151.0);
214 
215  sprintf (histo_n, "Tof_of_hits " );
216  sprintf (histo_t, "Tof_of_hits " );
217  meToF = dbeDT_->book1D(histo_n, histo_t, 100, -0.5, 50.) ;
218 
219  sprintf (histo_n, "DT_energy_loss_keV" );
220  sprintf (histo_t, "DT_energy_loss_keV" );
221  meEnergyLoss = dbeDT_->book1D(histo_n, histo_t, 100, 0.0, 10.0);
222 
223  sprintf (histo_n, "Momentum_at_MB1" );
224  sprintf (histo_t, "Momentum_at_MB1" );
225  meMomentumMB1 = dbeDT_->book1D(histo_n, histo_t, 100, 10.0, 200.0);
226 
227  sprintf (histo_n, "Momentum_at_MB4" );
228  sprintf (histo_t, "Momentum_at_MB4" );
229  meMomentumMB4 = dbeDT_->book1D(histo_n, histo_t, 100, 10.0, 200.0) ;
230 
231  sprintf (histo_n, "Loss_of_muon_Momentum_in_Iron" );
232  sprintf (histo_t, "Loss_of_muon_Momentum_in_Iron" );
233  meLossMomIron = dbeDT_->book1D(histo_n, histo_t, 80, 0.0, 40.0) ;
234 
235  sprintf (histo_n, "Local_x-coord_vs_local_z-coord_of_muon_hit" );
236  sprintf (histo_t, "Local_x-coord_vs_local_z-coord_of_muon_hit" );
237  meLocalXvsZ = dbeDT_->book2D(histo_n, histo_t,100, -150., 150., 100, -0.8, 0.8 ) ;
238 
239  sprintf (histo_n, "local_x-coord_vs_local_y-coord_of_muon_hit" );
240  sprintf (histo_t, "local_x-coord_vs_local_y-coord_of_muon_hit" );
241  meLocalXvsY = dbeDT_->book2D(histo_n, histo_t, 100, -150., 150., 100, -150., 150. );
242 
243  sprintf (histo_n, "Global_x-coord_vs_global_z-coord_of_muon_hit" );
244  sprintf (histo_t, "Global_x-coord_vs_global_z-coord_of_muon_hit" );
245  meGlobalXvsZ = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. ) ;
246 
247  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit" );
248  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit" );
249  meGlobalXvsY = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. ) ;
250 
251 // New histos
252 
253  sprintf (histo_n, "Global_x-coord_vs_global_z-coord_of_muon_hit_w-2" );
254  sprintf (histo_t, "Global_x-coord_vs_global_z-coord_of_muon_hit_w-2" );
255  meGlobalXvsZWm2 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
256 
257  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_w-2" );
258  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_w-2" );
259  meGlobalXvsYWm2 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
260 
261  sprintf (histo_n, "Global_x-coord_vs_global_z-coord_of_muon_hit_w-1" );
262  sprintf (histo_t, "Global_x-coord_vs_global_z-coord_of_muon_hit_w-1" );
263  meGlobalXvsZWm1 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
264 
265  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_w-1" );
266  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_w-1" );
267  meGlobalXvsYWm1 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
268 
269  sprintf (histo_n, "Global_x-coord_vs_global_z-coord_of_muon_hit_w0" );
270  sprintf (histo_t, "Global_x-coord_vs_global_z-coord_of_muon_hit_w0" );
271  meGlobalXvsZW0 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
272 
273  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_w0" );
274  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_w0" );
275  meGlobalXvsYW0 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
276 
277  sprintf (histo_n, "Global_x-coord_vs_global_z-coord_of_muon_hit_w1" );
278  sprintf (histo_t, "Global_x-coord_vs_global_z-coord_of_muon_hit_w1" );
279  meGlobalXvsZWp1 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
280 
281  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_w1" );
282  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_w1" );
283  meGlobalXvsYWp1 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
284 
285  sprintf (histo_n, "Global_x-coord_vs_global_z-coord_of_muon_hit_w2" );
286  sprintf (histo_t, "Global_x-coord_vs_global_z-coord_of_muon_hit_w2" );
287  meGlobalXvsZWp2 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
288 
289  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_w2" );
290  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_w2" );
291  meGlobalXvsYWp2 = dbeDT_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
292 
293 //
294 
295  sprintf (histo_n, "Wheel_occupancy" );
296  sprintf (histo_t, "Wheel_occupancy" );
297  meWheelOccup = dbeDT_->book1D(histo_n, histo_t, 10, -5.0, 5.0) ;
298 
299  sprintf (histo_n, "Station_occupancy" );
300  sprintf (histo_t, "Station_occupancy" );
301  meStationOccup = dbeDT_->book1D(histo_n, histo_t, 6, 0., 6.0) ;
302 
303  sprintf (histo_n, "Sector_occupancy" );
304  sprintf (histo_t, "Sector_occupancy" );
305  meSectorOccup = dbeDT_->book1D(histo_n, histo_t, 20, 0., 20.) ;
306 
307  sprintf (histo_n, "SuperLayer_occupancy" );
308  sprintf (histo_t, "SuperLayer_occupancy" );
309  meSuperLOccup = dbeDT_->book1D(histo_n, histo_t, 5, 0., 5.) ;
310 
311  sprintf (histo_n, "Layer_occupancy" );
312  sprintf (histo_t, "Layer_occupancy" );
313  meLayerOccup = dbeDT_->book1D(histo_n, histo_t,6, 0., 6.) ;
314 
315  sprintf (histo_n, "Wire_occupancy" );
316  sprintf (histo_t, "Wire_occupancy" );
317  meWireOccup = dbeDT_->book1D(histo_n, histo_t, 100, 0., 100.) ;
318 
319  sprintf (histo_n, "path_followed_by_muon" );
320  sprintf (histo_t, "path_followed_by_muon" );
321  mePathMuon = dbeDT_->book1D(histo_n, histo_t, 160, 0., 160.) ;
322 
323  sprintf (histo_n, "chamber_occupancy" );
324  sprintf (histo_t, "chamber_occupancy" );
325  meChamberOccup = dbeDT_->book1D(histo_n, histo_t, 251, 0., 251.) ;
326 
327  sprintf (histo_n, "radius_of_hit");
328  sprintf (histo_t, "radius_of_hit");
329  meHitRadius = dbeDT_->book1D(histo_n, histo_t, 100, 0., 1200. );
330 
331  sprintf (histo_n, "costheta_of_hit" );
332  sprintf (histo_t, "costheta_of_hit" );
333  meCosTheta = dbeDT_->book1D(histo_n, histo_t, 100, -1., 1.) ;
334 
335  sprintf (histo_n, "global_eta_of_hit" );
336  sprintf (histo_t, "global_eta_of_hit" );
337  meGlobalEta = dbeDT_->book1D(histo_n, histo_t, 60, -2.7, 2.7 );
338 
339  sprintf (histo_n, "global_phi_of_hit" );
340  sprintf (histo_t, "global_phi_of_hit" );
341  meGlobalPhi = dbeDT_->book1D(histo_n, histo_t, 60, -3.14, 3.14);
342 
343  }
344 
345 }
346 
348 {
349  meAllRPCHits = 0 ;
350  meMuRPCHits = 0 ;
351  meRegionOccup = 0 ;
352  meRingOccBar = 0 ;
353  meRingOccEndc = 0 ;
354  meStatOccBar = 0 ;
355  meStatOccEndc = 0 ;
356  meSectorOccBar = 0 ;
357  meSectorOccEndc = 0 ;
358  meLayerOccBar = 0 ;
359  meLayerOccEndc = 0 ;
360  meSubSectOccBar = 0 ;
361  meSubSectOccEndc = 0 ;
362  meRollOccBar = 0 ;
363  meRollOccEndc = 0 ;
364  meElossBar = 0 ;
365  meElossEndc = 0 ;
366  mepathRPC = 0 ;
367  meMomRB1 = 0 ;
368  meMomRB4 = 0 ;
369  meLossMomBar = 0 ;
370  meMomRE1 = 0 ;
371  meMomRE4 = 0 ;
372  meLossMomEndc = 0 ;
373  meLocalXvsYBar = 0 ;
374  meGlobalXvsZBar = 0 ;
375  meGlobalXvsYBar = 0 ;
376  meLocalXvsYEndc = 0 ;
377  meGlobalXvsZEndc = 0 ;
378  meGlobalXvsYEndc = 0 ;
379  meHitRadiusBar = 0 ;
380  meCosThetaBar = 0 ;
381  meHitRadiusEndc = 0 ;
382  meCosThetaEndc = 0 ;
383 
384  theRPCFile = new TFile(RPCoutputFile_.c_str(),"RECREATE");
385  theRPCFile->cd();
386 
387  Char_t histo_n[100];
388  Char_t histo_t[100];
389 
390  if ( dbeRPC_ ) {
391  dbeRPC_->setCurrentFolder("MuonRPCHitsV/RPCHitsValidationTask");
392 
393  sprintf (histo_n, "Number_of_all_RPC_hits" );
394  sprintf (histo_t, "Number_of_all_RPC_hits" );
395  meAllRPCHits = dbeRPC_->book1D(histo_n, histo_t, 100, 1.0, 101.0) ;
396 
397  sprintf (histo_n, "Number_of_muon_RPC_hits" );
398  sprintf (histo_t, "Number_of_muon_RPC_hits" );
399  meMuRPCHits = dbeRPC_->book1D(histo_n, histo_t, 50, 1., 51.);
400 
401  sprintf (histo_n, "Region_occupancy");
402  sprintf (histo_t, "Region_occupancy");
403  meRegionOccup = dbeRPC_->book1D(histo_n, histo_t, 6, -3.0, 3.0) ;
404 
405  sprintf (histo_n, "Ring_occupancy_barrel");
406  sprintf (histo_t, "Ring_occupancy_barrel");
407  meRingOccBar = dbeRPC_->book1D(histo_n, histo_t, 8, -3., 5.0) ;
408 
409  sprintf (histo_n, "Ring_occupancy_endcaps");
410  sprintf (histo_t, "Ring_occupancy_endcaps");
411  meRingOccEndc = dbeRPC_->book1D(histo_n, histo_t, 8, -3., 5.0) ;
412 
413  sprintf (histo_n, "Station_occupancy_barrel");
414  sprintf (histo_t, "Station_occupancy_barrel");
415  meStatOccBar = dbeRPC_->book1D(histo_n, histo_t, 8, 0., 8.);
416 
417  sprintf (histo_n, "Station_occupancy_endcaps" );
418  sprintf (histo_t, "Station_occupancy_endcaps" );
419  meStatOccEndc = dbeRPC_->book1D(histo_n, histo_t, 8, 0., 8.);
420 
421  sprintf (histo_n, "Sector_occupancy_barrel" );
422  sprintf (histo_t, "Sector_occupancy_barrel" );
423  meSectorOccBar = dbeRPC_->book1D(histo_n, histo_t, 16, 0., 16.) ;
424 
425  sprintf (histo_n, "Sector_occupancy_endcaps" );
426  sprintf (histo_t, "Sector_occupancy_endcaps" );
427  meSectorOccEndc = dbeRPC_->book1D(histo_n, histo_t, 16, 0., 16.) ;
428 
429  sprintf (histo_n, "Layer_occupancy_barrel" );
430  sprintf (histo_t, "Layer_occupancy_barrel" );
431  meLayerOccBar = dbeRPC_->book1D(histo_n, histo_t,4, 0., 4.) ;
432 
433  sprintf (histo_n, "Layer_occupancy_endcaps" );
434  sprintf (histo_t, "Layer_occupancy_endcaps" );
435  meLayerOccEndc = dbeRPC_->book1D(histo_n, histo_t,4, 0., 4.) ;
436 
437  sprintf (histo_n, "Subsector_occupancy_barrel" );
438  sprintf (histo_t, "Subsector_occupancy_barrel" );
439  meSubSectOccBar = dbeRPC_->book1D(histo_n, histo_t, 10, 0., 10.) ;
440 
441  sprintf (histo_n, "Subsector_occupancy_endcaps" );
442  sprintf (histo_t, "Subsector_occupancy_endcaps" );
443  meSubSectOccEndc = dbeRPC_->book1D(histo_n, histo_t, 10, 0., 10.) ;
444 
445  sprintf (histo_n, "Roll_occupancy_barrel" );
446  sprintf (histo_t, "Roll_occupancy_barrel" );
447  meRollOccBar = dbeRPC_->book1D(histo_n, histo_t, 6, 0., 6.) ;
448 
449  sprintf (histo_n, "Roll_occupancy_endcaps" );
450  sprintf (histo_t, "Roll_occupancy_endcaps" );
451  meRollOccEndc = dbeRPC_->book1D(histo_n, histo_t, 6, 0., 6.) ;
452 
453  sprintf (histo_n, "RPC_energy_loss_barrel" );
454  sprintf (histo_t, "RPC_energy_loss_barrel" );
455  meElossBar = dbeRPC_->book1D(histo_n, histo_t, 50, 0.0, 10.0) ;
456 
457  sprintf (histo_n, "RPC_energy_loss_endcaps" );
458  sprintf (histo_t, "RPC_energy_loss_endcaps" );
459  meElossEndc = dbeRPC_->book1D(histo_n, histo_t, 50, 0.0, 10.0) ;
460 
461  sprintf (histo_n, "path_followed_by_muon" );
462  sprintf (histo_t, "path_followed_by_muon" );
463  mepathRPC = dbeRPC_->book1D(histo_n, histo_t, 160, 0., 160.) ;
464 
465  sprintf (histo_n, "Momentum_at_RB1") ;
466  sprintf (histo_t, "Momentum_at_RB1") ;
467  meMomRB1 = dbeRPC_->book1D(histo_n, histo_t, 80, 10.0, 200.0) ;
468 
469  sprintf (histo_n, "Momentum_at_RB4") ;
470  sprintf (histo_t, "Momentum_at_RB4") ;
471  meMomRB4 = dbeRPC_->book1D(histo_n, histo_t, 80, 10.0, 200.0) ;
472 
473  sprintf (histo_n, "Loss_of_muon_Momentum_in_Iron_barrel" );
474  sprintf (histo_t, "Loss_of_muon_Momentum_in_Iron_barrel" );
475  meLossMomBar = dbeRPC_->book1D(histo_n, histo_t, 80, 0.0, 40.0) ;
476 
477  sprintf (histo_n, "Momentum_at_RE1");
478  sprintf (histo_t, "Momentum_at_RE1");
479  meMomRE1 = dbeRPC_->book1D(histo_n, histo_t, 100, 10.0, 300.0);
480 
481  sprintf (histo_n, "Momentum_at_RE4");
482  sprintf (histo_t, "Momentum_at_RE4");
483  meMomRE4 = dbeRPC_->book1D(histo_n, histo_t, 100, 10.0, 300.0);
484 
485  sprintf (histo_n, "Loss_of_muon_Momentum_in_Iron_endcap" );
486  sprintf (histo_t, "Loss_of_muon_Momentum_in_Iron_endcap" );
487  meLossMomEndc = dbeRPC_->book1D(histo_n, histo_t, 80, 0.0, 40.0) ;
488 
489  sprintf (histo_n, "local_x-coord_vs_local_y-coord_of_muon_hit") ;
490  sprintf (histo_t, "local_x-coord_vs_local_y-coord_of_muon_hit") ;
491  meLocalXvsYBar = dbeRPC_->book2D(histo_n, histo_t, 100, -150., 150., 100, -100., 100. );
492 
493  sprintf (histo_n, "Global_z-coord_vs_global_x-coord_of_muon_hit_barrel" );
494  sprintf (histo_t, "Global_z-coord_vs_global_x-coord_of_muon_hit_barrel" );
495  meGlobalXvsZBar = dbeRPC_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
496 
497  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_barrel" );
498  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_barrel" );
499  meGlobalXvsYBar = dbeRPC_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
500 
501  sprintf (histo_n, "radius_of_hit_barrel" );
502  sprintf (histo_t, "radius_of_hit_barrel" );
503  meHitRadiusBar = dbeRPC_->book1D(histo_n, histo_t, 100, 0., 1200.) ;
504 
505  sprintf (histo_n, "radius_of_hit_endcaps" );
506  sprintf (histo_t, "radius_of_hit_endcaps" );
507  meHitRadiusEndc = dbeRPC_->book1D(histo_n, histo_t, 100, 0., 1300.) ;
508 
509  sprintf (histo_n, "costheta_of_hit_barrel" ) ;
510  sprintf (histo_t, "costheta_of_hit_barrel" ) ;
511  meCosThetaBar = dbeRPC_->book1D(histo_n, histo_t, 100, -1., 1.);
512 
513  sprintf (histo_n, "costheta_of_hit_endcaps" );
514  sprintf (histo_t, "costheta_of_hit_endcaps" );
515  meCosThetaEndc = dbeRPC_->book1D(histo_n, histo_t, 100, -1., 1.);
516 
517  sprintf (histo_n, "Global_z-coord_vs_global_x-coord_of_muon_hit_endcaps" );
518  sprintf (histo_t, "Global_z-coord_vs_global_x-coord_of_muon_hit_endcaps" );
519  meGlobalXvsZEndc = dbeRPC_->book2D(histo_n, histo_t, 100, -1200., 1200., 100, -800., 800. ) ;
520 
521  sprintf (histo_n, "Global_x-coord_vs_global_y-coord_of_muon_hit_endcaps" );
522  sprintf (histo_t, "Global_x-coord_vs_global_y-coord_of_muon_hit_endcaps" );
523  meGlobalXvsYEndc = dbeRPC_->book2D(histo_n, histo_t, 100, -800., 800., 100, -800., 800. );
524 
525  }
526 
527 }
528 
530 {
531  meAllCSCHits =0 ;
532  meMuCSCHits =0 ;
533  meEnergyLoss_111 =0 ;
534  meToF_311 =0 ;
535  meEnergyLoss_112 =0 ;
536  meToF_312 =0 ;
537  meEnergyLoss_113 =0 ;
538  meToF_313 =0 ;
539  meEnergyLoss_114 =0 ;
540  meToF_314 =0 ;
541  meEnergyLoss_121 =0 ;
542  meToF_321 =0 ;
543  meEnergyLoss_122 =0 ;
544  meToF_322 =0 ;
545  meEnergyLoss_131 =0 ;
546  meToF_331 =0 ;
547  meEnergyLoss_132 =0 ;
548  meToF_332 =0 ;
549  meEnergyLoss_141 =0 ;
550  meToF_341 =0 ;
551  meEnergyLoss_211 =0 ;
552  meToF_411 =0 ;
553  meEnergyLoss_212 =0 ;
554  meToF_412 =0 ;
555  meEnergyLoss_213 =0 ;
556  meToF_413 =0 ;
557  meEnergyLoss_214 =0 ;
558  meToF_414 =0 ;
559  meEnergyLoss_221 =0 ;
560  meToF_421 =0 ;
561  meEnergyLoss_222 =0 ;
562  meToF_422 =0 ;
563  meEnergyLoss_231 =0 ;
564  meToF_431 =0 ;
565  meEnergyLoss_232 =0 ;
566  meToF_432 =0 ;
567  meEnergyLoss_241 =0 ;
568  meToF_441 =0 ;
569 
570 
571  theCSCFile = new TFile(CSCoutputFile_.c_str(),"RECREATE");
572  theCSCFile->cd();
573 
574  Char_t histo_n[100];
575  Char_t histo_t[100];
576 
577  if ( dbeCSC_ ) {
578  dbeCSC_->setCurrentFolder("MuonCSCHitsV/CSCHitsValidationTask");
579 
580  sprintf (histo_n, "Number_of_all_CSC_hits " );
581  sprintf (histo_t, "Number_of_all_CSC_hits " );
582  meAllCSCHits = dbeCSC_->book1D(histo_n, histo_t, 100, 1.0, 101.0) ;
583 
584  sprintf (histo_n, "Number_of_muon_CSC_hits" );
585  sprintf (histo_t, "Number_of_muon_CSC_hits" );
586  meMuCSCHits = dbeCSC_->book1D(histo_n, histo_t, 50, 1.0, 51.0);
587 
588  sprintf (histo_n, "111__energy_loss");
589  sprintf (histo_t, "111__energy_loss");
590  meEnergyLoss_111 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
591 
592  sprintf (histo_n, "311_tof");
593  sprintf (histo_t, "311_tof");
594  meToF_311 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
595 
596  sprintf (histo_n, "112__energy_loss");
597  sprintf (histo_t, "112__energy_loss");
598  meEnergyLoss_112 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
599 
600  sprintf (histo_n, "312_tof");
601  sprintf (histo_t, "312_tof");
602  meToF_312 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
603 
604  sprintf (histo_n, "113__energy_loss");
605  sprintf (histo_t, "113__energy_loss");
606  meEnergyLoss_111 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
607 
608  sprintf (histo_n, "313_tof");
609  sprintf (histo_t, "313_tof");
610  meToF_313 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
611 
612  sprintf (histo_n, "114__energy_loss");
613  sprintf (histo_t, "114__energy_loss");
614  meEnergyLoss_114 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
615 
616  sprintf (histo_n, "314_tof");
617  sprintf (histo_t, "314_tof");
618  meToF_314 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
619 
620  sprintf (histo_n, "121__energy_loss");
621  sprintf (histo_t, "121__energy_loss");
622  meEnergyLoss_121 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
623 
624  sprintf (histo_n, "321_tof");
625  sprintf (histo_t, "321_tof");
626  meToF_321 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
627 
628  sprintf (histo_n, "122__energy_loss");
629  sprintf (histo_t, "122__energy_loss");
630  meEnergyLoss_122 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
631 
632  sprintf (histo_n, "322_tof");
633  sprintf (histo_t, "322_tof");
634  meToF_322 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
635 
636  sprintf (histo_n, "131__energy_loss");
637  sprintf (histo_t, "131__energy_loss");
638  meEnergyLoss_131 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
639 
640  sprintf (histo_n, "331_tof");
641  sprintf (histo_t, "331_tof");
642  meToF_331 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
643 
644  sprintf (histo_n, "132__energy_loss");
645  sprintf (histo_t, "132__energy_loss");
646  meEnergyLoss_132 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
647 
648  sprintf (histo_n, "332_tof");
649  sprintf (histo_t, "332_tof");
650  meToF_332 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
651 
652  sprintf (histo_n, "141__energy_loss");
653  sprintf (histo_t, "141__energy_loss");
654  meEnergyLoss_141 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
655 
656  sprintf (histo_n, "341_tof");
657  sprintf (histo_t, "341_tof");
658  meToF_341 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
659 
660 
661 
662  sprintf (histo_n, "211__energy_loss");
663  sprintf (histo_t, "211__energy_loss");
664  meEnergyLoss_211 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
665 
666  sprintf (histo_n, "411_tof");
667  sprintf (histo_t, "411_tof");
668  meToF_411 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
669 
670  sprintf (histo_n, "212__energy_loss");
671  sprintf (histo_t, "212__energy_loss");
672  meEnergyLoss_212 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
673 
674  sprintf (histo_n, "412_tof");
675  sprintf (histo_t, "412_tof");
676  meToF_412 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
677 
678  sprintf (histo_n, "213__energy_loss");
679  sprintf (histo_t, "213__energy_loss");
680  meEnergyLoss_211 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
681 
682  sprintf (histo_n, "413_tof");
683  sprintf (histo_t, "413_tof");
684  meToF_413 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
685 
686  sprintf (histo_n, "214__energy_loss");
687  sprintf (histo_t, "214__energy_loss");
688  meEnergyLoss_214 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
689 
690  sprintf (histo_n, "414_tof");
691  sprintf (histo_t, "414_tof");
692  meToF_414 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
693 
694  sprintf (histo_n, "221__energy_loss");
695  sprintf (histo_t, "221__energy_loss");
696  meEnergyLoss_221 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
697 
698  sprintf (histo_n, "421_tof");
699  sprintf (histo_t, "421_tof");
700  meToF_421 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
701 
702  sprintf (histo_n, "222__energy_loss");
703  sprintf (histo_t, "222__energy_loss");
704  meEnergyLoss_222 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
705 
706  sprintf (histo_n, "422_tof");
707  sprintf (histo_t, "422_tof");
708  meToF_422 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
709 
710  sprintf (histo_n, "231__energy_loss");
711  sprintf (histo_t, "231__energy_loss");
712  meEnergyLoss_231 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
713 
714  sprintf (histo_n, "431_tof");
715  sprintf (histo_t, "431_tof");
716  meToF_431 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
717 
718  sprintf (histo_n, "232__energy_loss");
719  sprintf (histo_t, "232__energy_loss");
720  meEnergyLoss_232 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
721 
722  sprintf (histo_n, "432_tof");
723  sprintf (histo_t, "432_tof");
724  meToF_432 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
725 
726  sprintf (histo_n, "241__energy_loss");
727  sprintf (histo_t, "241__energy_loss");
728  meEnergyLoss_241 = dbeCSC_->book1D(histo_n, histo_t,50, 0.0, 50.0) ;
729 
730  sprintf (histo_n, "441_tof");
731  sprintf (histo_t, "441_tof");
732  meToF_441 = dbeCSC_->book1D(histo_n, histo_t, 60, 0.0, 60.0) ;
733 
734  }
735 
736 }
737 
739 {
740  //int DTHistos;
741  //DTHistos = 1000;
742  theDTFile->cd();
743 
744  if ( dbeDT_ ) {
745  dbeDT_->setCurrentFolder("MuonDTHitsV/DTHitsValidationTask");
746  // cout << " DTFile.size " << DToutputFile_.size() << " dbeDT " << dbeDT_ << endl;
748  }
749 
750 // gDirectory->pwd();
751 // theDTFile->ls();
752 // theDTFile->GetList()->ls();
753 // hmgr->save(DTHistos);
754 }
755 
757 {
758  //int RPCHistos;
759  //RPCHistos = 3000;
760  theRPCFile->cd();
761 
762  if ( dbeRPC_ ) {
763  dbeRPC_->setCurrentFolder("MuonRPCHitsV/RPCHitsValidationTask");
764  // cout << " RPCFile.size " << RPCoutputFile_.size() << " dbeRPC " << dbeRPC_ << endl;
766  }
767 
768 
769 
770 
771 // gDirectory->pwd();
772 // theRPCFile->ls();
773 // theRPCFile->GetList()->ls();
774 // hmgr->save(RPCHistos);
775 }
776 
778 {
779  //int CSCHistos;
780  //CSCHistos = 2000;
781  theCSCFile->cd();
782 
783  if ( dbeCSC_ ) {
784  dbeCSC_->setCurrentFolder("MuonCSCHitsV/CSCHitsValidationTask");
785  // cout << " CSCFile.size " << CSCoutputFile_.size() << " dbeCSC " << dbeCSC_ << endl;
787  }
788 
789 
790 
791 // gDirectory->pwd();
792 // theCSCFile->ls();
793 // theCSCFile->GetList()->ls();
794 // hmgr->save(CSCHistos);
795 }
796 
798 {
799 
800  if ( DToutputFile_.size() != 0 ) {
801  saveHistos_DT();
802  LogInfo("OutputInfo") << " DT MuonHits histos already saved" ;
803  } else {
804  LogInfo("OutputInfo") << " DT MuonHits histos NOT saved";
805  }
806 
807 
808 
809 // saveHistos_CSC();
810 // saveHistos_RPC();
811  if (verbosity > 0)
812  edm::LogInfo ("MuonSimHitsValidAnalyzer::endJob")
813  << "Terminating having processed " << count << " events.";
814  return;
815 
816 }
817 
819  const edm::EventSetup& iSetup)
820 {
822  ++count;
823 
825  int nrun = iEvent.id().run();
826  int nevt = iEvent.id().event();
827 
828  if (verbosity > 0) {
829  edm::LogInfo ("MuonSimHitsValidAnalyzer::analyze")
830  << "Processing run " << nrun << ", event " << nevt;
831  }
832 
834  if (getAllProvenances) {
835 
836  std::vector<const edm::Provenance*> AllProv;
837  iEvent.getAllProvenance(AllProv);
838 
839  if (verbosity > 0)
840  edm::LogInfo ("MuonSimHitsValidAnalyzer::analyze")
841  << "Number of Provenances = " << AllProv.size();
842 
843  if (printProvenanceInfo && (verbosity > 0)) {
844  TString eventout("\nProvenance info:\n");
845 
846  for (unsigned int i = 0; i < AllProv.size(); ++i) {
847  eventout += "\n ******************************";
848  eventout += "\n Module : ";
849  eventout += AllProv[i]->moduleLabel();
850  eventout += "\n ProductID : ";
851  eventout += AllProv[i]->productID().id();
852  eventout += "\n ClassName : ";
853  eventout += AllProv[i]->className();
854  eventout += "\n InstanceName : ";
855  eventout += AllProv[i]->productInstanceName();
856  eventout += "\n BranchName : ";
857  eventout += AllProv[i]->branchName();
858  }
859  eventout += " ******************************\n";
860  edm::LogInfo("MuonSimHitsValidAnalyzer::analyze") << eventout << "\n";
861  }
862  }
863 
865 
867 // fillCSC(iEvent, iSetup);
868  fillDT(iEvent, iSetup);
869  // fillRPC(iEvent, iSetup);
870 
871  if (verbosity > 0)
872  edm::LogInfo ("MuonSimHitsValidAnalyzer::analyze")
873  << "Done gathering data from event.";
874 
875  return;
876 }
877 
878 
879 
881  const edm::EventSetup& iSetup)
882 {
883 
884  TString eventout;
885  if (verbosity > 0)
886  eventout = "\nGathering CSC info:";
887 
889  edm::PSimHitContainer::const_iterator itHit;
890 
893  edm::ESHandle<CSCGeometry> theCSCGeometry;
894  iSetup.get<MuonGeometryRecord>().get(theCSCGeometry);
895  if (!theCSCGeometry.isValid()) {
896  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
897  << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
898  return;
899  }
900  const CSCGeometry& theCSCMuon(*theCSCGeometry);
901 
903  edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
904  iEvent.getByToken(CSCHitsToken_, MuonCSCContainer);
905  if (!MuonCSCContainer.isValid()) {
906  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
907  << "Unable to find MuonCSCHits in event!";
908  return;
909  }
910 
911  nummu_CSC =0;
912  meAllCSCHits->Fill( MuonCSCContainer->size() );
913 
915  int i = 0, j = 0;
916  for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end();
917  ++itHit) {
918  ++i;
919 
920 
922  DetId theDetUnitId(itHit->detUnitId());
923  int detector = theDetUnitId.det();
924  int subdetector = theDetUnitId.subdetId();
925 
927  if ((detector == dMuon) &&
928  (subdetector == sdMuonCSC)) {
929 
931  const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
932 
933  if (!theDet) {
934  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
935  << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
936  continue;
937  }
938 
939  ++j;
940 
942  // const BoundPlane& bsurf = theDet->surface();
943 
945 
946  if ( abs(itHit->particleType()) == 13 ) {
947 
948  nummu_CSC++;
949 
950  /* Comment out for the moment
951  const CSCDetId& id=CSCDetId(itHit->detUnitId());
952 
953  int cscid=id.endcap()*100000 + id.station()*10000 +
954  id.ring()*1000 + id.chamber()*10 +id.layer();
955 
956  int iden = cscid/1000;
957 
958  hmgr->getHisto1(iden+2000)->Fill( itHit->energyLoss()*pow6 );
959  hmgr->getHisto1(iden+2200)->Fill( itHit->tof() );
960  */
961  }
962  } else {
963  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
964  << "MuonCsc PSimHit " << i
965  << " is expected to be (det,subdet) = ("
966  << dMuon << "," << sdMuonCSC
967  << "); value returned is: ("
968  << detector << "," << subdetector << ")";
969  continue;
970  }
971  }
972 
973  if (verbosity > 1) {
974  eventout += "\n Number of CSC muon Hits collected:......... ";
975  eventout += j;
976  }
977 
978  meMuCSCHits->Fill( (float) nummu_CSC );
979 
980  if (verbosity > 0)
981  edm::LogInfo("MuonSimHitsValidAnalyzer::fillCSC") << eventout << "\n";
982 
983  return;
984 }
985 
986 
988  const edm::EventSetup& iSetup)
989 {
990  TString eventout;
991  if (verbosity > 0)
992  eventout = "\nGathering DT info:";
993 
995  edm::PSimHitContainer::const_iterator itHit;
996 
999  edm::ESHandle<DTGeometry> theDTGeometry;
1000  iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
1001  if (!theDTGeometry.isValid()) {
1002  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1003  << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
1004  return;
1005  }
1006  const DTGeometry& theDTMuon(*theDTGeometry);
1007 
1009  edm::Handle<edm::PSimHitContainer> MuonDTContainer;
1010  iEvent.getByToken(DTHitsToken_, MuonDTContainer);
1011  if (!MuonDTContainer.isValid()) {
1012  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1013  << "Unable to find MuonDTHits in event!";
1014  return;
1015  }
1016 
1017  touch1 = 0;
1018  touch4 = 0;
1019  nummu_DT = 0 ;
1020 
1021  meAllDTHits->Fill( MuonDTContainer->size() );
1022 
1024  int i = 0, j = 0;
1025  for (itHit = MuonDTContainer->begin(); itHit != MuonDTContainer->end();
1026  ++itHit) {
1027 
1028  ++i;
1029 
1031  DetId theDetUnitId(itHit->detUnitId());
1032  int detector = theDetUnitId.det();
1033  int subdetector = theDetUnitId.subdetId();
1034 
1036  if ((detector == dMuon) &&
1037  (subdetector == sdMuonDT)) {
1038 
1040  const GeomDetUnit *theDet = theDTMuon.idToDetUnit(theDetUnitId);
1041 
1042  if (!theDet) {
1043  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1044  << "Unable to get GeomDetUnit from theDTMuon for hit " << i;
1045  continue;
1046  }
1047 
1048  ++j;
1049 
1051  const BoundPlane& bsurf = theDet->surface();
1052 
1054 
1055  if ( abs(itHit->particleType()) == 13 ) {
1056 
1057  nummu_DT++;
1058  meToF->Fill( itHit->tof() );
1059  meEnergyLoss->Fill( itHit->energyLoss()*pow6 );
1060 
1061  iden = itHit->detUnitId();
1062 
1063  wheel = ((iden>>15) & 0x7 ) -3 ;
1064  station = ((iden>>22) & 0x7 ) ;
1065  sector = ((iden>>18) & 0xf ) ;
1066  superlayer = ((iden>>13) & 0x3 ) ;
1067  layer = ((iden>>10) & 0x7 ) ;
1068  wire = ((iden>>3) & 0x7f ) ;
1069 
1070  meWheelOccup->Fill((float)wheel);
1071  meStationOccup->Fill((float) station);
1072  meSectorOccup->Fill((float) sector);
1073  meSuperLOccup->Fill((float) superlayer);
1074  meLayerOccup->Fill((float) layer);
1075  meWireOccup->Fill((float) wire);
1076 
1077  // Define a quantity to take into account station, splayer and layer being hit.
1078  path = (station-1) * 40 + superlayer * 10 + layer;
1079  mePathMuon->Fill((float) path);
1080 
1081  // Define a quantity to take into chamber being hit.
1082  pathchamber = (wheel+2) * 50 + (station-1) * 12 + sector;
1083  meChamberOccup->Fill((float) pathchamber);
1084 
1086  if (station == 1 )
1087  {
1088  if (touch1 == 0)
1089  {
1090  mom1=itHit->pabs();
1092  touch1 = 1;
1093  }
1094  }
1095 
1097  if (station == 4 )
1098  {
1099  if ( touch4 == 0)
1100  {
1101  mom4=itHit->pabs();
1102  touch4 = 1;
1104  if (touch1 == 1 )
1105  {
1107  }
1108  }
1109  }
1110 
1112  meLocalXvsZ->Fill(itHit->localPosition().x(), itHit->localPosition().z() );
1113 
1115  meLocalXvsY->Fill(itHit->localPosition().x(), itHit->localPosition().y() );
1116 
1118 
1119  globposz = bsurf.toGlobal(itHit->localPosition()).z();
1120  globposeta = bsurf.toGlobal(itHit->localPosition()).eta();
1121  globposphi = bsurf.toGlobal(itHit->localPosition()).phi();
1122 
1123  radius = globposz* ( 1.+ exp(-2.* globposeta) ) / ( 1. - exp(-2.* globposeta ) ) ;
1124 
1125  costeta = ( 1. - exp(-2.*globposeta) ) /( 1. + exp(-2.* globposeta) ) ;
1126  sinteta = 2. * exp(-globposeta) /( 1. + exp(-2.*globposeta) );
1127 
1132 
1135 
1136 // New Histos
1137  if (wheel == -2) {
1140  }
1141  if (wheel == -1) {
1144  }
1145  if (wheel == 0) {
1148  }
1149  if (wheel == 1) {
1152  }
1153  if (wheel == 2) {
1156  }
1157 //
1159  meCosTheta->Fill(costeta);
1162 
1163  }
1164  } else {
1165  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1166  << "MuonDT PSimHit " << i
1167  << " is expected to be (det,subdet) = ("
1168  << dMuon << "," << sdMuonDT
1169  << "); value returned is: ("
1170  << detector << "," << subdetector << ")";
1171  continue;
1172  }
1173  }
1174 
1175  if (verbosity > 1) {
1176  eventout += "\n Number of DT muon Hits collected:......... ";
1177  eventout += j;
1178  }
1179  meMuDTHits->Fill( (float) nummu_DT );
1180 
1181  if (verbosity > 0)
1182  edm::LogInfo("MuonSimHitsValidAnalyzer::fillDT") << eventout << "\n";
1183 return;
1184 }
1185 
1186 
1188  const edm::EventSetup& iSetup)
1189 {
1190  TString eventout;
1191  if (verbosity > 0)
1192  eventout = "\nGathering RPC info:";
1193 
1195  edm::PSimHitContainer::const_iterator itHit;
1196 
1199  edm::ESHandle<RPCGeometry> theRPCGeometry;
1200  iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
1201  if (!theRPCGeometry.isValid()) {
1202  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1203  << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
1204  return;
1205  }
1206  const RPCGeometry& theRPCMuon(*theRPCGeometry);
1207 
1208  // get Muon RPC information
1209  edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
1210  iEvent.getByToken(RPCHitsToken_, MuonRPCContainer);
1211  if (!MuonRPCContainer.isValid()) {
1212  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1213  << "Unable to find MuonRPCHits in event!";
1214  return;
1215  }
1216 
1217  touch1 = 0;
1218  touch4 = 0;
1219  touche1 = 0;
1220  touche4 = 0;
1221  nummu_RPC = 0 ;
1222 
1223  meAllRPCHits->Fill( MuonRPCContainer->size() );
1224 
1226  int i = 0, j = 0;
1227  for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end();
1228  ++itHit) {
1229 
1230  ++i;
1231 
1233  DetId theDetUnitId(itHit->detUnitId());
1234  int detector = theDetUnitId.det();
1235  int subdetector = theDetUnitId.subdetId();
1236 
1238  if ((detector == dMuon) &&
1239  (subdetector == sdMuonRPC)) {
1240 
1242  const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
1243 
1244  if (!theDet) {
1245  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1246  << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
1247  continue;
1248  }
1249 
1250  ++j;
1251 
1253  const BoundPlane& bsurf = theDet->surface();
1254 
1256 
1257  if ( abs(itHit->particleType()) == 13 ) {
1258 
1259  nummu_RPC++;
1260 
1261  iden = itHit->detUnitId();
1262 
1263  region = ( ((iden>>0) & 0X3) -1 ) ;
1264  ring = ((iden>>2) & 0X7 ) ;
1265 
1266  if ( ring < 3 )
1267  {
1268  if ( region == 0 ) cout << "Region - Ring inconsistency" << endl;
1269  ring += 1 ;
1270  } else {
1271  ring -= 5 ;
1272  }
1273 
1274  station = ( ((iden>>5) & 0X3) + 1 ) ;
1275  sector = ( ((iden>>7) & 0XF) + 1 ) ;
1276  layer = ( ((iden>>11) & 0X1) + 1 ) ;
1277  subsector = ( ((iden>>12) & 0X7) + 1 ) ; // ! Beware: mask says 0x7 !!
1278  roll = ( (iden>>15) & 0X7) ;
1279 
1280  meRegionOccup->Fill((float)region); // Region
1281  if (region == 0 ) // Barrel
1282  {
1283  meRingOccBar->Fill((float) ring);
1284  meStatOccBar->Fill((float) station);
1285  meSectorOccBar->Fill((float) sector);
1286  meLayerOccBar->Fill((float) layer);
1287  meSubSectOccBar->Fill((float) subsector);
1288  meRollOccBar->Fill((float) roll);
1289 
1290  meElossBar->Fill(itHit->energyLoss()*pow6 );
1291  }
1292  if (region != 0 ) // Endcaps
1293  {
1294  meRingOccEndc->Fill((float)ring);
1295  meStatOccEndc->Fill((float) station);
1296  meSectorOccEndc->Fill((float) sector);
1297  meLayerOccEndc->Fill((float) layer);
1298  meSubSectOccEndc->Fill((float) subsector);
1299  meRollOccEndc->Fill((float) roll);
1300 
1301  meElossEndc->Fill(itHit->energyLoss()*pow6 );
1302  }
1303 
1304  // Define a quantity to take into account station, splayer and layer being hit.
1305  path = (region+1) * 50 + (ring+2) * 10 + (station -1) *2+ layer;
1306  if (region != 0) path -= 10 ;
1307  mepathRPC->Fill((float)path);
1308 
1310  if ( region == 0 ) // BARREL
1311  {
1312  if (station == 1 && layer == 1 )
1313  {
1314  if (touch1 == 0)
1315  {
1316  mom1=itHit->pabs();
1317  meMomRB1->Fill(mom1);
1318  touch1 = 1;
1319  }
1320  }
1322 
1323  if (station == 4 )
1324  {
1325  if ( touch4 == 0)
1326  {
1327  mom4=itHit->pabs();
1328  meMomRB4->Fill(mom4);
1329  touch4 = 1;
1331  if (touch1 == 1 )
1332  {
1334  }
1335  }
1336  }
1337  } // End of Barrel
1338 
1340  if ( region != 0 ) // ENDCAPS
1341  {
1342  if (station == 1 )
1343  {
1344  if (touche1 == 0)
1345  {
1346  mome1=itHit->pabs();
1347  meMomRE1->Fill(mome1);
1348  touche1 = 1;
1349  }
1350  }
1352  if (station == 4 )
1353  {
1354  if ( touche4 == 0)
1355  {
1356  mome4=itHit->pabs();
1357  meMomRE4->Fill(mome4);
1358  touche4 = 1;
1360  if (touche1 == 1 )
1361  {
1363  }
1364  }
1365  }
1366  } // End of Endcaps
1367 
1368  // X-Local Coordinate vs Y-Local Coordinate
1369  meLocalXvsYBar->Fill(itHit->localPosition().x(), itHit->localPosition().y() );
1370 
1372  globposz = bsurf.toGlobal(itHit->localPosition()).z();
1373  globposeta = bsurf.toGlobal(itHit->localPosition()).eta();
1374  globposphi = bsurf.toGlobal(itHit->localPosition()).phi();
1375 
1376  radius = globposz* ( 1.+ exp(-2.* globposeta) ) / ( 1. - exp(-2.* globposeta ) ) ;
1377  costeta = ( 1. - exp(-2.*globposeta) ) /( 1. + exp(-2.* globposeta) ) ;
1378  sinteta = 2. * exp(-globposeta) /( 1. + exp(-2.*globposeta) );
1379 
1382 
1383  if (region == 0 ) // Barrel
1384  {
1386  meCosThetaBar->Fill(costeta);
1389  }
1390  if (region != 0 ) // Endcaps
1391  {
1393  meCosThetaEndc->Fill(costeta);
1396  }
1397 
1398  }
1399 
1400  } else {
1401  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1402  << "MuonRpc PSimHit " << i
1403  << " is expected to be (det,subdet) = ("
1404  << dMuon << "," << sdMuonRPC
1405  << "); value returned is: ("
1406  << detector << "," << subdetector << ")";
1407  continue;
1408  }
1409  }
1410 
1411  if (verbosity > 1) {
1412  eventout += "\n Number of RPC muon Hits collected:......... ";
1413  eventout += j;
1414  }
1415 
1416  meMuRPCHits->Fill( (float) nummu_RPC );
1417 
1418  if (verbosity > 0)
1419  edm::LogInfo("MuonSimHitsValidAnalyzer::fillRPC") << eventout << "\n";
1420 
1421 return;
1422 }
1423 
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Event.cc:86
int i
Definition: DBlmapReader.cc:9
void fillCSC(const edm::Event &, const edm::EventSetup &)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:942
static const int sdMuonDT
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< edm::PSimHitContainer > CSCHitsToken_
Input tags.
edm::EDGetTokenT< edm::PSimHitContainer > DTHitsToken_
static const int sdMuonRPC
void fillRPC(const edm::Event &, const edm::EventSetup &)
T eta() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
float float float z
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< edm::PSimHitContainer > RPCHitsToken_
static const int sdMuonCSC
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
void setVerbose(unsigned level)
Definition: DQMStore.cc:619
bool isValid() const
Definition: HandleBase.h:76
Definition: DetId.h:18
MuonSimHitsValidAnalyzer(const edm::ParameterSet &)
std::string fName
parameter information
const T & get() const
Definition: EventSetup.h:55
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
edm::EventID id() const
Definition: EventBase.h:56
static const int dMuon
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2490
virtual const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: DTGeometry.cc:71
tuple cout
Definition: gather_cfg.py:121
virtual const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:93
virtual void analyze(const edm::Event &, const edm::EventSetup &)
volatile std::atomic< bool > shutdown_flag false
void showDirStructure(void) const
Definition: DQMStore.cc:3282
bool isValid() const
Definition: ESHandle.h:37
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1070
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
unsigned int count
private statistics information
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
void fillDT(const edm::Event &, const edm::EventSetup &)
virtual const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: RPCGeometry.cc:48
Definition: DDAxes.h:10