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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 32 of file LumiCalculator.cc.

Constructor & Destructor Documentation

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

Definition at line 60 of file LumiCalculator.cc.

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

60  :log_( new edm::LogInfo("LumiReport")),currentlumi_(0){
61  showTrgInfo_=pset.getUntrackedParameter<bool>("showTriggerInfo",false);
62 }
unsigned int currentlumi_
edm::LogInfo * log_
LumiCalculator::~LumiCalculator ( )
virtual

Definition at line 66 of file LumiCalculator.cc.

References log_.

66  {
67  delete log_; log_=0;
68 }
edm::LogInfo * log_

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 72 of file LumiCalculator.cc.

72  {
73 
74 }
void LumiCalculator::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 78 of file LumiCalculator.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 84 of file LumiCalculator.cc.

References edm::hlt::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(), lumiQTWidget::t, HLTConfigProvider::tableName(), trgpathMmap_, and HLTConfigProvider::triggerName().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 347 of file LumiCalculator.cc.

347  {
348 }
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 200 of file LumiCalculator.cc.

References trackerHits::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, n, perrunlumiinfo_, l1PerBitInfo::prescale, LumiSummary::L1::prescale, showTrgInfo_, lumiQTWidget::t, and trgpathMmap_.

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

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

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

References end, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by beginRun().

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

Member Data Documentation

unsigned int LumiCalculator::currentlumi_
private

Definition at line 55 of file LumiCalculator.cc.

Referenced by endLuminosityBlock().

HLTConfigProvider LumiCalculator::hltConfig_
private

Definition at line 47 of file LumiCalculator.cc.

Referenced by beginRun().

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

Definition at line 49 of file LumiCalculator.cc.

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

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

Definition at line 50 of file LumiCalculator.cc.

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

edm::LogInfo* LumiCalculator::log_
private

Definition at line 53 of file LumiCalculator.cc.

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

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

Definition at line 51 of file LumiCalculator.cc.

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

bool LumiCalculator::showTrgInfo_
private

Definition at line 54 of file LumiCalculator.cc.

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

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

Definition at line 48 of file LumiCalculator.cc.

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