CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CentralityTableProducer Class Reference

#include <yetkin/CentralityTableProducer/src/CentralityTableProducer.cc>

Inheritance diagram for CentralityTableProducer:
edm::EDAnalyzer

List of all members.

Public Member Functions

 CentralityTableProducer (const edm::ParameterSet &)
 ~CentralityTableProducer ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginRun (const edm::EventSetup &)
virtual void endJob ()
void printBin (const CentralityTable::CBin *)

Private Attributes

const CentralityBinsCB
CentralityTableCT
bool debug_
bool firstRunOnly_
edm::Service< TFileServicefs
edm::ESHandle< CentralityTableinputDB_
TFile * inputTFile_
string inputTFileName_
bool makeDBFromTFile_
bool makeTFileFromDB_
string rootTag_
unsigned int runnum_
ofstream text_

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 59 of file CentralityTableProducer.cc.


Constructor & Destructor Documentation

CentralityTableProducer::CentralityTableProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 102 of file CentralityTableProducer.cc.

References gather_cfg::cout, debug_, firstRunOnly_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), inputTFile_, inputTFileName_, makeDBFromTFile_, makeTFileFromDB_, and rootTag_.

                                                                              :
   text_("bins.txt"),
   runnum_(0)
{
   //now do what ever initialization is needed
   makeDBFromTFile_ = iConfig.getUntrackedParameter<bool>("makeDBFromTFile",1);
   makeTFileFromDB_ = iConfig.getUntrackedParameter<bool>("makeTFileFromDB",0);
   firstRunOnly_ = iConfig.getUntrackedParameter<bool>("isMC",false);
   debug_ = iConfig.getUntrackedParameter<bool>("debug",false);
   if(makeDBFromTFile_){
      inputTFileName_ = iConfig.getParameter<string>("inputTFile");
      rootTag_ = iConfig.getParameter<string>("rootTag");
      inputTFile_  = new TFile(inputTFileName_.data(),"read");
      cout<<inputTFileName_.data()<<endl;
   }
}
CentralityTableProducer::~CentralityTableProducer ( )

Definition at line 119 of file CentralityTableProducer.cc.

{
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)
}

Member Function Documentation

void CentralityTableProducer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 131 of file CentralityTableProducer.cc.

References CB, gather_cfg::cout, debug_, firstRunOnly_, fs, edm::EventBase::id(), TFileDirectory::make(), makeTFileFromDB_, CentralityProvider::print(), edm::EventID::run(), and runnum_.

{
  if(!makeTFileFromDB_) return;
  if((!firstRunOnly_ && runnum_ != iEvent.id().run()) || (firstRunOnly_ && runnum_ == 0)){
    runnum_ = iEvent.id().run();
    cout<<"Adding table for run : "<<runnum_<<endl;
    CentralityProvider cent(iSetup);
    if(debug_) cent.print();
    TFileDirectory subDir = fs->mkdir(Form("run%d",runnum_));
    CB = subDir.make<CentralityBins>((CentralityBins)cent);
  }    
}
void CentralityTableProducer::beginRun ( const edm::EventSetup iSetup) [private, virtual]

Definition at line 146 of file CentralityTableProducer.cc.

{
}
void CentralityTableProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 152 of file CentralityTableProducer.cc.

