CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/SimG4CMS/HcalTestBeam/src/HcalTB04Histo.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     HcalTestBeam
00004 // Class  :     HcalTB04Histo
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:
00010 //         Created:  Tue May 16 10:14:34 CEST 2006
00011 // $Id: HcalTB04Histo.cc,v 1.5 2010/01/12 07:11:39 hegner Exp $
00012 //
00013  
00014 // system include files
00015 #include <iostream>
00016 #include <cmath>
00017  
00018 // user include files
00019 #include "SimG4CMS/HcalTestBeam/interface/HcalTB04Histo.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 #include "FWCore/ServiceRegistry/interface/Service.h"
00022 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00023  
00024 //
00025 // constructors and destructor
00026 HcalTB04Histo::HcalTB04Histo(const edm::ParameterSet& ps) :
00027   iniE(0),  iEta(0), iPhi(0), edepS(0), edecS(0), edhcS(0), edepQ(0),
00028   edecQ(0), edhcQ(0), edehS(0), edehQ(0), latse(0), latqe(0), latsf(0), 
00029   latqf(0), lngs(0), lngq(0) {
00030 
00031   verbose    = ps.getUntrackedParameter<bool>("Verbose", false);
00032   double em1 = ps.getUntrackedParameter<double>("ETtotMax", 400.);
00033   double em2 = ps.getUntrackedParameter<double>("EHCalMax", 4.0);
00034 
00035   // Book histograms
00036   edm::Service<TFileService> tfile;
00037 
00038   if ( !tfile.isAvailable() )
00039     throw cms::Exception("BadConfig") << "TFileService unavailable: "
00040                                       << "please add it to config file";
00041   iniE = tfile->make<TH1D>("iniE",  "Incident Energy (GeV)",  4000,   0., em1);
00042   iEta = tfile->make<TH1D>("iEta",  "Eta at incidence     ",   300,   0.,  3.);
00043   iPhi = tfile->make<TH1D>("iPhi",  "Phi at incidence     ",   300,  -1.,  1.);
00044   edepS= tfile->make<TH1D>("edepS", "Energy deposit == Total (Simhit)",4000, 0., em1);
00045   edecS= tfile->make<TH1D>("edecS", "Energy deposit == ECal  (Simhit)",4000, 0., em1);
00046   edhcS= tfile->make<TH1D>("edhcS", "Energy deposit == HCal  (Simhit)",4000, 0., em2);
00047   edepQ= tfile->make<TH1D>("edepQ", "Energy deposit == Total (QIE)",   4000, 0., em1);
00048   edecQ= tfile->make<TH1D>("edecQ", "Energy deposit == ECal  (QIE)",   4000, 0., em1);
00049   edhcQ= tfile->make<TH1D>("edhcQ", "Energy deposit == HCal  (QIE)",   4000, 0., em2);
00050   edehS= tfile->make<TH2D>("edehS", "Hcal vs Ecal (Simhit)", 100,0.,em1, 100, 0.,em2);
00051   edehQ= tfile->make<TH2D>("edehQ", "Hcal vs Ecal (QIE)",    100,0.,em1, 100, 0.,em2);
00052   latse=  tfile->make<TProfile>("latse","Lat Prof (Eta Sim)",10,0.,10.);
00053   latqe=  tfile->make<TProfile>("latqe","Lat Prof (Eta QIE)",10,0.,10.);
00054   latsf=  tfile->make<TProfile>("latsf","Lat Prof (Phi Sim)",10,0.,10.);
00055   latqf=  tfile->make<TProfile>("latqf","Lat Prof (Phi QIE)",10,0.,10.); 
00056   lngs =  tfile->make<TProfile>("lngs", "Long. Prof (Sim)",  20,0.,20.); 
00057   lngq =  tfile->make<TProfile>("lngq", "Long. Prof (QIE)",  20,0.,20.);
00058 }
00059  
00060 HcalTB04Histo::~HcalTB04Histo() {}
00061  
00062 //
00063 // member functions
00064 //
00065 
00066 void HcalTB04Histo::fillPrimary(double energy, double eta, double phi) {
00067 
00068   LogDebug("HcalTBSim") << "HcalTB04Histo::fillPrimary: Energy " 
00069                         << energy << " Eta " << eta << " Phi " << phi;
00070   iniE->Fill(energy);
00071   iEta->Fill(eta);
00072   iPhi->Fill(phi);
00073 }
00074 
00075 void HcalTB04Histo::fillEdep(double etots, double eecals, double ehcals, 
00076                              double etotq, double eecalq, double ehcalq) {
00077 
00078   LogDebug("HcalTBSim") << "HcalTB04Histo:::fillEdep: Simulated Total "
00079                         << etots << " ECal " << eecals << " HCal " << ehcals
00080                         << " Digitised Total " << etotq << " ECal " << eecalq
00081                         << " HCal " << ehcalq;
00082   edepS->Fill(etots);
00083   edecS->Fill(eecals);
00084   edhcS->Fill(ehcals);
00085   edepQ->Fill(etotq);
00086   edecQ->Fill(eecalq);
00087   edhcQ->Fill(ehcalq);
00088   edehS->Fill(eecals, ehcals);
00089   edehQ->Fill(eecalq, ehcalq);
00090 }
00091 
00092 void HcalTB04Histo::fillTrnsProf(std::vector<double> es1, 
00093                                  std::vector<double> eq1,
00094                                  std::vector<double> es2, 
00095                                  std::vector<double> eq2) {
00096 
00097   unsigned int n1 = std::min(es1.size(),eq1.size());
00098   unsigned int n2 = std::min(es2.size(),eq2.size());
00099   unsigned int n  = std::min(n1,n2);
00100   for (unsigned int i = 0; i < n; i++) 
00101     LogDebug("HcalTBSim") << "HcalTB04Histo::fillTrnsProf [" << i
00102                           << "] SimEta " << es1[i] << " DigEta " << eq1[i]
00103                           << " SimPhi " << es2[i] << " DigPhi " << eq2[i];
00104   for (unsigned int i=0; i<(es1.size()); i++) {
00105     double tow = i+0.5;
00106     latse->Fill(tow, es1[i]);
00107   }
00108   for (unsigned int i=0; i<(eq1.size()); i++) {
00109     double tow = i+0.5;
00110     latqe->Fill(tow, eq1[i]);
00111   }
00112   for (unsigned int i=0; i<(es2.size()); i++) {
00113     double tow = i+0.5;
00114     latsf->Fill(tow, es2[i]);
00115   }
00116   for (unsigned int i=0; i<(eq2.size()); i++) {
00117     double tow = i+0.5;
00118     latqf->Fill(tow, eq2[i]);
00119   }
00120 }
00121 
00122 void HcalTB04Histo::fillLongProf(std::vector<double> es, 
00123                                  std::vector<double> eq) {
00124 
00125   unsigned int n = std::min(es.size(),eq.size());
00126   for (unsigned int i = 0; i < n; i++) 
00127     LogDebug("HcalTBSim") << "HcalTB04Histo::fillLongProf [" << i
00128                           << "] Sim " << es[i] << " Dig " << eq[i];
00129   for (unsigned int i=0; i<(es.size()); i++) {
00130     double lay = i+0.5;
00131     lngs->Fill(lay, es[i]);
00132   }
00133   for (unsigned int i=0; i<(eq.size()); i++) {
00134     double lay = i+0.5;
00135     lngq->Fill(lay, eq[i]);
00136   }
00137 }