/////////////////////////////////////////////////////////////////////////////// // this script analyses ntuples created by TProdSummary::UpdateNtuple /////////////////////////////////////////////////////////////////////////////// #define prod_summary_cxx #include "TStyle.h" #include "TCanvas.h" #include "OfflineMon/prod_summary.hh" //_____________________________________________________________________________ void prod_summary::Loop() { // In a ROOT session, you can do: // // prod_summary t("ProductionExe_0i_gphysr.210012-212133.root") // t.Loop(); // Loop on all entries // // histograms: // ----------- // h1[11] : average CPU time [sec] per event // h1[12] : average CPU time [GHz*sec] per event // h1[13] : average output event size vs liminosity // // h2[ 0] : average CPU time [sec] per event vs L(inst) // h2[ 1] : average CPU time [GHz*sec] per event vs L(inst) // h2[ 2] : average event size (KBytes) vs L(inst) //------------------------------------------------------------------------------- if (fChain == 0) return; if (h2[0] == 0) { h1[0] = new TH1F("h1_0","h1_0",100,0,2); h1[1] = new TH1F("h1_1","h1_1",100,0,2); h1[2] = new TH1F("h1_2","h1_2",100,0,2); h1[3] = new TH1F("h1_3","h1_3",100,0,2); h1[11] = new TH1F("h1_11","average CPU, sec",100,0,2); h1[12] = new TH1F("h1_12","average CPU, GHz*sec",100,0,2); h1[13] = new TH1F("h1_13","average output event size vs lumi",100,0,2); h1[21] = new TH1F("h1_21","event size",100,0,500); h2[0] = new TH2F("h2_0","CPU time (sec) vs L(inst)",100,0,2,100,0,20); h2[1] = new TH2F("h2_1","CPU[GHz*sec] per event vs L(inst)",100,0,2,100,0,20); h2[2] = new TH2F("h2_2","event size(kBytes) vs inst lumi / 1.e32", 100,0,2,1000,0,300000); h_r_nev = new TH2F("h_r_nev","N(output)/N(input) vs stream", 250,0,5,10,0,10); h_r_size = new TH2F("h_r_size","output_size/input_size vs stream", 250,0,5,10,0,10); for (int i=0; i<20; i++) { h_size_vs_lumi[i] = new TH2F(Form("h_s_size_vs_lumi_%i",i), Form("event size(kB) vs inst lumi/1.e32 for stream %c", (char)(i+65)), 100,0,2,400,0,400); } } Int_t nentries = Int_t(fChain->GetEntriesFast()); Int_t nbytes = 0, nb = 0; for (Int_t jentry=0; jentryGetEntry(jentry); nbytes += nb; fProdSummary->fData->fInputFileName = fInputFileName; fProdSummary->fData->fNodeName = fNodeName; float cpu_clock = fProdSummary->CpuClock(); int stream = (int) (fProdSummary->Stream() - 'a'); //----------------------------------------------------------------------------- // convert into bytes //----------------------------------------------------------------------------- float event_size = fInputFileSize*1024.*1024/(fNInputEvents+0.00001); if ((event_size > 250.) && (fNInputEvents > 0) && (fNSevereErrors == 0) && (fNCrashes == 0)) { printf("jentry, cpu_clock, event_size = %6i %10.3f %10.3f\n", jentry, cpu_clock,event_size); } if ((fNInputEvents > 0) && (fNSevereErrors == 0) && (fNCrashes == 0)) { double lumi = fInstLumi/1.e32; h2[0]->Fill(lumi,fCpuTime); h2[1]->Fill(lumi,fCpuTime*cpu_clock); h2[2]->Fill(lumi,event_size); h1[0]->Fill(lumi,fNInputEvents); h1[1]->Fill(lumi,fCpuTime*fNInputEvents); h1[2]->Fill(lumi,fCpuTime*cpu_clock*fNInputEvents); h1[3]->Fill(lumi,event_size*fNInputEvents); h1[21]->Fill(event_size); float output_size = 0; float nev_output = 0; for (int i=0; iFill (r_nev,stream); h_r_size->Fill(r_size,stream); h_size_vs_lumi[stream]->Fill(fInstLumi/1.e32,event_size); } } h1[11]->Divide(h1[1],h1[0]); h1[12]->Divide(h1[2],h1[0]); h1[13]->Divide(h1[3],h1[0]); } //_____________________________________________________________________________ prod_summary::prod_summary(const char* Filename) { // if parameter tree is not specified (or zero), connect the file // used to generate this class and read the Tree. TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(Filename); if (!f) { f = new TFile(Filename); } TTree* tree = (TTree*) gDirectory->Get("prod_summary"); Init(tree); fProdSummary = new TProdSummary(); } //_____________________________________________________________________________ prod_summary::prod_summary(TTree *tree) { // if parameter tree is not specified (or zero), connect the file // used to generate this class and read the Tree. const char fn[] = "results/production.195409-198379.0g.root"; if (tree == 0) { TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(fn); if (!f) { f = new TFile(fn); } tree = (TTree*) gDirectory->Get("prod_summary"); } Init(tree); fProdSummary = new TProdSummary(); } //_____________________________________________________________________________ prod_summary::~prod_summary() { if (!fChain) return; delete fChain->GetCurrentFile(); } //_____________________________________________________________________________ Int_t prod_summary::GetEntry(Int_t entry) { // Read contents of entry. if (!fChain) return 0; return fChain->GetEntry(entry); } Int_t prod_summary::LoadTree(Int_t entry) { // Set the environment to read one entry if (!fChain) return -5; Int_t centry = fChain->LoadTree(entry); if (centry < 0) return centry; if (fChain->IsA() != TChain::Class()) return centry; TChain *chain = (TChain*)fChain; if (chain->GetTreeNumber() != fCurrent) { fCurrent = chain->GetTreeNumber(); Notify(); } return centry; } //_____________________________________________________________________________ void prod_summary::Init(TTree *tree) { // The Init() function is called when the selector needs to initialize // a new tree or chain. Typically here the branch addresses of the tree // will be set. It is normaly not necessary to make changes to the // generated code, but the routine can be extended by the user if needed. // Init() will be called many times when running with PROOF. // Set branch addresses if (tree == 0) return; fChain = tree; fCurrent = -1; fChain->SetMakeClass(1); fChain->SetBranchAddress("fUniqueID",&fUniqueID); fChain->SetBranchAddress("fBits",&fBits); fChain->SetBranchAddress("fInputFileName",&fInputFileName); fChain->SetBranchAddress("fNodeName",&fNodeName); fChain->SetBranchAddress("fInstLumi",&fInstLumi); fChain->SetBranchAddress("fNInputEvents",&fNInputEvents); fChain->SetBranchAddress("fInputFileSize",&fInputFileSize); fChain->SetBranchAddress("fNSevereErrors",&fNSevereErrors); fChain->SetBranchAddress("fCpuTime",&fCpuTime); fChain->SetBranchAddress("fClkTime",&fClkTime); fChain->SetBranchAddress("fNCrashes",&fNCrashes); fChain->SetBranchAddress("fListOfCrashes",&fListOfCrashes_); fChain->SetBranchAddress("fListOfCrashes.fUniqueID",fListOfCrashes_fUniqueID); fChain->SetBranchAddress("fListOfCrashes.fBits",fListOfCrashes_fBits); fChain->SetBranchAddress("fListOfCrashes.fRunNumber",fListOfCrashes_fRunNumber); fChain->SetBranchAddress("fListOfCrashes.fEventNumber",fListOfCrashes_fEventNumber); fChain->SetBranchAddress("fNOutputFiles",&fNOutputFiles); fChain->SetBranchAddress("fListOfOutputFiles",&fListOfOutputFiles_); fChain->SetBranchAddress("fListOfOutputFiles.fUniqueID",fListOfOutputFiles_fUniqueID); fChain->SetBranchAddress("fListOfOutputFiles.fBits",fListOfOutputFiles_fBits); fChain->SetBranchAddress("fListOfOutputFiles.fName",fListOfOutputFiles_fName); fChain->SetBranchAddress("fListOfOutputFiles.fNRecords",fListOfOutputFiles_fNRecords); fChain->SetBranchAddress("fListOfOutputFiles.fNEvents",fListOfOutputFiles_fNEvents); fChain->SetBranchAddress("fListOfOutputFiles.fAverageEventSize",fListOfOutputFiles_fAverageEventSize); Notify(); } Bool_t prod_summary::Notify() { // The Notify() function is called when a new file is opened. This // can be either for a new TTree in a TChain or when when a new TTree // is started when using PROOF. Typically here the branch pointers // will be retrieved. It is normaly not necessary to make changes // to the generated code, but the routine can be extended by the // user if needed. // Get branch pointers b_ProdSummary_fUniqueID = fChain->GetBranch("fUniqueID"); b_ProdSummary_fBits = fChain->GetBranch("fBits"); b_ProdSummary_fInputFileName = fChain->GetBranch("fInputFileName"); b_ProdSummary_fNodeName = fChain->GetBranch("fNodeName"); b_ProdSummary_fInstLumi = fChain->GetBranch("fInstLumi"); b_ProdSummary_fNInputEvents = fChain->GetBranch("fNInputEvents"); b_ProdSummary_fInputFileSize = fChain->GetBranch("fInputFileSize"); b_ProdSummary_fNSevereErrors = fChain->GetBranch("fNSevereErrors"); b_ProdSummary_fCpuTime = fChain->GetBranch("fCpuTime"); b_ProdSummary_fClkTime = fChain->GetBranch("fClkTime"); b_ProdSummary_fNCrashes = fChain->GetBranch("fNCrashes"); b_ProdSummary_fListOfCrashes_ = fChain->GetBranch("fListOfCrashes"); b_fListOfCrashes_fUniqueID = fChain->GetBranch("fListOfCrashes.fUniqueID"); b_fListOfCrashes_fBits = fChain->GetBranch("fListOfCrashes.fBits"); b_fListOfCrashes_fRunNumber = fChain->GetBranch("fListOfCrashes.fRunNumber"); b_fListOfCrashes_fEventNumber = fChain->GetBranch("fListOfCrashes.fEventNumber"); b_ProdSummary_fNOutputFiles = fChain->GetBranch("fNOutputFiles"); b_ProdSummary_fListOfOutputFiles_ = fChain->GetBranch("fListOfOutputFiles"); b_fListOfOutputFiles_fUniqueID = fChain->GetBranch("fListOfOutputFiles.fUniqueID"); b_fListOfOutputFiles_fBits = fChain->GetBranch("fListOfOutputFiles.fBits"); b_fListOfOutputFiles_fName = fChain->GetBranch("fListOfOutputFiles.fName"); b_fListOfOutputFiles_fNRecords = fChain->GetBranch("fListOfOutputFiles.fNRecords"); b_fListOfOutputFiles_fNEvents = fChain->GetBranch("fListOfOutputFiles.fNEvents"); b_fListOfOutputFiles_fAverageEventSize = fChain->GetBranch("fListOfOutputFiles.fAverageEventSize"); return kTRUE; } void prod_summary::Show(Int_t entry) { // Print contents of entry. // If entry is not specified, print current entry if (!fChain) return; fChain->Show(entry); } Int_t prod_summary::Cut(Int_t entry) { // This function may be called from Loop. // returns 1 if entry is accepted. // returns -1 otherwise. return 1; }