CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CentralityTableProducer Class Reference

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

Inheritance diagram for CentralityTableProducer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 CentralityTableProducer (const edm::ParameterSet &)
 
 ~CentralityTableProducer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginRun (const edm::EventSetup &)
 
virtual void endJob () override
 
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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 57 of file CentralityTableProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 100 of file CentralityTableProducer.cc.

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

100  :
101  text_("bins.txt"),
102  runnum_(0)
103 {
104  //now do what ever initialization is needed
105  makeDBFromTFile_ = iConfig.getUntrackedParameter<bool>("makeDBFromTFile",1);
106  makeTFileFromDB_ = iConfig.getUntrackedParameter<bool>("makeTFileFromDB",0);
107  firstRunOnly_ = iConfig.getUntrackedParameter<bool>("isMC",false);
108  debug_ = iConfig.getUntrackedParameter<bool>("debug",false);
109  if(makeDBFromTFile_){
110  inputTFileName_ = iConfig.getParameter<string>("inputTFile");
111  rootTag_ = iConfig.getParameter<string>("rootTag");
112  inputTFile_ = new TFile(inputTFileName_.data(),"read");
113  cout<<inputTFileName_.data()<<endl;
114  }
115 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
tuple cout
Definition: gather_cfg.py:121
CentralityTableProducer::~CentralityTableProducer ( )

Definition at line 117 of file CentralityTableProducer.cc.

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

Member Function Documentation

void CentralityTableProducer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 129 of file CentralityTableProducer.cc.

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

130 {
131  if(!makeTFileFromDB_) return;
132  if((!firstRunOnly_ && runnum_ != iEvent.id().run()) || (firstRunOnly_ && runnum_ == 0)){
133  runnum_ = iEvent.id().run();
134  cout<<"Adding table for run : "<<runnum_<<endl;
135  CentralityProvider cent(iSetup);
136  if(debug_) cent.print();
137  TFileDirectory subDir = fs->mkdir(Form("run%d",runnum_));
138  CB = subDir.make<CentralityBins>((CentralityBins)cent);
139  }
140 }
RunNumber_t run() const
Definition: EventID.h:42
T * make(const Args &...args) const
make new ROOT object
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
edm::Service< TFileService > fs
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:121
void CentralityTableProducer::beginRun ( const edm::EventSetup iSetup)
privatevirtual

Definition at line 144 of file CentralityTableProducer.cc.

145 {
146 }
void CentralityTableProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 150 of file CentralityTableProducer.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), CentralityTable::CBin::b, cond::service::PoolDBOutputService::beginOfTime(), CentralityTable::CBin::bin_edge, CentralityBins::bMeanOfBin(), CentralityBins::bSigmaOfBin(), CB, gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), CT, cond::service::PoolDBOutputService::currentTime(), cond::service::PoolDBOutputService::endOfTime(), CentralityBins::getNbins(), inputTFile_, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), j, CentralityBins::lowEdgeOfBin(), CentralityTable::m_table, makeDBFromTFile_, CentralityTable::BinValues::mean, 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_, text_, and CentralityTable::BinValues::var.

