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 
736  DTHistos = 1000;
737  theDTFile->cd();
738 
739  if ( dbeDT_ ) {
740  dbeDT_->setCurrentFolder("MuonDTHitsV/DTHitsValidationTask");
741  // cout << " DTFile.size " << DToutputFile_.size() << " dbeDT " << dbeDT_ << endl;
743  }
744 
745 // gDirectory->pwd();
746 // theDTFile->ls();
747 // theDTFile->GetList()->ls();
748 // hmgr->save(DTHistos);
749 }
750 
752 {
753  int RPCHistos;
754  RPCHistos = 3000;
755  theRPCFile->cd();
756 
757  if ( dbeRPC_ ) {
758  dbeRPC_->setCurrentFolder("MuonRPCHitsV/RPCHitsValidationTask");
759  // cout << " RPCFile.size " << RPCoutputFile_.size() << " dbeRPC " << dbeRPC_ << endl;
761  }
762 
763 
764 
765 
766 // gDirectory->pwd();
767 // theRPCFile->ls();
768 // theRPCFile->GetList()->ls();
769 // hmgr->save(RPCHistos);
770 }
771 
773 {
774  int CSCHistos;
775  CSCHistos = 2000;
776  theCSCFile->cd();
777 
778  if ( dbeCSC_ ) {
779  dbeCSC_->setCurrentFolder("MuonCSCHitsV/CSCHitsValidationTask");
780  // cout << " CSCFile.size " << CSCoutputFile_.size() << " dbeCSC " << dbeCSC_ << endl;
782  }
783 
784 
785 
786 // gDirectory->pwd();
787 // theCSCFile->ls();
788 // theCSCFile->GetList()->ls();
789 // hmgr->save(CSCHistos);
790 }
791 
793 {
794 
795  if ( DToutputFile_.size() != 0 ) {
796  saveHistos_DT();
797  LogInfo("OutputInfo") << " DT MuonHits histos already saved" ;
798  } else {
799  LogInfo("OutputInfo") << " DT MuonHits histos NOT saved";
800  }
801 
802 
803 
804 // saveHistos_CSC();
805 // saveHistos_RPC();
806  if (verbosity > 0)
807  edm::LogInfo ("MuonSimHitsValidAnalyzer::endJob")
808  << "Terminating having processed " << count << " events.";
809  return;
810 
811 }
812 
814  const edm::EventSetup& iSetup)
815 {
817  ++count;
818 
820  int nrun = iEvent.id().run();
821  int nevt = iEvent.id().event();
822 
823  if (verbosity > 0) {
824  edm::LogInfo ("MuonSimHitsValidAnalyzer::analyze")
825  << "Processing run " << nrun << ", event " << nevt;
826  }
827 
829  if (getAllProvenances) {
830 
831  std::vector<const edm::Provenance*> AllProv;
832  iEvent.getAllProvenance(AllProv);
833 
834  if (verbosity > 0)
835  edm::LogInfo ("MuonSimHitsValidAnalyzer::analyze")
836  << "Number of Provenances = " << AllProv.size();
837 
838  if (printProvenanceInfo && (verbosity > 0)) {
839  TString eventout("\nProvenance info:\n");
840 
841  for (unsigned int i = 0; i < AllProv.size(); ++i) {
842  eventout += "\n ******************************";
843  eventout += "\n Module : ";
844  eventout += AllProv[i]->moduleLabel();
845  eventout += "\n ProductID : ";
846  eventout += AllProv[i]->productID().id();
847  eventout += "\n ClassName : ";
848  eventout += AllProv[i]->className();
849  eventout += "\n InstanceName : ";
850  eventout += AllProv[i]->productInstanceName();
851  eventout += "\n BranchName : ";
852  eventout += AllProv[i]->branchName();
853  }
854  eventout += " ******************************\n";
855  edm::LogInfo("MuonSimHitsValidAnalyzer::analyze") << eventout << "\n";
856  }
857  }
858 
860 
862 // fillCSC(iEvent, iSetup);
863  fillDT(iEvent, iSetup);
864  // fillRPC(iEvent, iSetup);
865 
866  if (verbosity > 0)
867  edm::LogInfo ("MuonSimHitsValidAnalyzer::analyze")
868  << "Done gathering data from event.";
869 
870  return;
871 }
872 
873 
874 
876  const edm::EventSetup& iSetup)
877 {
878 
879  TString eventout;
880  if (verbosity > 0)
881  eventout = "\nGathering CSC info:";
882 
884  edm::PSimHitContainer::const_iterator itHit;
885 
888  edm::ESHandle<CSCGeometry> theCSCGeometry;
889  iSetup.get<MuonGeometryRecord>().get(theCSCGeometry);
890  if (!theCSCGeometry.isValid()) {
891  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
892  << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
893  return;
894  }
895  const CSCGeometry& theCSCMuon(*theCSCGeometry);
896 
898  edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
899  iEvent.getByLabel(CSCHitsSrc_,MuonCSCContainer);
900 // iEvent.getByLabel("g4SimHits","MuonCSCHits",MuonCSCContainer);
901  if (!MuonCSCContainer.isValid()) {
902  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
903  << "Unable to find MuonCSCHits in event!";
904  return;
905  }
906 
907  nummu_CSC =0;
908  meAllCSCHits->Fill( MuonCSCContainer->size() );
909 
911  int i = 0, j = 0;
912  for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end();
913  ++itHit) {
914  ++i;
915 
916 
918  DetId theDetUnitId(itHit->detUnitId());
919  int detector = theDetUnitId.det();
920  int subdetector = theDetUnitId.subdetId();
921 
923  if ((detector == dMuon) &&
924  (subdetector == sdMuonCSC)) {
925 
927  const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
928 
929  if (!theDet) {
930  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
931  << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
932  continue;
933  }
934 
935  ++j;
936 
938  // const BoundPlane& bsurf = theDet->surface();
939 
941 
942  if ( abs(itHit->particleType()) == 13 ) {
943 
944  nummu_CSC++;
945 
946  /* Comment out for the moment
947  const CSCDetId& id=CSCDetId(itHit->detUnitId());
948 
949  int cscid=id.endcap()*100000 + id.station()*10000 +
950  id.ring()*1000 + id.chamber()*10 +id.layer();
951 
952  int iden = cscid/1000;
953 
954  hmgr->getHisto1(iden+2000)->Fill( itHit->energyLoss()*pow6 );
955  hmgr->getHisto1(iden+2200)->Fill( itHit->tof() );
956  */
957  }
958  } else {
959  edm::LogWarning("MuonSimHitsValidAnalyzer::fillCSC")
960  << "MuonCsc PSimHit " << i
961  << " is expected to be (det,subdet) = ("
962  << dMuon << "," << sdMuonCSC
963  << "); value returned is: ("
964  << detector << "," << subdetector << ")";
965  continue;
966  }
967  }
968 
969  if (verbosity > 1) {
970  eventout += "\n Number of CSC muon Hits collected:......... ";
971  eventout += j;
972  }
973 
974  meMuCSCHits->Fill( (float) nummu_CSC );
975 
976  if (verbosity > 0)
977  edm::LogInfo("MuonSimHitsValidAnalyzer::fillCSC") << eventout << "\n";
978 
979  return;
980 }
981 
982 
984  const edm::EventSetup& iSetup)
985 {
986  TString eventout;
987  if (verbosity > 0)
988  eventout = "\nGathering DT info:";
989 
991  edm::PSimHitContainer::const_iterator itHit;
992 
995  edm::ESHandle<DTGeometry> theDTGeometry;
996  iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
997  if (!theDTGeometry.isValid()) {
998  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
999  << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
1000  return;
1001  }
1002  const DTGeometry& theDTMuon(*theDTGeometry);
1003 
1005  edm::Handle<edm::PSimHitContainer> MuonDTContainer;
1006  iEvent.getByLabel(DTHitsSrc_,MuonDTContainer);
1007 // iEvent.getByLabel("g4SimHits","MuonDTHits",MuonDTContainer);
1008  if (!MuonDTContainer.isValid()) {
1009  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1010  << "Unable to find MuonDTHits in event!";
1011  return;
1012  }
1013 
1014  touch1 = 0;
1015  touch4 = 0;
1016  nummu_DT = 0 ;
1017 
1018  meAllDTHits->Fill( MuonDTContainer->size() );
1019 
1021  int i = 0, j = 0;
1022  for (itHit = MuonDTContainer->begin(); itHit != MuonDTContainer->end();
1023  ++itHit) {
1024 
1025  ++i;
1026 
1028  DetId theDetUnitId(itHit->detUnitId());
1029  int detector = theDetUnitId.det();
1030  int subdetector = theDetUnitId.subdetId();
1031 
1033  if ((detector == dMuon) &&
1034  (subdetector == sdMuonDT)) {
1035 
1037  const GeomDetUnit *theDet = theDTMuon.idToDetUnit(theDetUnitId);
1038 
1039  if (!theDet) {
1040  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1041  << "Unable to get GeomDetUnit from theDTMuon for hit " << i;
1042  continue;
1043  }
1044 
1045  ++j;
1046 
1048  const BoundPlane& bsurf = theDet->surface();
1049 
1051 
1052  if ( abs(itHit->particleType()) == 13 ) {
1053 
1054  nummu_DT++;
1055  meToF->Fill( itHit->tof() );
1056  meEnergyLoss->Fill( itHit->energyLoss()*pow6 );
1057 
1058  iden = itHit->detUnitId();
1059 
1060  wheel = ((iden>>15) & 0x7 ) -3 ;
1061  station = ((iden>>22) & 0x7 ) ;
1062  sector = ((iden>>18) & 0xf ) ;
1063  superlayer = ((iden>>13) & 0x3 ) ;
1064  layer = ((iden>>10) & 0x7 ) ;
1065  wire = ((iden>>3) & 0x7f ) ;
1066 
1067  meWheelOccup->Fill((float)wheel);
1068  meStationOccup->Fill((float) station);
1069  meSectorOccup->Fill((float) sector);
1070  meSuperLOccup->Fill((float) superlayer);
1071  meLayerOccup->Fill((float) layer);
1072  meWireOccup->Fill((float) wire);
1073 
1074  // Define a quantity to take into account station, splayer and layer being hit.
1075  path = (station-1) * 40 + superlayer * 10 + layer;
1076  mePathMuon->Fill((float) path);
1077 
1078  // Define a quantity to take into chamber being hit.
1079  pathchamber = (wheel+2) * 50 + (station-1) * 12 + sector;
1080  meChamberOccup->Fill((float) pathchamber);
1081 
1083  if (station == 1 )
1084  {
1085  if (touch1 == 0)
1086  {
1087  mom1=itHit->pabs();
1089  touch1 = 1;
1090  }
1091  }
1092 
1094  if (station == 4 )
1095  {
1096  if ( touch4 == 0)
1097  {
1098  mom4=itHit->pabs();
1099  touch4 = 1;
1101  if (touch1 == 1 )
1102  {
1104  }
1105  }
1106  }
1107 
1109  meLocalXvsZ->Fill(itHit->localPosition().x(), itHit->localPosition().z() );
1110 
1112  meLocalXvsY->Fill(itHit->localPosition().x(), itHit->localPosition().y() );
1113 
1115 
1116  globposz = bsurf.toGlobal(itHit->localPosition()).z();
1117  globposeta = bsurf.toGlobal(itHit->localPosition()).eta();
1118  globposphi = bsurf.toGlobal(itHit->localPosition()).phi();
1119 
1120  radius = globposz* ( 1.+ exp(-2.* globposeta) ) / ( 1. - exp(-2.* globposeta ) ) ;
1121 
1122  costeta = ( 1. - exp(-2.*globposeta) ) /( 1. + exp(-2.* globposeta) ) ;
1123  sinteta = 2. * exp(-globposeta) /( 1. + exp(-2.*globposeta) );
1124 
1129 
1132 
1133 // New Histos
1134  if (wheel == -2) {
1137  }
1138  if (wheel == -1) {
1141  }
1142  if (wheel == 0) {
1145  }
1146  if (wheel == 1) {
1149  }
1150  if (wheel == 2) {
1153  }
1154 //
1156  meCosTheta->Fill(costeta);
1159 
1160  }
1161  } else {
1162  edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT")
1163  << "MuonDT PSimHit " << i
1164  << " is expected to be (det,subdet) = ("
1165  << dMuon << "," << sdMuonDT
1166  << "); value returned is: ("
1167  << detector << "," << subdetector << ")";
1168  continue;
1169  }
1170  }
1171 
1172  if (verbosity > 1) {
1173  eventout += "\n Number of DT muon Hits collected:......... ";
1174  eventout += j;
1175  }
1176  meMuDTHits->Fill( (float) nummu_DT );
1177 
1178  if (verbosity > 0)
1179  edm::LogInfo("MuonSimHitsValidAnalyzer::fillDT") << eventout << "\n";
1180 return;
1181 }
1182 
1183 
1185  const edm::EventSetup& iSetup)
1186 {
1187  TString eventout;
1188  if (verbosity > 0)
1189  eventout = "\nGathering RPC info:";
1190 
1192  edm::PSimHitContainer::const_iterator itHit;
1193 
1196  edm::ESHandle<RPCGeometry> theRPCGeometry;
1197  iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
1198  if (!theRPCGeometry.isValid()) {
1199  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1200  << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
1201  return;
1202  }
1203  const RPCGeometry& theRPCMuon(*theRPCGeometry);
1204 
1205  // get Muon RPC information
1206  edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
1207  iEvent.getByLabel(RPCHitsSrc_,MuonRPCContainer);
1208 // iEvent.getByLabel("g4SimHits","MuonRPCHits",MuonRPCContainer);
1209  if (!MuonRPCContainer.isValid()) {
1210  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1211  << "Unable to find MuonRPCHits in event!";
1212  return;
1213  }
1214 
1215  touch1 = 0;
1216  touch4 = 0;
1217  touche1 = 0;
1218  touche4 = 0;
1219  nummu_RPC = 0 ;
1220 
1221  meAllRPCHits->Fill( MuonRPCContainer->size() );
1222 
1224  int i = 0, j = 0;
1225  for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end();
1226  ++itHit) {
1227 
1228  ++i;
1229 
1231  DetId theDetUnitId(itHit->detUnitId());
1232  int detector = theDetUnitId.det();
1233  int subdetector = theDetUnitId.subdetId();
1234 
1236  if ((detector == dMuon) &&
1237  (subdetector == sdMuonRPC)) {
1238 
1240  const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
1241 
1242  if (!theDet) {
1243  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1244  << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
1245  continue;
1246  }
1247 
1248  ++j;
1249 
1251  const BoundPlane& bsurf = theDet->surface();
1252 
1254 
1255  if ( abs(itHit->particleType()) == 13 ) {
1256 
1257  nummu_RPC++;
1258 
1259  iden = itHit->detUnitId();
1260 
1261  region = ( ((iden>>0) & 0X3) -1 ) ;
1262  ring = ((iden>>2) & 0X7 ) ;
1263 
1264  if ( ring < 3 )
1265  {
1266  if ( region == 0 ) cout << "Region - Ring inconsistency" << endl;
1267  ring += 1 ;
1268  } else {
1269  ring -= 5 ;
1270  }
1271 
1272  station = ( ((iden>>5) & 0X3) + 1 ) ;
1273  sector = ( ((iden>>7) & 0XF) + 1 ) ;
1274  layer = ( ((iden>>11) & 0X1) + 1 ) ;
1275  subsector = ( ((iden>>12) & 0X7) + 1 ) ; // ! Beware: mask says 0x7 !!
1276  roll = ( (iden>>15) & 0X7) ;
1277 
1278  meRegionOccup->Fill((float)region); // Region
1279  if (region == 0 ) // Barrel
1280  {
1281  meRingOccBar->Fill((float) ring);
1282  meStatOccBar->Fill((float) station);
1283  meSectorOccBar->Fill((float) sector);
1284  meLayerOccBar->Fill((float) layer);
1285  meSubSectOccBar->Fill((float) subsector);
1286  meRollOccBar->Fill((float) roll);
1287 
1288  meElossBar->Fill(itHit->energyLoss()*pow6 );
1289  }
1290  if (region != 0 ) // Endcaps
1291  {
1292  meRingOccEndc->Fill((float)ring);
1293  meStatOccEndc->Fill((float) station);
1294  meSectorOccEndc->Fill((float) sector);
1295  meLayerOccEndc->Fill((float) layer);
1296  meSubSectOccEndc->Fill((float) subsector);
1297  meRollOccEndc->Fill((float) roll);
1298 
1299  meElossEndc->Fill(itHit->energyLoss()*pow6 );
1300  }
1301 
1302  // Define a quantity to take into account station, splayer and layer being hit.
1303  path = (region+1) * 50 + (ring+2) * 10 + (station -1) *2+ layer;
1304  if (region != 0) path -= 10 ;
1305  mepathRPC->Fill((float)path);
1306 
1308  if ( region == 0 ) // BARREL
1309  {
1310  if (station == 1 && layer == 1 )
1311  {
1312  if (touch1 == 0)
1313  {
1314  mom1=itHit->pabs();
1315  meMomRB1->Fill(mom1);
1316  touch1 = 1;
1317  }
1318  }
1320 
1321  if (station == 4 )
1322  {
1323  if ( touch4 == 0)
1324  {
1325  mom4=itHit->pabs();
1326  meMomRB4->Fill(mom4);
1327  touch4 = 1;
1329  if (touch1 == 1 )
1330  {
1332  }
1333  }
1334  }
1335  } // End of Barrel
1336 
1338  if ( region != 0 ) // ENDCAPS
1339  {
1340  if (station == 1 )
1341  {
1342  if (touche1 == 0)
1343  {
1344  mome1=itHit->pabs();
1345  meMomRE1->Fill(mome1);
1346  touche1 = 1;
1347  }
1348  }
1350  if (station == 4 )
1351  {
1352  if ( touche4 == 0)
1353  {
1354  mome4=itHit->pabs();
1355  meMomRE4->Fill(mome4);
1356  touche4 = 1;
1358  if (touche1 == 1 )
1359  {
1361  }
1362  }
1363  }
1364  } // End of Endcaps
1365 
1366  // X-Local Coordinate vs Y-Local Coordinate
1367  meLocalXvsYBar->Fill(itHit->localPosition().x(), itHit->localPosition().y() );
1368 
1370  globposz = bsurf.toGlobal(itHit->localPosition()).z();
1371  globposeta = bsurf.toGlobal(itHit->localPosition()).eta();
1372  globposphi = bsurf.toGlobal(itHit->localPosition()).phi();
1373 
1374  radius = globposz* ( 1.+ exp(-2.* globposeta) ) / ( 1. - exp(-2.* globposeta ) ) ;
1375  costeta = ( 1. - exp(-2.*globposeta) ) /( 1. + exp(-2.* globposeta) ) ;
1376  sinteta = 2. * exp(-globposeta) /( 1. + exp(-2.*globposeta) );
1377 
1380 
1381  if (region == 0 ) // Barrel
1382  {
1384  meCosThetaBar->Fill(costeta);
1387  }
1388  if (region != 0 ) // Endcaps
1389  {
1391  meCosThetaEndc->Fill(costeta);
1394  }
1395 
1396  }
1397 
1398  } else {
1399  edm::LogWarning("MuonSimHitsValidAnalyzer::fillRPC")
1400  << "MuonRpc PSimHit " << i
1401  << " is expected to be (det,subdet) = ("
1402  << dMuon << "," << sdMuonRPC
1403  << "); value returned is: ("
1404  << detector << "," << subdetector << ")";
1405  continue;
1406  }
1407  }
1408 
1409  if (verbosity > 1) {
1410  eventout += "\n Number of RPC muon Hits collected:......... ";
1411  eventout += j;
1412  }
1413 
1414  meMuRPCHits->Fill( (float) nummu_RPC );
1415 
1416  if (verbosity > 0)
1417  edm::LogInfo("MuonSimHitsValidAnalyzer::fillRPC") << eventout << "\n";
1418 
1419 return;
1420 }
1421 
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:71
int i
Definition: DBlmapReader.cc:9
const std::string & label
Definition: MVAComputer.cc:186
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:514
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:1898
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
static const int sdMuonRPC
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
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:196
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
const int verbosity
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
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:41
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void showDirStructure(void) const
Definition: DQMStore.cc:2554
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:642
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
unsigned int count
private statistics information
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void fillDT(const edm::Event &, const edm::EventSetup &)
Definition: DDAxes.h:10