Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:53

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: HcalTestHistoManager.cc
0003 // Description: Histogram managing class in HcalTestAnalysis (HcalTest)
0004 ///////////////////////////////////////////////////////////////////////////////
0005 
0006 #include "SimG4CMS/Calo/interface/HcalTestHistoManager.h"
0007 
0008 #include "FWCore/PluginManager/interface/PluginManager.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 #include <cmath>
0012 #include <iostream>
0013 #include <memory>
0014 
0015 //#define EDM_ML_DEBUG
0016 
0017 HcalTestHistoManager::HcalTestHistoManager(const std::string& file) : tree_(nullptr), kount_(0) {
0018   edm::Service<TFileService> fs;
0019   if (fs.isAvailable()) {
0020     h_ = std::make_unique<HcalTestHistoClass>();
0021 
0022     tree_ = fs->make<TTree>("HcalTest", "HcalTest");
0023     tree_->SetAutoSave(10000);
0024     tree_->Branch("HcalTestHisto", "HcalTestHistoClass", &h_);
0025     edm::LogVerbatim("HcalSim") << "HcalTestHistoManager:===>>>  Book the Tree";
0026   } else {
0027     edm::LogVerbatim("HcalSim") << "HcalTestHistoManager:===>>> No file provided";
0028   }
0029 }
0030 
0031 HcalTestHistoManager::~HcalTestHistoManager() {
0032   edm::LogVerbatim("HcalSim") << "================================================================="
0033                               << "====================\n=== HcalTestHistoManager: Start writing user "
0034                               << "histograms after " << kount_ << " events ";
0035 }
0036 
0037 void HcalTestHistoManager::fillTree(HcalTestHistoClass* histos) {
0038   ++kount_;
0039 #ifdef EDM_ML_DEBUG
0040   edm::LogVerbatim("HcalSim") << "HcalTestHistoManager: tree pointer for " << kount_ << " = " << histos;
0041 #endif
0042   if (tree_) {
0043     h_.reset(histos);
0044     tree_->Fill();
0045   }
0046 }