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
LumiCalculator Class Reference
Inheritance diagram for LumiCalculator:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 LumiCalculator (edm::ParameterSet const &pset)
 
virtual ~LumiCalculator ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 (edm::Event const &e, edm::EventSetup const &c) override
 
virtual void beginJob () override
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &c) override
 
virtual void endJob () override
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) override
 
std::vector< std::string > splitpathstr (const std::string &strValue, const std::string separator)
 

Private Attributes

unsigned int currentlumi_
 
HLTConfigProvider hltConfig_
 
std::map< std::string,
hltPerPathInfo
hltmap_
 
std::map< std::string,
l1PerBitInfo
l1map_
 
edm::LogInfolog_
 
std::vector< MyPerLumiInfoperrunlumiinfo_
 
bool showTrgInfo_
 
std::multimap< std::string,
std::string > 
trgpathMmap_
 

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 &)
 
- 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

Definition at line 34 of file LumiCalculator.cc.

Constructor & Destructor Documentation

LumiCalculator::LumiCalculator ( edm::ParameterSet const &  pset)
explicit

Definition at line 62 of file LumiCalculator.cc.

References edm::ParameterSet::getUntrackedParameter(), HLT_25ns14e33_v1_cff::InputTag, and showTrgInfo_.

62  :log_( new edm::LogInfo("LumiReport")),currentlumi_(0){
63  showTrgInfo_=pset.getUntrackedParameter<bool>("showTriggerInfo",false);
64  consumes<LumiSummary,edm::InLumi>(edm::InputTag("lumiProducer",""));
65  consumes<LumiSummaryRunHeader,edm::InRun>(edm::InputTag("lumiProducer",""));
66 }
unsigned int currentlumi_
edm::LogInfo * log_
LumiCalculator::~LumiCalculator ( )
virtual

Definition at line 70 of file LumiCalculator.cc.

References log_.

70  {
71  delete log_; log_=0;
72 }
edm::LogInfo * log_

Member Function Documentation