References CentralityTable::CBin::b, CentralityTable::CBin::bin_edge, CentralityBins::bMeanOfBin(), CentralityBins::bSigmaOfBin(), CB, gather_cfg::cout, CT, CentralityBins::getNbins(), inputTFile_, edm::Service< T >::isAvailable(), j, CentralityBins::lowEdgeOfBin(), CentralityTable::m_table, makeDBFromTFile_, CentralityTable::CBin::n_coll, CentralityTable::CBin::n_hard, CentralityTable::CBin::n_part, CentralityBins::NcollMeanOfBin(), CentralityBins::NcollSigmaOfBin(), CentralityBins::NhardMeanOfBin(), CentralityBins::NhardSigmaOfBin(), CentralityBins::NpartMeanOfBin(), CentralityBins::NpartSigmaOfBin(), fetchall_from_DQM_v2::pool, printBin(), rootTag_, runnum_, and text_.

                                {

   if(makeDBFromTFile_){
      runnum_ = 1;
      // Get values from root file
      CB = (CentralityBins*) inputTFile_->Get(Form("%s/run%d",rootTag_.data(),runnum_));
      cout<<rootTag_.data()<<endl;
      CT = new CentralityTable();
      CT->m_table.reserve(CB->getNbins());

      text_<<"# BinEdge NpartMean NpartVar NcollMean NcollVar NhardMean NhardVar bMean bVar"<<endl;
   for(int j=0; j<CB->getNbins(); j++){
       CentralityTable::CBin* thisBin = new CentralityTable::CBin();
       thisBin->bin_edge = CB->lowEdgeOfBin(j);
       thisBin->n_part.mean = CB->NpartMeanOfBin(j);
       thisBin->n_part.var  = CB->NpartSigmaOfBin(j);
       thisBin->n_coll.mean = CB->NcollMeanOfBin(j);
       thisBin->n_coll.var  = CB->NcollSigmaOfBin(j);
       thisBin->n_hard.mean = CB->NhardMeanOfBin(j);
       thisBin->n_hard.var  = CB->NhardSigmaOfBin(j);
       thisBin->b.mean = CB->bMeanOfBin(j);
       thisBin->b.var = CB->bSigmaOfBin(j);
       printBin(thisBin);
       CT->m_table.push_back(*thisBin);
       if(thisBin) delete thisBin;
  }

      edm::Service<cond::service::PoolDBOutputService> pool;
      if( pool.isAvailable() ){
         if( pool->isNewTagRequest( "HeavyIonRcd" ) ){
            pool->createNewIOV<CentralityTable>( CT, pool->beginOfTime(), pool->endOfTime(), "HeavyIonRcd" );
         }else{
            pool->appendSinceTime<CentralityTable>( CT, pool->currentTime(), "HeavyIonRcd" );
         }
      }
   }
}
void CentralityTableProducer::printBin ( const CentralityTable::CBin thisBin) [private]

Definition at line 191 of file CentralityTableProducer.cc.

References CentralityTable::CBin::b, CentralityTable::CBin::bin_edge, gather_cfg::cout, CentralityTable::CBin::n_coll, CentralityTable::CBin::n_hard, CentralityTable::CBin::n_part, and text_.

Referenced by endJob().

                                                                        {
  
   cout<<"HF Cut = "<<thisBin->bin_edge<<endl;
   cout<<"Npart = "<<thisBin->n_part.mean<<endl;
   cout<<"sigma = "<<thisBin->n_part.var<<endl;
   cout<<"Ncoll = "<<thisBin->n_coll.mean<<endl;
   cout<<"sigma = "<<thisBin->n_coll.var<<endl;
   cout<<"B     = "<<thisBin->b.mean<<endl;
   cout<<"sigma = "<<thisBin->b.var<<endl;
   text_<<Form("%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f",
               (Float_t)thisBin->bin_edge,
               (Float_t)thisBin->n_part.mean,
               (Float_t)thisBin->n_part.var,
               (Float_t)thisBin->n_coll.mean,
               (Float_t)thisBin->n_coll.var,
               (Float_t)thisBin->n_hard.mean,
               (Float_t)thisBin->n_hard.var,
               (Float_t)thisBin->b.mean,
               (Float_t)thisBin->b.var)
        <<endl;
   cout<<"__________________________________________________"<<endl;
   
}

Member Data Documentation

Definition at line 85 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

Definition at line 84 of file CentralityTableProducer.cc.

Referenced by endJob().

Definition at line 74 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

Definition at line 73 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

Definition at line 79 of file CentralityTableProducer.cc.

Referenced by analyze().

Definition at line 76 of file CentralityTableProducer.cc.

Definition at line 77 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

Definition at line 78 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

Definition at line 71 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

Definition at line 72 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

Definition at line 81 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

unsigned int CentralityTableProducer::runnum_ [private]

Definition at line 87 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

ofstream CentralityTableProducer::text_ [private]

Definition at line 82 of file CentralityTableProducer.cc.

Referenced by endJob(), and printBin().