36 using Clock = chrono::steady_clock;
55 const string &subdir){
59 figure->Print(luminosity, subdir);
74 auto start_time = Clock::now();
77 size_t num_threads =
multithreaded_ ? min(babies.size(),
static_cast<size_t>(thread::hardware_concurrency())) : 1;
78 cout <<
"Processing " << babies.size() <<
" babies with " << num_threads <<
" threads." << endl;
83 vector<future<long> > num_entries_future(babies.size());
87 for(
const auto &baby: babies){
92 long printStep=Nbabies/20+1;
93 auto start_entries_time = Clock::now();
94 for(
auto& entries: num_entries_future){
95 num_entries += entries.get();
97 if(
min_print_ && ((Nfiles-1)%printStep==0 || Nfiles==Nbabies)){
98 double seconds = chrono::duration<double>(Clock::now()-start_entries_time).count();
99 cout<<
"Done "<<setw(log10(Nbabies)+1)<<Nfiles<<
"/"<<Nbabies<<
" files: "<<setw(10)<<
AddCommas(num_entries)
105 for(
const auto &baby: babies){
109 auto end_time = Clock::now();
110 double num_seconds = chrono::duration<double>(end_time-start_time).count();
111 if(!
min_print_) cout << endl << num_threads <<
" threads processed " 112 << babies.size() <<
" babies with " 113 <<
AddCommas(num_entries) <<
" events in " 114 << num_seconds <<
" seconds = " 115 << 0.001*num_entries/num_seconds <<
" kHz." 121 auto start_time = Clock::now();
122 Baby &baby = *baby_ptr;
128 tag =
"Baby for processes";
133 if(proc != baby.
processes_.cbegin()) oss <<
", ";
134 oss << (*proc)->name_;
140 if(!
min_print_) cout <<
"Processing " << tag << endl;
146 if(!
min_print_) cout << tag <<
" has " << num_entries <<
" entries." << endl;
149 vector<pair<const Process*, set<Figure::FigureComponent*> > > proc_figs(baby.
processes_.size());
152 proc_figs.at(iproc).first = proc;
157 Timer timer(tag, num_entries, 10.);
158 for(
long entry = 0; entry < num_entries; ++entry){
162 for(
const auto &proc_fig: proc_figs){
163 if(proc_fig.first->cut_.IsScalar()){
164 if(!proc_fig.first->cut_.GetScalar(baby))
continue;
166 if(!
HavePass(proc_fig.first->cut_.GetVector(baby)))
continue;
168 for(
const auto &component: proc_fig.second){
169 lock_guard<mutex> lock(component->mutex_);
170 component->RecordEvent(baby);
175 auto end_time = Clock::now();
176 double num_seconds = chrono::duration<double>(end_time - start_time).count();
179 if(!
min_print_) cout <<
"Finished processing " << tag <<
". " 180 << num_entries <<
" events in " << num_seconds <<
" seconds = " 181 << 0.001*num_entries/num_seconds <<
" kHz. "<< endl;
189 for(
const auto &baby: proc->Babies()){
197 set<const Process*> processes;
199 for(
const auto &process: figure->GetProcesses()){
200 processes.insert(process);
207 set<Figure::FigureComponent*> figure_components;
209 auto processes = figure->GetProcesses();
210 auto loc = processes.find(process);
211 if(loc == processes.end())
continue;
212 figure_components.insert(figure->GetComponent(process));
214 return figure_components;
std::vector< ScalarType > VectorType
TString HoursMinSec(float fseconds)
NamedFunc::VectorType VectorType
std::vector< std::unique_ptr< Figure > > figures_
Figures to be produced.
const std::set< std::string > & FileNames() const
Abstract base class for access to ntuple variables.
const std::vector< std::unique_ptr< Figure > > & Figures() const
ScalarType(const Baby &) ScalarFunc
TString AddCommas(double num)
VectorType(const Baby &) VectorFunc
NamedFunc::VectorFunc VectorFunc
std::set< Figure::FigureComponent * > GetComponents(const Process *process) const
std::string Basename(const std::string &filename)
virtual void GetEntry(long entry)
Change current entry.
TString RoundNumber(double num, int decimals, double denom=1.)
PlotMaker()
Standard constructor.
chrono::steady_clock Clock
void Clear()
Empties list of plots to be produced at next PlotMaker::MakePlots call.
std::set< Baby * > GetBabies() const
std::set< const Process * > GetProcesses() const
std::unique_ptr< Activator > Activate()
long GetEntries() const
Get number of entries in TChain and cache it.
long GetYield(Baby *baby_ptr)
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
NamedFunc::ScalarFunc ScalarFunc
bool HavePass(const NamedFunc::VectorType &v)
std::set< const Process * > processes_
NamedFunc::ScalarType ScalarType