void LumiCalculator::analyze ( edm::Event const &  e,
edm::EventSetup const &  c 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 76 of file LumiCalculator.cc.

76  {
77 
78 }
void LumiCalculator::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 82 of file LumiCalculator.cc.

82  {
83 
84 }
void LumiCalculator::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file LumiCalculator.cc.

References Exception, edm::ParameterSet::getParameter(), runregparse::hlt, hltConfig_, hltmap_, lumiCalc2::hltname, i, HLTConfigProvider::init(), l1map_, log_, HLTConfigProvider::moduleLabels(), HLTConfigProvider::modulePSet(), HLTConfigProvider::moduleType(), perrunlumiinfo_, hltPerPathInfo::prescale, edm::RunBase::run(), showTrgInfo_, HLTConfigProvider::size(), findQualityFiles::size, splitpathstr(), AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, HLTConfigProvider::tableName(), trgpathMmap_, and HLTConfigProvider::triggerName().

88  {
89  //std::cout<<"I'm in run number "<<run.run()<<std::endl;
90  //if(!hltConfig_.init("HLT")){
91  // throw cms::Exception("HLT process cannot be initialized");
92  //}
93  bool changed(true);
94  const std::string processname("HLT");
95  if(!hltConfig_.init(run,c,processname,changed)){
96  throw cms::Exception("HLT process cannot be initialized");
97  }
98  perrunlumiinfo_.clear();
99  trgpathMmap_.clear();
100  hltmap_.clear();
101  l1map_.clear();
102  //hltConfig_.dump("processName");
103  //hltConfig_.dump("TableName");
104  //hltConfig_.dump("Triggers");
105  //hltConfig_.dump("Modules");
106  if(showTrgInfo_){
107  *log_<<"======Trigger Configuration Overview======\n";
108  *log_<<"Run "<<run.run()<<" Trigger Table : "<<hltConfig_.tableName()<<"\n";
109  }
110  unsigned int totaltrg=hltConfig_.size();
111  for (unsigned int t=0;t<totaltrg;++t){
113  std::vector<std::string> numpathmodules=hltConfig_.moduleLabels(hltname);
114  if(showTrgInfo_){
115  *log_<<t<<" HLT path\t"<<hltname<<"\n";
116  }
118  hlt.prescale=1;
119  hltmap_.insert(std::make_pair(hltname,hlt));
120  std::vector<std::string>::iterator hltpathBeg=numpathmodules.begin();
121  std::vector<std::string>::iterator hltpathEnd=numpathmodules.end();
122  unsigned int mycounter=0;
123  for(std::vector<std::string>::iterator numpathmodule = hltpathBeg;
124  numpathmodule!=hltpathEnd; ++numpathmodule ) {
125  if (hltConfig_.moduleType(*numpathmodule) != "HLTLevel1GTSeed"){
126  continue;
127  }
128  ++mycounter;
129 
130  edm::ParameterSet l1GTPSet=hltConfig_.modulePSet(*numpathmodule);
131  std::string l1pathname=l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression");
132  //*log_<<"numpathmodule "<< *numpathmodule <<" : l1pathname "<<l1pathname<<"\n";
133  if(mycounter>1){
134  if(showTrgInfo_){
135  *log_<<"\tskip and erase previous seeds : multiple L1SeedsLogicalExpressions per hlt path\n";
136  }
137  //erase all previously calculated seeds for this path
138  trgpathMmap_.erase(hltname);
139  continue;
140  }
141  if(l1pathname.find("(")!=std::string::npos){
142  if(showTrgInfo_){
143  *log_<<" L1SeedsLogicalExpression(Complex)\t"<<l1pathname<<"\n";
144  *log_<<"\tskip:contain complex logic\n";
145  }
146  continue;
147  }else if(l1pathname.find("OR")!=std::string::npos){
148  if(showTrgInfo_){
149  *log_<<" L1SeedsLogicalExpression(ORed)\t"<<l1pathname<<"\n";
150  }
151  std::vector<std::string> seeds=splitpathstr(l1pathname," OR ");
152  if(seeds.size()>2){
153  if(showTrgInfo_){
154  *log_<<"\tskip:contain >1 OR\n";
155  }
156  continue;
157  }else{
158  for(std::vector<std::string>::iterator i=seeds.begin();i!=seeds.end();++i){
159  if(i->size()!=0 && showTrgInfo_) *log_<<"\t\tseed: "<<*i<<"\n";
160  if(i==seeds.begin()){//for now we take the first one from OR
161  trgpathMmap_.insert(std::make_pair(hltname,*i));
162  }
163  }
164  }
165  }else if (l1pathname.find("AND")!=std::string::npos){
166  if(showTrgInfo_){
167  *log_<<" L1SeedsLogicalExpression(ANDed)\t"<< l1pathname<< "\n";
168  }
169  std::vector<std::string> seeds=splitpathstr(l1pathname," AND ");
170  if(seeds.size()>2){
171  if(showTrgInfo_){
172  *log_<<"\tskip:contain >1 AND\n";
173  }
174  continue;
175  }else{
176  for(std::vector<std::string>::iterator i=seeds.begin();
177  i!=seeds.end();++i){
178  if(i->size()!=0 && showTrgInfo_) *log_<<"\t\tseed: "<<*i<<"\n";
179  if(i==seeds.begin()){//for now we take the first one
180  trgpathMmap_.insert(std::make_pair(hltname,*i));
181  }
182  }
183  }
184  }else{
185  if(showTrgInfo_){
186  *log_<<" L1SeedsLogicalExpression(ONE)\t"<< l1pathname<<"\n";
187  }
188  if(splitpathstr(l1pathname," NOT ").size()>1){
189  if(showTrgInfo_){
190  *log_<<"\tskip:contain NOT\n";
191  }
192  continue;
193  }
194  trgpathMmap_.insert(std::make_pair(hltname,l1pathname));
195  }
196  }
197  }
198  if(showTrgInfo_){
199  *log_<<"================\n";
200  }
201 }
std::map< std::string, l1PerBitInfo > l1map_
unsigned int size() const
number of trigger paths in trigger table
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
unsigned int prescale
const std::string moduleType(const std::string &module) const
C++ class name of module.
RunNumber_t run() const
Definition: RunBase.h:42
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< std::string > splitpathstr(const std::string &strValue, const std::string separator)
const std::string & tableName() const
HLT ConfDB table name.
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
std::vector< MyPerLumiInfo > perrunlumiinfo_
HLTConfigProvider hltConfig_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
edm::LogInfo * log_
std::map< std::string, hltPerPathInfo > hltmap_
tuple size
Write out results.
std::multimap< std::string, std::string > trgpathMmap_
void LumiCalculator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 351 of file LumiCalculator.cc.

351  {
352 }
void LumiCalculator::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
overrideprivatevirtual

Integrated Luminosity per Lumi Section instantaneousLumi*93.244(sec)

for(hltit=hltitBeg;hltit!=hltitEnd;++hltit){ }

Reimplemented from edm::EDAnalyzer.

Definition at line 204 of file LumiCalculator.cc.

References EnergyCorrector::c, currentlumi_, MyPerLumiInfo::deadcount, edm::LuminosityBlock::getByLabel(), edm::Run::getByLabel(), edm::LuminosityBlock::getRun(), hltmap_, lumiCalc2::hltname, i, edm::LuminosityBlockBase::id(), MyPerLumiInfo::intglumi, prof2calltree::l, l1map_, MyPerLumiInfo::livefraction, log_, MyPerLumiInfo::lsnum, edm::LuminosityBlockID::luminosityBlock(), runregparse::lumiSummary, gen::n, perrunlumiinfo_, l1PerBitInfo::prescale, LumiSummary::L1::prescale, showTrgInfo_, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, and trgpathMmap_.

205  {
209  //std::cout<<"I'm in lumi block "<<lumiBlock.id()<<std::endl;
210 
212  lumiBlock.getByLabel("lumiProducer", lumiSummary);
213 
214  edm::Handle<LumiSummaryRunHeader> lumiSummaryRH;
215  lumiBlock.getRun().getByLabel("lumiProducer", lumiSummaryRH);
216 
218  l.lsnum=lumiBlock.id().luminosityBlock();
219 
220  //
221  //collect lumi.
222  //
223  l.deadcount=lumiSummary->deadcount();
224  l.intglumi=lumiSummary->avgInsDelLumi()*93.244;
225  l.livefraction=lumiSummary->liveFrac();
226 
227  *log_<<"====== Lumi Section "<<lumiBlock.id().luminosityBlock()<<" ======\n";
228  *log_<<"\t Luminosity "<<l.intglumi<<"\n";
229  *log_<<"\t Dead count "<<l.deadcount<<"\n";
230  *log_<<"\t Deadtime corrected Luminosity "<<l.intglumi*l.livefraction<<"\n";
231 
232  //
233  //print correlated hlt-l1 info, only if you ask
234  //
235  if(showTrgInfo_){
236  std::map<std::string,hltPerPathInfo>::iterator hltit;
237  std::map<std::string,hltPerPathInfo>::iterator hltitBeg=hltmap_.begin();
238  std::map<std::string,hltPerPathInfo>::iterator hltitEnd=hltmap_.end();
239 
240  typedef std::pair< std::multimap<std::string,std::string>::iterator,std::multimap<std::string,std::string>::iterator > TRGMAPIT;
241  unsigned int c=0;
242  for(hltit=hltitBeg;hltit!=hltitEnd;++hltit){
243  std::string hltname=hltit->first;
244  *log_<<c<<" HLT path "<<hltname<<" , prescale : "<<hltit->second.prescale<<"\n";
245  TRGMAPIT ppp;
246  ppp=trgpathMmap_.equal_range(hltname);
247  if(ppp.first==ppp.second){
248  *log_<<" no L1\n";
249  }
250  for(std::multimap<std::string,std::string>::iterator mit=ppp.first; mit!=ppp.second; ++mit){
251  std::string l1name=mit->second;
252  *log_<<" L1 name : "<<l1name;
253  LumiSummary::L1 l1result = lumiSummary->l1info(lumiSummaryRH->getL1Index(l1name));
254  *log_<<" prescale : "<<l1result.prescale<<"\n";
255  *log_<<"\n";
256  }
257  ++c;
258  }
259  }
260  //
261  //accumulate hlt counts. Absent for now
262  //
268  //
269  //accumulate l1 counts
270  //
271  size_t n=lumiSummary->nTriggerLine();
272  for(size_t i=0;i<n;++i){
273  std::string l1bitname = lumiSummaryRH->getL1Name(lumiSummary->l1info(i).triggernameidx);
274  l1PerBitInfo t;
275  if(currentlumi_==0){
276  t.prescale=lumiSummary->l1info(i).prescale;
277  l1map_.insert(std::make_pair(l1bitname,t));
278  }
279  }
280 
281  perrunlumiinfo_.push_back(l);
282 
283  ++currentlumi_;
284 }
std::map< std::string, l1PerBitInfo > l1map_
int i
Definition: DBlmapReader.cc:9
unsigned int currentlumi_
tuple lumiSummary
Definition: runregparse.py:290
std::vector< MyPerLumiInfo > perrunlumiinfo_
unsigned int lsnum
unsigned int prescale
Definition: LumiSummary.h:26
unsigned int prescale
unsigned long long deadcount
edm::LogInfo * log_
std::map< std::string, hltPerPathInfo > hltmap_
std::multimap< std::string, std::string > trgpathMmap_
void LumiCalculator::endRun ( edm::Run const &  run,
edm::EventSetup const &  c 
)
overrideprivatevirtual

Notes on calculation:

  1. CMS recorded Luminosity per run : sum over HLX&&HF certified LS lumiSummary->avgInsDelLumi()*93.244*livefraction()

    1. Effective Luminosity per run per trigger line: For the moment, we take only the first L1 seed in case of 'OR' or 'AND' relationship between HLT and L1 seeds

    avgInsDelLumi()*93.244*livefraction()/(HLTprescale*L1prescale) for now HLTprescale=1

    1. LHC delivered: there is no point in calculating delivered when data do not contain all LS

Reimplemented from edm::EDAnalyzer.

Definition at line 287 of file LumiCalculator.cc.

References gather_cfg::cout, hltmap_, l1map_, log_, perrunlumiinfo_, edm::RunBase::run(), and trgpathMmap_.

287  {
304  //std::cout<<"valid trigger lines "<<trgpathMmap_.size()<<std::endl;
305  //std::cout<<"total lumi lines "<<perrunlumiinfo_.size()<<std::endl;
306  std::vector<MyPerLumiInfo>::const_iterator lumiIt;
307  std::vector<MyPerLumiInfo>::const_iterator lumiItBeg=perrunlumiinfo_.begin();
308  std::vector<MyPerLumiInfo>::const_iterator lumiItEnd=perrunlumiinfo_.end();
309  float recorded=0.0;
310 
311  *log_<<"================ Run Summary "<<run.run()<<"================\n";
312  for(lumiIt=lumiItBeg;lumiIt!=lumiItEnd;++lumiIt){//loop over LS
313  recorded += lumiIt->intglumi*lumiIt->livefraction;
314  }
315  *log_<<" CMS Recorded Lumi (e+27cm^-2) : "<<recorded<<"\n";
316  *log_<<" Effective Lumi (e+27cm^-2) per trigger path: "<<"\n\n";
317  std::multimap<std::string,std::string>::iterator it;
318  std::multimap<std::string,std::string>::iterator itBeg=trgpathMmap_.begin();
319  std::multimap<std::string,std::string>::iterator itEnd=trgpathMmap_.end();
320  unsigned int cc=0;
321  for(it=itBeg;it!=itEnd;++it){
322  *log_<<" "<<cc<<" "<<it->first<<" - "<<it->second<<" : ";
323  ++cc;
324  std::map<std::string,hltPerPathInfo>::const_iterator hltIt=hltmap_.find(it->first);
325  if( hltIt==hltmap_.end() ){
326  std::cout<<"HLT path "<<it->first<<" not found"<<std::endl;
327  *log_<<"\n";
328  continue;
329  }
330  std::map<std::string,l1PerBitInfo>::const_iterator l1It=l1map_.find(it->second);
331  if( l1It==l1map_.end() ){
332  std::cout<<"L1 bit "<<it->second<<" not found"<<std::endl;
333  *log_<<"\n";
334  continue;
335  }
336  unsigned int hltprescale=hltIt->second.prescale;
337  unsigned int l1prescale=l1It->second.prescale;
338  if( hltprescale!=0 && l1prescale!=0 ){
339  float effectiveLumi=recorded/(hltprescale*l1prescale);
340  *log_<<effectiveLumi<<"\n";
341  }else{
342  *log_<<"0 prescale exception\n";
343  continue;
344  }
345  *log_<<"\n";
346  }
347 }
std::map< std::string, l1PerBitInfo > l1map_
std::vector< MyPerLumiInfo > perrunlumiinfo_
edm::LogInfo * log_
std::map< std::string, hltPerPathInfo > hltmap_
tuple cout
Definition: gather_cfg.py:121
std::multimap< std::string, std::string > trgpathMmap_
std::vector< std::string > LumiCalculator::splitpathstr ( const std::string &  strValue,
const std::string  separator 
)
private

Definition at line 355 of file LumiCalculator.cc.

References end, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by beginRun().

355  {
356  std::vector<std::string> vecstrResult;
357  boost::regex re(separator);
358  boost::sregex_token_iterator p(strValue.begin(),strValue.end(),re,-1);
359  boost::sregex_token_iterator end;
360  while(p!=end){
361  vecstrResult.push_back(*p++);
362  }
363  return vecstrResult;
364 }
#define end
Definition: vmac.h:37

Member Data Documentation

unsigned int LumiCalculator::currentlumi_
private

Definition at line 57 of file LumiCalculator.cc.

Referenced by endLuminosityBlock().

HLTConfigProvider LumiCalculator::hltConfig_
private

Definition at line 49 of file LumiCalculator.cc.

Referenced by beginRun().

std::map<std::string,hltPerPathInfo> LumiCalculator::hltmap_
private

Definition at line 51 of file LumiCalculator.cc.

Referenced by beginRun(), endLuminosityBlock(), and endRun().

std::map<std::string,l1PerBitInfo> LumiCalculator::l1map_
private

Definition at line 52 of file LumiCalculator.cc.

Referenced by beginRun(), endLuminosityBlock(), and endRun().

edm::LogInfo* LumiCalculator::log_
private

Definition at line 55 of file LumiCalculator.cc.

Referenced by beginRun(), endLuminosityBlock(), endRun(), and ~LumiCalculator().

std::vector<MyPerLumiInfo> LumiCalculator::perrunlumiinfo_
private

Definition at line 53 of file LumiCalculator.cc.

Referenced by beginRun(), endLuminosityBlock(), and endRun().

bool LumiCalculator::showTrgInfo_
private

Definition at line 56 of file LumiCalculator.cc.

Referenced by beginRun(), endLuminosityBlock(), and LumiCalculator().

std::multimap<std::string,std::string> LumiCalculator::trgpathMmap_
private

Definition at line 50 of file LumiCalculator.cc.

Referenced by beginRun(), endLuminosityBlock(), and endRun().