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

Public Member Functions

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

Private Member Functions

virtual void analyze (edm::Event const &e, edm::EventSetup const &c)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &c)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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(), and showTrgInfo_.

62  :log_( new edm::LogInfo("LumiReport")),currentlumi_(0){
63  showTrgInfo_=pset.getUntrackedParameter<bool>("showTriggerInfo",false);
64 }
unsigned int currentlumi_
tuple pset
Definition: CrabTask.py:85
edm::LogInfo * log_
LumiCalculator::~LumiCalculator ( )
virtual

Definition at line 68 of file LumiCalculator.cc.

References log_.

68  {
69  delete log_; log_=0;
70 }
edm::LogInfo * log_

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 74 of file LumiCalculator.cc.

74  {
75 
76 }
void LumiCalculator::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 80 of file LumiCalculator.cc.

80  {
81 
82 }
void LumiCalculator::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file LumiCalculator.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 352 of file LumiCalculator.cc.

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

Integrated Luminosity per Lumi Section instantaneousLumi*93.244(sec)

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

Reimplemented from edm::EDAnalyzer.

Definition at line 202 of file LumiCalculator.cc.

References trackerHits::c, l1PerBitInfo::count, currentlumi_, MyPerLumiInfo::deadcount, edm::LuminosityBlock::getByLabel(), hltmap_, i, edm::LuminosityBlockBase::id(), MyPerLumiInfo::intglumi, prof2calltree::l, l1map_, MyPerLumiInfo::livefraction, log_, MyPerLumiInfo::lsnum, edm::LuminosityBlockID::luminosityBlock(), runregparse::lumiSummary, n, perrunlumiinfo_, l1PerBitInfo::prescale, LumiSummary::L1::prescale, LumiSummary::L1::ratecount, showTrgInfo_, matplotRender::t, and trgpathMmap_.

203  {
207  //std::cout<<"I'm in lumi block "<<lumiBlock.id()<<std::endl;
208 
210  lumiBlock.getByLabel("lumiProducer", lumiSummary);
211 
213  l.lsnum=lumiBlock.id().luminosityBlock();
214 
215  //
216  //collect lumi.
217  //
218  l.deadcount=lumiSummary->deadcount();
219  l.intglumi=lumiSummary->avgInsDelLumi()*93.244;
220  l.livefraction=lumiSummary->liveFrac();
221 
222  *log_<<"====== Lumi Section "<<lumiBlock.id().luminosityBlock()<<" ======\n";
223  *log_<<"\t Luminosity "<<l.intglumi<<"\n";
224  *log_<<"\t Dead count "<<l.deadcount<<"\n";
225  *log_<<"\t Deadtime corrected Luminosity "<<l.intglumi*l.livefraction<<"\n";
226 
227  //
228  //print correlated hlt-l1 info, only if you ask
229  //
230  if(showTrgInfo_){
231  std::map<std::string,hltPerPathInfo>::iterator hltit;
232  std::map<std::string,hltPerPathInfo>::iterator hltitBeg=hltmap_.begin();
233  std::map<std::string,hltPerPathInfo>::iterator hltitEnd=hltmap_.end();
234 
235  typedef std::pair< std::multimap<std::string,std::string>::iterator,std::multimap<std::string,std::string>::iterator > TRGMAPIT;
236  unsigned int c=0;
237  for(hltit=hltitBeg;hltit!=hltitEnd;++hltit){
238  std::string hltname=hltit->first;
239  *log_<<c<<" HLT path "<<hltname<<" , prescale : "<<hltit->second.prescale<<" , in : "<<hltit->second.inputcount<<" , out : "<<hltit->second.outputcount<<"\n";
240  TRGMAPIT ppp;
241  ppp=trgpathMmap_.equal_range(hltname);
242  if(ppp.first==ppp.second){
243  *log_<<" no L1\n";
244  }
245  for(std::multimap<std::string,std::string>::iterator mit=ppp.first; mit!=ppp.second; ++mit){
246  std::string l1name=mit->second;
247  *log_<<" L1 name : "<<l1name;
248  LumiSummary::L1 l1result=lumiSummary->l1info(l1name);
249  *log_<<" , count : "<<l1result.ratecount<<" , prescale : "<<l1result.prescale<<"\n";
250  *log_<<"\n";
251  }
252  ++c;
253  }
254  }
255  //
256  //accumulate hlt counts. Absent for now
257  //
263  //
264  //accumulate l1 counts
265  //
266  size_t n=lumiSummary->nTriggerLine();
267  for(size_t i=0;i<n;++i){
268  std::string l1bitname=lumiSummary->l1info(i).triggername;
269  l1PerBitInfo t;
270  if(currentlumi_==0){
271  t.count=lumiSummary->l1info(i).ratecount;
272  t.prescale=lumiSummary->l1info(i).prescale;
273  l1map_.insert(std::make_pair(l1bitname,t));
274  }else{
275  std::map<std::string,l1PerBitInfo>::iterator it=l1map_.find(l1bitname);
276  if(it!=l1map_.end()){
277  it->second.count += lumiSummary->l1info(i).ratecount;
278  }
279  }
280  }
281 
282  perrunlumiinfo_.push_back(l);
283 
284  ++currentlumi_;
285 }
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:28
unsigned int prescale
unsigned long long deadcount
unsigned int ratecount
Definition: LumiSummary.h:27
edm::LogInfo * log_
std::map< std::string, hltPerPathInfo > hltmap_
unsigned int count
std::multimap< std::string, std::string > trgpathMmap_
void LumiCalculator::endRun ( edm::Run const &  run,
edm::EventSetup const &  c 
)
privatevirtual

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 288 of file LumiCalculator.cc.

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

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

References end, and L1TEmulatorMonitor_cff::p.

Referenced by beginRun().

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

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