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 // iEvent.getByLabel("g4SimHits","MuonCSCHits",MuonCSCContainer);
906  if (!MuonCSCContainer.isValid()) {
907  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
908  << "Unable to find MuonCSCHits in event!";
909  return;
910  }
911 
912  nummu_CSC =0;
913  meAllCSCHits->Fill( MuonCSCContainer->size() );
914 
916  int i = 0, j = 0;
917  for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end();
918  ++itHit) {
919  ++i;
920 
921 
923  DetId theDetUnitId(itHit->detUnitId());
924  int detector = theDetUnitId.det();
925  int subdetector = theDetUnitId.subdetId();
926 
928  if ((detector == dMuon) &&
929  (subdetector == sdMuonCSC)) {
930 
932  const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
933 
934  if (!theDet) {
935  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
936  << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
937  continue;
938  }
939 
940  ++j;
941 
943  // const BoundPlane& bsurf = theDet->surface();
944 
946 
947  if ( abs(itHit->particleType()) == 13 ) {
948 
949  nummu_CSC++;
950 
951  /* Comment out for the moment
952  const CSCDetId& id=CSCDetId(itHit->detUnitId());
953 
954  int cscid=id.endcap()*100000 + id.station()*10000 +
955  id.ring()*1000 + id.chamber()*10 +id.layer();
956 
957  int iden = cscid/1000;
958 
959  hmgr->getHisto1(iden+2000)->Fill( itHit->energyLoss()*pow6 );
960  hmgr->getHisto1(iden+2200)->Fill( itHit->tof() );
961  */
962  }
963  } else {
964  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
965  << "MuonCsc PSimHit " << i
966  << " is expected to be (det,subdet) = ("
967  << dMuon << "," << sdMuonCSC
968  << "); value returned is: ("
969  << detector << "," << subdetector << ")";
970  continue;
971  }
972  }
973 
974  if (verbosity > 1) {
975  eventout += "\n Number of CSC muon Hits collected:......... ";
976  eventout += j;
977  }
978 
979  meMuCSCHits->Fill( (float) nummu_CSC );
980 
981  if (verbosity > 0)
982  edm::LogInfo("MuonSimHitsValidAnalyzer::fillCSC") << eventout << "\n";
983 
984  return;
985 }
986 
987 
989  const edm::EventSetup& iSetup)
990 {
991  TString eventout;
992  if (verbosity > 0)
993  eventout = "\nGathering DT info:";
994 
996  edm::PSimHitContainer::const_iterator itHit;
997 
1000  edm::ESHandle<DTGeometry> theDTGeometry;
1001  iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
1002  if (!theDTGeometry.isValid()) {
1003  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1004  << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
1005  return;
1006  }
1007  const DTGeometry& theDTMuon(*theDTGeometry);
1008 
1010  edm::Handle<edm::PSimHitContainer> MuonDTContainer;
1011  iEvent.getByToken(DTHitsToken_, MuonDTContainer);
1012 // iEvent.getByLabel("g4SimHits","MuonDTHits",MuonDTContainer);
1013  if (!MuonDTContainer.isValid()) {
1014  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1015  << "Unable to find MuonDTHits in event!";
1016  return;
1017  }
1018 
1019  touch1 = 0;
1020  touch4 = 0;
1021  nummu_DT = 0 ;
1022 
1023  meAllDTHits->Fill( MuonDTContainer->size() );
1024 
1026  int i = 0, j = 0;
1027  for (itHit = MuonDTContainer->begin(); itHit != MuonDTContainer->end();
1028  ++itHit) {
1029 
1030  ++i;
1031 
1033  DetId theDetUnitId(itHit->detUnitId());
1034  int detector = theDetUnitId.det();
1035  int subdetector = theDetUnitId.subdetId();
1036 
1038  if ((detector == dMuon) &&
1039  (subdetector == sdMuonDT)) {
1040 
1042  const GeomDetUnit *theDet = theDTMuon.idToDetUnit(theDetUnitId);
1043 
1044  if (!theDet) {
1045  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1046  << "Unable to get GeomDetUnit from theDTMuon for hit " << i;
1047  continue;
1048  }
1049 
1050  ++j;
1051 
1053  const BoundPlane& bsurf = theDet->surface();
1054 
1056 
1057  if ( abs(itHit->particleType()) == 13 ) {
1058 
1059  nummu_DT++;
1060  meToF->Fill( itHit->tof() );
1061  meEnergyLoss->Fill( itHit->energyLoss()*pow6 );
1062 
1063  iden = itHit->detUnitId();
1064 
1065  wheel = ((iden>>15) & 0x7 ) -3 ;
1066  station = ((iden>>22) & 0x7 ) ;
1067  sector = ((iden>>18) & 0xf ) ;
1068  superlayer = ((iden>>13) & 0x3 ) ;
1069  layer = ((iden>>10) & 0x7 ) ;
1070  wire = ((iden>>3) & 0x7f ) ;
1071 
1072  meWheelOccup->Fill((float)wheel);
1073  meStationOccup->Fill((float) station);
1074  meSectorOccup->Fill((float) sector);
1075  meSuperLOccup->Fill((float) superlayer);
1076  meLayerOccup->Fill((float) layer);
1077  meWireOccup->Fill((float) wire);
1078 
1079  // Define a quantity to take into account station, splayer and layer being hit.
1080  path = (station-1) * 40 + superlayer * 10 + layer;
1081  mePathMuon->Fill((float) path);
1082 
1083  // Define a quantity to take into chamber being hit.
1084  pathchamber = (wheel+2) * 50 + (station-1) * 12 + sector;
1085  meChamberOccup->Fill((float) pathchamber);
1086 
1088  if (station == 1 )
1089  {
1090  if (touch1 == 0)
1091  {
1092  mom1=itHit->pabs();
1094  touch1 = 1;
1095  }
1096  }
1097 
1099  if (station == 4 )
1100  {
1101  if ( touch4 == 0)
1102  {
1103  mom4=itHit->pabs();
1104  touch4 = 1;
1106  if (touch1 == 1 )
1107  {
1109  }
1110  }
1111  }
1112 
1114  meLocalXvsZ->Fill(itHit->localPosition().x(), itHit->localPosition().z() );
1115 
1117  meLocalXvsY->Fill(itHit->localPosition().x(), itHit->localPosition().y() );
1118 
1120 
1121  globposz = bsurf.toGlobal(itHit->localPosition()).z();
1122  globposeta = bsurf.toGlobal(itHit->localPosition()).eta();
1123  globposphi = bsurf.toGlobal(itHit->localPosition()).phi();
1124 
1125  radius = globposz* ( 1.+ exp(-2.* globposeta) ) / ( 1. - exp(-2.* globposeta ) ) ;
1126 
1127  costeta = ( 1. - exp(-2.*globposeta) ) /( 1. + exp(-2.* globposeta) ) ;
1128  sinteta = 2. * exp(-globposeta) /( 1. + exp(-2.*globposeta) );
1129 
1134 
1137 
1138 // New Histos
1139  if (wheel == -2) {
1142  }
1143  if (wheel == -1) {
1146  }
1147  if (wheel == 0) {
1150  }
1151  if (wheel == 1) {
1154  }
1155  if (wheel == 2) {
1158  }
1159 //
1161  meCosTheta->Fill(costeta);
1164 
1165  }
1166  } else {
1167  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1168  << "MuonDT PSimHit " << i
1169  << " is expected to be (det,subdet) = ("
1170  << dMuon << "," << sdMuonDT
1171  << "); value returned is: ("
1172  << detector << "," << subdetector << ")";
1173  continue;
1174  }
1175  }
1176 
1177  if (verbosity > 1) {
1178  eventout += "\n Number of DT muon Hits collected:......... ";
1179  eventout += j;
1180  }
1181  meMuDTHits->Fill( (float) nummu_DT );
1182 
1183  if (verbosity > 0)
1184  edm::LogInfo("MuonSimHitsValidAnalyzer::fillDT") << eventout << "\n";
1185 return;
1186 }
1187 
1188 
1190  const edm::EventSetup& iSetup)
1191 {
1192  TString eventout;
1193  if (verbosity > 0)
1194  eventout = "\nGathering RPC info:";
1195 
1197  edm::PSimHitContainer::const_iterator itHit;
1198 
1201  edm::ESHandle<RPCGeometry> theRPCGeometry;
1202  iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
1203  if (!theRPCGeometry.isValid()) {
1204  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1205  << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
1206  return;
1207  }
1208  const RPCGeometry& theRPCMuon(*theRPCGeometry);
1209 
1210  // get Muon RPC information
1211  edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
1212  iEvent.getByToken(RPCHitsToken_, MuonRPCContainer);
1213 // iEvent.getByLabel("g4SimHits","MuonRPCHits",MuonRPCContainer);
1214  if (!MuonRPCContainer.isValid()) {
1215  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1216  << "Unable to find MuonRPCHits in event!";
1217  return;
1218  }
1219 
1220  touch1 = 0;
1221  touch4 = 0;
1222  touche1 = 0;
1223  touche4 = 0;
1224  nummu_RPC = 0 ;
1225 
1226  meAllRPCHits->Fill( MuonRPCContainer->size() );
1227 
1229  int i = 0, j = 0;
1230  for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end();
1231  ++itHit) {
1232 
1233  ++i;
1234 
1236  DetId theDetUnitId(itHit->detUnitId());
1237  int detector = theDetUnitId.det();
1238  int subdetector = theDetUnitId.subdetId();
1239 
1241  if ((detector == dMuon) &&
1242  (subdetector == sdMuonRPC)) {
1243 
1245  const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
1246 
1247  if (!theDet) {
1248  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1249  << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
1250  continue;
1251  }
1252 
1253  ++j;
1254 
1256  const BoundPlane& bsurf = theDet->surface();
1257 
1259 
1260  if ( abs(itHit->particleType()) == 13 ) {
1261 
1262  nummu_RPC++;
1263 
1264  iden = itHit->detUnitId();
1265 
1266  region = ( ((iden>>0) & 0X3) -1 ) ;
1267  ring = ((iden>>2) & 0X7 ) ;
1268 
1269  if ( ring < 3 )
1270  {
1271  if ( region == 0 ) cout << "Region - Ring inconsistency" << endl;
1272  ring += 1 ;
1273  } else {
1274  ring -= 5 ;
1275  }
1276 
1277  station = ( ((iden>>5) & 0X3) + 1 ) ;
1278  sector = ( ((iden>>7) & 0XF) + 1 ) ;
1279  layer = ( ((iden>>11) & 0X1) + 1 ) ;
1280  subsector = ( ((iden>>12) & 0X7) + 1 ) ; // ! Beware: mask says 0x7 !!
1281  roll = ( (iden>>15) & 0X7) ;
1282 
1283  meRegionOccup->Fill((float)region); // Region
1284  if (region == 0 ) // Barrel
1285  {
1286  meRingOccBar->Fill((float) ring);
1287  meStatOccBar->Fill((float) station);
1288  meSectorOccBar->Fill((float) sector);
1289  meLayerOccBar->Fill((float) layer);
1290  meSubSectOccBar->Fill((float) subsector);
1291  meRollOccBar->Fill((float) roll);
1292 
1293  meElossBar->Fill(itHit->energyLoss()*pow6 );
1294  }
1295  if (region != 0 ) // Endcaps
1296  {
1297  meRingOccEndc->Fill((float)ring);
1298  meStatOccEndc->Fill((float) station);
1299  meSectorOccEndc->Fill((float) sector);
1300  meLayerOccEndc->Fill((float) layer);
1301  meSubSectOccEndc->Fill((float) subsector);
1302  meRollOccEndc->Fill((float) roll);
1303 
1304  meElossEndc->Fill(itHit->energyLoss()*pow6 );
1305  }
1306 
1307  // Define a quantity to take into account station, splayer and layer being hit.
1308  path = (region+1) * 50 + (ring+2) * 10 + (station -1) *2+ layer;
1309  if (region != 0) path -= 10 ;
1310  mepathRPC->Fill((float)path);
1311 
1313  if ( region == 0 ) // BARREL
1314  {
1315  if (station == 1 && layer == 1 )
1316  {
1317  if (touch1 == 0)
1318  {
1319  mom1=itHit->pabs();
1320  meMomRB1->Fill(mom1);
1321  touch1 = 1;
1322  }
1323  }
1325 
1326  if (station == 4 )
1327  {
1328  if ( touch4 == 0)
1329  {
1330  mom4=itHit->pabs();
1331  meMomRB4->Fill(mom4);
1332  touch4 = 1;
1334  if (touch1 == 1 )
1335  {
1337  }
1338  }
1339  }
1340  } // End of Barrel
1341 
1343  if ( region != 0 ) // ENDCAPS
1344  {
1345  if (station == 1 )
1346  {
1347  if (touche1 == 0)
1348  {
1349  mome1=itHit->pabs();
1350  meMomRE1->Fill(mome1);
1351  touche1 = 1;
1352  }
1353  }
1355  if (station == 4 )
1356  {
1357  if ( touche4 == 0)
1358  {
1359  mome4=itHit->pabs();
1360  meMomRE4->Fill(mome4);
1361  touche4 = 1;
1363  if (touche1 == 1 )
1364  {
1366  }
1367  }
1368  }
1369  } // End of Endcaps
1370 
1371  // X-Local Coordinate vs Y-Local Coordinate
1372  meLocalXvsYBar->Fill(itHit->localPosition().x(), itHit->localPosition().y() );
1373 
1375  globposz = bsurf.toGlobal(itHit->localPosition()).z();
1376  globposeta = bsurf.toGlobal(itHit->localPosition()).eta();
1377  globposphi = bsurf.toGlobal(itHit->localPosition()).phi();
1378 
1379  radius = globposz* ( 1.+ exp(-2.* globposeta) ) / ( 1. - exp(-2.* globposeta ) ) ;
1380  costeta = ( 1. - exp(-2.*globposeta) ) /( 1. + exp(-2.* globposeta) ) ;
1381  sinteta = 2. * exp(-globposeta) /( 1. + exp(-2.*globposeta) );
1382 
1385 
1386  if (region == 0 ) // Barrel
1387  {
1389  meCosThetaBar->Fill(costeta);
1392  }
1393  if (region != 0 ) // Endcaps
1394  {
1396  meCosThetaEndc->Fill(costeta);
1399  }
1400 
1401  }
1402 
1403  } else {
1404  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1405  << "MuonRpc PSimHit " << i
1406  << " is expected to be (det,subdet) = ("
1407  << dMuon << "," << sdMuonRPC
1408  << "); value returned is: ("
1409  << detector << "," << subdetector << ")";
1410  continue;
1411  }
1412  }
1413 
1414  if (verbosity > 1) {
1415  eventout += "\n Number of RPC muon Hits collected:......... ";
1416  eventout += j;
1417  }
1418 
1419  meMuRPCHits->Fill( (float) nummu_RPC );
1420 
1421  if (verbosity > 0)
1422  edm::LogInfo("MuonSimHitsValidAnalyzer::fillRPC") << eventout << "\n";
1423 
1424 return;
1425 }
1426 
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:872
static const int sdMuonDT
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: RPCGeometry.cc:48
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:243
edm::EDGetTokenT< edm::PSimHitContainer > RPCHitsToken_
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:93
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 save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
void setVerbose(unsigned level)
Definition: DQMStore.cc:548
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
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: DTGeometry.cc:71
tuple cout
Definition: gather_cfg.py:121
virtual void analyze(const edm::Event &, const edm::EventSetup &)
volatile std::atomic< bool > shutdown_flag false
void showDirStructure(void) const
Definition: DQMStore.cc:2961
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:1000
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:584
void fillDT(const edm::Event &, const edm::EventSetup &)
Definition: DDAxes.h:10