16 #include "TObjString.h"
26 : m_LumiTree (nullptr)
27 , m_recordTTree (false)
30 , m_trigger (
"COOLONL_TRIGGER/")
31 , m_lumioff (
"COOLOFL_TRIGGER/")
32 , m_lumionl (
"COOLONL_TRIGGER/")
33 , m_lumitag (
"OflLumi-8TeV-002")
35 , m_laroff (
"COOLOFL_LAR/")
36 , m_bsonl (
"COOLONL_INDET/")
37 , m_bstag (
"IndetBeamposOnl-HLT-UPD1-001-00")
39 , m_parlvl1menufolder (
"/TRIGGER/LVL1/Menu")
40 , m_parhltmenufolder (
"/TRIGGER/HLT/Menu")
41 , m_parhltprescalesfolder (
"/TRIGGER/HLT/Prescales")
42 , m_parlumilvl1folder (
"/TRIGGER/LUMI/LVL1COUNTERS")
43 , m_parlumihltfolder (
"/TRIGGER/LUMI/HLTCOUNTERS")
44 , m_parlvl1prescalesfolder (
"/TRIGGER/LVL1/Prescales")
45 , m_parlvl1lblbfolder (
"/TRIGGER/LUMI/LBLB")
46 , m_parlareventvetofolder (
"/LAR/BadChannelsOfl/EventVeto")
47 , m_paronlbeamspotfolder (
"/Indet/Onl/Beampos")
49 , m_logger(
"LumiCalculator" )
50 , m_lbcollname (
"LumiBlocks")
51 , m_uselivetrigger (false)
60 , m_livetime_beforeprescale(0)
61 , m_livetime_afterprescale(0)
62 , m_afterprescaleof(false)
64 , m_beforeprescaleof(false)
74 , m_clumiblocknbrend(0)
76 , m_totalPrescaleWLiveTime(0.)
77 , m_t_totalPrescaleWLiveTime(0.)
79 , m_t_totalPrescale(0.)
80 , m_lumiWOPrescale(0.)
81 , m_t_lumiWOPrescale(0.)
92 , m_t_totalgoodblock(0)
93 , m_t_totalbadblock(0)
94 , m_t_totall1befpresc(0)
103 , m_l1ratediveffxsec(0.)
104 , m_total_l1ratediveffxsec(0.)
105 , m_total_l1ratediveffxsecRun(0.)
106 , m_l1ratediveffxsec_recorded(0.)
107 , m_total_l1ratediveffxsec_recorded(0.)
108 , m_total_l1ratediveffxsecRun_recorded(0.)
109 , m_mintrigrate(5./120.)
114 , m_lumitrigrateplb(0)
116 , m_intlumitrigrate(0)
117 , m_lumitrigrateplb_recorded(0)
118 , m_intlumitrigrate_recorded(0)
120 , m_intlumitrigrateruns(0)
121 , m_intlumitrigrateruns_recorded(0)
124 , m_makecollList(false)
134 , m_onlinelumi(false)
299 IOVTime((*it)->stopRunNumber(),(*it)->stopLumiBlockNumber()));
302 std::string onlfolder;
303 std::string oflfolder;
307 onlfolder =
"/TRIGGER/LUMI/OnlPrefLumi";
308 oflfolder =
"/TRIGGER/OFLLUMI/OflPrefLumi";
312 onlfolder =
"/TRIGGER/LUMI/LBLESTONL";
313 oflfolder =
"/TRIGGER/OFLLUMI/LBLESTOFL";
320 m_lumi_database = m_lumionl + m_data_db;
321 m_parlumiestfolder = onlfolder;
323 m_lumi_database = m_lumioff + m_data_db;
324 m_parlumiestfolder = oflfolder;
327 m_trig_database = m_trigger + m_data_db;
328 m_lar_database = m_laroff + m_data_db;
329 m_bs_database = m_bsonl + m_data_db;
335 cq_lumi =
new CoolQuery(m_lumi_database, triggerchain);
341 cq_trigger =
new CoolQuery(m_trig_database, triggerchain);
350 cq_lar =
new CoolQuery(m_lar_database, triggerchain);
360 cq_bs =
new CoolQuery(m_bs_database, triggerchain);
378 m_totalPrescaleWLiveTime = 0.;
379 m_totalPrescale = 0.;
380 m_lumiWOPrescale = 0.;
388 m_livetime_l1acc = 0;
393 m_livtrig_totall1acc = 0;
399 m_livetime_beforeprescale = 0;
400 m_livetime_afterprescale = 0;
402 m_beforeprescale = 0;
403 m_totall1befpresc = 0;
409 m_totalgoodblock = 0;
412 m_clumiblocknbrend =0;
414 m_lbcollectionname =
"LumiBlocks";
415 m_triggerchain = triggerchain;
419 m_l1ratediveffxsec = 0.;
420 m_total_l1ratediveffxsec = 0.;
421 m_total_l1ratediveffxsecRun = 0.;
422 m_l1ratediveffxsec_recorded = 0.;
423 m_total_l1ratediveffxsec_recorded = 0.;
424 m_total_l1ratediveffxsecRun_recorded = 0.;
431 bool firstL1Missing =
true;
432 bool firstHLTMissing =
true;
434 std::set<cool::ValidityKey> lbrunset;
438 if (m_collsgrl!=0) {
delete m_collsgrl; m_collsgrl=0; }
439 if (m_makecollList) {
441 m_collsgrl->SetVersion(
"30");
442 m_collsgrl->AddMetaData(
"Query",
"Generated by LumiCalculator");
447 if (m_triglevel == 0){
449 if (triggerchain ==
"None") {
452 m_logger <<
Root::kWARNING <<
"Invalid trigger: [" << triggerchain <<
"] - will proceed with no trigger defined!" <<
Root::GEndl;
458 int reti = regcomp(&
regex,
"_[[:digit:]]?b[[:digit:]]+_", REG_EXTENDED);
461 reti = regexec(&
regex, triggerchain.c_str(), 0, NULL, 0);
462 if ( !reti && !m_usebs) {
463 m_logger <<
Root::kWARNING <<
"Trigger: [" << triggerchain <<
"] appears to be a b-jet trigger, but online beamspot validity not included in livefraction!" <<
Root::GEndl;
469 if (m_lumimethod !=
"") {
472 m_Lumiid = m_lumichannel;
486 std::map<cool::ValidityKey, CoolQuery::LumiFolderData> LumiDataMap;
489 std::map<cool::ValidityKey, cool::UInt63> L1starttime_map;
490 std::map<cool::ValidityKey, cool::UInt63> L1endtime_map;
493 std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> Livetime_map;
494 std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> L1accept_map;
498 IOVTime((*it)->stopRunNumber(),(*it)->stopLumiBlockNumber()));
509 m_t_totalgoodblock = 0;
510 m_t_totalbadblock = 0;
511 m_t_totall1befpresc = 0;
512 m_t_totalPrescaleWLiveTime = 0.;
513 m_t_totalPrescale = 0.;
514 m_t_lumiWOPrescale = 0. ;
522 if(m_lbstart_prev == m_lbstart && m_lbstop_prev == m_lbstop && m_runnbr_prev == m_runnbr){
523 m_logger <<
Root::kWARNING <<
"Skipping multiply stored IOVRange: [" << m_lbstart <<
"-" << m_lbstop <<
"]" <<
Root::GEndl;
528 if ( m_runnbr!=m_runnbr_prev ) {
530 if (m_runnbr < m_minrun) m_minrun = m_runnbr;
531 if (m_runnbr > m_maxrun) m_maxrun = m_runnbr;
534 m_total_l1ratediveffxsecRun=0.;
535 m_total_l1ratediveffxsecRun_recorded=0.;
546 m_triggerlowerchains.clear();
548 m_L1triggerchains.clear();
551 std::string lowerch =
"";
554 if(m_triglevel == 3){
555 m_L3id = cq_trigger->
getHLTChannelId(triggerchain, m_parhltmenufolder);
559 m_triggerlowerchains.push_back(lowerch);
565 m_triggerlowerchains.push_back(lowerch);
567 m_L1id = cq_trigger->
getL1ChannelId(lowerch, m_parlvl1menufolder );
570 }
else if(m_triglevel == 2){
572 m_triggerlowerchains.push_back(lowerch);
573 m_L2id = cq_trigger->
getHLTChannelId(triggerchain, m_parhltmenufolder);
576 ParseL1Trigger(lowerch, cq_trigger);
578 }
else if(m_triglevel == 1){
580 ParseL1Trigger(triggerchain, cq_trigger);
583 if (firstL1Missing && (!m_L1Valid && m_triglevel > 0)) {
584 firstL1Missing =
false;
588 if (firstHLTMissing && ((!m_L2Valid && m_triglevel > 1) || (!m_L3Valid && m_triglevel > 2)) ) {
589 firstHLTMissing =
false;
596 if(m_uselivetrigger){
597 m_LiveL1id = cq_trigger->
getL1ChannelId(m_livetrigger, m_parlvl1menufolder);
602 m_LiveValid = m_L1Valid;
606 if (m_uselivetrigger)
607 m_logger <<
Root::kWARNING <<
"Runnumber: [" << m_runnbr <<
"] can't find livefraction trigger [" << m_livetrigger <<
"]! Livefraction won't be calculated!" <<
Root::GEndl;
609 m_logger <<
Root::kWARNING <<
"Runnumber: [" << m_runnbr <<
"] can't find trigger [" << triggerchain <<
"]! Livefraction won't be calculated!" <<
Root::GEndl;
618 Livetime_map.clear();
619 L1accept_map.clear();
625 if (m_L1Valid && m_triglevel >= 1)
629 L1starttime_map.clear();
630 L1endtime_map.clear();
639 cool::ValidityKey runstarttime = L1starttime_map.begin()->second;
640 cool::ValidityKey runendtime = L1endtime_map.rbegin()->second;
642 cq_lar->
setIOV(runstarttime, runendtime);
643 LArObj = cq_lar->
getIOVData<cool::UInt32>(
"EventVeto", m_parlareventvetofolder, 0, m_lartag);
652 BSObj = cq_bs->
getIOVData<cool::Int32>(
"status", m_paronlbeamspotfolder, 0, m_bstag);
659 LumiDataMap = cq_lumi->
getLumiFolderData(m_parlumiestfolder, m_lumitag, m_Lumiid);
664 m_lbstart_prev = m_lbstart;
665 m_lbstop_prev = m_lbstop;
666 m_runnbr_prev = m_runnbr;
673 m_logger <<
Root::kINFO <<
"Beginning calculation for ";
674 if (m_triglevel > 0) {
675 m_logger <<
Root::kINFO <<
"Trigger " << m_triggerchain;
676 if(m_triggerlowerchains.size() > 0){
684 m_logger <<
Root::kINFO <<
"Run " << m_runnbr <<
" LB [" << m_lbstart <<
"-" << m_lbstop <<
"]" <<
Root::GEndl;
696 if (m_L1idList.size() <= 1) {
697 L1preObj = cq_trigger->
getIOVData<cool::Int32>(
"Lvl1Prescale", m_parlvl1prescalesfolder, m_L1id);
705 L1preObj = cq_trigger->
getIOVData<cool::Int32>(
"Lvl1Prescale", m_parlvl1prescalesfolder, m_L1idList[0]);
708 std::list< std::pair<IOVRange, cool::Int32> >
::iterator it;
710 m_logger <<
Root::kINFO << std::setw(10) << std::left << m_L1triggerchains[0];
711 for(
it = L1preObj.
data.begin();
it != L1preObj.
data.end(); ++
it) {
712 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
715 m_logger <<
it->second <<
", ";
717 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
722 for (
unsigned int iid=1; iid < m_L1idList.size(); iid++) {
723 L1preOther = cq_trigger->
getIOVData<cool::Int32>(
"Lvl1Prescale", m_parlvl1prescalesfolder, m_L1idList[iid]);
726 m_logger <<
Root::kINFO << std::setw(10) << std::left << m_L1triggerchains[iid];
727 for(
it = L1preOther.
data.begin();
it != L1preOther.
data.end(); ++
it) {
728 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
731 m_logger <<
it->second <<
", ";
733 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
739 std::list< std::pair<IOVRange, cool::Int32> >
::iterator it2;
740 for(
it1 = L1preObj.
data.begin(), it2 = L1preOther.
data.begin();
it1 != L1preObj.
data.end(); ++
it1, ++it2) {
743 if ((it2->second > 0) && (
it1->second > it2->second)) {
745 if ((
it1->second > 1) && (it2->second > 1)) {
746 m_logger <<
Root::kWARNING <<
"L1 Prescales combined with both triggers prescaled for Run " << m_runnbr <<
"!" <<
Root::GEndl;
748 it1->second = it2->second;
755 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L1 Pre:";
756 for(
it = L1preObj.
data.begin();
it != L1preObj.
data.end(); ++
it) {
757 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
760 m_logger <<
it->second <<
", ";
762 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
772 L2preObj = cq_trigger->
getIOVData<cool::Float>(
"Prescale", m_parhltprescalesfolder, 20000 + m_L2id);
775 L2preObj = cq_trigger->
getIOVData<cool::Float>(
"Prescale", m_parhltprescalesfolder, 2*m_L2id);
780 L3preObj = cq_trigger->
getIOVData<cool::Float>(
"Prescale", m_parhltprescalesfolder, 2*m_L3id+1);
784 L1starttime_map.clear();
785 L1endtime_map.clear();
790 if (L1starttime_map.begin()->first > iovr->
start().
re_time() || L1starttime_map.rbegin()->first < iovr->
stop().
re_time()) {
791 m_lbstart = (L1starttime_map.begin()->first & 0xFFFFFFFF);
792 m_lbstop = (L1starttime_map.rbegin()->first & 0xFFFFFFFF);
793 m_logger <<
Root::kINFO <<
"Restricting to valid ATLAS lumi block range [" << m_lbstart <<
"-" << m_lbstop <<
"]" <<
Root::GEndl;
803 int firstMissing = -1;
804 int lastMissing = -1;
806 for (cool::ValidityKey currentVK = L1starttime_map.begin()->first; currentVK <= L1starttime_map.rbegin()->first; currentVK++) {
812 m_clumiblocknbr = curIOV.
event();
813 m_clumiblocknbrend = curIOV.
event()+1;
816 if (lbrunset.count(curIOV.
re_time()) != 0) {
820 lbrunset.insert(curIOV.
re_time());
824 m_totalgoodblock += 1;
825 m_t_totalgoodblock += 1;
831 if (itOL == LumiDataMap.end()) {
836 if (firstMissing < 0) {
838 firstMissing = curIOV.
event();
839 lastMissing = firstMissing;
840 }
else if (
int(curIOV.
event()) == (lastMissing+1)) {
842 lastMissing = curIOV.
event();
845 if (firstMissing == lastMissing) {
846 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB " << firstMissing <<
" !" <<
Root::GEndl;
848 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB [" << firstMissing <<
"-" << lastMissing <<
"] !" <<
Root::GEndl;
850 firstMissing = curIOV.
event();
851 lastMissing = firstMissing;
855 if (currentVK == L1starttime_map.rbegin()->first) {
856 if (firstMissing == lastMissing) {
857 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB " << firstMissing <<
" !" <<
Root::GEndl;
859 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB [" << firstMissing <<
"-" << lastMissing <<
"] !" <<
Root::GEndl;
871 if (firstMissing >= 0) {
872 if (firstMissing == lastMissing) {
873 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB " << firstMissing <<
" !" <<
Root::GEndl;
875 m_logger <<
Root::kWARNING <<
"Luminosity info not found for Run " << m_runnbr <<
" LB [" << firstMissing <<
"-" << lastMissing <<
"] !" <<
Root::GEndl;
886 m_instLumi = (itOL->second).LBAvInstLumi;
887 m_AvEvtsPerBX = (itOL->second).LBAvEvtsPerBX;
888 m_Valid = (itOL->second).Valid;
893 m_beforeprescale = 0.;
894 m_afterprescale = 0.;
904 if(m_L1Valid && m_triglevel > 0) {
909 m_l1prescale = L1preObj.
getValue(curIOV);
911 m_l1prescale = 0xFFFFFF /
float(0x1000000 - L1preObj.
getValue(curIOV));
914 m_l1prescale = L1preObj.
getValue(curIOV);
917 if (m_triglevel >=2) {
921 m_l2prescale = L2preObj.
getValue(curIOV);
931 if(m_triglevel == 3){
935 m_l3prescale = L3preObj.
getValue(curIOV);
951 m_livetime_l1acc = l1count.
L1Accept;
952 if(m_livetime_afterprescale > 0.){
953 m_livefrac = m_livetime_l1acc/(
float)m_livetime_afterprescale;
959 if (m_runnbr == 286367) {
963 if (m_runnbr == 281385) {
964 if (m_clumiblocknbr <= 196) {
966 }
else if (m_clumiblocknbr <= 374) {
972 if(m_livetime_beforeprescale > 0 && m_livetime_afterprescale <= 0 ){
973 std::string ttrig =
"";
974 ttrig = triggerchain;
975 if(m_uselivetrigger)ttrig = m_livetrigger;
976 m_logger <<
Root::kWARNING <<
"L1 counts after prescale (before veto) are 0.0 for trigger " << ttrig <<
"! Livefraction set to zero!" <<
Root::GEndl;
977 m_logger <<
Root::kWARNING <<
"Try using a high rate L1 trigger for livetime calculation: --livetrigger=<high rate L1 trigger> " <<
Root::GEndl;
978 m_logger <<
Root::kINFO << m_runnbr <<
"[" << m_clumiblocknbr <<
"]: L1Acc: " << m_l1acc <<
", AfterPrescale: " << m_afterprescale <<
", L1Presc: " << m_l1prescale <<
Root::GEndl;
984 cool::ValidityKey lbstarttime = L1starttime_map.find(currentVK)->second;
985 cool::ValidityKey lbendtime = L1endtime_map.find(currentVK)->second;
995 std::list<std::pair<IOVRange, cool::UInt32> > larlist;
998 for (
std::list<std::pair<IOVRange, cool::UInt32> >::
iterator it = larlist.begin();
it != larlist.end(); ++
it) {
999 if (
it->second == 0)
continue;
1000 float dtime = (
it->first.stop().re_time() -
it->first.start().re_time())/1.E9;
1002 if (m_verbose ==
true) {
1003 m_logger <<
Root::kINFO <<
"Found LAr veto from " <<
it->first.start().re_time() <<
" to " <<
it->first.stop().re_time() <<
" = " << dtime <<
" seconds" <<
Root::GEndl;
1023 if(m_verbose ==
true){
1024 m_logger <<
Root::kINFO << m_runnbr <<
"[" << m_clumiblocknbr <<
"]: Online beamspot invalid with Lumi=" << m_instLumi <<
" 10^30 cm-2 s-1" <<
Root::GEndl;
1031 l1count = L1accept_map.find(currentVK)->second;
1033 m_beforeprescaleof =
false;
1035 m_afterprescaleof =
false;
1039 m_deltaT = (lbendtime-lbstarttime)/1.E9;
1040 m_lbstarttime = lbstarttime/1.E9;
1041 m_lbendtime = lbendtime/1.E9;
1043 if (m_deltaT > 0.) m_larfrac = 1.-m_lartime/m_deltaT;
1046 if(m_onlinelumi ==
true){
1049 cool::UInt32 tempValid = (m_Valid & 1023);
1051 if(tempValid == 10){
1053 if((m_Valid >> 22) == 301
1054 || (m_Valid >> 22) == 302
1055 || (m_Valid >> 22) == 101
1056 || (m_Valid >> 22) == 102
1057 || (m_Valid >> 22) == 103
1058 || (m_Valid >> 22) == 104
1062 m_Valid = tempValid;
1065 m_Valid = tempValid;
1075 if(m_verbose ==
true){
1076 m_logger <<
Root::kINFO << m_runnbr <<
"[" << m_clumiblocknbr <<
"]: L1Acc: " << m_l1acc;
1077 if(m_uselivetrigger) m_logger <<
", Livetime trigger L1Acc: " << m_livetime_l1acc;
1078 m_logger <<
", InstLumi: " << m_instLumi <<
", deltaT: " << m_deltaT <<
", AvEvtsPerBX: " << m_AvEvtsPerBX <<
", BeforePrescale: " << m_beforeprescale <<
", AfterPrescale: " << m_afterprescale;
1079 if (m_uselivetrigger) m_logger <<
", Livetime trigger BeforePrescale: " << m_livetime_beforeprescale <<
" Livetime trigger AfterPrescale: " << m_livetime_afterprescale;
1081 m_logger <<
", Livefrac: " << m_livefrac <<
", L1Presc: " << m_l1prescale <<
", HLTPresc: " << m_l2prescale <<
", Valid: " << m_Valid;
1083 m_logger <<
", Livefrac: " << m_livefrac <<
", L1Presc: " << m_l1prescale <<
", L2Presc: " << m_l2prescale <<
", L3Presc: " << m_l3prescale <<
", Valid: " << m_Valid;
1085 if (m_uselar) m_logger <<
", LAr ready fraction: " << m_larfrac;
1091 if(m_Valid%10 != 0){
1095 m_totalbadblock += 1;
1096 m_t_totalbadblock += 1;
1097 m_logger <<
Root::kWARNING <<
"Skipping lumiblock " << m_runnbr <<
"[" << m_clumiblocknbr <<
"] with invalid inst. lumi. (valid=" << m_Valid <<
")!" <<
Root::GEndl;
1099 }
else if ((m_triglevel > 0) && (m_l1prescale < 0. || m_l2prescale < 0. || m_l3prescale < 0.)) {
1102 m_totalbadblock += 1;
1103 m_t_totalbadblock += 1;
1104 m_logger <<
Root::kWARNING <<
"Lumiblock " << m_runnbr <<
"[" << m_clumiblocknbr <<
"] has a disabled or incorrectly specified trigger.! " <<
Root::GEndl;
1113 m_totalDelL += (m_deltaT*m_instLumi);
1114 m_t_totalDelL += (m_deltaT*m_instLumi);
1115 m_t_deltaT += m_deltaT;
1118 m_totall1acc += m_l1acc;
1119 m_livtrig_totall1acc += m_livetime_l1acc;
1120 m_t_l1acc += m_l1acc;
1121 m_totall1befpresc += m_beforeprescale;
1122 m_t_totall1befpresc += m_beforeprescale;
1123 m_totall2acc += m_l2acc;
1124 m_t_l2acc += m_l2acc;
1125 m_totall3acc += m_l3acc;
1126 m_t_l3acc += m_l3acc;
1127 m_livetime = m_livefrac*m_deltaT;
1128 m_totaltime += m_livetime;
1129 m_t_totaltime += m_livetime;
1131 double totalPrescale = m_l1prescale * m_l2prescale * m_l3prescale;
1134 if (m_l1prescale < 0. ) totalPrescale = 0.;
1135 if (m_l2prescale < 0. ) totalPrescale = 0.;
1136 if (m_l3prescale < 0. ) totalPrescale = 0.;
1139 if (m_triglevel == 0) totalPrescale = 1.;
1143 m_lumiWOPrescale += m_livetime*m_instLumi ;
1144 m_t_lumiWOPrescale += m_livetime*m_instLumi ;
1146 m_lumiLAr += m_livetime*m_larfrac*m_instLumi;
1147 m_t_lumiLAr += m_livetime*m_larfrac*m_instLumi;
1149 if (totalPrescale > 0.) {
1150 m_totalPrescaleWLiveTime += m_livetime/totalPrescale;
1151 m_t_totalPrescaleWLiveTime += m_livetime/totalPrescale;
1152 m_totalPrescale += 1./totalPrescale;
1153 m_t_totalPrescale += 1./totalPrescale;
1154 m_intLumi = m_larfrac * m_livetime * m_instLumi/totalPrescale;
1158 m_totalL += m_intLumi;
1159 m_t_totalL += m_intLumi;
1160 m_totalLRun += m_intLumi;
1164 m_l1rate = ( m_livetime>0 ? m_l1acc / m_livetime : 0. );
1165 m_l2rate = ( m_livetime>0 ? m_l2acc / m_livetime : 0. );
1166 m_l3rate = ( m_livetime>0 ? m_l3acc / m_livetime : 0. );
1169 m_l1ratediveffxsec = (
float)m_afterprescale/( m_deltaT*m_effxsec );
1170 m_total_l1ratediveffxsec += (
float)m_afterprescale / m_effxsec ;
1171 m_total_l1ratediveffxsecRun += (
float)m_afterprescale / m_effxsec ;
1174 m_l1ratediveffxsec_recorded = (
float)m_l1acc /( m_deltaT*m_effxsec );
1175 m_total_l1ratediveffxsec_recorded += (
float)m_l1acc / m_effxsec ;
1176 m_total_l1ratediveffxsecRun_recorded += (
float)m_l1acc / m_effxsec ;
1178 if (m_collsgrl!=0) {
1179 if ( m_l1rate>=m_mintrigrate )
1180 m_collsgrl->AddRunLumiBlock(m_runnbr,m_clumiblocknbr);
1185 m_logger <<
Root::kINFO <<
"L1rate a/ prescale: " << m_afterprescale <<
", Delivered LumiFromL1rate (/ub): " << m_l1ratediveffxsec <<
", Delivered TotalLumiFromL1rate (/ub): " << m_total_l1ratediveffxsec
1189 if(m_LumiTree != 0)m_LumiTree->Fill();
1194 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;
1195 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;
1198 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;
1199 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L1BeforePresc: " << std::setw(10) << std::left << m_t_totall1befpresc <<
Root::GEndl;
1201 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Prescale Weighted Livetime: " << m_t_totalPrescaleWLiveTime <<
Root::GEndl;
1202 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Good LBs : " << m_t_totalgoodblock - m_t_totalbadblock <<
Root::GEndl;
1203 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Bad LBs : " << m_t_totalbadblock <<
Root::GEndl;
1205 if ( m_effxsec==1.0 ) {
1206 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL delivered (ub^-1) : " << m_t_totalDelL <<
Root::GEndl;
1207 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL after livefraction (ub^-1): " << m_t_lumiWOPrescale <<
Root::GEndl;
1209 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL after LAr fraction (ub^-1): " << m_t_lumiLAr <<
Root::GEndl;
1210 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL recorded after prescale (ub^-1) : " << m_t_totalL <<
Root::GEndl;
1212 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL delived (ub^-1) : " << m_total_l1ratediveffxsec <<
Root::GEndl;
1213 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"IntL recorded (ub^-1) : " << m_total_l1ratediveffxsec_recorded <<
Root::GEndl;
1217 if(m_triglevel >= 1){
1219 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L1 Prescales: ";
1221 std::list< std::pair<IOVRange, cool::Int32> >
::iterator it;
1222 for(
it = L1preObj.
data.begin();
it != L1preObj.
data.end(); ++
it) {
1223 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" ;
1226 m_logger <<
it->second <<
", ";
1228 m_logger << (0xFFFFFF /
float(0x1000000 -
it->second)) <<
", ";
1230 m_logger <<
it->second <<
", ";
1236 if(m_triglevel >= 2){
1239 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"HLT Prescales: ";
1242 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L2 Prescales: ";
1245 std::list< std::pair<IOVRange, cool::Float> >
::iterator it;
1246 for(
it = L2preObj.
data.begin();
it != L2preObj.
data.end(); ++
it) {
1247 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" <<
it->second <<
", ";
1252 if(m_triglevel == 3){
1254 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"L3 Prescales: ";
1256 std::list< std::pair<IOVRange, cool::Float> >
::iterator it;
1257 for(
it = L3preObj.
data.begin();
it != L3preObj.
data.end(); ++
it) {
1258 m_logger <<
Root::kINFO << std::setw(1) << std::left <<
"[" <<
it->first.start().event() <<
"," <<
it->first.stop().event()-1 <<
"]:" <<
it->second <<
", ";
1271 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" <<
1272 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;
1273 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
1274 << 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;
1275 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)
1277 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;
1279 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"First Run: " << std::setw(10) << std::left << m_minrun <<
Root::GEndl;
1280 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Last Run: " << std::setw(10) << std::left << m_maxrun <<
Root::GEndl;
1281 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total L1BeforePresc: " << std::setw(10) << std::left << m_totall1befpresc <<
Root::GEndl;
1282 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total Livetime : " << m_totaltime <<
Root::GEndl;
1283 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total prescale weighted Livetime: " << m_totalPrescaleWLiveTime <<
Root::GEndl;
1284 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total Good LBs : " << m_totalgoodblock - m_totalbadblock <<
Root::GEndl;
1285 m_logger <<
Root::kINFO<< std::setw(10) << std::left <<
"Total Bad LBs : " << m_totalbadblock <<
Root::GEndl;
1286 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL delivered (ub^-1) : " << m_totalDelL <<
Root::GEndl;
1287 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL after livefraction (ub^-1): " << m_lumiWOPrescale <<
Root::GEndl;
1289 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL after LAr fraction (ub^-1): " << m_lumiLAr <<
Root::GEndl;
1290 m_logger <<
Root::kINFO << std::setw(10) << std::left <<
"Total IntL recorded (ub^-1) : " << m_totalL <<
Root::GEndl;
1294 if(m_makecollList ==
true){
1296 if (m_collsgrl!=0) {
1297 TString collisionsxml =
"collisions_" + m_collsgrl->GetSuggestedName() +
".xml";
1299 writer.SetGoodRunsList( *m_collsgrl );
1300 writer.SetFilename( collisionsxml.Data() );
1303 delete m_collsgrl; m_collsgrl=0;
1309 if(m_makePlots ==
true) { this->
MakePlots(triggerchain); }
1331 if (lowerch.find(
',', last) == std::string::npos) {
1339 next = lowerch.find(
',', last);
1353 }
while (
next != std::string::npos);
1364 os << std::left <<
"-----------------------------------" << std::endl;
1365 os << std::left <<
" LumiCalculator summary" << std::endl;
1366 os << std::left <<
"-----------------------------------" << std::endl;
1367 os << std::setw(10) << std::left <<
"Trigger: " << std::setw(10) << std::left <<
m_triggerchain << std::endl;
1368 os << std::setw(10) << std::left <<
"First Run: " << std::setw(10) << std::left <<
m_minrun << std::endl;
1369 os << std::setw(10) << std::left <<
"Last Run: " << std::setw(10) << std::left <<
m_maxrun << std::endl;
1370 os << std::setw(10) << std::left <<
"Total L1BeforePresc: " << std::setw(10) << std::left <<
m_totall1befpresc << std::endl;
1371 os << std::setw(10) << std::left <<
"Total Livetime : " <<
m_totaltime << std::endl;
1374 os << std::setw(10) << std::left <<
"Total Bad LBs : " <<
m_totalbadblock << std::endl;
1375 os << std::setw(10) << std::left <<
"Total IntL delivered (ub^-1) : " <<
m_totalDelL << std::endl;
1376 os << std::setw(10) << std::left <<
"Total IntL after livefraction (ub^-1): " <<
m_lumiWOPrescale << std::endl;
1378 os << std::setw(10) << std::left <<
"Total IntL after LAr fraction (ub^-1): " <<
m_lumiLAr << std::endl;
1379 os << std::setw(10) << std::left <<
"Total IntL recorded (ub^-1) : " <<
m_totalL << std::endl;
1389 m_ntrigplbVec.push_back(
new TH1F(Form(
"run%d_ntrigplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1390 m_trigrateplbVec.push_back(
new TH1F(Form(
"run%d_trigrateplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1391 m_lumiplbVec.push_back(
new TH1F(Form(
"run%d_peaklumiplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1392 m_lumitrigrateplbVec.push_back(
new TH1F(Form(
"run%d_peaklumitrigrateplb",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1393 m_intlumiVec.push_back(
new TH1F(Form(
"run%d_intlumi",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1394 m_intlumitrigrateVec.push_back(
new TH1F(Form(
"run%d_intlumitrigrate",runnbr), Form(
"Run %d",runnbr) , maxlb, 0.,
float(maxlb)) );
1407 this->
SetHistogramStyle(
m_ntrigplb, Form(
"Run = %d",runnbr),
"Luminosity block number", Form(
"# %s triggers / LB",trigName.Data()));
1409 this->
SetHistogramStyle(
m_lumiplb, Form(
"Run = %d",runnbr),
"Luminosity block number",
"Delivered luminosity (#mub^{-1}/s)");
1410 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()));
1411 this->
SetHistogramStyle(
m_intlumi, Form(
"Run = %d",runnbr),
"Luminosity block number",
"Integrated delivered luminosity (#mub^{-1})");
1412 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()));
1414 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()));
1435 hist->SetFillColor(33);
1437 if (xaxis!=0)
hist->GetXaxis()->SetTitle(xaxis);
1438 if (yaxis!=0)
hist->GetYaxis()->SetTitle(yaxis);
1440 hist->GetXaxis()->SetLabelFont(52);
1441 hist->GetXaxis()->SetLabelSize(0.04);
1442 hist->GetXaxis()->SetTitleSize(0.05);
1443 hist->GetXaxis()->SetTitleOffset(1.28);
1444 hist->GetXaxis()->SetTitleFont(42);
1446 hist->GetYaxis()->SetLabelFont(52);
1447 hist->GetYaxis()->SetLabelSize(0.04);
1448 hist->GetYaxis()->SetTitleSize(0.05);
1449 hist->GetYaxis()->SetTitleOffset(1.25);
1450 hist->GetYaxis()->SetTitleFont(42);
1452 hist->SetStats(
false);
1454 hist->SetLineWidth(2);
1487 m_intlumiruns->SetBins(runnbrend-runnbrstart+10,
float(runnbrstart),
float(runnbrend+10));
1493 m_avgintperbx->SetTitle(
"Lumi-weighted Interactions per BX");
1494 this->
SetHistogramStyle(
m_avgintperbx,
"Lumi-weighted Average Interactions per BX",
"Average Interactions per BX",
"Recorded Luminosity (mb-1)");
1499 float totalL(0.), total_l1ratediveffxsec(0.), total_l1ratediveffxsec_recorded(0.), totalLRun(0.), total_l1ratediveffxsecRun(0.), total_l1ratediveffxsecRun_recorded(0.);
1553 total_l1ratediveffxsec,total_l1ratediveffxsec_recorded),
"Run number", Form(
"%s Luminosity (#mu b^{-1})",triggerchain.c_str()));
1555 total_l1ratediveffxsec,total_l1ratediveffxsec_recorded),
"Run number", Form(
"%s Luminosity (#mu b^{-1})",triggerchain.c_str()));
1560 TString histFileName = TString(
"ilumicalc_histograms_") + TString(triggerchain) + ( runnbrstart==runnbrend ? Form(
"_%d_",runnbrstart) : Form(
"_%d-%d_",runnbrstart,runnbrend)) + TString(
m_lumitag) + TString(
".root");
1561 TFile *
ff =
new TFile(histFileName.Data(),
"recreate");
1584 TObjString larTag(
m_lartag.c_str());
1585 larTag.Write(
"larTag");