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