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