Normalise with prescales.
39 assert(fs::exists(
input));
40 TChain * oldchain =
new TChain(
"events");
41 oldchain->Add(
input.c_str());
43 vector<RecJet> * recJets =
nullptr;
44 Event *
event =
nullptr;
46 oldchain->SetBranchAddress(
"recJets", &recJets);
47 oldchain->SetBranchAddress(
"event", &event);
48 oldchain->SetBranchAddress(
"trigger", &trigger);
50 if (fs::exists(output))
52 auto newfile = TFile::Open(output.c_str(),
"RECREATE");
53 auto newtree = oldchain->CloneTree(0);
55 MetaInfo metainfo(newtree);
56 if (nNow == 0) metainfo.Print();
57 metainfo.AddCorrection(
"normalised");
59 int year = metainfo.year();
62 assert(total_lumi > 0);
63 auto inv_total_lumi = 1./total_lumi;
69 vector<ControlPlots> corr ;
70 for (
int i=0; i<metainfo.GetNRecEvWgts(); i++)
73 cout <<
"looping over events:" << endl;
75 Looper looper(__func__, oldchain, nSplit, nNow);
76 while (looper.Next()) {
79 auto leadingInTk = recJets->begin();
80 while (leadingInTk != recJets->end()
81 && abs(leadingInTk->Rapidity()) >= 2.5)
85 if (leadingInTk != recJets->end() && leadingInTk->CorrPt() >=
maxpt)
continue;
88 auto preHLT = trigger->
PreHLT.front();
89 auto preL1min = trigger->
PreL1min.front();
90 auto preL1max = trigger->
PreL1max.front();
91 assert(preL1min == preL1max);
92 if (preL1min != preL1max)
93 cerr <<
"\x1B[31m\e[1m" << preL1min <<
' ' << preL1max <<
"\x1B[30m\e[0m\n";
95 auto prescale = preHLT * preL1min;
101 static vector<map<pair<int,int>,
int>> prescales(1);
102 pair<int,int> runlum = {
event->runNo,
event->lumi};
103 if (prescales.front().count(runlum))
104 assert(prescales.front().at(runlum) == prescale);
106 prescales.front()[runlum] = prescale;
110 assert(event->genWgts.size() == 0 && event->recWgts.size() == 1 && event->recWgts.front() == 1);
113 for (
size_t i = 0; i < corr.size(); ++i)
114 event->recWgts.at(i) *= prescale * inv_total_lumi;
117 for(
size_t i=0; i<corr.size(); i++){
118 if(recJets->size()==0)
continue;
119 corr.at(i)(*recJets,
event->recWgts.at(i));
123 cout <<
"saving" << endl;
125 for (
size_t i = 0; i < corr.size(); ++i)
126 corr.at(i).Write(newfile);
127 auto controlplots = newfile->mkdir(
"controlplots");