ATLAS Offline Software
getLumi.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 
15 
16 #include <iostream>
17 
18 #ifndef XAOD_ANALYSIS
19 //int main(int argc, char* argv[]) {
20 int main( int, char** ) {
21  std::cout << " This application is currently only available in the analysis releases \n \
22  Please setup an AthAnalysisBase release to use this application." << std::endl;
23  return 0;
24 }
25 
26 #else
27 
28 
29 #include "TROOT.h"
30 #include "TFile.h"
31 #include "TTree.h"
32 #include "TBranch.h"
33 #include "TApplication.h"
34 #include "TKey.h"
35 #include "TDirectory.h"
36 #include "TSystem.h"
37 #include "TObjString.h"
38 
39 #include <getopt.h>
40 #include <cstdlib>
41 #include <vector>
42 
44 
45 #include "xAODRootAccess/Init.h"
46 #include "xAODRootAccess/TEvent.h"
49 
50 struct lbx {
51  lbx() : nExpected(0),nSeen(0) {}
52  long nExpected;
53  long nSeen;
54  bool fromSuspect = false;
55 };
56 
57 int main(int argc, char* argv[]) {
58  const char* optstring = "m";
59  bool showMissing = false;
60 static struct option long_options[] =
61  {
62  /* name has_arg flag val */
63  {"showMissing", no_argument , NULL, 'm'}
64  };
65 
66  int longindex;
67  int option;
68  //int begin = 0;
69  //int end = 999;
70  int nOptions = 0;
71  while ((option = getopt_long(argc, argv,
72  optstring, long_options, &longindex)) != -1) {
73  switch (option) {
74  case 'm' :
75  showMissing = true;nOptions++;
76  break;
77  case '?' :
78  printf("Please supply a valid option to the program. Exiting\n");
79  exit(1);
80  break;
81  }
82  }
83 
84 
85 
86  //first arg is the lumicalc file
87  if(argc<3+nOptions) {
88  std::cout << "Usage: <lumicalcfile.root> <list of xAOD or D3PD>" << std::endl;
89  std::cout << "Option: -m lists run numbers with any missing lumi" << std::endl;
90  std::cout << "" << std::endl;
91  std::cout << "Further Documentation: see https://twiki.cern.ch/twiki/bin/view/AtlasProtected/AthAnalysisBase#How_to_check_the_luminosity_cove " <<std::endl;
92  return 0;
93  }
94  gSystem->Load("libTree.so");
95 
96  bool readXML=false;
97  Root::TGoodRunsList fromXAOD;Root::TGoodRunsList fromXAODIncomplete;Root::TGoodRunsList fromXAODSuspect;Root::TGoodRunsList fromXAODPossiblySuspect;
98  std::map<uint, std::map<uint, lbx> > lbxs;
100 
101  bool hasMask(false);
102  Root::TGoodRunsListReader grlMaskReader;
103  //hunt for xml files... we will use these as 'masks' for the included lumi
104  for(int i=2+nOptions;i<argc;i++) {
105  std::string s(argv[i]);
106  if(s.find(".xml")==std::string::npos) continue;
107  grlMaskReader.AddXMLFile( s );
108  hasMask=true;
109  }
110  Root::TGoodRunsList grlMask;
111  if(hasMask) {
112  grlMaskReader.Interpret();grlMask.AddGRL(grlMaskReader.GetMergedGoodRunsList());
113  }
114 
115  std::vector<std::string> lumiFiles;
116 
117  //open all the d3pd-like files, and hunt for their lumi strings
118  for(int i=1+nOptions;i<argc;i++) {
119  //require to have ".root" in it
120  std::string s(argv[i]);
121  if(s.find(".root")==std::string::npos) continue;
122  TFile *file = TFile::Open(argv[i]);
123  if(file==0) continue;
124  std::cout << s;
125 
126  //check if this file is a LumiMetaData file ... if it is we add to the list for later
127  TTree *tmp = (TTree*)file->Get( "LumiMetaData" );
128  if(tmp) {
129  std::cout << "is lumicalc [ok]" << std::endl;
130  file->Close();
131  lumiFiles.push_back(s);
132  continue;
133  }
134 
135  //try to get lumi
136 
137  //if this is xAOD, it will have a MetaData tree ...
138  if(file->Get("MetaData")!=0) {
139  TTree* metaTree = static_cast<TTree*>(file->Get("MetaData"));
140  //use TEvent if the MetaData tree contains an EventFormat branch and only 1 entry
141  //WB : 21/11/2016 - actually just always avoid using TEvent
142  bool useTEvent(false);
143  /*if(metaTree->GetEntries()==1 && metaTree->FindBranch("EventFormat")) {
144  useTEvent = true;
145  } else {*/
146  metaTree->SetMakeClass(1);
147  //}
148  std::vector<unsigned int> startRunNumber;
149  std::vector<unsigned int> stopRunNumber;
150  std::vector<unsigned int> startLumiBlockNumber;
151  std::vector<unsigned int> stopLumiBlockNumber;
152  std::vector<unsigned int> eventsExpected;
153  std::vector<unsigned int> eventsSeen;
154 
155  //use TEvent to read the lumiblocks, if we can
156  bool ok(false);
158  const xAOD::LumiBlockRangeContainer* lbrs = 0;
159  xAOD::LumiBlockRangeAuxContainer* lbrs_aux = 0;
160  if(useTEvent && event.readFrom(file,true,"MetaData").isSuccess()) {
161  if(event.containsMeta<xAOD::LumiBlockRangeContainer>("LumiBlocks")) {
162  event.retrieveMetaInput<xAOD::LumiBlockRangeContainer>(lbrs, "LumiBlocks").isSuccess();
163  }
164  } else {
165  useTEvent=false;
166  if(metaTree->FindBranch("LumiBlocksAux.")) {
167  if(metaTree->FindBranch("LumiBlocksAux.")->GetSplitLevel()==0) {
168  std::cout << " Unable to read unsplit LumiBlocksAux" << std::endl;
169  }
170  lbrs = new xAOD::LumiBlockRangeContainer();
171  lbrs_aux = new xAOD::LumiBlockRangeAuxContainer;
172  const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->setStore( lbrs_aux );
173  metaTree->SetBranchAddress("LumiBlocksAux.startRunNumber",&startRunNumber);
174  metaTree->SetBranchAddress("LumiBlocksAux.stopRunNumber",&stopRunNumber);
175  metaTree->SetBranchAddress("LumiBlocksAux.startLumiBlockNumber",&startLumiBlockNumber);
176  metaTree->SetBranchAddress("LumiBlocksAux.stopLumiBlockNumber",&stopLumiBlockNumber);
177  metaTree->SetBranchAddress("LumiBlocksAux.eventsExpected",&eventsExpected);
178  metaTree->SetBranchAddress("LumiBlocksAux.eventsSeen",&eventsSeen);
179  }
180  }
181 
182  if(lbrs) {
183  std::cout << "...xAOD LumiBlocks";
184  for(int ii=0;ii<metaTree->GetEntries();ii++) {
185  if(!useTEvent) {
186  const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->clear();
187  metaTree->GetEntry(ii);
188  for(unsigned int j=0;j<startRunNumber.size();j++) {
189  xAOD::LumiBlockRange* r = new xAOD::LumiBlockRange; const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->push_back(r);
190  r->setStartRunNumber(startRunNumber.at(j));r->setStopRunNumber(stopRunNumber.at(j));
191  r->setStartLumiBlockNumber(startLumiBlockNumber.at(j));r->setStopLumiBlockNumber(stopLumiBlockNumber.at(j));
192  r->setEventsExpected(eventsExpected.at(j));r->setEventsSeen(eventsSeen.at(j));
193  }
194  }
195 
196  //add lb to grl
197  for(auto lbr : *lbrs) {
198  for(uint runNum = lbr->startRunNumber(); runNum <= lbr->stopRunNumber(); runNum++) {
199  if(lbr->startLumiBlockNumber()!=lbr->stopLumiBlockNumber()) {std::cout << " Unexpected behaviour. Please report! " << std::endl; exit(1);}
200  for(uint lb = lbr->startLumiBlockNumber(); lb <= lbr->stopLumiBlockNumber(); lb++) {
201  lbxs[runNum][lb].nSeen += lbr->eventsSeen();
202  if(lbxs[runNum][lb].nExpected!=0 && lbxs[runNum][lb].nExpected != lbr->eventsExpected()) {
203  std::cout << "...mismatch on expected events in [run,lb]=[" << runNum << "," << lb << "] got " << lbr->eventsExpected() << " but had " << lbxs[runNum][lb].nExpected << std::endl;
204  std::cout << "...PLEASE REPORT THIS to hn-atlas-PATHelp@cern.ch ... for now I will assume the larger number is correct" << std::endl;
205  if(lbxs[runNum][lb].nExpected < lbr->eventsExpected()) lbxs[runNum][lb].nExpected = lbr->eventsExpected();
206  }
207  else if(lbxs[runNum][lb].nExpected==0) lbxs[runNum][lb].nExpected=lbr->eventsExpected();
208  }
209  }
210  }
211  ok=true;
212  }
213  std::cout << "...ok" << std::endl;
214  if(!useTEvent) { delete lbrs; delete lbrs_aux; }
215  }
216 
217  lbrs = 0;lbrs_aux=0;
218  if(useTEvent && event.readFrom(file,true,"MetaData").isSuccess()) {
219  if(event.containsMeta<xAOD::LumiBlockRangeContainer>("IncompleteLumiBlocks")) {
220  event.retrieveMetaInput<xAOD::LumiBlockRangeContainer>(lbrs, "IncompleteLumiBlocks").isSuccess();
221  }
222  } else {
223  useTEvent=false;
224  if(metaTree->FindBranch("IncompleteLumiBlocksAux.")) {
225  if(metaTree->FindBranch("IncompleteLumiBlocksAux.")->GetSplitLevel()==0) {
226  std::cout << " Unable to read unsplit IncompleteLumiBlocksAux" << std::endl;
227  }
228  lbrs = new xAOD::LumiBlockRangeContainer();
229  lbrs_aux = new xAOD::LumiBlockRangeAuxContainer;
230  const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->setStore( lbrs_aux );
231  metaTree->ResetBranchAddresses();
232  metaTree->SetBranchAddress("IncompleteLumiBlocksAux.startRunNumber",&startRunNumber);
233  metaTree->SetBranchAddress("IncompleteLumiBlocksAux.stopRunNumber",&stopRunNumber);
234  metaTree->SetBranchAddress("IncompleteLumiBlocksAux.startLumiBlockNumber",&startLumiBlockNumber);
235  metaTree->SetBranchAddress("IncompleteLumiBlocksAux.stopLumiBlockNumber",&stopLumiBlockNumber);
236  metaTree->SetBranchAddress("IncompleteLumiBlocksAux.eventsExpected",&eventsExpected);
237  metaTree->SetBranchAddress("IncompleteLumiBlocksAux.eventsSeen",&eventsSeen);
238  }
239  }
240 
241  if(lbrs) {
242  std::cout << "...xAOD IncompleteLumiBlocks";
243  for(int ii=0;ii<metaTree->GetEntries();ii++) {
244  if(!useTEvent) {
245  const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->clear();
246  metaTree->GetEntry(ii);
247  for(unsigned int j=0;j<startRunNumber.size();j++) {
248  xAOD::LumiBlockRange* r = new xAOD::LumiBlockRange; const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->push_back(r);
249  r->setStartRunNumber(startRunNumber.at(j));r->setStopRunNumber(stopRunNumber.at(j));
250  r->setStartLumiBlockNumber(startLumiBlockNumber.at(j));r->setStopLumiBlockNumber(stopLumiBlockNumber.at(j));
251  r->setEventsExpected(eventsExpected.at(j));r->setEventsSeen(eventsSeen.at(j));
252  }
253  }
254 
255  //add lb to grl
256  for(auto lbr : *lbrs) {
257  for(uint runNum = lbr->startRunNumber(); runNum <= lbr->stopRunNumber(); runNum++) {
258  if(lbr->startLumiBlockNumber()!=lbr->stopLumiBlockNumber()) {std::cout << " Unexpected behaviour. Please report! " << std::endl; exit(1);}
259  for(uint lb = lbr->startLumiBlockNumber(); lb <= lbr->stopLumiBlockNumber(); lb++) {
260  lbxs[runNum][lb].nSeen += lbr->eventsSeen();
261  if(lbxs[runNum][lb].nExpected!=0 && lbxs[runNum][lb].nExpected != lbr->eventsExpected()) {
262  std::cout << "...mismatch on expected events in [run,lb]=[" << runNum << "," << lb << "] got " << lbr->eventsExpected() << " but had " << lbxs[runNum][lb].nExpected << std::endl;
263  std::cout << "...PLEASE REPORT THIS to hn-atlas-PATHelp@cern.ch ... for now I will assume the larger number is correct" << std::endl;
264  if(lbxs[runNum][lb].nExpected < lbr->eventsExpected()) lbxs[runNum][lb].nExpected = lbr->eventsExpected();
265  }
266  else if(lbxs[runNum][lb].nExpected==0) lbxs[runNum][lb].nExpected=lbr->eventsExpected();
267  }
268  }
269  }
270  ok=true;
271  }
272  std::cout << "...ok" << std::endl;
273  if(!useTEvent) { delete lbrs; lbrs = 0; delete lbrs_aux; lbrs_aux=0; }
274  }
275 
276 
277 
278  lbrs = 0;lbrs_aux=0;
279  if(useTEvent && event.readFrom(file,true,"MetaData").isSuccess()) {
280  if(event.containsMeta<xAOD::LumiBlockRangeContainer>("SuspectLumiBlocks")) {
281  event.retrieveMetaInput<xAOD::LumiBlockRangeContainer>(lbrs, "SuspectLumiBlocks").isSuccess();
282  }
283  } else {
284  useTEvent=false;
285  if(metaTree->FindBranch("SuspectLumiBlocksAux.")) {
286  if(metaTree->FindBranch("SuspectLumiBlocksAux.")->GetSplitLevel()==0) {
287  std::cout << " Unable to read unsplit SuspectLumiBlocks" << std::endl;
288  }
289  lbrs = new xAOD::LumiBlockRangeContainer();
290  lbrs_aux = new xAOD::LumiBlockRangeAuxContainer;
291  const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->setStore( lbrs_aux );
292  metaTree->ResetBranchAddresses();
293  metaTree->SetBranchAddress("SuspectLumiBlocksAux.startRunNumber",&startRunNumber);
294  metaTree->SetBranchAddress("SuspectLumiBlocksAux.stopRunNumber",&stopRunNumber);
295  metaTree->SetBranchAddress("SuspectLumiBlocksAux.startLumiBlockNumber",&startLumiBlockNumber);
296  metaTree->SetBranchAddress("SuspectLumiBlocksAux.stopLumiBlockNumber",&stopLumiBlockNumber);
297  metaTree->SetBranchAddress("SuspectLumiBlocksAux.eventsExpected",&eventsExpected);
298  metaTree->SetBranchAddress("SuspectLumiBlocksAux.eventsSeen",&eventsSeen);
299  }
300  }
301 
302  if(lbrs) {
303  std::cout << "...xAOD SuspectLumiBlocksAux";
304  for(int ii=0;ii<metaTree->GetEntries();ii++) {
305  if(!useTEvent) {
306  const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->clear();
307  metaTree->GetEntry(ii);
308  for(unsigned int j=0;j<startRunNumber.size();j++) {
309  xAOD::LumiBlockRange* r = new xAOD::LumiBlockRange; const_cast<xAOD::LumiBlockRangeContainer*>(lbrs)->push_back(r);
310  r->setStartRunNumber(startRunNumber.at(j));r->setStopRunNumber(stopRunNumber.at(j));
311  r->setStartLumiBlockNumber(startLumiBlockNumber.at(j));r->setStopLumiBlockNumber(stopLumiBlockNumber.at(j));
312  r->setEventsExpected(eventsExpected.at(j));r->setEventsSeen(eventsSeen.at(j));
313  }
314  }
315  //add lb to grl
316  for(auto lbr : *lbrs) {
317  for(uint runNum = lbr->startRunNumber(); runNum <= lbr->stopRunNumber(); runNum++) {
318  if(lbr->startLumiBlockNumber()!=lbr->stopLumiBlockNumber()) {std::cout << " Unexpected behaviour. Please report! " << std::endl; exit(1);}
319  for(uint lb = lbr->startLumiBlockNumber(); lb <= lbr->stopLumiBlockNumber(); lb++) {
320  lbxs[runNum][lb].nSeen += lbr->eventsSeen();
321  lbxs[runNum][lb].fromSuspect = true;
322  if(lbxs[runNum][lb].nExpected!=0 && lbxs[runNum][lb].nExpected != lbr->eventsExpected()) {
323  std::cout << "...mismatch on expected events in [run,lb]=[" << runNum << "," << lb << "] got " << lbr->eventsExpected() << " but had " << lbxs[runNum][lb].nExpected << std::endl;
324  std::cout << "...PLEASE REPORT THIS to hn-atlas-PATHelp@cern.ch ... for now I will assume the larger number is correct" << std::endl;
325  if(lbxs[runNum][lb].nExpected < lbr->eventsExpected()) lbxs[runNum][lb].nExpected = lbr->eventsExpected();
326  }
327  else if(lbxs[runNum][lb].nExpected==0) lbxs[runNum][lb].nExpected=lbr->eventsExpected();
328 
329  }
330  }
331  }
332  ok=true;
333  }
334  std::cout << "...ok" << std::endl;
335  if(!useTEvent) { delete lbrs; lbrs = 0; delete lbrs_aux; lbrs_aux=0; }
336  }
337 
338  if(ok) { file->Close(); delete file; continue; } //don't try to read Lumi folder
339  }
340 
341 
342  if(file->GetDirectory("Lumi")==0) { std::cout << "...no Lumi folder. Skipping" << std::endl; }
343  else {
344  file->cd("Lumi");
345  //look for lumiTree first
346  TTree* lumiTree = dynamic_cast<TTree*>(gDirectory->Get("lumiTree"));
347  if(lumiTree) {
348  std::cout << "...lumiTree";
349  //use the lumitree instead
350  TString *in = 0;
351  lumiTree->SetBranchAddress("lumi",&in);
352  for(int j=0;j<lumiTree->GetEntries();j++) {
353  lumiTree->GetEntry(j);
354  grlReader.AddXMLString(*in); readXML=true;
355  }
356  std::cout << "...ok" << std::endl;
357  } else {
358  TList* keys = gDirectory->GetListOfKeys();
359  //loop over all that are objstrings
360  for( Int_t j = 0; j < keys->GetEntries(); ++j ) {
361  TKey *key = dynamic_cast<TKey*>( keys->At( j ) );
362  TObjString* ostring = (TObjString*) key->ReadObjectAny( TObjString::Class() );
363  if( ! ostring ) { std::cout << "...skipping object: " << key->GetName() << std::endl; continue;}
364  // Check that it has the right format:
365  if( ostring->GetString().BeginsWith( "<?xml version=" ) && ostring->GetString().Contains( "DOCTYPE LumiRangeCollection" ) ) {
366  grlReader.AddXMLString( ostring->GetString() ); readXML=true;
367  std::cout << "...ok" << std::endl;
368  }
369  }
370  }
371  }
372  file->Close();
373  delete file;
374  }
375 
376 
377  //loop over lbx and build up the complete/incomplete/suspect list:
378  std::stringstream definitelySuspect;
379  std::stringstream possiblySuspect;
380  for(auto& it : lbxs) {
381  uint runNum = it.first;
382  for(auto& it2 : it.second) {
383  uint lbn = it2.first;
384  if(it2.second.nSeen > it2.second.nExpected) { fromXAODSuspect.AddRunLumiBlock(runNum,lbn); continue; }
385 
386  if(it2.second.fromSuspect) { fromXAODPossiblySuspect.AddRunLumiBlock(runNum,lbn);}
387 
388  if(it2.second.nSeen==it2.second.nExpected) { fromXAOD.AddRunLumiBlock(runNum,lbn); }
389  else { fromXAODIncomplete.AddRunLumiBlock(runNum,lbn); }
390  }
391  }
392 
394  l.AddGRL(fromXAOD); lIncomplete.AddGRL(fromXAODIncomplete); lSuspect.AddGRL(fromXAODSuspect);lPossiblySuspect.AddGRL(fromXAODPossiblySuspect);//have to do this because of weird GRL behaviour
395  if(readXML) {
396  grlReader.Interpret();
397  l.AddGRL(grlReader.GetMergedGoodRunsList());
398  }
399 
400  double totalLumi = 0; double totalLumiIncomplete = 0; double totalLumiSuspect=0;double allMissing=0; double totalLumiPossiblySuspect=0;
401  std::map<UInt_t, float> missingRuns;std::map<UInt_t,bool> allRuns;std::set<UInt_t> incompleteRuns;std::set<UInt_t> suspectRuns;
402  std::map<UInt_t, std::string> missingRunLB; //lumiblocks that are missing
403 
404 
405 
406 
407 
408 
409  Root::TGoodRunsList providedL; //keeps track of what came from lumicalc file
410 
411  if(lumiFiles.size()==0) {
412  std::cout << "FATAL: No lumicalc file provided, please include at least one lumicalc file in your input list" << std::endl;
413  return 0;
414  }
415 
416  std::cout << "Reading LumiMetaData...";
417 
418  for(auto lfile : lumiFiles) {
419  TFile *lumicalcFile = TFile::Open(lfile.c_str());
420  if(lumicalcFile==0) {
421  std::cout << "Could not open lumicalc file: " << argv[1+nOptions] << std::endl;
422  return 0;
423  }
424 
425  TTree *tmp = (TTree*)lumicalcFile->Get( "LumiMetaData" );
426  if(!tmp) {
427  std::cout << "Could not find LumiMetaData tree in lumicalc file: " << argv[1+nOptions] << std::endl;
428  return 0;
429  }
430 
431  //structure expected is as given by iLumiCalc:
432  // RunNbr, AvergeInteractionPerXing, IntLumi
433  UInt_t runNbr=0;Float_t intLumi=0;TBranch *b_runNbr;TBranch *b_intLumi;
434  UInt_t lb=0.; TBranch *b_lb;
435  if(tmp->SetBranchAddress("RunNbr",&runNbr,&b_runNbr)!=0) {
436  std::cout << "Could not find RunNbr branch in LumiMetaData TTree" << std::endl; return 0;
437  }
438  if(tmp->SetBranchAddress("LBStart",&lb,&b_lb)!=0) {
439  std::cout << "Could not find LBStart branch in Data TTree" << std::endl; return 0;
440  }
441  if(tmp->SetBranchAddress("IntLumi",&intLumi,&b_intLumi)!=0) {
442  std::cout << "Could not find IntLumi branch in Data TTree" << std::endl; return 0;
443  }
444  long nEntries = tmp->GetEntries();
445 
446  int startMissingBlock = -1;UInt_t lastRunNumber=0;int lastLb=0;double missingLumi=0;
447 
448  for(long i=0;i<nEntries;i++) {
449  b_runNbr->GetEntry(i);b_intLumi->GetEntry(i);b_lb->GetEntry(i);
450  if(hasMask && !grlMask.HasRunLumiBlock(runNbr,lb)) continue;
451  providedL.AddRunLumiBlock(runNbr,lb);
452  bool hasLumi = l.HasRunLumiBlock(runNbr,lb);
453  if(hasLumi) totalLumi += intLumi;
454  else if(lIncomplete.HasRunLumiBlock(runNbr,lb)) {hasLumi=true; totalLumiIncomplete += intLumi; incompleteRuns.insert(runNbr);} //else if ensures we never double count lumi
455  else if(lSuspect.HasRunLumiBlock(runNbr,lb)) {hasLumi=true;totalLumiSuspect += intLumi; suspectRuns.insert(runNbr); definitelySuspect << "(" << runNbr << "," << lb << "),";}
456 
457  if(lPossiblySuspect.HasRunLumiBlock(runNbr,lb)) {totalLumiPossiblySuspect += intLumi; possiblySuspect << "(" << runNbr << "," << lb << "),"; }
458 
459  if(!hasLumi && intLumi==0.) hasLumi=true; //if there is no lumi, it's as good as having some
460  if((lastRunNumber!=runNbr&&startMissingBlock>=0) || (hasLumi && startMissingBlock>=0)) {
461  //print now, if startMissingBlock not negative
462  missingRunLB[lastRunNumber] += ((startMissingBlock==lastLb) ? TString::Format("%d",startMissingBlock) : TString::Format("%d-%d",startMissingBlock,lastLb));
463  missingRunLB[lastRunNumber] += ",";
464  if(showMissing) std::cout << "[" << lastRunNumber << "," << startMissingBlock << "-" << lastLb << "," << missingLumi << "]";
465  missingRuns[lastRunNumber]+=missingLumi;
466  allMissing+=missingLumi; missingLumi=0;
467  startMissingBlock=-1;
468  }
469  if(!hasLumi && startMissingBlock==-1) {startMissingBlock=lb;missingLumi=intLumi/1E6;}
470  else if(!hasLumi) { missingLumi+=(intLumi/1E6); }
471  lastRunNumber=runNbr;lastLb=lb;
472  allRuns[runNbr] = true;
473  }
474  lumicalcFile->Close();
475  allMissing += missingLumi;
476  if(missingLumi) {
477  missingRuns[lastRunNumber] += missingLumi;
478  missingRunLB[lastRunNumber] += ((startMissingBlock==lastLb) ? TString::Format("%d",startMissingBlock) : TString::Format("%d-%d",startMissingBlock,lastLb));
479  missingRunLB[lastRunNumber] += ",";
480  }
481  }
482  std::cout << "Done" << std::endl;
483  std::cout << "--------------------------------------------" << std::endl;
484  std::cout << "***************LUMI REPORT******************" << std::endl << std::endl;
485 
486 
487 
488  if(possiblySuspect.str().size()) {
489  std::cout << "Possibly suspect lumiblocks: " << possiblySuspect.str() << std::endl;
490  }
491  if(definitelySuspect.str().size()) {
492  std::cout << "WARNING ... Definitely suspect lumiblocks (please report this!): " << definitelySuspect.str() << std::endl;
493  } else {
494  std::cout << std::endl << "No definitely suspect lumiblocks, that's good!";
495  }
496 
497 
498 
499  std::cout << std::endl << "Runs with incomplete blocks: ";
500  for(auto r : incompleteRuns) {
501  std::cout << r << ",";
502  }
503  std::cout << std::endl << "Runs with missing blocks (missing blocks in brackets): " << std::endl << std::endl;
504  for(auto it=missingRuns.begin();it!=missingRuns.end();++it) {
505  std::cout << " " << it->first << ": " << it->second << " pb-1 (" << missingRunLB[it->first] << ")" << std::endl;
506  }
507  std::cout << std::endl << "Complete runs: ";
508  for(std::map<UInt_t,bool>::iterator it=allRuns.begin();it!=allRuns.end();++it) {
509  if(missingRuns.find(it->first) == missingRuns.end() && incompleteRuns.find(it->first)==incompleteRuns.end() && suspectRuns.find(it->first) == suspectRuns.end()) std::cout << it->first << ",";
510  }
511  std::cout << std::endl;
512 
513  std::cout << std::endl;
514  std::cout << "Complete Luminosity = " << totalLumi/1E6 << " pb-1" << std::endl;
515  if(totalLumiIncomplete) std::cout << "Incomplete Luminosity = " << totalLumiIncomplete/1E6 << " pb-1 (this is partially processed lumi blocks)" << std::endl;
516  if(totalLumiSuspect) std::cout << "Definitely Suspect Luminosity = " << totalLumiSuspect/1E6 << " pb-1 (this is problematic luminosity... please report!)" << std::endl;
517  std::cout << "Complete+Incomplete";
518  if(totalLumiSuspect) std::cout << "+Suspect";
519  std::cout << " Luminosity = " << (totalLumi+totalLumiIncomplete+totalLumiSuspect)/1E6 << " pb-1" << std::endl;
520  if(totalLumiPossiblySuspect) {
521  std::cout << " (of which is possibly suspect = " << totalLumiPossiblySuspect/1E6 << " pb-1 (caused by jobs that did not finish correctly))" << std::endl;
522  }
523  if(allMissing) {
524  std::cout << "(Missing Lumonisity = " << allMissing << " pb-1) (this is luminosity in your lumicalc files that you appear not to have run over)"; //already divided by 1E6 in loop above
525  //if(!showMissing) std::cout << " rerun with the '-m' option to see runs where this luminosity resides";
526  std::cout << std::endl;
527  }
528 
529  /*
530  Root::TGoodRunsList allL(l); allL.AddGRL(lIncomplete);allL.AddGRL(lSuspect);
531  auto uncovered = allL.GetPartNotIn(providedL);
532  if(!uncovered.IsEmpty()) {
533  std::cout << "Input files contain following lumiblocks not covered by lumicalc file:" << std::endl;
534  uncovered.Summary(1);
535  }*/
536 
537 }
538 
539 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Root::TGoodRunsListReader
Definition: TGoodRunsListReader.h:34
beamspotman.r
def r
Definition: beamspotman.py:676
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::startLumiBlockNumber
startLumiBlockNumber
Definition: LumiBlockRange_v1.cxx:58
StateLessPT_NewConfig.Format
Format
Definition: StateLessPT_NewConfig.py:146
xAOD::LumiBlockRangeAuxContainer_v1
Auxiliary container for xAOD::LumiBlockRangeContainer_v1.
Definition: LumiBlockRangeAuxContainer_v1.h:34
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Root::TGoodRunsList::AddRunLumiBlock
void AddRunLumiBlock(Int_t runnr, Int_t lumiblocknr)
Definition: TGoodRunsList.cxx:413
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
skel.runNum
runNum
Definition: skel.ABtoEVGEN.py:137
xAOD::eventsSeen
setStartLumiBlockNumber setStopLumiBlockNumber eventsSeen
Definition: LumiBlockRange_v1.cxx:84
handi.long_options
list long_options
Definition: handi.py:43
xAOD::stopLumiBlockNumber
setStartLumiBlockNumber stopLumiBlockNumber
Definition: LumiBlockRange_v1.cxx:71
xAOD::LumiBlockRangeContainer
LumiBlockRangeContainer_v1 LumiBlockRangeContainer
Declare the latest version of the container.
Definition: LumiBlockRangeContainer.h:17
xAOD::LumiBlockRange
LumiBlockRange_v1 LumiBlockRange
Declare the latest version of the class.
Definition: LumiBlockRange.h:16
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:132
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::LumiBlockRangeAuxContainer
LumiBlockRangeAuxContainer_v1 LumiBlockRangeAuxContainer
Declare the latest version of the auxiliary container.
Definition: LumiBlockRangeAuxContainer.h:16
TEvent.h
file
TFile * file
Definition: tile_monitor.h:29
Init.h
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
dqt_zlumi_pandas.grlReader
grlReader
Definition: dqt_zlumi_pandas.py:88
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
calibdata.exit
exit
Definition: calibdata.py:236
Root::TGoodRunsList
Definition: TGoodRunsList.h:31
TGoodRunsListReader.h
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
xAOD::LumiBlockRange_v1
Class describing a luminosity block range.
Definition: LumiBlockRange_v1.h:33
Root::TGoodRunsListReader::Interpret
Bool_t Interpret()
Definition: TGoodRunsListReader.cxx:71
LumiBlockRangeContainer.h
main
int main(int, char **)
getLumi - the lumi helper application author: Will Buttinger (will@cern.ch) Small program to quickly ...
Definition: getLumi.cxx:20
Root::TGoodRunsList::AddGRL
void AddGRL(const TGoodRunsList &other)
Definition: TGoodRunsList.cxx:32
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
LumiBlockRangeAuxContainer.h
Root::TGoodRunsList::HasRunLumiBlock
Bool_t HasRunLumiBlock(Int_t runnr, Int_t lumiblocknr) const
Definition: TGoodRunsList.cxx:221
Root::TGoodRunsListReader::GetMergedGoodRunsList
const TGoodRunsList GetMergedGoodRunsList(const Root::BoolOperation &operation=OR) const
Definition: TGoodRunsListReader.cxx:318
Root::TGoodRunsListReader::AddXMLFile
void AddXMLFile(const TString &xmlfile)
Definition: TGoodRunsListReader.h:48
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
SeparateEncodingFile.readXML
def readXML(filename)
Definition: SeparateEncodingFile.py:8
validation.lfile
lfile
Definition: validation.py:110
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37