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
Inheritance diagram for CentralityTableProducer:
edm::EDAnalyzer

Public Member Functions

 CentralityTableProducer (const edm::ParameterSet &)
 
 ~CentralityTableProducer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 40 of file CentralityTableProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file CentralityTableProducer.cc.

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

83  :
84  text_("bins.txt"),
85  runnum_(0)
86 {
87  //now do what ever initialization is needed
88  makeDBFromTFile_ = iConfig.getUntrackedParameter<bool>("makeDBFromTFile",1);
89  makeTFileFromDB_ = iConfig.getUntrackedParameter<bool>("makeTFileFromDB",0);
90  firstRunOnly_ = iConfig.getUntrackedParameter<bool>("isMC",false);
91  debug_ = iConfig.getUntrackedParameter<bool>("debug",false);
92  if(makeDBFromTFile_){
93  inputTFileName_ = iConfig.getParameter<string>("inputTFile");
94  rootTag_ = iConfig.getParameter<string>("rootTag");
95  inputTFile_ = new TFile(inputTFileName_.data(),"read");
96  cout<<inputTFileName_.data()<<endl;
97  }
98 }
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 100 of file CentralityTableProducer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 112 of file CentralityTableProducer.cc.

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

113 {
114  if(!makeTFileFromDB_) return;
115  if((!firstRunOnly_ && runnum_ != iEvent.id().run()) || (firstRunOnly_ && runnum_ == 0)){
116  runnum_ = iEvent.id().run();
117  cout<<"Adding table for run : "<<runnum_<<endl;
118  CentralityProvider cent(iSetup);
119  if(debug_) cent.print();
120  TFileDirectory subDir = fs->mkdir(Form("run%d",runnum_));
121  CB = subDir.make<CentralityBins>((CentralityBins)cent);
122  }
123 }
RunNumber_t run() const
Definition: EventID.h:42
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
edm::Service< TFileService > fs
edm::EventID id() const
Definition: EventBase.h:56
T * make() const
make new ROOT object
tuple cout
Definition: gather_cfg.py:121
void CentralityTableProducer::beginRun ( const edm::EventSetup iSetup)
privatevirtual

Definition at line 127 of file CentralityTableProducer.cc.

128 {
129 }
void CentralityTableProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 133 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.

133  {
134 
135  if(makeDBFromTFile_){
136  runnum_ = 1;
137  // Get values from root file
138  CB = (CentralityBins*) inputTFile_->Get(Form("%s/run%d",rootTag_.data(),runnum_));
139  cout<<rootTag_.data()<<endl;
140  CT = new CentralityTable();
141  CT->m_table.reserve(CB->getNbins());
142 
143  text_<<"# BinEdge NpartMean NpartVar NcollMean NcollVar NhardMean NhardVar bMean bVar"<<endl;
144  for(int j=0; j<CB->getNbins(); j++){
146  thisBin->bin_edge = CB->lowEdgeOfBin(j);
147  thisBin->n_part.mean = CB->NpartMeanOfBin(j);
148  thisBin->n_part.var = CB->NpartSigmaOfBin(j);
149  thisBin->n_coll.mean = CB->NcollMeanOfBin(j);
150  thisBin->n_coll.var = CB->NcollSigmaOfBin(j);
151  thisBin->n_hard.mean = CB->NhardMeanOfBin(j);
152  thisBin->n_hard.var = CB->NhardSigmaOfBin(j);
153  thisBin->b.mean = CB->bMeanOfBin(j);
154  thisBin->b.var = CB->bSigmaOfBin(j);
155  printBin(thisBin);
156  CT->m_table.push_back(*thisBin);
157  if(thisBin) delete thisBin;
158  }
159 
161  if( pool.isAvailable() ){
162  if( pool->isNewTagRequest( "HeavyIonRcd" ) ){
163  pool->createNewIOV<CentralityTable>( CT, pool->beginOfTime(), pool->endOfTime(), "HeavyIonRcd" );
164  }else{
165  pool->appendSinceTime<CentralityTable>( CT, pool->currentTime(), "HeavyIonRcd" );
166  }
167  }
168  }
169 }
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:47
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 172 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().

172  {
173 
174  cout<<"HF Cut = "<<thisBin->bin_edge<<endl;
175  cout<<"Npart = "<<thisBin->n_part.mean<<endl;
176  cout<<"sigma = "<<thisBin->n_part.var<<endl;
177  cout<<"Ncoll = "<<thisBin->n_coll.mean<<endl;
178  cout<<"sigma = "<<thisBin->n_coll.var<<endl;
179  cout<<"B = "<<thisBin->b.mean<<endl;
180  cout<<"sigma = "<<thisBin->b.var<<endl;
181  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",
182  (Float_t)thisBin->bin_edge,
183  (Float_t)thisBin->n_part.mean,
184  (Float_t)thisBin->n_part.var,
185  (Float_t)thisBin->n_coll.mean,
186  (Float_t)thisBin->n_coll.var,
187  (Float_t)thisBin->n_hard.mean,
188  (Float_t)thisBin->n_hard.var,
189  (Float_t)thisBin->b.mean,
190  (Float_t)thisBin->b.var)
191  <<endl;
192  cout<<"__________________________________________________"<<endl;
193 
194 }
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

const CentralityBins* CentralityTableProducer::CB
private

Definition at line 66 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

CentralityTable* CentralityTableProducer::CT
private

Definition at line 65 of file CentralityTableProducer.cc.

Referenced by endJob().

bool CentralityTableProducer::debug_
private

Definition at line 55 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

bool CentralityTableProducer::firstRunOnly_
private

Definition at line 54 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

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

Definition at line 60 of file CentralityTableProducer.cc.

Referenced by analyze().

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

Definition at line 57 of file CentralityTableProducer.cc.

TFile* CentralityTableProducer::inputTFile_
private

Definition at line 58 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

string CentralityTableProducer::inputTFileName_
private

Definition at line 59 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

bool CentralityTableProducer::makeDBFromTFile_
private

Definition at line 52 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

bool CentralityTableProducer::makeTFileFromDB_
private

Definition at line 53 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

string CentralityTableProducer::rootTag_
private

Definition at line 62 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

unsigned int CentralityTableProducer::runnum_
private

Definition at line 68 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

ofstream CentralityTableProducer::text_
private

Definition at line 63 of file CentralityTableProducer.cc.

Referenced by endJob(), and printBin().