CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/SimG4CMS/Calo/src/HcalTestHistoManager.cc

Go to the documentation of this file.
00001 
00002 // File: HcalTestHistoManager.cc
00003 // Description: Histogram managing class in HcalTestAnalysis (HcalTest)
00005 
00006 #include "SimG4CMS/Calo/interface/HcalTestHistoManager.h"
00007 
00008 #include "FWCore/PluginManager/interface/PluginManager.h"
00009 
00010 #include <iostream>
00011 #include <cmath>
00012 
00013 HcalTestHistoManager::HcalTestHistoManager(const std::string & file) :
00014   tree(0), h(0), kount(0) {
00015   if (fs.isAvailable()) {
00016     h    = new HcalTestHistoClass();
00017 
00018     tree = fs->make<TTree>("HcalTest", "HcalTest");
00019     tree->SetAutoSave(10000);
00020     tree->Branch("HcalTestHisto", "HcalTestHistoClass", &h); 
00021     edm::LogInfo("HcalSim") << "HcalTestHistoManager:===>>>  Book the Tree";
00022   } else {
00023     edm::LogInfo("HcalSim") << "HcalTestHistoManager:===>>> No file provided";
00024   }
00025 }
00026 
00027 HcalTestHistoManager::~HcalTestHistoManager() {
00028 
00029   edm::LogInfo("HcalSim") << "============================================="
00030                           << "========================================\n"
00031                           << "=== HcalTestHistoManager: Start writing user "
00032                           << "histograms after " << kount << " events ";
00033   if (h) delete h;
00034 }
00035 
00036 void HcalTestHistoManager::fillTree(HcalTestHistoClass *  histos) {
00037 
00038   kount++;
00039   LogDebug("HcalSim") << "HcalTestHistoManager: tree pointer for " << kount 
00040                       << " = " << histos;
00041   if (tree) {
00042     h = histos;
00043     tree->Fill();
00044   }
00045 }