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 
33  // Book histograms
35 
36  if ( !tfile.isAvailable() )
37  throw cms::Exception("BadConfig") << "TFileService unavailable: "
38  << "please add it to config file";
39  iniE = tfile->make<TH1D>("iniE", "Incident Energy (GeV)", 4000, 0., em1);
40  iEta = tfile->make<TH1D>("iEta", "Eta at incidence ", 300, 0., 3.);
41  iPhi = tfile->make<TH1D>("iPhi", "Phi at incidence ", 300, -1., 1.);
42  edepS= tfile->make<TH1D>("edepS", "Energy deposit == Total",4000, 0., em1);
43  edecS= tfile->make<TH1D>("edecS", "Energy deposit == ECal ",300, -2., 28.);
44  edhcS= tfile->make<TH1D>("edhcS", "Energy deposit == HCal ",4000, 0., em2);
45  edepN= tfile->make<TH1D>("edepN", "Etot/Ebeam ", 200, -2.5, 2.5);
46  edecN= tfile->make<TH1D>("edecN", "Eecal/Ebeam ", 200, -2.5, 2.5);
47  edhcN= tfile->make<TH1D>("edhcN", "Ehcal/Ebeam ", 200, -2.5, 2.5);
48  edehS= tfile->make<TH2D>("edehS", "Hcal vs Ecal", 100,0.,em1, 100, 0.,em2);
49 
50  if (mkTree_) {
51  tree_ = tfile->make<TTree>("TB06Sim", "TB06Sim");
52  tree_->Branch("eBeam_", &eBeam_, "eBeam_/D");
53  tree_->Branch("etaBeam_", &etaBeam_, "etaBeam_/D");
54  tree_->Branch("phiBeam_", &phiBeam_, "phiBeam_/D");
55  tree_->Branch("edepEC_", &edepEC_, "edepEC_/D");
56  tree_->Branch("edepHB_", &edepHB_, "edepHB_/D");
57  tree_->Branch("edepHO_", &edepHO_, "edepHO_/D");
58  tree_->Branch("noiseEC_", &noiseEC_, "noiseEC_/D");
59  tree_->Branch("noiseHB_", &noiseHB_, "noiseHB_/D");
60  tree_->Branch("noiseHO_", &noiseHO_, "noiseHO_/D");
61  tree_->Branch("edepS1_", &edepS1_, "edepS1_/D");
62  tree_->Branch("edepS2_", &edepS2_, "edepS2_/D");
63  tree_->Branch("edepS3_", &edepS3_, "edepS3_/D");
64  tree_->Branch("edepS4_", &edepS4_, "edepS4_/D");
65  tree_->Branch("edepVC_", &edepVC_, "edepVC_/D");
66  tree_->Branch("edepS7_", &edepS7_, "edepS7_/D");
67  tree_->Branch("edepS8_", &edepS8_, "edepS8_/D");
68  }
69 }
70 
72 
73 //
74 // member functions
75 //
76 
77 void HcalTB06Histo::fillPrimary(double energy, double eta, double phi) {
78 
79  if (verbose_)
80  edm::LogInfo("HcalTBSim") << "HcalTB06Histo::fillPrimary: Energy "
81  << energy << " Eta " << eta << " Phi " << phi;
82  eBeam_ = energy;
83  etaBeam_ = eta;
84  phiBeam_ = phi;
85  iniE->Fill(energy);
86  iEta->Fill(eta);
87  iPhi->Fill(phi);
88 }
89 
90 void HcalTB06Histo::fillEdep(double etots, double eecals, double ehcals) {
91 
92  if (verbose_)
93  edm::LogInfo("HcalTBSim") << "HcalTB06Histo:::fillEdep: Simulated Total "
94  << etots << " ECal " << eecals << " HCal "
95  << ehcals;
96  edepS->Fill(etots);
97  edecS->Fill(eecals);
98  edhcS->Fill(ehcals);
99  edepN->Fill(etots/eBeam_);
100  edecN->Fill(eecals/eBeam_);
101  edhcN->Fill(ehcals/eBeam_);
102  edehS->Fill(eecals, ehcals);
103 }
104 
105 void HcalTB06Histo::fillTree(std::vector<double>& ecalo,
106  std::vector<double>& etrig) {
107 
108  if (mkTree_) {
109  edepEC_ = ecalo[0];
110  noiseEC_= ecalo[1];
111  edepHB_ = ecalo[2];
112  noiseHB_= ecalo[3];
113  edepHO_ = ecalo[4];
114  noiseHO_= ecalo[5];
115  edepS1_ = etrig[0];
116  edepS2_ = etrig[1];
117  edepS3_ = etrig[2];
118  edepS4_ = etrig[3];
119  edepVC_ = etrig[4];
120  edepS7_ = etrig[5];
121  edepS8_ = etrig[6];
122  tree_->Fill();
123  if (verbose_)
124  edm::LogInfo("HcalTBSim") << "HcalTB06Histo:::fillTree: Energies "
125  << edepEC_ << ":" << noiseEC_ << ":" << edepHB_
126  << ":" << noiseHB_ << ":" << edepHO_ << ":"
127  << noiseHO_ << " Trigger counters " << edepS1_
128  << ":" << edepS2_ << ":" << edepS3_ << ":"
129  << edepS4_ << ":" << edepVC_ << ":" << edepS7_ << ":" << edepS8_;
130  }
131 }
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:46
void fillPrimary(double energy, double eta, double phi)
HcalTB06Histo(const edm::ParameterSet &ps)