CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 39 of file CentralityTableProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 78 of file CentralityTableProducer.cc.

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

78  : text_("bins.txt"), runnum_(0) {
79  //now do what ever initialization is needed
80  makeDBFromTFile_ = iConfig.getUntrackedParameter<bool>("makeDBFromTFile", true);
81  makeTFileFromDB_ = iConfig.getUntrackedParameter<bool>("makeTFileFromDB", false);
82  firstRunOnly_ = iConfig.getUntrackedParameter<bool>("isMC", false);
83  debug_ = iConfig.getUntrackedParameter<bool>("debug", false);
84  if (makeDBFromTFile_) {
85  inputTFileName_ = iConfig.getParameter<string>("inputTFile");
86  rootTag_ = iConfig.getParameter<string>("rootTag");
87  inputTFile_ = new TFile(inputTFileName_.data(), "read");
88  cout << inputTFileName_.data() << endl;
89  }
90 }
T getUntrackedParameter(std::string const &, T const &) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple cout
Definition: gather_cfg.py:144
CentralityTableProducer::~CentralityTableProducer ( )
override

Definition at line 92 of file CentralityTableProducer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 102 of file CentralityTableProducer.cc.

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

102  {
103  if (!makeTFileFromDB_)
104  return;
105  if ((!firstRunOnly_ && runnum_ != iEvent.id().run()) || (firstRunOnly_ && runnum_ == 0)) {
106  runnum_ = iEvent.id().run();
107  cout << "Adding table for run : " << runnum_ << endl;
108  TFileDirectory subDir = fs->mkdir(Form("run%d", runnum_));
109  CB = subDir.make<CentralityBins>();
110  }
111 }
RunNumber_t run() const
Definition: EventID.h:38
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:59
tuple cout
Definition: gather_cfg.py:144
void CentralityTableProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 114 of file CentralityTableProducer.cc.

References CentralityTable::CBin::b, CentralityTable::CBin::bin_edge, CentralityBins::bMeanOfBin(), CentralityBins::bSigmaOfBin(), CB, gather_cfg::cout, cond::service::PoolDBOutputService::currentTime(), CentralityBins::getNbins(), inputTFile_, edm::Service< T >::isAvailable(), 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_, CentralityTable::BinValues::var, and cond::service::PoolDBOutputService::writeOneIOV().

114  {
115  if (makeDBFromTFile_) {
116  runnum_ = 1;
117  // Get values from root file
118  CB = (CentralityBins*)inputTFile_->Get(Form("%s/run%d", rootTag_.data(), runnum_));
119  cout << rootTag_.data() << endl;
120  CentralityTable CT;
121  CT.m_table.reserve(CB->getNbins());
122 
123  text_ << "# BinEdge NpartMean NpartVar NcollMean NcollVar NhardMean NhardVar bMean bVar" << endl;
124  for (int j = 0; j < CB->getNbins(); j++) {
126  thisBin->bin_edge = CB->lowEdgeOfBin(j);
127  thisBin->n_part.mean = CB->NpartMeanOfBin(j);
128  thisBin->n_part.var = CB->NpartSigmaOfBin(j);
129  thisBin->n_coll.mean = CB->NcollMeanOfBin(j);
130  thisBin->n_coll.var = CB->NcollSigmaOfBin(j);
131  thisBin->n_hard.mean = CB->NhardMeanOfBin(j);
132  thisBin->n_hard.var = CB->NhardSigmaOfBin(j);
133  thisBin->b.mean = CB->bMeanOfBin(j);
134  thisBin->b.var = CB->bSigmaOfBin(j);
135  printBin(thisBin);
136  CT.m_table.push_back(*thisBin);
137  if (thisBin)
138  delete thisBin;
139  }
140 
142  if (pool.isAvailable()) {
143  pool->writeOneIOV(CT, pool->currentTime(), "HeavyIonRcd");
144  }
145  }
146 }
void printBin(const CentralityTable::CBin *)
std::vector< CBin > m_table
float NpartSigmaOfBin(int bin) const
float lowEdgeOfBin(int bin) const
float NcollMeanOfBin(int bin) const
bool isAvailable() const
Definition: Service.h:40
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
float bSigmaOfBin(int bin) const
float NhardMeanOfBin(int bin) const
float NpartMeanOfBin(int bin) const
int getNbins() const
float bMeanOfBin(int bin) const
tuple cout
Definition: gather_cfg.py:144
float NhardSigmaOfBin(int bin) const
float NcollSigmaOfBin(int bin) const
void CentralityTableProducer::printBin ( const CentralityTable::CBin thisBin)
private

Definition at line 148 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().

148  {
149  cout << "HF Cut = " << thisBin->bin_edge << endl;
150  cout << "Npart = " << thisBin->n_part.mean << endl;
151  cout << "sigma = " << thisBin->n_part.var << endl;
152  cout << "Ncoll = " << thisBin->n_coll.mean << endl;
153  cout << "sigma = " << thisBin->n_coll.var << endl;
154  cout << "B = " << thisBin->b.mean << endl;
155  cout << "sigma = " << thisBin->b.var << endl;
156  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",
157  (Float_t)thisBin->bin_edge,
158  (Float_t)thisBin->n_part.mean,
159  (Float_t)thisBin->n_part.var,
160  (Float_t)thisBin->n_coll.mean,
161  (Float_t)thisBin->n_coll.var,
162  (Float_t)thisBin->n_hard.mean,
163  (Float_t)thisBin->n_hard.var,
164  (Float_t)thisBin->b.mean,
165  (Float_t)thisBin->b.var)
166  << endl;
167  cout << "__________________________________________________" << endl;
168 }
tuple cout
Definition: gather_cfg.py:144

Member Data Documentation

const CentralityBins* CentralityTableProducer::CB
private

Definition at line 62 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

bool CentralityTableProducer::debug_
private

Definition at line 53 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

bool CentralityTableProducer::firstRunOnly_
private

Definition at line 52 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

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

Definition at line 57 of file CentralityTableProducer.cc.

Referenced by analyze().

TFile* CentralityTableProducer::inputTFile_
private

Definition at line 55 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

string CentralityTableProducer::inputTFileName_
private

Definition at line 56 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer().

bool CentralityTableProducer::makeDBFromTFile_
private

Definition at line 50 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

bool CentralityTableProducer::makeTFileFromDB_
private

Definition at line 51 of file CentralityTableProducer.cc.

Referenced by analyze(), and CentralityTableProducer().

string CentralityTableProducer::rootTag_
private

Definition at line 59 of file CentralityTableProducer.cc.

Referenced by CentralityTableProducer(), and endJob().

unsigned int CentralityTableProducer::runnum_
private

Definition at line 64 of file CentralityTableProducer.cc.

Referenced by analyze(), and endJob().

ofstream CentralityTableProducer::text_
private

Definition at line 60 of file CentralityTableProducer.cc.

Referenced by endJob(), and printBin().