CMS 3D CMS Logo

HcalTB06Histo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalTestBeam
4 // Class : HcalTB06Histo
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Tue Oct 10 10:14:34 CEST 2006
11 //
12 
13 // system include files
14 #include <iostream>
15 #include <cmath>
16 
17 // user include files
22 
23 //
24 // constructors and destructor
26 
27  verbose_ = ps.getUntrackedParameter<bool>("Verbose", false);
28  double em1 = ps.getUntrackedParameter<double>("ETtotMax", 400.);
29  double em2 = ps.getUntrackedParameter<double>("EHCalMax", 4.0);
30  mkTree_ = ps.getUntrackedParameter<bool>("MakeTree", false);
31  eBeam_ = 50.;
32  mip_ = ps.getParameter<double>("MIP");
33  edm::LogInfo("HcalTBSim") << "Verbose :" << verbose_ << " MakeTree: "
34  << mkTree_ << " EMax: " << em1 << ":" << em2
35  << " MIP " << mip_;
36 
37  // Book histograms
39 
40  if ( !tfile.isAvailable() )
41  throw cms::Exception("BadConfig") << "TFileService unavailable: "
42  << "please add it to config file";
43  iniE = tfile->make<TH1D>("iniE", "Incident Energy (GeV)", 4000, 0., em1);
44  iEta = tfile->make<TH1D>("iEta", "Eta at incidence ", 300, 0., 3.);
45  iPhi = tfile->make<TH1D>("iPhi", "Phi at incidence ", 300, -1., 1.);
46  edepS= tfile->make<TH1D>("edepS", "Energy deposit == Total",4000, 0., em1);
47  edecS= tfile->make<TH1D>("edecS", "Energy deposit == ECal ",300, -2., 28.);
48  edhcS= tfile->make<TH1D>("edhcS", "Energy deposit == HCal ",4000, 0., em2);
49  edepN= tfile->make<TH1D>("edepN", "Etot/Ebeam ", 200, -2.5, 2.5);
50  edecN= tfile->make<TH1D>("edecN", "Eecal/Ebeam ", 200, -2.5, 2.5);
51  edhcN= tfile->make<TH1D>("edhcN", "Ehcal/Ebeam ", 200, -2.5, 2.5);
52  emhcN= tfile->make<TH1D>("emhcN", "Ehcal/Ebeam MIP in Ecal", 200, -2.5, 2.5);
53  edehS= tfile->make<TH2D>("edehS", "Hcal vs Ecal", 100,0.,em1, 100, 0.,em2);
54 
55  if (mkTree_) {
56  tree_ = tfile->make<TTree>("TB06Sim", "TB06Sim");
57  tree_->Branch("eBeam_", &eBeam_, "eBeam_/D");
58  tree_->Branch("etaBeam_", &etaBeam_, "etaBeam_/D");
59  tree_->Branch("phiBeam_", &phiBeam_, "phiBeam_/D");
60  tree_->Branch("edepEC_", &edepEC_, "edepEC_/D");
61  tree_->Branch("edepHB_", &edepHB_, "edepHB_/D");
62  tree_->Branch("edepHO_", &edepHO_, "edepHO_/D");
63  tree_->Branch("noiseEC_", &noiseEC_, "noiseEC_/D");
64  tree_->Branch("noiseHB_", &noiseHB_, "noiseHB_/D");
65  tree_->Branch("noiseHO_", &noiseHO_, "noiseHO_/D");
66  tree_->Branch("edepS1_", &edepS1_, "edepS1_/D");
67  tree_->Branch("edepS2_", &edepS2_, "edepS2_/D");
68  tree_->Branch("edepS3_", &edepS3_, "edepS3_/D");
69  tree_->Branch("edepS4_", &edepS4_, "edepS4_/D");
70  tree_->Branch("edepVC_", &edepVC_, "edepVC_/D");
71  tree_->Branch("edepS7_", &edepS7_, "edepS7_/D");
72  tree_->Branch("edepS8_", &edepS8_, "edepS8_/D");
73  }
74 }
75 
77 
78 //
79 // member functions
80 //
81 
82 void HcalTB06Histo::fillPrimary(double energy, double eta, double phi) {
83 
84  if (verbose_)
85  edm::LogInfo("HcalTBSim") << "HcalTB06Histo::fillPrimary: Energy "
86  << energy << " Eta " << eta << " Phi " << phi;
87  eBeam_ = energy;
88  etaBeam_ = eta;
89  phiBeam_ = phi;
90  iniE->Fill(energy);
91  iEta->Fill(eta);
92  iPhi->Fill(phi);
93 }
94 
95 void HcalTB06Histo::fillEdep(double etots, double eecals, double ehcals) {
96 
97  if (verbose_)
98  edm::LogInfo("HcalTBSim") << "HcalTB06Histo:::fillEdep: Simulated Total "
99  << etots << " ECal " << eecals << " HCal "
100  << ehcals;
101  edepS->Fill(etots);
102  edecS->Fill(eecals);
103  edhcS->Fill(ehcals);
104  edepN->Fill(etots/eBeam_);
105  edecN->Fill(eecals/eBeam_);
106  edhcN->Fill(ehcals/eBeam_);
107  if(eecals <= mip_) { emhcN->Fill(etots/eBeam_); }
108  edehS->Fill(eecals, ehcals);
109 }
110 
111 void HcalTB06Histo::fillTree(std::vector<double>& ecalo,
112  std::vector<double>& etrig) {
113 
114  if (mkTree_) {
115  edepEC_ = ecalo[0];
116  noiseEC_= ecalo[1];
117  edepHB_ = ecalo[2];
118  noiseHB_= ecalo[3];
119  edepHO_ = ecalo[4];
120  noiseHO_= ecalo[5];
121  edepS1_ = etrig[0];
122  edepS2_ = etrig[1];
123  edepS3_ = etrig[2];
124  edepS4_ = etrig[3];
125  edepVC_ = etrig[4];
126  edepS7_ = etrig[5];
127  edepS8_ = etrig[6];
128  tree_->Fill();
129  if (verbose_)
130  edm::LogInfo("HcalTBSim") << "HcalTB06Histo:::fillTree: Energies "
131  << edepEC_ << ":" << noiseEC_ << ":" << edepHB_
132  << ":" << noiseHB_ << ":" << edepHO_ << ":"
133  << noiseHO_ << " Trigger counters " << edepS1_
134  << ":" << edepS2_ << ":" << edepS3_ << ":"
135  << edepS4_ << ":" << edepVC_ << ":" << edepS7_ << ":" << edepS8_;
136  }
137 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual ~HcalTB06Histo()
void fillEdep(double etots, double eecals, double ehcals)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void fillTree(std::vector< double > &ecalo, std::vector< double > &etrig)
bool isAvailable() const
Definition: Service.h:40
void fillPrimary(double energy, double eta, double phi)
HcalTB06Histo(const edm::ParameterSet &ps)