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