Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-16 23:05:20

0001 // -*- C++ -*-
0002 //
0003 // Package:     HcalTestBeam
0004 // Class  :     HcalTB04Histo
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:
0010 //         Created:  Tue May 16 10:14:34 CEST 2006
0011 //
0012 
0013 // system include files
0014 #include <iostream>
0015 #include <cmath>
0016 
0017 // user include files
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 #include "FWCore/ServiceRegistry/interface/Service.h"
0020 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0021 #include "SimG4CMS/HcalTestBeam/interface/HcalTB04Histo.h"
0022 
0023 //#define EDM_ML_DEBUG
0024 
0025 //
0026 // constructors and destructor
0027 HcalTB04Histo::HcalTB04Histo(const edm::ParameterSet& ps)
0028     : iniE(nullptr),
0029       iEta(nullptr),
0030       iPhi(nullptr),
0031       edepS(nullptr),
0032       edecS(nullptr),
0033       edhcS(nullptr),
0034       edepQ(nullptr),
0035       edecQ(nullptr),
0036       edhcQ(nullptr),
0037       edehS(nullptr),
0038       edehQ(nullptr),
0039       latse(nullptr),
0040       latqe(nullptr),
0041       latsf(nullptr),
0042       latqf(nullptr),
0043       lngs(nullptr),
0044       lngq(nullptr) {
0045   verbose = ps.getUntrackedParameter<bool>("Verbose", false);
0046   double em1 = ps.getUntrackedParameter<double>("ETtotMax", 400.);
0047   double em2 = ps.getUntrackedParameter<double>("EHCalMax", 4.0);
0048 
0049   // Book histograms
0050   edm::Service<TFileService> tfile;
0051 
0052   if (!tfile.isAvailable())
0053     throw cms::Exception("BadConfig") << "TFileService unavailable: "
0054                                       << "please add it to config file";
0055   iniE = tfile->make<TH1D>("iniE", "Incident Energy (GeV)", 4000, 0., em1);
0056   iEta = tfile->make<TH1D>("iEta", "Eta at incidence     ", 300, 0., 3.);
0057   iPhi = tfile->make<TH1D>("iPhi", "Phi at incidence     ", 300, -1., 1.);
0058   edepS = tfile->make<TH1D>("edepS", "Energy deposit == Total (Simhit)", 4000, 0., em1);
0059   edecS = tfile->make<TH1D>("edecS", "Energy deposit == ECal  (Simhit)", 4000, 0., em1);
0060   edhcS = tfile->make<TH1D>("edhcS", "Energy deposit == HCal  (Simhit)", 4000, 0., em2);
0061   edepQ = tfile->make<TH1D>("edepQ", "Energy deposit == Total (QIE)", 4000, 0., em1);
0062   edecQ = tfile->make<TH1D>("edecQ", "Energy deposit == ECal  (QIE)", 4000, 0., em1);
0063   edhcQ = tfile->make<TH1D>("edhcQ", "Energy deposit == HCal  (QIE)", 4000, 0., em2);
0064   edehS = tfile->make<TH2D>("edehS", "Hcal vs Ecal (Simhit)", 100, 0., em1, 100, 0., em2);
0065   edehQ = tfile->make<TH2D>("edehQ", "Hcal vs Ecal (QIE)", 100, 0., em1, 100, 0., em2);
0066   latse = tfile->make<TProfile>("latse", "Lat Prof (Eta Sim)", 10, 0., 10.);
0067   latqe = tfile->make<TProfile>("latqe", "Lat Prof (Eta QIE)", 10, 0., 10.);
0068   latsf = tfile->make<TProfile>("latsf", "Lat Prof (Phi Sim)", 10, 0., 10.);
0069   latqf = tfile->make<TProfile>("latqf", "Lat Prof (Phi QIE)", 10, 0., 10.);
0070   lngs = tfile->make<TProfile>("lngs", "Long. Prof (Sim)", 20, 0., 20.);
0071   lngq = tfile->make<TProfile>("lngq", "Long. Prof (QIE)", 20, 0., 20.);
0072 }
0073 
0074 HcalTB04Histo::~HcalTB04Histo() {}
0075 
0076 //
0077 // member functions
0078 //
0079 
0080 void HcalTB04Histo::fillPrimary(double energy, double eta, double phi) {
0081 #ifdef EDM_ML_DEBUG
0082   edm::LogVerbatim("HcalTBSim") << "HcalTB04Histo::fillPrimary: Energy " << energy << " Eta " << eta << " Phi " << phi;
0083 #endif
0084   iniE->Fill(energy);
0085   iEta->Fill(eta);
0086   iPhi->Fill(phi);
0087 }
0088 
0089 void HcalTB04Histo::fillEdep(double etots, double eecals, double ehcals, double etotq, double eecalq, double ehcalq) {
0090 #ifdef EDM_ML_DEBUG
0091   edm::LogVerbatim("HcalTBSim") << "HcalTB04Histo:::fillEdep: Simulated Total " << etots << " ECal " << eecals
0092                                 << " HCal " << ehcals << " Digitised Total " << etotq << " ECal " << eecalq << " HCal "
0093                                 << ehcalq;
0094 #endif
0095   edepS->Fill(etots);
0096   edecS->Fill(eecals);
0097   edhcS->Fill(ehcals);
0098   edepQ->Fill(etotq);
0099   edecQ->Fill(eecalq);
0100   edhcQ->Fill(ehcalq);
0101   edehS->Fill(eecals, ehcals);
0102   edehQ->Fill(eecalq, ehcalq);
0103 }
0104 
0105 void HcalTB04Histo::fillTrnsProf(const std::vector<double>& es1,
0106                                  const std::vector<double>& eq1,
0107                                  const std::vector<double>& es2,
0108                                  const std::vector<double>& eq2) {
0109 #ifdef EDM_ML_DEBUG
0110   unsigned int n1 = std::min(es1.size(), eq1.size());
0111   unsigned int n2 = std::min(es2.size(), eq2.size());
0112   unsigned int n = std::min(n1, n2);
0113   for (unsigned int i = 0; i < n; i++)
0114     edm::LogVerbatim("HcalTBSim") << "HcalTB04Histo::fillTrnsProf [" << i << "] SimEta " << es1[i] << " DigEta "
0115                                   << eq1[i] << " SimPhi " << es2[i] << " DigPhi " << eq2[i];
0116 #endif
0117   for (unsigned int i = 0; i < (es1.size()); i++) {
0118     double tow = i + 0.5;
0119     latse->Fill(tow, es1[i]);
0120   }
0121   for (unsigned int i = 0; i < (eq1.size()); i++) {
0122     double tow = i + 0.5;
0123     latqe->Fill(tow, eq1[i]);
0124   }
0125   for (unsigned int i = 0; i < (es2.size()); i++) {
0126     double tow = i + 0.5;
0127     latsf->Fill(tow, es2[i]);
0128   }
0129   for (unsigned int i = 0; i < (eq2.size()); i++) {
0130     double tow = i + 0.5;
0131     latqf->Fill(tow, eq2[i]);
0132   }
0133 }
0134 
0135 void HcalTB04Histo::fillLongProf(const std::vector<double>& es, const std::vector<double>& eq) {
0136 #ifdef EDM_ML_DEBUG
0137   unsigned int n = std::min(es.size(), eq.size());
0138   for (unsigned int i = 0; i < n; i++)
0139     edm::LogVerbatim("HcalTBSim") << "HcalTB04Histo::fillLongProf [" << i << "] Sim " << es[i] << " Dig " << eq[i];
0140 #endif
0141   for (unsigned int i = 0; i < (es.size()); i++) {
0142     double lay = i + 0.5;
0143     lngs->Fill(lay, es[i]);
0144   }
0145   for (unsigned int i = 0; i < (eq.size()); i++) {
0146     double lay = i + 0.5;
0147     lngq->Fill(lay, eq[i]);
0148   }
0149 }