#include "TFile.h" #include "TTree.h" #include "TBrowser.h" #include "TChain.h" #include "TH2.h" #include "TCanvas.h" #define fNLength 80 // maximum allowed length of the file name; #define tChainFiles "fullntps.in" #define calibFiles "calibntps.in" void tchain_ttree() { char fName[fNLength]; TChain *fullNtps = new TChain("EdwRootNtp"); ifstream files_in(tChainFiles); while(!files_in.eof()) { files_in.getline(fName,fNLength); if(fName[0] != '#' && strlen(fName)>2) fullNtps->Add(fName); }; files_in.close(); fullNtps->SetName("fullNtps"); //-- to avoid that TChain and TTree from calibntps_xxx file have the same name; ULong64_t NentFull = fullNtps->GetEntries(); ifstream calib_in(calibFiles); while(!calib_in.eof()) { calib_in.getline(fName,fNLength); if(fName[0] != '#' && strlen(fName)>2) { //-- To skip text header (comments' line has to start with "#"!!!); cHeat = new TCanvas("cHeat","ERA: Heat.vs.Ioniz",200,10,650,550); TChain *cloneNtps = (TChain*)fullNtps->Clone(); TFile *calibF = new TFile(fName); TTree *calibNtps = (TTree*)calibF->Get("EdwRootNtp"); ULong64_t NentCalib = calibNtps->GetEntries(); //-- check that N entries in TChain and in the calibration file is the same; if(NentCalib != NentFull) { cout << "!!! Nentries in " << fName << "(" << NentCalib; cout << ") doesn't correspond to Nentries in TChain(" << NentFull << ")!!!" << endl; return 1; //-- stop the execution; }; cout << ".This " << fName << " has " << NentCalib << " evts" << endl; Double_t Xmax = cloneNtps->GetMaximum("WienerAmpl_centre_Ge73"); Double_t Ymax = calibNtps->GetMaximum("WienerAmpl_chaleur_Ge73"); cout << ".Xmax: " << Xmax << ", Ymax: " << Ymax << endl; cloneNtps->AddFriend(calibNtps,"calibNtps"); cout << ".newYmax: " << cloneNtps->GetMaximum("calibNtps.WienerAmpl_chaleur_Ge73")<GetMaximum("WienerAmpl_chaleur_Ge73")<cd(); cHeat->Divide(2,1); cHeat->cd(1); TVirtualPad::Pad()->SetLogy(1); calibNtps->Draw("WienerAmpl_chaleur_Ge73"); cHeat->cd(2); TVirtualPad::Pad()->SetLogy(1); cloneNtps->Draw("calibNtps.WienerAmpl_chaleur_Ge73"); // calibF->Close(); // cloneNtps->Reset(); }; }; calib_in.close(); fullNtps->Reset(); }