CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CentralityTableProducer Class Reference
Inheritance diagram for CentralityTableProducer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 CentralityTableProducer (const edm::ParameterSet &)
 
 ~CentralityTableProducer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

const CentralityBinsCB
 
CentralityTableCT
 
bool debug_
 
bool firstRunOnly_
 
edm::Service< TFileServicefs
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 39 of file CentralityTableProducer.cc.

Constructor & Destructor Documentation

◆ CentralityTableProducer()

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

Definition at line 79 of file CentralityTableProducer.cc.

79  : text_("bins.txt"), runnum_(0) {
80  //now do what ever initialization is needed
81  makeDBFromTFile_ = iConfig.getUntrackedParameter<bool>("makeDBFromTFile", true);
82  makeTFileFromDB_ = iConfig.getUntrackedParameter<bool>("makeTFileFromDB", false);
83  firstRunOnly_ = iConfig.getUntrackedParameter<bool>("isMC", false);
84  debug_ = iConfig.getUntrackedParameter<bool>("debug", false);
85  if (makeDBFromTFile_) {
86  inputTFileName_ = iConfig.getParameter<string>("inputTFile");
87  rootTag_ = iConfig.getParameter<string>("rootTag");
88  inputTFile_ = new TFile(inputTFileName_.data(), "read");
89  cout << inputTFileName_.data() << endl;
90  }
91 }

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

◆ ~CentralityTableProducer()

CentralityTableProducer::~CentralityTableProducer ( )
override

Definition at line 93 of file CentralityTableProducer.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 103 of file CentralityTableProducer.cc.

103  {
104  if (!makeTFileFromDB_)
105  return;
106  if ((!firstRunOnly_ && runnum_ != iEvent.id().run()) || (firstRunOnly_ && runnum_ == 0)) {
107  runnum_ = iEvent.id().run();
108  cout << "Adding table for run : " << runnum_ << endl;
109  TFileDirectory subDir = fs->mkdir(Form("run%d", runnum_));
110  CB = subDir.make<CentralityBins>();
111  }
112 }

References CB, gather_cfg::cout, firstRunOnly_, fs, iEvent, makeTFileFromDB_, TFileService::mkdir(), runnum_, and PostProcessorHcalIsoTrack_cfi::subDir.

◆ endJob()

void CentralityTableProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 115 of file CentralityTableProducer.cc.

115  {
116  if (makeDBFromTFile_) {
117  runnum_ = 1;
118  // Get values from root file
119  CB = (CentralityBins*)inputTFile_->Get(Form("%s/run%d", rootTag_.data(), runnum_));
120  cout << rootTag_.data() << endl;
121  CT = new CentralityTable();
122  CT->m_table.reserve(CB->getNbins());
123 
124  text_ << "# BinEdge NpartMean NpartVar NcollMean NcollVar NhardMean NhardVar bMean bVar" << endl;
125  for (int j = 0; j < CB->getNbins(); j++) {
127  thisBin->bin_edge = CB->lowEdgeOfBin(j);
128  thisBin->n_part.mean = CB->NpartMeanOfBin(j);
129  thisBin->n_part.var = CB->NpartSigmaOfBin(j);
130  thisBin->n_coll.mean = CB->NcollMeanOfBin(j);
131  thisBin->n_coll.var = CB->NcollSigmaOfBin(j);
132  thisBin->n_hard.mean = CB->NhardMeanOfBin(j);
133  thisBin->n_hard.var = CB->NhardSigmaOfBin(j);
134  thisBin->b.mean = CB->bMeanOfBin(j);
135  thisBin->b.var = CB->bSigmaOfBin(j);
136  printBin(thisBin);
137  CT->m_table.push_back(*thisBin);
138  if (thisBin)
139  delete thisBin;
140  }
141 
143  if (pool.isAvailable()) {
144  if (pool->isNewTagRequest("HeavyIonRcd")) {
145  pool->createNewIOV<CentralityTable>(CT, pool->beginOfTime(), pool->endOfTime(), "HeavyIonRcd");
146  } else {
147  pool->appendSinceTime<CentralityTable>(CT, pool->currentTime(), "HeavyIonRcd");
148  }
149  }
150  }
151 }

References CentralityTable::CBin::b, CentralityTable::CBin::bin_edge, CentralityBins::bMeanOfBin(), CentralityBins::bSigmaOfBin(), CB, gather_cfg::cout, CT, CentralityBins::getNbins(), inputTFile_, dqmiolumiharvest::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(), submitPVResolutionJobs::pool, printBin(), rootTag_, runnum_, text_, and CentralityTable::BinValues::var.

◆ printBin()

void CentralityTableProducer::printBin ( const CentralityTable::CBin thisBin)
private

Definition at line 153 of file CentralityTableProducer.cc.

153  {
154  cout << "HF Cut = " << thisBin->bin_edge << endl;
155  cout << "Npart = " << thisBin->n_part.mean << endl;
156  cout << "sigma = " << thisBin->n_part.var << endl;
157  cout << "Ncoll = " << thisBin->n_coll.mean << endl;
158  cout << "sigma = " << thisBin->n_coll.var << endl;
159  cout << "B = " << thisBin->b.mean << endl;
160  cout << "sigma = " << thisBin->b.var << endl;
161  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",
162  (Float_t)thisBin->bin_edge,
163  (Float_t)thisBin->n_part.mean,
164  (Float_t)thisBin->n_part.var,
165  (Float_t)thisBin->n_coll.mean,
166  (Float_t)thisBin->n_coll.var,
167  (Float_t)thisBin->n_hard.mean,
168  (Float_t)thisBin->n_hard.var,
169  (Float_t)thisBin->b.mean,
170  (Float_t)thisBin->b.var)
171  << endl;
172  cout << "__________________________________________________" << endl;
173 }

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().