150  {
151 
152  if(makeDBFromTFile_){
153  runnum_ = 1;
154  // Get values from root file
155  CB = (CentralityBins*) inputTFile_->Get(Form("%s/run%d",rootTag_.data(),runnum_));
156  cout<<rootTag_.data()<<endl;
157  CT = new CentralityTable();
158  CT->m_table.reserve(CB->getNbins());
159 
160  text_<<"# BinEdge NpartMean NpartVar NcollMean NcollVar NhardMean NhardVar bMean bVar"<<endl;
161  for(int j=0; j<CB->getNbins(); j++){
163  thisBin->bin_edge = CB->lowEdgeOfBin(j);
164  thisBin->n_part.mean = CB->NpartMeanOfBin(j);
165  thisBin->n_part.var = CB->NpartSigmaOfBin(j);
166  thisBin->n_coll.mean = CB->NcollMeanOfBin(j);
167  thisBin->n_coll.var = CB->NcollSigmaOfBin(j);
168  thisBin->n_hard.mean = CB->NhardMeanOfBin(j);
169  thisBin->n_hard.var = CB->NhardSigmaOfBin(j);
170  thisBin->b.mean = CB->bMeanOfBin(j);
171  thisBin->b.var = CB->bSigmaOfBin(j);
172  printBin(thisBin);
173  CT->m_table.push_back(*thisBin);
174  if(thisBin) delete thisBin;
175  }
176 
178  if( pool.isAvailable() ){
179  if( pool->isNewTagRequest( "HeavyIonRcd" ) ){
180  pool->createNewIOV<CentralityTable>( CT, pool->beginOfTime(), pool->endOfTime(), "HeavyIonRcd" );
181  }else{
182  pool->appendSinceTime<CentralityTable>( CT, pool->currentTime(), "HeavyIonRcd" );
183  }
184  }
185  }
186 }
void printBin(const CentralityTable::CBin *)
std::vector< CBin > m_table
float NpartSigmaOfBin(int bin) const
float lowEdgeOfBin(int bin) const
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
float NcollMeanOfBin(int bin) const
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:46
int j
Definition: DBlmapReader.cc:9
float bSigmaOfBin(int bin) const
float NhardMeanOfBin(int bin) const
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
float NpartMeanOfBin(int bin) const
int getNbins() const
float bMeanOfBin(int bin) const
tuple cout
Definition: gather_cfg.py:121
float NhardSigmaOfBin(int bin) const
float NcollSigmaOfBin(int bin) const
void CentralityTableProducer::printBin ( const CentralityTable::CBin thisBin)
private

Definition at line 189 of file CentralityTableProducer.cc.

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

Referenced by endJob().

189  {
190 
191  cout<<"HF Cut = "<<thisBin->bin_edge<<endl;
192  cout<<"Npart = "<<thisBin->n_part.mean<<endl;
193  cout<<"sigma = "<<thisBin->n_part.var<<endl;
194  cout<<"Ncoll = "<<thisBin->n_coll.mean<<endl;
195  cout<<"sigma = "<<thisBin->n_coll.var<<endl;
196  cout<<"B = "<<thisBin->b.mean<<endl;
197  cout<<"sigma = "<<thisBin->b.var<<endl;
198  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",
199  (Float_t)thisBin->bin_edge,
200  (Float_t)thisBin->n_part.mean,
201  (Float_t)thisBin->n_part.var,
202  (Float_t)thisBin->n_coll.mean,
203  (Float_t)thisBin->n_coll.var,
204  (Float_t)thisBin->n_hard.mean,
205  (Float_t)thisBin->n_hard.var,
206  (Float_t)thisBin->b.mean,
207  (Float_t)thisBin->b.var)
208  <<endl;
209  cout<<"__________________________________________________"<<endl;
210 
211 }
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

const CentralityBins* CentralityTableProducer::CB
private

Definition at line 83 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

CentralityTable* CentralityTableProducer::CT
private

Definition at line 82 of file CentralityTableProducer.cc.

Referenced by endJob().

bool CentralityTableProducer::debug_
private

Definition at line 72 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

bool CentralityTableProducer::firstRunOnly_
private

Definition at line 71 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

edm::Service<TFileService> CentralityTableProducer::fs
private

Definition at line 77 of file CentralityTableProducer.cc.

Referenced by analyze().

edm::ESHandle<CentralityTable> CentralityTableProducer::inputDB_
private

Definition at line 74 of file CentralityTableProducer.cc.

TFile* CentralityTableProducer::inputTFile_
private

Definition at line 75 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

string CentralityTableProducer::inputTFileName_
private

Definition at line 76 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

bool CentralityTableProducer::makeDBFromTFile_
private

Definition at line 69 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

bool CentralityTableProducer::makeTFileFromDB_
private

Definition at line 70 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

string CentralityTableProducer::rootTag_
private

Definition at line 79 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

unsigned int CentralityTableProducer::runnum_
private

Definition at line 85 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

ofstream CentralityTableProducer::text_
private

Definition at line 80 of file CentralityTableProducer.cc.

Referenced by endJob(), and printBin().