CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/SimG4CMS/HcalTestBeam/src/HcalTB02Histo.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     HcalTestBeam
00004 // Class  :     HcalTB02Histo
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:
00010 //         Created:  Sun May 21 10:14:34 CEST 2006
00011 // $Id: HcalTB02Histo.cc,v 1.4 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/HcalTB02Histo.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 HcalTB02Histo::HcalTB02Histo(const edm::ParameterSet& ps) :
00027   rt_tbTimes(0),  rt_TransProf(0) {
00028 
00029   verbose    = ps.getUntrackedParameter<bool>("Verbose", false);
00030   edm::LogInfo("HcalTBSim") << "HcalTB02Histo:: initialised with o/p file "
00031                             << fileName << " verbosity " << verbose;
00032 
00033   // Book histograms
00034   edm::Service<TFileService> tfile;
00035 
00036   if ( !tfile.isAvailable() )
00037     throw cms::Exception("BadConfig") << "TFileService unavailable: "
00038                                       << "please add it to config file";
00039 
00040   char title[80];
00041   for (int ilayer=0; ilayer<19; ilayer++) {
00042     sprintf(title, "Scint. Energy in Layer %d ", ilayer);
00043     TH1D *h = tfile->make<TH1D>(title, title, 500, 0., 1.5);
00044     rt_histoProf.push_back(h);
00045     edm::LogInfo("HcalTBSim") << "HcalTB02Histo:: Initialise Histo " <<title;
00046   }
00047   sprintf(title, "All Hit Time slices");
00048   rt_tbTimes   = tfile->make<TH1D>(title, title, 100, 0., 100.);
00049   edm::LogInfo("HcalTBSim") << "HcalTB02Histo:: Initialise Histo " << title;
00050   sprintf(title, "Transv. Shower Profile");
00051   rt_TransProf = tfile->make<TH2D>(title, title, 100, 0., 1., 1000, 0., 0.5);
00052   edm::LogInfo("HcalTBSim") << "HcalTB02Histo:: Initialise Histo " << title;
00053 }
00054  
00055 HcalTB02Histo::~HcalTB02Histo() {
00056   edm::LogInfo("HcalTBSim") << " Deleting HcalTB02Histo";
00057 }
00058  
00059 //
00060 // member functions
00061 //
00062  
00063 void HcalTB02Histo::fillAllTime(float v) {
00064 
00065   LogDebug("HcalTBSim") << "HcalTB02Histo::Fill Time histo with " << v;
00066   if (rt_tbTimes) {
00067     rt_tbTimes->Fill(v);
00068   }
00069 }
00070 
00071 void HcalTB02Histo::fillTransProf(float u, float v) {
00072 
00073   LogDebug("HcalTBSim") << "HcalTB02Histo:::Fill Shower Transv. Profile histo"
00074                         << " with " << u << " and " << v;
00075   if (rt_TransProf) {
00076     rt_TransProf->Fill(u,v);
00077   }
00078 }
00079 
00080 void HcalTB02Histo::fillProfile(int ilayer, float value) {
00081 
00082   if (ilayer < (int)(rt_histoProf.size())) {
00083     rt_histoProf[ilayer]->Fill(value);
00084     LogDebug("HcalTBSim") << "HcalTB02Histo::Fill profile " << ilayer
00085                           << " with " << value;
00086   }
00087 }
00088 
00089 float HcalTB02Histo::getMean(int ilayer) {
00090 
00091   if (ilayer < (int)(rt_histoProf.size())) {
00092     return rt_histoProf[ilayer]->GetMean();
00093   } else {
00094     return 0;
00095   }
00096 }
00097 
00098 float HcalTB02Histo::getRMS(int ilayer) {
00099 
00100   if (ilayer < (int)(rt_histoProf.size())) {
00101     return rt_histoProf[ilayer]->GetRMS();
00102   } else {
00103     return 0;
00104   }
00105 }