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