20 #include "TObjString.h"
32 : m_LumiTree (nullptr)
33 , m_recordTTree (false)
36 , m_trigger (
"COOLONL_TRIGGER/")
37 , m_lumioff (
"COOLOFL_TRIGGER/")
38 , m_lumionl (
"COOLONL_TRIGGER/")
39 , m_lumitag (
"OflLumi-8TeV-002")
41 , m_laroff (
"COOLOFL_LAR/")
42 , m_bsonl (
"COOLONL_INDET/")
43 , m_bstag (
"IndetBeamposOnl-HLT-UPD1-001-00")
45 , m_parlvl1menufolder (
"/TRIGGER/LVL1/Menu")
46 , m_parhltmenufolder (
"/TRIGGER/HLT/Menu")
47 , m_parhltprescalesfolder (
"/TRIGGER/HLT/Prescales")
48 , m_parlumilvl1folder (
"/TRIGGER/LUMI/LVL1COUNTERS")
49 , m_parlumihltfolder (
"/TRIGGER/LUMI/HLTCOUNTERS")
50 , m_parlvl1prescalesfolder (
"/TRIGGER/LVL1/Prescales")
51 , m_parlvl1lblbfolder (
"/TRIGGER/LUMI/LBLB")
52 , m_parlareventvetofolder (
"/LAR/BadChannelsOfl/EventVeto")
53 , m_paronlbeamspotfolder (
"/Indet/Onl/Beampos")
55 , m_logger(
"LumiCalculator" )
56 , m_lbcollname (
"LumiBlocks")
57 , m_uselivetrigger (false)
80 , m_livtrig_totall1acc(0)
81 , m_totall1befpresc(0)
88 , m_livetime_beforeprescale(0)
89 , m_livetime_afterprescale(0)
90 , m_afterprescaleof(false)
92 , m_beforeprescaleof(false)
102 , m_clumiblocknbrend(0)
104 , m_totalPrescaleWLiveTime(0.)
105 , m_t_totalPrescaleWLiveTime(0.)
106 , m_totalPrescale(0.)
107 , m_t_totalPrescale(0.)
108 , m_lumiWOPrescale(0.)
109 , m_t_lumiWOPrescale(0.)
120 , m_t_totalgoodblock(0)
121 , m_t_totalbadblock(0)
122 , m_t_totall1befpresc(0)
130 , m_l1ratediveffxsec(0.)
131 , m_total_l1ratediveffxsec(0.)
132 , m_total_l1ratediveffxsecRun(0.)
133 , m_l1ratediveffxsec_recorded(0.)
134 , m_total_l1ratediveffxsec_recorded(0.)
135 , m_total_l1ratediveffxsecRun_recorded(0.)
136 , m_mintrigrate(5./120.)
141 , m_lumitrigrateplb(0)
143 , m_intlumitrigrate(0)
144 , m_lumitrigrateplb_recorded(0)
145 , m_intlumitrigrate_recorded(0)
147 , m_intlumitrigrateruns(0)
148 , m_intlumitrigrateruns_recorded(0)
151 , m_makecollList(false)
161 , m_onlinelumi(false)
326 IOVTime((*it)->stopRunNumber(),(*it)->stopLumiBlockNumber()));
329 std::string onlfolder;
330 std::string oflfolder;
334 onlfolder =
"/TRIGGER/LUMI/OnlPrefLumi";
335 oflfolder =
"/TRIGGER/OFLLUMI/OflPrefLumi";
339 onlfolder =
"/TRIGGER/LUMI/LBLESTONL";
340 oflfolder =
"/TRIGGER/OFLLUMI/LBLESTOFL";
347 m_lumi_database = m_lumionl + m_data_db;
348 m_parlumiestfolder = std::move(onlfolder);
350 m_lumi_database = m_lumioff + m_data_db;
351 m_parlumiestfolder = std::move(oflfolder);
354 m_trig_database = m_trigger + m_data_db;
355 m_lar_database = m_laroff + m_data_db;
356 m_bs_database = m_bsonl + m_data_db;
362 cq_lumi =
new CoolQuery(m_lumi_database, triggerchain);
368 cq_trigger =
new CoolQuery(m_trig_database, triggerchain);
377 cq_lar =
new CoolQuery(m_lar_database, triggerchain);
387 cq_bs =
new CoolQuery(m_bs_database, triggerchain);
406 m_totalPrescaleWLiveTime = 0.;
407 m_totalPrescale = 0.;
408 m_lumiWOPrescale = 0.;
416 m_livetime_l1acc = 0;
421 m_livtrig_totall1acc = 0;
427 m_livetime_beforeprescale = 0;
428 m_livetime_afterprescale = 0;
430 m_beforeprescale = 0;
431 m_totall1befpresc = 0;
437 m_totalgoodblock = 0;
440 m_clumiblocknbrend =0;
442 m_lbcollectionname =
"LumiBlocks";
443 m_triggerchain = triggerchain;
447 m_l1ratediveffxsec = 0.;
448 m_total_l1ratediveffxsec = 0.;
449 m_total_l1ratediveffxsecRun = 0.;
450 m_l1ratediveffxsec_recorded = 0.;
451 m_total_l1ratediveffxsec_recorded = 0.;
452 m_total_l1ratediveffxsecRun_recorded = 0.;
459 bool firstL1Missing =
true;
460 bool firstHLTMissing =
true;
462 std::set<cool::ValidityKey> lbrunset;
466 if (m_collsgrl!=0) {
delete m_collsgrl; m_collsgrl=0; }
467 if (m_makecollList) {
469 m_collsgrl->SetVersion(
"30");
470 m_collsgrl->AddMetaData(
"Query",
"Generated by LumiCalculator");
475 if (m_triglevel == 0){
477 if (triggerchain ==
"None") {
480 m_logger <<
Root::kWARNING <<
"Invalid trigger: [" << triggerchain <<
"] - will proceed with no trigger defined!" <<
Root::GEndl;
486 int reti = regcomp(&
regex,
"_[[:digit:]]?b[[:digit:]]+_", REG_EXTENDED);
489 reti = regexec(&
regex, triggerchain.c_str(), 0, NULL, 0);
490 if ( !reti && !m_usebs) {
491 m_logger <<
Root::kWARNING <<
"Trigger: [" << triggerchain <<
"] appears to be a b-jet trigger, but online beamspot validity not included in livefraction!" <<
Root::GEndl;
497 if (m_lumimethod !=
"") {
500 m_Lumiid = m_lumichannel;
514 std::map<cool::ValidityKey, CoolQuery::LumiFolderData> LumiDataMap;
517 std::map<cool::ValidityKey, cool::UInt63> L1starttime_map;
518 std::map<cool::ValidityKey, cool::UInt63> L1endtime_map;
521 std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> Livetime_map;
522 std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> L1accept_map;
525 const auto iovr = std::make_unique<IOVRange>(
IOVTime((*it)->startRunNumber(),(*it)->startLumiBlockNumber()),
526 IOVTime((*it)->stopRunNumber(),(*it)->stopLumiBlockNumber()));
537 m_t_totalgoodblock = 0;
538 m_t_totalbadblock = 0;
539 m_t_totall1befpresc = 0;
540 m_t_totalPrescaleWLiveTime = 0.;
541 m_t_totalPrescale = 0.;
542 m_t_lumiWOPrescale = 0. ;
550 if(m_lbstart_prev == m_lbstart && m_lbstop_prev == m_lbstop && m_runnbr_prev == m_runnbr){
551 m_logger <<
Root::kWARNING <<
"Skipping multiply stored IOVRange: [" << m_lbstart <<
"-" << m_lbstop <<
"]" <<
Root::GEndl;
556 if ( m_runnbr!=m_runnbr_prev ) {
558 if (m_runnbr < m_minrun) m_minrun = m_runnbr;
559 if (m_runnbr > m_maxrun) m_maxrun = m_runnbr;
562 m_total_l1ratediveffxsecRun=0.;
563 m_total_l1ratediveffxsecRun_recorded=0.;
574 m_triggerlowerchains.clear();
576 m_L1triggerchains.clear();
579 std::string lowerch =
"";
582 if(m_triglevel == 3){
583 m_L3id = cq_trigger->
getHLTChannelId(triggerchain, m_parhltmenufolder);
587 m_triggerlowerchains.push_back(lowerch);
590 if (m_L2id == UINT_MAX) {
591 throw std::runtime_error(
"LumiCalculator::IntegrateLumi : getHLTChannelId returned invalid value.");
596 m_triggerlowerchains.push_back(lowerch);
598 m_L1id = cq_trigger->
getL1ChannelId(lowerch, m_parlvl1menufolder );
601 }
else if(m_triglevel == 2){
603 m_triggerlowerchains.push_back(lowerch);
604 m_L2id = cq_trigger->
getHLTChannelId(triggerchain, m_parhltmenufolder);
607 ParseL1Trigger(lowerch, cq_trigger);
609 }
else if(m_triglevel == 1){
611 ParseL1Trigger(triggerchain, cq_trigger);
614 if (firstL1Missing && (!m_L1Valid && m_triglevel > 0)) {
615 firstL1Missing =
false;
619 if (firstHLTMissing && ((!m_L2Valid && m_triglevel > 1) || (!m_L3Valid && m_triglevel > 2)) ) {
620 firstHLTMissing =
false;
627 if(m_uselivetrigger){
628 m_LiveL1id = cq_trigger->
getL1ChannelId(m_livetrigger, m_parlvl1menufolder);
633 m_LiveValid = m_L1Valid;
637 if (m_uselivetrigger)
638 m_logger <<
Root::kWARNING <<
"Runnumber: [" << m_runnbr <<
"] can't find livefraction trigger [" << m_livetrigger <<
"]! Livefraction won't be calculated!" <<
Root::GEndl;
640 m_logger <<
Root::kWARNING <<
"Runnumber: [" << m_runnbr <<
"] can't find trigger [" << triggerchain <<
"]! Livefraction won't be calculated!" <<
Root::GEndl;
649 Livetime_map.clear();
650 L1accept_map.clear();
656 if (m_L1Valid && m_triglevel >= 1)
660 L1starttime_map.clear();
661 L1endtime_map.clear();
670 cool::ValidityKey runstarttime = L1starttime_map.begin()->second;
671 cool::ValidityKey runendtime = L1endtime_map.rbegin()->second;
673 cq_lar->
setIOV(runstarttime, runendtime);
674 LArObj = cq_lar->
getIOVData<cool::UInt32>(
"EventVeto", m_parlareventvetofolder, 0, m_lartag);
683 BSObj = cq_bs->
getIOVData<cool::Int32>(
"status", m_paronlbeamspotfolder, 0, m_bstag);
690 LumiDataMap = cq_lumi->
getLumiFolderData(m_parlumiestfolder, m_lumitag, m_Lumiid);
695 m_lbstart_prev = m_lbstart;
696 m_lbstop_prev = m_lbstop;
697 m_runnbr_prev = m_runnbr;
704 m_logger <<
Root::kINFO <<
"Beginning calculation for ";
705 if (m_triglevel > 0) {
706 m_logger <<
Root::kINFO <<
"Trigger " << m_triggerchain;
707 if(m_triggerlowerchains.size() > 0){
715 m_logger <<
Root::kINFO <<
"Run " << m_runnbr <<
" LB [" << m_lbstart <<
"-" << m_lbstop <<
"]" <<
Root::GEndl;
727 if (m_L1idList.size() <= 1) {
728 L1preObj = cq_trigger->
getIOVData<cool::Int32>(
"Lvl1Prescale", m_parlvl1prescalesfolder, m_L1id);
736 L1preObj = cq_trigger->
getIOVData<cool::Int32>(
"Lvl1Prescale", m_parlvl1prescalesfolder, m_L1idList[0]);
739 std::list< std::pair<IOVRange, cool::Int32> >
::iterator it;
741 m_logger <<
Root::kINFO << std::setw(10) << std::left << m_L1triggerchains[0];
742 for(
it = L1preObj.
data.begin();
it != L1preObj.
data.end(); ++
it) {
743 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
746 m_logger <<
it->second <<
", ";
748 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
753 for (
unsigned int iid=1; iid < m_L1idList.size(); iid++) {
754 L1preOther = cq_trigger->
getIOVData<cool::Int32>(
"Lvl1Prescale", m_parlvl1prescalesfolder, m_L1idList[iid]);
757 m_logger <<
Root::kINFO << std::setw(10) << std::left << m_L1triggerchains[iid];
758 for(
it = L1preOther.
data.begin();
it != L1preOther.
data.end(); ++
it) {
759 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
762 m_logger <<
it->second <<
", ";
764 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
770 std::list< std::pair<IOVRange, cool::Int32> >
::iterator it2;
771 for(
it1 = L1preObj.
data.begin(), it2 = L1preOther.
data.begin();
it1 != L1preObj.
data.end(); ++
it1, ++it2) {
774 if ((it2->second > 0) && (
it1->second > it2->second)) {
776 if ((
it1->second > 1) && (it2->second > 1)) {
777 m_logger <<
Root::kWARNING <<
"L1 Prescales combined with both triggers prescaled for Run " << m_runnbr <<
"!" <<
Root::GEndl;
779 it1->second = it2->second;
786 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L1 Pre:";
787 for(
it = L1preObj.
data.begin();
it != L1preObj.
data.end(); ++
it) {
788 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
791 m_logger <<
it->second <<
", ";
793 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
803 L2preObj = cq_trigger->
getIOVData<cool::Float>(
"Prescale", m_parhltprescalesfolder, 20000 + m_L2id);
806 L2preObj = cq_trigger->
getIOVData<cool::Float>(
"Prescale", m_parhltprescalesfolder, 2*m_L2id);
811 L3preObj = cq_trigger->
getIOVData<cool::Float>(
"Prescale", m_parhltprescalesfolder, 2*m_L3id+1);
815 L1starttime_map.clear();
816 L1endtime_map.clear();
821 if (L1starttime_map.begin()->first > iovr->
start().
re_time() || L1starttime_map.rbegin()->first < iovr->
stop().
re_time()) {
822 m_lbstart = (L1starttime_map.begin()->first & 0xFFFFFFFF);
823 m_lbstop = (L1starttime_map.rbegin()->first & 0xFFFFFFFF);
824 m_logger <<
Root::kINFO <<
"Restricting to valid ATLAS lumi block range [" << m_lbstart <<
"-" << m_lbstop <<
"]" <<
Root::GEndl;
834 int firstMissing = -1;
835 int lastMissing = -1;
837 for (cool::ValidityKey currentVK = L1starttime_map.begin()->first; currentVK <= L1starttime_map.rbegin()->first; currentVK++) {
843 m_clumiblocknbr = curIOV.
event();
844 m_clumiblocknbrend = curIOV.
event()+1;
847 if (lbrunset.count(curIOV.
re_time()) != 0) {
851 lbrunset.insert(curIOV.
re_time());
855 m_totalgoodblock += 1;
856 m_t_totalgoodblock += 1;
862 if (itOL == LumiDataMap.end()) {
867 if (firstMissing < 0) {
869 firstMissing = curIOV.
event();
870 lastMissing = firstMissing;
871 }
else if (
int(curIOV.
event()) == (lastMissing+1)) {
873 lastMissing = curIOV.
event();
876 if (firstMissing == lastMissing) {
877 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB " << firstMissing <<
" !" <<
Root::GEndl;
879 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB [" << firstMissing <<
"-" << lastMissing <<
"] !" <<
Root::GEndl;
881 firstMissing = curIOV.
event();
882 lastMissing = firstMissing;
886 if (currentVK == L1starttime_map.rbegin()->first) {
887 if (firstMissing == lastMissing) {
888 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB " << firstMissing <<
" !" <<
Root::GEndl;
890 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB [" << firstMissing <<
"-" << lastMissing <<
"] !" <<
Root::GEndl;
902 if (firstMissing >= 0) {
903 if (firstMissing == lastMissing) {
904 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB " << firstMissing <<
" !" <<
Root::GEndl;
906 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB [" << firstMissing <<
"-" << lastMissing <<
"] !" <<
Root::GEndl;
917 m_instLumi = (itOL->second).LBAvInstLumi;
918 m_AvEvtsPerBX = (itOL->second).LBAvEvtsPerBX;
919 m_Valid = (itOL->second).Valid;
924 m_beforeprescale = 0.;
925 m_afterprescale = 0.;
935 if(m_L1Valid && m_triglevel > 0) {
940 m_l1prescale = L1preObj.
getValue(curIOV);
942 m_l1prescale = 0xFFFFFF /
float(0x1000000 - L1preObj.
getValue(curIOV));
945 m_l1prescale = L1preObj.
getValue(curIOV);
948 if (m_triglevel >=2) {
952 m_l2prescale = L2preObj.
getValue(curIOV);
962 if(m_triglevel == 3){
966 m_l3prescale = L3preObj.
getValue(curIOV);
982 m_livetime_l1acc = l1count.
L1Accept;
983 if(m_livetime_afterprescale > 0.){
984 m_livefrac = m_livetime_l1acc/(
float)m_livetime_afterprescale;
990 if (m_runnbr == 286367) {
994 if (m_runnbr == 281385) {
995 if (m_clumiblocknbr <= 196) {
997 }
else if (m_clumiblocknbr <= 374) {
1003 if(m_livetime_beforeprescale > 0 && m_livetime_afterprescale <= 0 ){
1004 std::string ttrig =
"";
1005 ttrig = triggerchain;
1006 if(m_uselivetrigger)ttrig = m_livetrigger;
1007 m_logger <<
Root::kWARNING <<
"L1 counts after prescale (before veto) are 0.0 for trigger " << std::move(ttrig) <<
"! Livefraction set to zero!" <<
Root::GEndl;
1008 m_logger <<
Root::kWARNING <<
"Try using a high rate L1 trigger for livetime calculation: --livetrigger=<high rate L1 trigger> " <<
Root::GEndl;
1009 m_logger <<
Root::kINFO << m_runnbr <<
"[" << m_clumiblocknbr <<
"]: L1Acc: " << m_l1acc <<
", AfterPrescale: " << m_afterprescale <<
", L1Presc: " << m_l1prescale <<
Root::GEndl;
1014 auto itStartTime = L1starttime_map.find(currentVK);
1015 auto itEndTime = L1endtime_map.find(currentVK);
1016 if (itStartTime == L1starttime_map.end() or itEndTime == L1endtime_map.end()){
1017 throw std::runtime_error(
"LumiCalculator::IntegrateLumi Start or End times not found in map.");
1019 cool::ValidityKey lbstarttime = L1starttime_map.find(currentVK)->second;
1020 cool::ValidityKey lbendtime = L1endtime_map.find(currentVK)->second;
1030 std::list<std::pair<IOVRange, cool::UInt32> > larlist;
1033 for (
std::list<std::pair<IOVRange, cool::UInt32> >::
iterator it = larlist.begin();
it != larlist.end(); ++
it) {
1034 if (
it->second == 0)
continue;
1035 float dtime = (
it->first.stop().re_time() -
it->first.start().re_time())/1.E9;
1037 if (m_verbose ==
true) {
1038 m_logger <<
Root::kINFO <<
"Found LAr veto from " <<
it->first.start().re_time() <<
" to " <<
it->first.stop().re_time() <<
" = " << dtime <<
" seconds" <<
Root::GEndl;
1058 if(m_verbose ==
true){
1059 m_logger <<
Root::kINFO << m_runnbr <<
"[" << m_clumiblocknbr <<
"]: Online beamspot invalid with Lumi=" << m_instLumi <<
" 10^30 cm-2 s-1" <<
Root::GEndl;
1066 l1count = L1accept_map.find(currentVK)->second;
1068 m_beforeprescaleof =
false;
1070 m_afterprescaleof =
false;
1074 m_deltaT = (lbendtime-lbstarttime)/1.E9;
1075 m_lbstarttime = lbstarttime/1.E9;
1076 m_lbendtime = lbendtime/1.E9;
1078 if (m_deltaT > 0.) m_larfrac = 1.-m_lartime/m_deltaT;
1081 if(m_onlinelumi ==
true){
1084 cool::UInt32 tempValid = (m_Valid & 1023);
1086 if(tempValid == 10){
1088 if((m_Valid >> 22) == 301
1089 || (m_Valid >> 22) == 302
1090 || (m_Valid >> 22) == 101
1091 || (m_Valid >> 22) == 102
1092 || (m_Valid >> 22) == 103
1093 || (m_Valid >> 22) == 104
1097 m_Valid = tempValid;
1100 m_Valid = tempValid;
1110 if(m_verbose ==
true){
1111 m_logger <<
Root::kINFO << m_runnbr <<
"[" << m_clumiblocknbr <<
"]: L1Acc: " << m_l1acc;
1112 if(m_uselivetrigger) m_logger <<
", Livetime trigger L1Acc: " << m_livetime_l1acc;
1113 m_logger <<
", InstLumi: " << m_instLumi <<
", deltaT: " << m_deltaT <<
", AvEvtsPerBX: " << m_AvEvtsPerBX <<
", BeforePrescale: " << m_beforeprescale <<
", AfterPrescale: " << m_afterprescale;
1114 if (m_uselivetrigger) m_logger <<
", Livetime trigger BeforePrescale: " << m_livetime_beforeprescale <<
" Livetime trigger AfterPrescale: " << m_livetime_afterprescale;
1116 m_logger <<
", Livefrac: " << m_livefrac <<
", L1Presc: " << m_l1prescale <<
", HLTPresc: " << m_l2prescale <<
", Valid: " << m_Valid;
1118 m_logger <<
", Livefrac: " << m_livefrac <<
", L1Presc: " << m_l1prescale <<
", L2Presc: " << m_l2prescale <<
", L3Presc: " << m_l3prescale <<
", Valid: " << m_Valid;
1120 if (m_uselar) m_logger <<
", LAr ready fraction: " << m_larfrac;
1126 if(m_Valid%10 != 0){
1130 m_totalbadblock += 1;
1131 m_t_totalbadblock += 1;
1132 m_logger <<
Root::kWARNING <<
"Skipping lumiblock " << m_runnbr <<
"[" << m_clumiblocknbr <<
"] with invalid inst. lumi. (valid=" << m_Valid <<
")!" <<
Root::GEndl;
1134 }
else if ((m_triglevel > 0) && (m_l1prescale < 0. || m_l2prescale < 0. || m_l3prescale < 0.)) {
1137 m_totalbadblock += 1;
1138 m_t_totalbadblock += 1;
1139 m_logger <<
Root::kWARNING <<
"Lumiblock " << m_runnbr <<
"[" << m_clumiblocknbr <<
"] has a disabled or incorrectly specified trigger.! " <<
Root::GEndl;
1148 m_totalDelL += (m_deltaT*m_instLumi);
1149 m_t_totalDelL += (m_deltaT*m_instLumi);
1150 m_t_deltaT += m_deltaT;
1153 m_totall1acc += m_l1acc;
1154 m_livtrig_totall1acc += m_livetime_l1acc;
1155 m_t_l1acc += m_l1acc;
1156 m_totall1befpresc += m_beforeprescale;
1157 m_t_totall1befpresc += m_beforeprescale;
1158 m_totall2acc += m_l2acc;
1159 m_t_l2acc += m_l2acc;
1160 m_totall3acc += m_l3acc;
1161 m_t_l3acc += m_l3acc;
1162 m_livetime = m_livefrac*m_deltaT;
1163 m_totaltime += m_livetime;
1164 m_t_totaltime += m_livetime;
1166 double totalPrescale = m_l1prescale * m_l2prescale * m_l3prescale;
1169 if (m_l1prescale < 0. ) totalPrescale = 0.;
1170 if (m_l2prescale < 0. ) totalPrescale = 0.;
1171 if (m_l3prescale < 0. ) totalPrescale = 0.;
1174 if (m_triglevel == 0) totalPrescale = 1.;
1178 m_lumiWOPrescale += m_livetime*m_instLumi ;
1179 m_t_lumiWOPrescale += m_livetime*m_instLumi ;
1181 m_lumiLAr += m_livetime*m_larfrac*m_instLumi;
1182 m_t_lumiLAr += m_livetime*m_larfrac*m_instLumi;
1184 if (totalPrescale > 0.) {
1185 m_totalPrescaleWLiveTime += m_livetime/totalPrescale;
1186 m_t_totalPrescaleWLiveTime += m_livetime/totalPrescale;
1187 m_totalPrescale += 1./totalPrescale;
1188 m_t_totalPrescale += 1./totalPrescale;
1189 m_intLumi = m_larfrac * m_livetime * m_instLumi/totalPrescale;
1193 m_totalL += m_intLumi;
1194 m_t_totalL += m_intLumi;
1195 m_totalLRun += m_intLumi;
1199 m_l1rate = ( m_livetime>0 ? m_l1acc / m_livetime : 0. );
1200 m_l2rate = ( m_livetime>0 ? m_l2acc / m_livetime : 0. );
1201 m_l3rate = ( m_livetime>0 ? m_l3acc / m_livetime : 0. );
1204 m_l1ratediveffxsec = (
float)m_afterprescale/( m_deltaT*m_effxsec );
1205 m_total_l1ratediveffxsec += (
float)m_afterprescale / m_effxsec ;
1206 m_total_l1ratediveffxsecRun += (
float)m_afterprescale / m_effxsec ;
1209 m_l1ratediveffxsec_recorded = (
float)m_l1acc /( m_deltaT*m_effxsec );
1210 m_total_l1ratediveffxsec_recorded += (
float)m_l1acc / m_effxsec ;
1211 m_total_l1ratediveffxsecRun_recorded += (
float)m_l1acc / m_effxsec ;
1213 if (m_collsgrl!=0) {
1214 if ( m_l1rate>=m_mintrigrate )
1215 m_collsgrl->AddRunLumiBlock(m_runnbr,m_clumiblocknbr);
1220 m_logger <<
Root::kINFO <<
"L1rate a/ prescale: " << m_afterprescale <<
", Delivered LumiFromL1rate (/ub): " << m_l1ratediveffxsec <<
", Delivered TotalLumiFromL1rate (/ub): " << m_total_l1ratediveffxsec
1224 if(m_LumiTree != 0)m_LumiTree->Fill();
1229 m_logger <<
Root::kINFO<< std::setw(10) << std::right <<
"Run" << std::setw(10) << std::right <<
"L1-Acc" << std::setw(10) << std::right <<
"L2-Acc" << std::setw(10) << std::right <<
"L3-Acc" << std::setw(10) << std::right <<
"LiveTime" << std::setw(18) << std::right <<
"IntL rec.(ub^-1)" << std::setw(18) << std::right <<
"IntL del.(ub^-1)" <<
Root::GEndl;
1230 m_logger <<
Root::kINFO<< std::setw(10) << std::right << m_runnbr << std::setw(10) << std::right << m_t_l1acc << std::setw(10) << std::right << m_t_l2acc << std::setw(10) << std::right << m_t_l3acc << std::setw(10) << std::right << m_t_totaltime << std::setw(18) << std::right << m_t_totalL << std::setw(18) << std::right << m_t_totalDelL <<
Root::GEndl;
1233 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"L1/2/3 accept: " << std::setw(10) << std::left << m_t_l1acc << std::setw(10) << std::left << m_t_l2acc << std::setw(10) << std::left << m_t_l3acc <<
Root::GEndl;
1234 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L1BeforePresc: " << std::setw(10) << std::left << m_t_totall1befpresc <<
Root::GEndl;
1236 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Prescale Weighted Livetime: " << m_t_totalPrescaleWLiveTime <<
Root::GEndl;
1237 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Good LBs : " << m_t_totalgoodblock - m_t_totalbadblock <<
Root::GEndl;
1238 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Bad LBs : " << m_t_totalbadblock <<
Root::GEndl;
1240 if ( m_effxsec==1.0 ) {
1241 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL delivered (ub^-1) : " << m_t_totalDelL <<
Root::GEndl;
1242 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL after livefraction (ub^-1): " << m_t_lumiWOPrescale <<
Root::GEndl;
1244 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL after LAr fraction (ub^-1): " << m_t_lumiLAr <<
Root::GEndl;
1245 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL recorded after prescale (ub^-1) : " << m_t_totalL <<
Root::GEndl;
1247 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL delived (ub^-1) : " << m_total_l1ratediveffxsec <<
Root::GEndl;
1248 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL recorded (ub^-1) : " << m_total_l1ratediveffxsec_recorded <<
Root::GEndl;
1252 if(m_triglevel >= 1){
1254 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L1 Prescales: ";
1256 std::list< std::pair<IOVRange, cool::Int32> >
::iterator it;
1257 for(
it = L1preObj.
data.begin();
it != L1preObj.
data.end(); ++
it) {
1258 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
1261 m_logger <<
it->second <<
", ";
1263 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
1265 m_logger <<
it->second <<
", ";
1271 if(m_triglevel >= 2){
1274 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"HLT Prescales: ";
1277 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L2 Prescales: ";
1280 std::list< std::pair<IOVRange, cool::Float> >
::iterator it;
1281 for(
it = L2preObj.
data.begin();
it != L2preObj.
data.end(); ++
it) {
1282 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" <<
it->second <<
", ";
1287 if(m_triglevel == 3){
1289 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L3 Prescales: ";
1291 std::list< std::pair<IOVRange, cool::Float> >
::iterator it;
1292 for(
it = L3preObj.
data.begin();
it != L3preObj.
data.end(); ++
it) {
1293 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" <<
it->second <<
", ";
1306 m_logger <<
Root::kINFO<< std::setw(10) << std::right <<
"Total" << std::setw(10) << std::right <<
"L1-Acc" << std::setw(10) << std::right <<
"L2-Acc" << std::setw(10) << std::right <<
"L3-Acc" <<
1307 std::setw(10) << std::right <<
"LiveTime" << std::setw(18) << std::right <<
"IntL rec.(ub^-1)" << std::setw(18) << std::right <<
"IntL del.(ub^-1)" <<
Root::GEndl;
1308 m_logger <<
Root::kINFO<< std::setw(10) << std::right <<
"" << std::setw(10) << std::right << m_totall1acc << std::setw(10) << std::right << m_totall2acc << std::setw(10) << std::right
1309 << m_totall3acc << std::setw(10) << std::right << m_totaltime << std::setw(18) << std::right << m_totalL << std::setw(18) << std::right << m_totalDelL <<
Root::GEndl;
1310 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total L1/2/3 accept: " << std::setw(10) << std::left << m_totall1acc << std::setw(10) << std::left << m_totall2acc << std::setw(10)
1312 if(m_uselivetrigger)m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total L1 livetime trigger accept: " << std::setw(10) << std::left << m_livtrig_totall1acc <<
Root::GEndl;
1314 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"First Run: " << std::setw(10) << std::left << m_minrun <<
Root::GEndl;
1315 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Last Run: " << std::setw(10) << std::left << m_maxrun <<
Root::GEndl;
1316 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total L1BeforePresc: " << std::setw(10) << std::left << m_totall1befpresc <<
Root::GEndl;
1317 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total Livetime : " << m_totaltime <<
Root::GEndl;
1318 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total prescale weighted Livetime: " << m_totalPrescaleWLiveTime <<
Root::GEndl;
1319 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total Good LBs : " << m_totalgoodblock - m_totalbadblock <<
Root::GEndl;
1320 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total Bad LBs : " << m_totalbadblock <<
Root::GEndl;
1321 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL delivered (ub^-1) : " << m_totalDelL <<
Root::GEndl;
1322 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL after livefraction (ub^-1): " << m_lumiWOPrescale <<
Root::GEndl;
1324 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL after LAr fraction (ub^-1): " << m_lumiLAr <<
Root::GEndl;
1325 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL recorded (ub^-1) : " << m_totalL <<
Root::GEndl;
1329 if(m_makecollList ==
true){
1331 if (m_collsgrl!=0) {
1332 TString collisionsxml =
"collisions_" + m_collsgrl->GetSuggestedName() +
".xml";
1334 writer.SetGoodRunsList( *m_collsgrl );
1335 writer.SetFilename( collisionsxml.Data() );
1338 delete m_collsgrl; m_collsgrl=0;
1344 if(m_makePlots ==
true) { this->
MakePlots(triggerchain); }
1366 if (lowerch.find(
',', last) == std::string::npos) {
1374 next = lowerch.find(
',', last);
1388 }
while (
next != std::string::npos);
1399 os << std::left <<
"-----------------------------------" << std::endl;
1400 os << std::left <<
" LumiCalculator summary" << std::endl;
1401 os << std::left <<
"-----------------------------------" << std::endl;
1402 os << std::setw(10) << std::left <<
"Trigger: " << std::setw(10) << std::left <<
m_triggerchain << std::endl;
1403 os << std::setw(10) << std::left <<
"First Run: " << std::setw(10) << std::left <<
m_minrun << std::endl;
1404 os << std::setw(10) << std::left <<
"Last Run: " << std::setw(10) << std::left <<
m_maxrun << std::endl;
1405 os << std::setw(10) << std::left <<
"Total L1BeforePresc: " << std::setw(10) << std::left <<
m_totall1befpresc << std::endl;
1406 os << std::setw(10) << std::left <<
"Total Livetime : " <<
m_totaltime << std::endl;
1409 os << std::setw(10) << std::left <<
"Total Bad LBs : " <<
m_totalbadblock << std::endl;
1410 os << std::setw(10) << std::left <<
"Total IntL delivered (ub^-1) : " <<
m_totalDelL << std::endl;
1411 os << std::setw(10) << std::left <<
"Total IntL after livefraction (ub^-1): " <<
m_lumiWOPrescale << std::endl;
1413 os << std::setw(10) << std::left <<
"Total IntL after LAr fraction (ub^-1): " <<
m_lumiLAr << std::endl;
1414 os << std::setw(10) << std::left <<
"Total IntL recorded (ub^-1) : " <<
m_totalL << std::endl;
1424 m_ntrigplbVec.push_back(
new TH1F(Form(
"run%d_ntrigplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1425 m_trigrateplbVec.push_back(
new TH1F(Form(
"run%d_trigrateplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1426 m_lumiplbVec.push_back(
new TH1F(Form(
"run%d_peaklumiplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1427 m_lumitrigrateplbVec.push_back(
new TH1F(Form(
"run%d_peaklumitrigrateplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1428 m_intlumiVec.push_back(
new TH1F(Form(
"run%d_intlumi",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1429 m_intlumitrigrateVec.push_back(
new TH1F(Form(
"run%d_intlumitrigrate",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1442 this->
SetHistogramStyle(
m_ntrigplb, Form(
"Run = %d",runnbr),
"Luminosity block number", Form(
"# %s triggers / LB",trigName.Data()));
1444 this->
SetHistogramStyle(
m_lumiplb, Form(
"Run = %d",runnbr),
"Luminosity block number",
"Delivered luminosity (#mub^{-1}/s)");
1445 this->
SetHistogramStyle(
m_lumitrigrateplb, Form(
"Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr),
"Luminosity block number", Form(
"%s luminosity (#mub^{-1}/s)",trigName.Data()));
1446 this->
SetHistogramStyle(
m_intlumi, Form(
"Run = %d",runnbr),
"Luminosity block number",
"Integrated delivered luminosity (#mub^{-1})");
1447 this->
SetHistogramStyle(
m_intlumitrigrate, Form(
"Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr),
"Luminosity block number", Form(
"%s Integrated luminosity (#mub^{-1})",trigName.Data()));
1449 this->
SetHistogramStyle(
m_intlumitrigrate_recorded, Form(
"Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr),
"Luminosity block number", Form(
"%s Integrated recorded luminosity (#mub^{-1})",trigName.Data()));
1470 hist->SetFillColor(33);
1472 if (xaxis!=0)
hist->GetXaxis()->SetTitle(xaxis);
1473 if (yaxis!=0)
hist->GetYaxis()->SetTitle(yaxis);
1475 hist->GetXaxis()->SetLabelFont(52);
1476 hist->GetXaxis()->SetLabelSize(0.04);
1477 hist->GetXaxis()->SetTitleSize(0.05);
1478 hist->GetXaxis()->SetTitleOffset(1.28);
1479 hist->GetXaxis()->SetTitleFont(42);
1481 hist->GetYaxis()->SetLabelFont(52);
1482 hist->GetYaxis()->SetLabelSize(0.04);
1483 hist->GetYaxis()->SetTitleSize(0.05);
1484 hist->GetYaxis()->SetTitleOffset(1.25);
1485 hist->GetYaxis()->SetTitleFont(42);
1487 hist->SetStats(
false);
1489 hist->SetLineWidth(2);
1522 m_intlumiruns->SetBins(runnbrend-runnbrstart+10,
float(runnbrstart),
float(runnbrend+10));
1528 m_avgintperbx->SetTitle(
"Lumi-weighted Interactions per BX");
1529 this->
SetHistogramStyle(
m_avgintperbx,
"Lumi-weighted Average Interactions per BX",
"Average Interactions per BX",
"Recorded Luminosity (mb-1)");
1534 float totalL(0.), total_l1ratediveffxsec(0.), total_l1ratediveffxsec_recorded(0.), totalLRun(0.), total_l1ratediveffxsecRun(0.), total_l1ratediveffxsecRun_recorded(0.);
1588 total_l1ratediveffxsec,total_l1ratediveffxsec_recorded),
"Run number", Form(
"%s Luminosity (#mu b^{-1})",triggerchain.c_str()));
1590 total_l1ratediveffxsec,total_l1ratediveffxsec_recorded),
"Run number", Form(
"%s Luminosity (#mu b^{-1})",triggerchain.c_str()));
1595 TString histFileName = TString(
"ilumicalc_histograms_") + TString(triggerchain) + ( runnbrstart==runnbrend ? Form(
"_%d_",runnbrstart) : Form(
"_%d-%d_",runnbrstart,runnbrend)) + TString(
m_lumitag) + TString(
".root");
1596 TFile *
ff =
new TFile(histFileName.Data(),
"recreate");
1619 TObjString larTag(
m_lartag.c_str());
1620 larTag.Write(
"larTag");