Member Data Documentation

◆ CB

const CentralityBins* CentralityTableProducer::CB
private

Definition at line 63 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

◆ CT

CentralityTable* CentralityTableProducer::CT
private

Definition at line 62 of file CentralityTableProducer.cc.

Referenced by endJob().

◆ debug_

bool CentralityTableProducer::debug_
private

Definition at line 53 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

◆ firstRunOnly_

bool CentralityTableProducer::firstRunOnly_
private

Definition at line 52 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

◆ fs

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

Definition at line 57 of file CentralityTableProducer.cc.

Referenced by analyze().

◆ inputTFile_

TFile* CentralityTableProducer::inputTFile_
private

Definition at line 55 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

◆ inputTFileName_

string CentralityTableProducer::inputTFileName_
private

Definition at line 56 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

◆ makeDBFromTFile_

bool CentralityTableProducer::makeDBFromTFile_
private

Definition at line 50 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

◆ makeTFileFromDB_

bool CentralityTableProducer::makeTFileFromDB_
private

Definition at line 51 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

◆ rootTag_

string CentralityTableProducer::rootTag_
private

Definition at line 59 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

◆ runnum_

unsigned int CentralityTableProducer::runnum_
private

Definition at line 65 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

◆ text_

ofstream CentralityTableProducer::text_
private

Definition at line 60 of file CentralityTableProducer.cc.

Referenced by endJob(), and printBin().

CentralityTableProducer::CB
const CentralityBins * CB
Definition: CentralityTableProducer.cc:63
CentralityTable::CBin
Definition: CentralityTable.h:16
CentralityTable
Definition: CentralityTable.h:7
CentralityTableProducer::printBin
void printBin(const CentralityTable::CBin *)
Definition: CentralityTableProducer.cc:153
CentralityTable::CBin::n_coll
BinValues n_coll
Definition: CentralityTable.h:19
CentralityTable::CBin::n_part
BinValues n_part
Definition: CentralityTable.h:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CentralityTable::CBin::bin_edge
float bin_edge
Definition: CentralityTable.h:17
CentralityTableProducer::debug_
bool debug_
Definition: CentralityTableProducer.cc:53
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
TFileDirectory
Definition: TFileDirectory.h:24
CentralityBins::NcollSigmaOfBin
float NcollSigmaOfBin(int bin) const
Definition: CentralityBins.h:61
CentralityTableProducer::rootTag_
string rootTag_
Definition: CentralityTableProducer.cc:59
CentralityTableProducer::inputTFileName_
string inputTFileName_
Definition: CentralityTableProducer.cc:56
PostProcessorHcalIsoTrack_cfi.subDir
subDir
Definition: PostProcessorHcalIsoTrack_cfi.py:5
CentralityTableProducer::text_
ofstream text_
Definition: CentralityTableProducer.cc:60
CentralityBins
Definition: CentralityBins.h:37
CentralityTable::m_table
std::vector< CBin > m_table
Definition: CentralityTable.h:39
CentralityTableProducer::inputTFile_
TFile * inputTFile_
Definition: CentralityTableProducer.cc:55
CentralityBins::bMeanOfBin
float bMeanOfBin(int bin) const
Definition: CentralityBins.h:67
CentralityTable::BinValues::var
float var
Definition: CentralityTable.h:11
CentralityBins::NhardMeanOfBin
float NhardMeanOfBin(int bin) const
Definition: CentralityBins.h:63
CentralityTableProducer::firstRunOnly_
bool firstRunOnly_
Definition: CentralityTableProducer.cc:52
CentralityBins::NhardSigmaOfBin
float NhardSigmaOfBin(int bin) const
Definition: CentralityBins.h:65
CentralityBins::lowEdgeOfBin
float lowEdgeOfBin(int bin) const
Definition: CentralityBins.h:53
TFileService::mkdir
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
CentralityBins::NcollMeanOfBin
float NcollMeanOfBin(int bin) const
Definition: CentralityBins.h:59
edm::Service< cond::service::PoolDBOutputService >
iEvent
int iEvent
Definition: GenABIO.cc:224
CentralityTableProducer::makeDBFromTFile_
bool makeDBFromTFile_
Definition: CentralityTableProducer.cc:50
CentralityTable::BinValues::mean
float mean
Definition: CentralityTable.h:10
CentralityTableProducer::fs
edm::Service< TFileService > fs
Definition: CentralityTableProducer.cc:57
CentralityTableProducer::CT
CentralityTable * CT
Definition: CentralityTableProducer.cc:62
CentralityBins::bSigmaOfBin
float bSigmaOfBin(int bin) const
Definition: CentralityBins.h:69
CentralityTableProducer::runnum_
unsigned int runnum_
Definition: CentralityTableProducer.cc:65
CentralityTable::CBin::b
BinValues b
Definition: CentralityTable.h:21
CentralityTable::CBin::n_hard
BinValues n_hard
Definition: CentralityTable.h:20
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CentralityTableProducer::makeTFileFromDB_
bool makeTFileFromDB_
Definition: CentralityTableProducer.cc:51
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CentralityBins::getNbins
int getNbins() const
Definition: CentralityBins.h:51
CentralityBins::NpartMeanOfBin
float NpartMeanOfBin(int bin) const
Definition: CentralityBins.h:55
CentralityBins::NpartSigmaOfBin
float NpartSigmaOfBin(int bin) const
Definition: CentralityBins.h:57
submitPVResolutionJobs.pool
pool
Definition: submitPVResolutionJobs.py:351