/** * Merge all files in folder path with names matching the regular expression filematch into trees in a ROOT file. * * @param filematch Merge files whose names match this regular expression (default: read all) * @param path Merge files in this folder (default: current folder) */ void merge_all(const char *filematch = "[0-9]+[a-z]+.out", const char *path = ".") { TFile *outfile = new TFile("out.root","RECREATE"); // create ROOT file ifstream infile; TSystemDirectory dir(path,path); // open given folder TList *files = dir.GetListOfFiles(); // get all files in that folder TRegexp re(filematch); // create regular expression from given parameter outfile->cd(); // switch current directory to ROOT file Int_t n = 0; for (Int_t i = 0; ; i++){ // for loop incrementing index i TObject *f = files->At(i); // get file from folder with index i if (f){ // if next file was found TString filename = f->GetName(); // get filename TString fn = filename; fn.Resize(filename.Length() - 4); // shorten filename by extension ".out" ULong64_t jobnumber; char logtype[64]; double data[1024]; if ((re.Index(filename, &n) == 0) && (sscanf(fn.Data(), "%Ld%s", &jobnumber, logtype) == 2)){ // if filename matches regular expression and contains jobnumber infile.open(filename.Data()); // open file TNtupleD *tree = (TNtupleD*)outfile->Get(logtype); // get corresponding tree from file if (!tree) { // if tree does not yet exist TString bdescriptor; bdescriptor.ReadLine(infile); // read branch descriptor from file header bdescriptor.ReplaceAll(" ",":"); // format branch descriptor for root ("x y z" -> "x:y:z") tree = new TNtupleD(logtype, logtype, bdescriptor.Data()); // create new tree with name logtype from filename printf("%ss have %i columns\n", logtype, tree->GetNvar()); } else infile.ignore(9999, '\n'); // if tree already exists skip file header n = tree->GetNvar(); // get number of file columns cout << "Adding " << filename << '\n'; while (1){ for (int j = 0; j < n; j++) infile >> data[j]; // read values into data array if (!infile) break; // if something happened during reading: stop tree->Fill(data); // fill data into tree } infile.close(); // close file cout << "Entries: " << tree->GetEntries() << '\n'; } } else break;
void paracoor( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); TTree* tree = (TTree*)file->Get("TestTree"); if(!tree) { cout << "--- No TestTree saved in ROOT file. Parallel coordinates will not be plotted" << endl; return; } // first get list of leaves in tree TObjArray* leafList = tree->GetListOfLeaves(); vector<TString> vars; vector<TString> mvas; for (Int_t iar=0; iar<leafList->GetSize(); iar++) { TLeaf* leaf = (TLeaf*)leafList->At(iar); if (leaf != 0) { TString leafName = leaf->GetName(); if (leafName != "type" && leafName != "weight" && leafName != "boostweight" && leafName != "class" && leafName != "className" && leafName != "classID" && !leafName.Contains("prob_")) { // is MVA ? if (TMVAGlob::ExistMethodName( leafName )) { mvas.push_back( leafName ); } else { vars.push_back( leafName ); } } } } cout << "--- Found: " << vars.size() << " variables" << endl; cout << "--- Found: " << mvas.size() << " MVA(s)" << endl; TString type[2] = { "Signal", "Background" }; const Int_t nmva = mvas.size(); TCanvas* csig[nmva]; TCanvas* cbkg[nmva]; for (Int_t imva=0; imva<mvas.size(); imva++) { cout << "--- Plotting parallel coordinates for : " << mvas[imva] << " & input variables" << endl; for (Int_t itype=0; itype<2; itype++) { // create draw option TString varstr = mvas[imva] + ":"; for (Int_t ivar=0; ivar<vars.size(); ivar++) varstr += vars[ivar] + ":"; varstr.Resize( varstr.Last( ':' ) ); // create canvas TString mvashort = mvas[imva]; mvashort.ReplaceAll("MVA_",""); TCanvas* c1 = (itype == 0) ? csig[imva] : cbkg[imva]; c1 = new TCanvas( Form( "c1_%i",itype ), Form( "Parallel coordinate representation for %s and input variables (%s events)", mvashort.Data(), type[itype].Data() ), 50*(itype), 50*(itype), 750, 500 ); tree->Draw( varstr.Data(), Form("classID==%i",1-itype) , "para" ); c1->ToggleEditor(); gStyle->SetOptTitle(0); TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject( "ParaCoord" ); TParallelCoordVar* mvavar = (TParallelCoordVar*)para->GetVarList()->FindObject( mvas[imva] ); Double_t minrange = tree->GetMinimum( mvavar->GetName() ); Double_t maxrange = tree->GetMaximum( mvavar->GetName() ); Double_t width = 0.2*(maxrange - minrange); Double_t x1 = minrange, x2 = x1 + width; TParallelCoordRange* parrange = new TParallelCoordRange( mvavar, x1, x2 ); parrange->SetLineColor(4); mvavar->AddRange( parrange ); para->AddSelection("-1"); for (Int_t ivar=1; ivar<TMath::Min(Int_t(vars.size()) + 1,3); ivar++) { TParallelCoordVar* var = (TParallelCoordVar*)para->GetVarList()->FindObject( vars[ivar] ); minrange = tree->GetMinimum( var->GetName() ); maxrange = tree->GetMaximum( var->GetName() ); width = 0.2*(maxrange - minrange); switch (ivar) { case 0: { x1 = minrange; x2 = x1 + width; break; } case 1: { x1 = 0.5*(maxrange + minrange - width)*0.02; x2 = x1 + width*0.02; break; } case 2: { x1 = maxrange - width; x2 = x1 + width; break; } } parrange = new TParallelCoordRange( var, x1, x2 ); parrange->SetLineColor( ivar == 0 ? 2 : ivar == 1 ? 5 : 6 ); var->AddRange( parrange ); para->AddSelection( Form("%i",ivar) ); } c1->Update(); TString fname = Form( "plots/paracoor_c%i_%s", imva, itype == 0 ? "S" : "B" ); TMVAGlob::imgconv( c1, fname ); } } }
void Example_tags(TString topDir = "/star/rcf/GC/daq/tags") { ////////////////////////////////////////////////////////////////////////// // // // Example_tags.C // // // // shows how to use the STAR tags files // // Input: top level directory // // // // what it does: // // 1. creates TChain from all tags files down from the topDir // // 2. loops over all events in the chain // // // // owner: Alexandre V. Vaniachine <*****@*****.**> // ////////////////////////////////////////////////////////////////////////// gSystem->Load("libTable"); gSystem->Load("St_base"); // start benchmarks gBenchmark = new TBenchmark(); gBenchmark->Start("total"); // set loop optimization level gROOT->ProcessLine(".O4"); // gather all files from the same top directory into one chain // topDir must end with "/" topDir +='/'; St_FileSet dirs(topDir); St_DataSetIter next(&dirs,0); St_DataSet *set = 0; TChain chain("Tag"); while ( (set = next()) ) { if (strcmp(set->GetTitle(),"file") || !(strstr(set->GetName(),".tags.root"))) continue; chain.Add(gSystem->ConcatFileName(topDir,set->Path())); } UInt_t nEvents = chain->GetEntries(); cout<<"chained "<<nEvents<<" events "<<endl; TObjArray *files = chain.GetListOfFiles(); UInt_t nFiles = files->GetEntriesFast(); cout << "chained " << nFiles << " files from " << topDir << endl; TObjArray *leaves = chain.GetListOfLeaves(); Int_t nleaves = leaves->GetEntriesFast(); TString tableName = " "; TObjArray *tagTable = new TObjArray; Int_t tableCount = 0; Int_t *tableIndex = new Int_t[nleaves]; Int_t tagCount = 0; // decode tag table names for (Int_t l=0;l<nleaves;l++) { TLeaf *leaf = (TLeaf*)leaves->UncheckedAt(l); tagCount+=leaf->GetNdata(); TBranch *branch = leaf->GetBranch(); // new tag table name if ( strstr(branch->GetName(), tableName.Data()) == 0 ) { tableName = branch->GetName(); // the tableName is encoded in the branch Name before the "." tableName.Resize(tableName->Last('.')); tagTable->AddLast(new TObjString(tableName.Data())); tableCount++; } tableIndex[l]=tableCount-1; } cout << " tot num tables, tags = " << tableCount << " " << tagCount << endl << endl; //EXAMPLE 1: how to print out names of all tags and values for first event for (l=0;l<nleaves;l++) { leaf = (TLeaf*)leaves->UncheckedAt(l); branch = leaf->GetBranch(); branch->GetEntry(); // tag comment is in the title TString Title = leaf->GetTitle(); Int_t dim = leaf->GetNdata(); if (dim==1) { Title.ReplaceAll('['," '"); Title.ReplaceAll(']',"'"); } cout << "\n Table: "; cout.width(10); cout << ((TObjString*)tagTable->UncheckedAt(tableIndex[l]))->GetString() <<" -- has tag: " << Title << endl; for (Int_t i=0;i<dim;i++) { cout <<" "<< leaf->GetName(); if (dim>1) cout << '['<<i<<']'; cout << " = " << leaf->GetValue(i) << endl; } } // EXAMPLE 2: how to make a plot c1 = new TCanvas("c1","Beam-Gas Rejection",600,1000); gStyle->SetMarkerStyle(8); chain->Draw("n_trk_tpc[0]:n_trk_tpc[1]"); // EXAMPLE 3: how to make a selection (write selected event numbers on the plot) Int_t ncoll=0; char aevent[10]; TText t(0,0,"a"); t.SetTextFont(52); t.SetTextSize(0.02); Float_t cut = 0.35; cout <<"\n Events with ntrk>400 and |asim|<"<<cut<<endl; //loop over all events: READ ONLY n_trk_tpc AND mEventNumber BRANCHES! gBenchmark->Start("loop"); for (Int_t i=0;i<nFiles;i++) { chain.LoadTree(*(chain.GetTreeOffset()+i)); TTree *T = chain.GetTree(); //must renew leaf pointer for each tree TLeaf *ntrk = T->GetLeaf("n_trk_tpc"); TLeaf *run = T->GetLeaf("mRunNumber"); TLeaf *event = T->GetLeaf("mEventNumber"); for (Int_t j=0; j<T->GetEntries(); j++){ ntrk->GetBranch()->GetEntry(j); event->GetBranch()->GetEntry(j); run->GetBranch()->GetEntry(j); Int_t Nm=ntrk->GetValue(0); Int_t Np=ntrk->GetValue(1); Int_t Ntrk = Np+Nm; // avoid division by 0 Float_t asim = Np-Nm; if (Ntrk>0) asim /= Ntrk; if (-cut < asim&&asim < cut && Ntrk>400) { cout<<" Run "<<(UInt_t)run->GetValue() <<", Event "<<event->GetValue() <<endl; ncoll++; sprintf(aevent,"%d",event->GetValue()); t.DrawText(Np+10,Nm+10,aevent); } } } gBenchmark->Stop("loop"); t.SetTextSize(0.05); t.DrawText(50,2550,"ntrk>400 and |(Np-Nm)/(Np+Nm)| < 0.35 "); t.DrawText(500,-300,"Ntrk with tanl<0 "); cout << " Selected " << ncoll << " collision candidates out of " << nEvents << " events" << endl; // stop timer and print benchmarks gBenchmark->Print("loop"); gBenchmark->Stop("total"); gBenchmark->Print("total"); }
void MPDummyForLowStat(const char* stfile, int thr=30, int nGen=40,Bool_t bin=kTRUE) { // show degrees of freedom with low stat TFile* fl = TFile::Open(stfile); if (!fl) {printf("Failed to open %s\n",stfile); return;} TList* lst = (TList*)fl->Get("clist"); if (!lst) {printf("No clist in %s\n",stfile); return;} TH1* hstdof = (TH1*)lst->FindObject("DOFstat"); if (!hstdof) {printf("No DOFstat histo in %s\n",stfile); return;} // int ndof = hstdof->GetNbinsX(); TAxis* xax = hstdof->GetXaxis(); printf("%4s\t%-50s\t%s","cnt"," DOF ID_name","entries"); Mille* ml = 0; AliAlgSteer* algSteer=0; AliAlgMPRecord* mpRec=0; // if (bin) ml = new Mille(Form("%s.%s",mpDummy.Data(),"mille")); else { algSteer = new AliAlgSteer(); algSteer->SetMPDatFileName(mpDummy.Data()); algSteer->SetMPOutType(AliAlgSteer::kMPRec); algSteer->InitMPRecOutput(); mpRec = algSteer->GetMPRecord(); } // int labDum[1] = {0}, cnt=0; float locDum[1] = {0}, gloDum[1] = {kDummyDer}; // for (int i=1;i<=ndof;i++) { if (hstdof->GetBinContent(i)>thr) continue; TString labS = xax->GetBinLabel(i); printf("%4d\t%-50s\t%7d\n",cnt++,labS.Data(),(int)hstdof->GetBinContent(i)); int indL = labS.Index("_"); if (indL>0) labS.Resize(indL); else { printf("Failed to extract label from %s\n",labS.Data()); exit(1); } labDum[0] = labS.Atoi(); if (bin) { for (int j=nGen;j--;) { ml->mille(0, locDum, 1, gloDum, labDum, kDummyRes, kDummyErr); ml->end(); } } else { mpRec->DummyRecord(kDummyRes,kDummyErr,kDummyDer,labDum[0]); for (int j=nGen;j--;) algSteer->GetMPRecTree()->Fill(); } } // if (bin) delete ml; else { algSteer->CloseMPRecOutput(); delete algSteer; } // lst->SetOwner(); delete lst; fl->Close(); delete fl; }
void macroComparison(string sfileA,string sfileB,string sfileC, string fname){ TFile * fileA = new TFile(TString(sfileA), "READ"); TFile * fileB = new TFile(TString(sfileB), "READ"); TFile * fileC = new TFile(TString(sfileC), "READ"); // get canvas name TList *listA = fileA->GetListOfKeys(); TString canvasnameA = listA->At(0)->GetName(); TList *listB = fileB->GetListOfKeys(); TString canvasnameB = listB->At(0)->GetName(); TList *listC = fileC->GetListOfKeys(); TString canvasnameC = listC->At(0)->GetName(); // make histogram name out of canvas name TString histonameA = canvasnameA; Ssiz_t objIndexA = histonameA.Index("canvas"); histonameA.Resize(objIndexA); histonameA+= "_data_hist"; TString histonameB = canvasnameB; Ssiz_t objIndexB = histonameB.Index("canvas"); histonameB.Resize(objIndexB); histonameB+= "_data_hist"; TString histonameC = canvasnameC; Ssiz_t objIndexC = histonameC.Index("canvas"); histonameC.Resize(objIndexC); histonameC+= "_data_hist"; // get canvas from files // get histograms from canvases TCanvas *cvA = (TCanvas*) fileA->Get(canvasnameA); TH1D * histoA = (TH1D*) cvA->FindObject(histonameA)->Clone(); // set name to different value cvA->SetName("dummy"); TCanvas *cvB = (TCanvas*) fileB->Get(canvasnameB); TH1D * histoB = (TH1D*) cvB->FindObject(histonameB)->Clone(); cvB->SetName("dummy2"); TCanvas *cvC = (TCanvas*) fileC->Get(canvasnameC); TH1D * histoC = (TH1D*) cvC->FindObject(histonameC)->Clone(); // ratio plots TH1D * histoAoverBRatio = (TH1D*) histoA->Clone(); TH1D * histoAoverCRatio = (TH1D*) histoA->Clone(); TH1D * histoBoverCRatio = (TH1D*) histoB->Clone(); histoAoverBRatio->Divide(histoB); histoAoverCRatio->Divide(histoC); histoBoverCRatio->Divide(histoC); // make new Canvas for plotting TCanvas *cv1 = new TCanvas(histonameA, histonameA, 1024,1024); cv1->cd(); cv1->Clear(); cv1->Divide(1,2,0.01,0.0); cv1->cd(1); cv1->SetFillColor(0); gStyle->SetOptTitle(0); gPad->SetFillColor(0); gPad->SetPad( 0.0, 0.25, 1.0, 1.0 ); gPad->SetTopMargin(0.1); gPad->SetLeftMargin(0.16); gPad->SetRightMargin(0.04); cv1->cd(2); cv1->SetFillColor(0); gStyle->SetOptTitle(0); gPad->SetFillColor(0); gPad->SetPad( 0.0, 0.0, 1.0, 0.25 ); gPad->SetBottomMargin(0.375); gPad->SetLeftMargin(0.16); gPad->SetRightMargin(0.04); gPad->SetGridy(); cv1->cd(1); histoA->SetMarkerStyle(20); histoA->SetMarkerSize(2); histoA->SetMarkerColor(1); histoA->Draw("E1X0"); // histoA->DrawNormalized("E1X0"); histoB->SetMarkerStyle(21); histoB->SetMarkerSize(2); histoB->SetMarkerColor(2); histoB->Draw("E1X0SAME"); // histoB->DrawNormalized("E1X0SAME"); histoC->SetMarkerStyle(22); histoC->SetMarkerSize(2); histoC->SetMarkerColor(3); histoC->Draw("E1X0SAME"); // histoC->DrawNormalized("E1X0SAME"); TLegend *leg = new TLegend(0.685, 0.575, 0.8, 0.875); leg->AddEntry(histoA,"A"); leg->AddEntry(histoB,"B"); leg->AddEntry(histoC,"C"); leg->Draw("SAME"); // set style for ratio plots histoAoverBRatio->SetMarkerStyle(20); histoAoverCRatio->SetMarkerStyle(21); histoBoverCRatio->SetMarkerStyle(22); histoAoverBRatio->SetMarkerSize(1); histoAoverCRatio->SetMarkerSize(1); histoBoverCRatio->SetMarkerSize(1); histoAoverBRatio->SetMarkerColor(1); histoAoverCRatio->SetMarkerColor(2); histoBoverCRatio->SetMarkerColor(3); histoAoverBRatio->SetLineColor(1); histoAoverCRatio->SetLineColor(2); histoBoverCRatio->SetLineColor(3); cv1->cd(2); histoAoverBRatio->GetYaxis()->SetRangeUser(0.9,1.1); histoAoverBRatio->GetYaxis()->CenterTitle(1); histoAoverBRatio->GetYaxis()->SetTitleSize( 0.16 ); histoAoverBRatio->GetYaxis()->SetTitleOffset( 0.425 ); histoAoverBRatio->GetYaxis()->SetLabelSize( 0.16 ); histoAoverBRatio->GetYaxis()->SetNdivisions( 505 ); histoAoverBRatio->GetXaxis()->SetTitleSize( 0.16 ); histoAoverBRatio->GetXaxis()->SetLabelSize( 0.16 ); histoAoverBRatio->GetXaxis()->SetTitleOffset( 1 ); histoAoverBRatio->GetXaxis()->SetLabelOffset( 0.006 ); histoAoverBRatio->GetXaxis()->SetNdivisions( 510 ); histoAoverBRatio->GetXaxis()->SetTickLength( histoAoverBRatio->GetXaxis()->GetTickLength() * 3.0 ); histoAoverBRatio->SetYTitle("Data/Data"); histoAoverBRatio->Draw("E1X0"); histoAoverCRatio->Draw("E1X0SAME"); histoBoverCRatio->Draw("E1X0SAME"); cv1->Update(); cv1->Print(TString(fname)+TString("_Linear.png")); /// the same with log scale // make new Canvas for plotting TCanvas *cv2 = new TCanvas(histonameA+"log", histonameA+"log", 1024,1024); cv2->cd(); cv2->Clear(); cv2->Divide(1,2,0.01,0.0); cv2->cd(1); cv2->SetFillColor(0); gStyle->SetOptTitle(0); gPad->SetLogy(); gPad->SetFillColor(0); gPad->SetPad( 0.0, 0.25, 1.0, 1.0 ); gPad->SetTopMargin(0.1); gPad->SetLeftMargin(0.16); gPad->SetRightMargin(0.04); cv2->cd(2); cv2->SetFillColor(0); gStyle->SetOptTitle(0); gPad->SetFillColor(0); gPad->SetPad( 0.0, 0.0, 1.0, 0.25 ); gPad->SetBottomMargin(0.375); gPad->SetLeftMargin(0.16); gPad->SetRightMargin(0.04); gPad->SetGridy(); cv2->cd(1); histoA->Draw("E1X0"); histoB->Draw("E1X0SAME"); histoC->Draw("E1X0SAME"); TLegend *leg2 = new TLegend(0.685, 0.575, 0.8, 0.875); leg2->AddEntry(histoA,"A"); leg2->AddEntry(histoB,"B"); leg2->AddEntry(histoC,"C"); leg2->Draw("SAME"); cv2->cd(2); histoAoverBRatio->Draw("E1X0"); histoAoverCRatio->Draw("E1X0SAME"); histoBoverCRatio->Draw("E1X0SAME"); cv2->Update(); cv2->Print(TString(fname)+TString("_Log.png")); }
TCanvas* plotTGraphs(std::vector<TGraph*> theGraphs, bool autoFormat, TString titleString, bool logX, bool logY) { gROOT->cd(); TCanvas* theCanvas = new TCanvas(titleString, titleString, 1600, 1200); theCanvas->cd(); theCanvas->SetLeftMargin(.13); theCanvas->SetRightMargin(.06); theCanvas->SetGrid(1, 1); gPad->SetTickx(1); gPad->SetTicky(1); gPad->SetLogx(logX); gPad->SetLogy(logY); //Create frame based on the min and max from all the histograms; double minX = minFromTGraphs(theGraphs, true, true); double minY = minFromTGraphs(theGraphs, true, false); double maxX = maxFromTGraphs(theGraphs, true, true); double maxY = maxFromTGraphs(theGraphs, true, false); double lengthX = maxX - minX; double lengthY = maxY - minY; double widen = 0.05; if(!logX) { minX -= widen * lengthX; maxX += widen * lengthX; } else { minX *= widen; maxX /= widen; } if(!logY) { minY -= widen * lengthY; maxY += widen * lengthY; } else { minY *= widen; maxY /= widen; } TH1F* theFrameHist = theCanvas->DrawFrame(minX, minY, maxX, maxY); theFrameHist->SetTitleOffset(1.5, "y"); theFrameHist->SetTitleOffset(1.3, "X"); theFrameHist->SetTitle(titleString); //If it doesn't have a title string use the first histogram if(TString(theFrameHist->GetXaxis()->GetTitle()) == "") { theFrameHist->SetXTitle(theGraphs[0]->GetXaxis()->GetTitle()); theFrameHist->SetYTitle(theGraphs[0]->GetYaxis()->GetTitle()); } theCanvas->Update(); theCanvas->Modified(); TLegend* theLegend = nullptr; if(theGraphs.size() > 1) { double legendSize = .05 * theGraphs.size(); if(legendSize < .15) legendSize = .15; // theLegend = new TLegend(0.55, .8 - legendSize, 0.87, 0.8); //Top Right // theLegend = new TLegend(0.2, .8 - legendSize, 0.47, 0.8); //Top Left theLegend = new TLegend(0.55, .4 - legendSize, 0.87, 0.4); //Bottom Right } for (unsigned int i = 0; i < theGraphs.size(); i++) { if(autoFormat) { theGraphs[i]->SetLineColor(MR_GRAPH_COLOR_LIST[i % MR_GRAPH_NUMCOLORS]); theGraphs[i]->SetMarkerColor(MR_GRAPH_COLOR_LIST[i % MR_GRAPH_NUMCOLORS]); theGraphs[i]->SetMarkerStyle(MR_MARKER_STYLE_LIST[i % MR_MARKER_NUMSTYLES]); } theGraphs[i]->Draw("P E1 same"); if(theLegend != nullptr) { TString legendString = theGraphs[i]->GetTitle(); legendString.Resize(legendString.First(';')); theLegend->AddEntry(theGraphs[i], legendString, "P E1"); } } if(theLegend != nullptr) theLegend->Draw("same"); return theCanvas; }
void AddTask_GammaCaloDalitzV1_pPb( Int_t trainConfig = 1, //change different set of cuts Bool_t isMC = kFALSE, //run MC Int_t enableQAMesonTask = 0, //enable QA in AliAnalysisTaskGammaConvV1 Int_t enableQAPhotonTask = 0, // enable additional QA task TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input Int_t doWeightingPart = 0, //enable Weighting TString generatorName = "DPMJET", TString cutnumberAODBranch = "8000000060084000001500000", // cutnumber for AOD branch Bool_t enableExtendedMatching = kFALSE, //enable or disable extended matching histograms for conversion electrons <-> cluster Bool_t isUsingTHnSparse = kTRUE, //enable or disable usage of THnSparses for background estimation Bool_t enableV0findingEffi = kFALSE ) { Int_t isHeavyIon = 2; // ================== GetAnalysisManager =============================== AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); if (!mgr) { Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found."); return ; } // ================== GetInputEventHandler ============================= AliVEventHandler *inputHandler=mgr->GetInputEventHandler(); //========= Add PID Reponse to ANALYSIS manager ==== if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){ gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); AddTaskPIDResponse(isMC); } Printf("here \n"); //========= Set Cutnumber for V0Reader ================================ //06000078400100001500000000 TString cutnumberPhoton = "06000078400100007500000000"; TString cutnumberEvent = "80000003"; TString cutnumberElectron = "90005400000002000000"; //Electron Cuts Bool_t doEtaShift = kFALSE; AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); //========= Add V0 Reader to ANALYSIS manager if not yet existent ===== TString V0ReaderName = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data()); if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){ AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1(V0ReaderName.Data()); fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE); fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output fV0ReaderV1->SetUseAODConversionPhoton(kTRUE); fV0ReaderV1->SetProduceV0FindingEfficiency(enableV0findingEffi); if (!mgr) { Error("AddTask_V0ReaderV1", "No analysis manager found."); return; } AliConvEventCuts *fEventCuts=NULL; if(cutnumberEvent!=""){ fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data()); fEventCuts->SetPreSelectionCutFlag(kTRUE); fEventCuts->SetV0ReaderName(V0ReaderName); if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){ fEventCuts->DoEtaShift(doEtaShift); fV0ReaderV1->SetEventCuts(fEventCuts); fEventCuts->SetFillCutHistograms("",kTRUE); } } // Set AnalysisCut Number AliConversionPhotonCuts *fCuts=NULL; if(cutnumberPhoton!=""){ fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data()); fCuts->SetPreSelectionCutFlag(kTRUE); fCuts->SetIsHeavyIon(isHeavyIon); fCuts->SetV0ReaderName(V0ReaderName); if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){ fV0ReaderV1->SetConversionCuts(fCuts); fCuts->SetFillCutHistograms("",kTRUE); } } if(inputHandler->IsA()==AliAODInputHandler::Class()){ // AOD mode fV0ReaderV1->AliV0ReaderV1::SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data())); } fV0ReaderV1->Init(); AliLog::SetGlobalLogLevel(AliLog::kFatal); //connect input V0Reader mgr->AddTask(fV0ReaderV1); mgr->ConnectInput(fV0ReaderV1,0,cinput); } //================================================ //========= Add Electron Selector ================ if( !(AliDalitzElectronSelector*)mgr->GetTask("ElectronSelector") ){ AliDalitzElectronSelector *fElectronSelector = new AliDalitzElectronSelector("ElectronSelector"); // Set AnalysisCut Number AliDalitzElectronCuts *fElecCuts=0; if( cutnumberElectron!=""){ fElecCuts= new AliDalitzElectronCuts(cutnumberElectron.Data(),cutnumberElectron.Data()); if(fElecCuts->InitializeCutsFromCutString(cutnumberElectron.Data())){ fElectronSelector->SetDalitzElectronCuts(fElecCuts); fElecCuts->SetFillCutHistograms("",kTRUE); } } fElectronSelector->Init(); mgr->AddTask(fElectronSelector); AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer(); //connect input V0Reader mgr->ConnectInput (fElectronSelector,0,cinput1); } //================================================ //========= Add task to the ANALYSIS manager ===== //================================================ AliAnalysisTaskGammaCaloDalitzV1 *task=NULL; task= new AliAnalysisTaskGammaCaloDalitzV1(Form("GammaCaloDalitz_%i",trainConfig)); task->SetIsHeavyIon(isHeavyIon); task->SetIsMC(isMC); task->SetV0ReaderName(V0ReaderName); // Cut Numbers to use in Analysis Int_t numberOfCuts = 2; if ( trainConfig == 1 || trainConfig == 2 ) numberOfCuts = 4; TString *eventCutArray = new TString[numberOfCuts]; TString *photonCutArray = new TString[numberOfCuts]; TString *clusterCutArray = new TString[numberOfCuts]; TString *electronCutArray = new TString[numberOfCuts]; TString *mesonCutArray = new TString[numberOfCuts]; //************************************************ EMCAL clusters ********************************************************** if ( trainConfig == 1){ // min energy = 0.3 GeV/c eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1111100043022030000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 eventCutArray[1] = "80052013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1111100043022030000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kEMC7 eventCutArray[2] = "80000013"; photonCutArray[2] = "00200009327002008250400000"; clusterCutArray[2] = "1111100043022030000"; electronCutArray[2] = "90475400233102623110"; mesonCutArray[2] = "0263103100000000"; //standart cut, kINT7 eventCutArray[3] = "80052013"; photonCutArray[3] = "00200009327002008250400000"; clusterCutArray[3] = "1111100043022030000"; electronCutArray[3] = "90475400233102623110"; mesonCutArray[3] = "0263103100000000"; //standard cut, kEMC7 } else if ( trainConfig == 2 ){ eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "2000000048033200000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 eventCutArray[1] = "80062013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "2000000048033200000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kPHI7 eventCutArray[2] = "80000013"; photonCutArray[2] = "00200009327002008250400000"; clusterCutArray[2] = "2000000048033200000"; electronCutArray[2] = "90475400233102623110"; mesonCutArray[2] = "0263103100000000"; //standart cut, kINT7 eventCutArray[3] = "80062013"; photonCutArray[3] = "00200009327002008250400000"; clusterCutArray[3] = "2000000048033200000"; electronCutArray[3] = "90475400233102623110"; mesonCutArray[3] = "0263103100000000"; //standard cut, kPHI7 } else if ( trainConfig == 3){ // min energy = 0.3 GeV/c eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1111100053032230000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1331100053032230000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kEMC7 } else if ( trainConfig == 4){ eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "2000000048033200000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "2444400048033200000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kPHI7 } else if ( trainConfig == 5 ){ eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1002100053032230000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 with TRD eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1001300053032230000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kINT7 No TRD } else if ( trainConfig == 6 ) { eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "2000000048033300000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "2444400048033300000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kINT7 } else if ( trainConfig == 7 ){ // min energy = 0.3 GeV/c eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1221100053032230000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1331100053032230000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kEMC7 } else { Error(Form("GammaConvDalitzCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration"); return; } TList *EventCutList = new TList(); TList *ConvCutList = new TList(); TList *ClusterCutList = new TList(); TList *ElectronCutList = new TList(); TList *MesonCutList = new TList(); TList *HeaderList = new TList(); if (doWeightingPart==1) { TObjString *Header1 = new TObjString("pi0_1"); HeaderList->Add(Header1); } if (doWeightingPart==2){ TObjString *Header3 = new TObjString("eta_2"); HeaderList->Add(Header3); } if (doWeightingPart==3) { TObjString *Header1 = new TObjString("pi0_1"); HeaderList->Add(Header1); TObjString *Header3 = new TObjString("eta_2"); HeaderList->Add(Header3); } EventCutList->SetOwner(kTRUE); AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts]; ConvCutList->SetOwner(kTRUE); AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts]; ClusterCutList->SetOwner(kTRUE); AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts]; ElectronCutList->SetOwner(kTRUE); AliDalitzElectronCuts **analysisElectronCuts = new AliDalitzElectronCuts*[numberOfCuts]; MesonCutList->SetOwner(kTRUE); AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts]; for(Int_t i = 0; i<numberOfCuts; i++){ //create AliCaloTrackMatcher instance, if there is none present TString caloCutPos = clusterCutArray[i]; caloCutPos.Resize(1); TString TrackMatcherName = Form("CaloTrackMatcher_%s",caloCutPos.Data()); if( !(AliCaloTrackMatcher*)mgr->GetTask(TrackMatcherName.Data()) ){ AliCaloTrackMatcher* fTrackMatcher = new AliCaloTrackMatcher(TrackMatcherName.Data(),caloCutPos.Atoi()); fTrackMatcher->SetV0ReaderName(V0ReaderName); mgr->AddTask(fTrackMatcher); mgr->ConnectInput(fTrackMatcher,0,cinput); } analysisEventCuts[i] = new AliConvEventCuts(); analysisEventCuts[i]->SetV0ReaderName(V0ReaderName); analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data()); EventCutList->Add(analysisEventCuts[i]); analysisEventCuts[i]->SetFillCutHistograms("",kFALSE); analysisCuts[i] = new AliConversionPhotonCuts(); analysisCuts[i]->SetV0ReaderName(V0ReaderName); analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data()); analysisCuts[i]->SetIsHeavyIon(isHeavyIon); ConvCutList->Add(analysisCuts[i]); analysisCuts[i]->SetFillCutHistograms("",kFALSE); analysisClusterCuts[i] = new AliCaloPhotonCuts(); analysisClusterCuts[i]->SetV0ReaderName(V0ReaderName); analysisClusterCuts[i]->SetCaloTrackMatcherName(TrackMatcherName); analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data()); ClusterCutList->Add(analysisClusterCuts[i]); analysisClusterCuts[i]->SetExtendedMatching(enableExtendedMatching); analysisClusterCuts[i]->SetFillCutHistograms(""); analysisElectronCuts[i] = new AliDalitzElectronCuts(); if( !analysisElectronCuts[i]->InitializeCutsFromCutString(electronCutArray[i].Data())) { cout<< "ERROR: analysisElectronCuts [ " <<i<<" ] "<<endl; return 0; } ElectronCutList->Add(analysisElectronCuts[i]); analysisElectronCuts[i]->SetFillCutHistograms("",kFALSE,electronCutArray[i].Data()); analysisMesonCuts[i] = new AliConversionMesonCuts(); analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data()); MesonCutList->Add(analysisMesonCuts[i]); analysisMesonCuts[i]->SetFillCutHistograms(""); analysisEventCuts[i]->SetAcceptedHeader(HeaderList); } task->SetEventCutList(numberOfCuts,EventCutList); task->SetConversionCutList(numberOfCuts,ConvCutList); task->SetCaloCutList(numberOfCuts,ClusterCutList); task->SetMesonCutList(numberOfCuts,MesonCutList); task->SetElectronCutList(numberOfCuts,ElectronCutList); task->SetMoveParticleAccordingToVertex(kTRUE); task->SetDoMesonAnalysis(kTRUE); task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA task->SetDoClusterQA(1); //Attention new switch small for Cluster QA task->SetUseTHnSparse(isUsingTHnSparse); //connect containers AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("GammaCaloDalitz_%i",trainConfig), TList::Class(), AliAnalysisManager::kOutputContainer,Form("GammaCaloDalitz_%i.root",trainConfig)); mgr->AddTask(task); mgr->ConnectInput(task,0,cinput); mgr->ConnectOutput(task,1,coutput); return; }
void DrawMLPoutputMovie( TFile* file, const TString& methodType, const TString& methodTitle ) { gROOT->SetBatch( 1 ); // define Canvas layout here! const Int_t width = 600; // size of canvas // this defines how many canvases we need TCanvas* c = 0; Float_t nrms = 4; Float_t xmin = -1.2; Float_t xmax = 1.2; Float_t ymin = 0; Float_t ymax = 0; Float_t maxMult = 6.0; Int_t countCanvas = 0; Bool_t first = kTRUE; TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring"; TDirectory *epochDir = (TDirectory*)file->Get( dirname ); if (!epochDir) { cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl; exit(1); } // now read all evolution histograms TIter keyItTit(epochDir->GetListOfKeys()); TKey *titkeyTit; while ((titkeyTit = (TKey*)keyItTit())) { if (!gROOT->GetClass(titkeyTit->GetClassName())->InheritsFrom("TH1F")) continue; TString name = titkeyTit->GetName(); if (!name.BeginsWith("convergencetest___")) continue; if (!name.Contains("_train_")) continue; // only for training so far if (name.EndsWith( "_B")) continue; // must be signal histogram if (!name.EndsWith( "_S")) { cout << "Big troubles with histogram: " << name << " -> should end with _S" << endl; exit(1); } // create canvas countCanvas++; TString ctitle = Form("TMVA response %s",methodTitle.Data()); c = new TCanvas( Form("canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 ); TH1F* sig = (TH1F*)titkeyTit->ReadObj(); sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) ); TString dataType = (name.Contains("_train_") ? "(training sample)" : "(test sample)"); // find background TString nbn = sig->GetName(); nbn[nbn.Length()-1] = 'B'; TH1F* bgd = dynamic_cast<TH1F*>(epochDir->Get( nbn )); if (bgd == 0) { cout << "Big troubles with histogram: " << bgd << " -> cannot find!" << endl; exit(1); } cout << "sig = " << sig->GetName() << endl; cout << "bgd = " << bgd->GetName() << endl; // set the histogram style TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd ); // normalise both signal and background TMVAGlob::NormalizeHists( sig, bgd ); // set only first time, then same for all plots if (first) { if (xmin == 0 && xmax == 0) { xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), bgd->GetMean() - nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmin() ); xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), bgd->GetMean() + nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmax() ); } ymin = 0; ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult; first = kFALSE; } // build a frame Int_t nb = 100; TString hFrameName(TString("frame") + methodTitle); TObject *o = gROOT->FindObject(hFrameName); if(o) delete o; TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), nb, xmin, xmax, nb, ymin, ymax ); frame->GetXaxis()->SetTitle( methodTitle + " response" ); frame->GetYaxis()->SetTitle("(1/N) dN^{ }/^{ }dx"); TMVAGlob::SetFrameStyle( frame ); // find epoch number (4th token) TObjArray* tokens = name.Tokenize("_"); TString es = ((TObjString*)tokens->At(4))->GetString(); if (!es.IsFloat()) { cout << "Big troubles in epoch parsing: \"" << es << "\" is not float" << endl; exit(1); } Int_t epoch = es.Atoi(); // eventually: draw the frame frame->Draw(); c->GetPad(0)->SetLeftMargin( 0.105 ); frame->GetYaxis()->SetTitleOffset( 1.2 ); // Draw legend TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() ); legend->SetFillStyle( 1 ); legend->AddEntry(sig,TString("Signal ") + dataType, "F"); legend->AddEntry(bgd,TString("Background ") + dataType, "F"); legend->SetBorderSize(1); legend->SetMargin( 0.15 ); legend->Draw("same"); TText* t = new TText(); t->SetTextSize( 0.04 ); t->SetTextColor( 1 ); t->SetTextAlign( 31 ); t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form( "Epoch: %i", epoch) ); // overlay signal and background histograms sig->Draw("samehist"); bgd->Draw("samehist"); // save to file TString dirname = "movieplots"; TString foutname = dirname + "/" + name; foutname.Resize( foutname.Length()-2 ); foutname.ReplaceAll("convergencetest___",""); foutname += ".gif"; cout << "storing file: " << foutname << endl; c->Update(); c->Print(foutname); } }
void bfcread_tagsBranch( const char *MainFile="/afs/rhic.bnl.gov/star/data/samples/gstar.tags.root", Int_t printEvent=1, const char *fname="qa_tags.out", Int_t fullPrint=0) { // start timer TStopwatch timer; timer.Start(); cout << endl << endl; cout << " bfcread_tagsBranch.C: input file = " << MainFile << endl; cout << " bfcread_tagsBranch.C: print event # " << printEvent << endl; cout << " bfcread_tagsBranch.C: output file = " << fname << endl; cout << " bfcread_tagsBranch.C: full printout = " << fullPrint << endl; cout << endl; ofstream fout(fname); fout << endl << endl; fout << " bfcread_tagsBranch.C: input file = " << MainFile << endl; fout << " bfcread_tagsBranch.C: print evt# = " << printEvent << endl; fout << " bfcread_tagsBranch.C: output file = " << fname << endl; fout << " bfcread_tagsBranch.C: full printout = " << fullPrint << endl; fout << endl; TFile *file = TFile::Open(MainFile); TTree *tree = (TTree*)file->Get("Tag"); cout <<" read file: " << file->GetName() << endl << endl; Int_t nEntries = tree->GetEntries(); cout << " Total # events = " << nEntries << endl; TObjArray *leaves = tree->GetListOfLeaves(); Int_t nLeaves = leaves->GetEntriesFast(); cout << " Total # leaves = " << nLeaves << endl; TString *tName = new TString(" "); TNamed *tableName=0; TObjArray *tagTable = new TObjArray; Int_t tableCount = 0; Int_t *tableIndex = new Int_t[nLeaves]; Int_t tagCount = 0; TBranch *branch=0; TLeaf *leaf=0; Int_t ndim =0; //count number of tag tables encoded in the TTree branch names for (Int_t l=0;l<nLeaves;l++) { leaf = (TLeaf*)leaves->UncheckedAt(l); tagCount+=leaf->GetNdata(); branch = leaf->GetBranch(); cout << "leaf # " << l << " br name = " << branch->GetName() << endl; //new tag table name if ( strstr(branch->GetName(), tName->Data()) == 0 ) { tName = new TString(branch->GetName()); tName->Resize(tName->Index(".")); //the tableName is encoded in the branch Name before the "." tableName = new TNamed(tName->Data(),"Tag"); tagTable->AddLast(tableName); tableCount++; } tableIndex[l]=tableCount-1; } cout << endl << " Total num tables(branches),tags = " << tableCount << " " << tagCount << endl << endl; Int_t *countTagsTable = new Int_t[tableCount]; Int_t *countLeavesTable = new Int_t[tableCount]; Float_t *sumTagsLeaf = new Float_t[nLeaves]; Int_t *countTagsLeaf = new Int_t[nLeaves]; // Now loop over leaves (to get values of tags) Int_t setBranch = -1; Int_t nowBranch = -1; for (Int_t l=0;l<nLeaves;l++) { leaf = (TLeaf*)leaves->UncheckedAt(l); branch = leaf->GetBranch(); ndim = leaf->GetNdata(); nowBranch = tableIndex[l]; //cout << " nowbranch, setBranch = " << // nowBranch << ", "<< setBranch << endl; Float_t RtableIndex=tableIndex[l]; if (nowBranch != setBranch){ setBranch=nowBranch; cout << " QAInfo: branch "; cout.width(2); cout << tableIndex[l] << " = "; cout.width(10); cout << ((TNamed*)tagTable->UncheckedAt(tableIndex[l]))->GetName(); cout << endl; fout << " QAInfo: branch "; fout.width(2); fout << RtableIndex << " = "; fout.width(10); fout << ((TNamed*)tagTable->UncheckedAt(tableIndex[l]))->GetName(); fout << endl; } countTagsTable[tableIndex[l]]+=leaf->GetNdata(); countLeavesTable[tableIndex[l]]++; countTagsLeaf[l]+=ndim; Float_t Rl=l; Float_t Rndim=ndim; cout << " QAInfo: leaf "; cout.width(3); cout << l << " has "; cout.width(1); cout << ndim << " tags:"; cout << endl; fout << " QAInfo: leaf "; fout.width(3); fout << Rl << " has "; fout.width(1); fout << Rndim << " tags:"; fout << endl; // loop over all events in each leaf for (Int_t nev=0; nev<nEntries; nev++) { branch->GetEntry(nev); // loop over all tags in each leaf for each event for (Int_t itag=0;itag<ndim;itag++) { Int_t ik = nev+1; if (ik==printEvent) { cout << " QAInfo: " << leaf->GetName(); if (ndim>1) cout << '['<<itag<<']'; cout << " = " << leaf->GetValue(itag) << endl; fout << " QAInfo: " << leaf->GetName(); if (ndim>1) fout << '['<<itag<<']'; fout << " = " << leaf->GetValue(itag) << endl; } sumTagsLeaf[l]+=leaf->GetValue(itag); } } } cout << endl << endl; fout << endl << endl; if (fullPrint == 1){ // loop over leaves again for printout at end for (Int_t m=0; m<nLeaves; m++){ leaf = (TLeaf*)leaves->UncheckedAt(m); branch = leaf->GetBranch(); ndim = leaf->GetNdata(); cout << " QAInfo: branch "; cout.width(2); cout << tableIndex[m] << " = "; cout.width(10); cout << ((TNamed*)tagTable->UncheckedAt(tableIndex[m]))->GetName(); cout << ", leaf "; cout.width(3); cout << m << " = "; cout.width(24); cout << leaf->GetName(); cout << ", #tags = "; cout.width(1); cout << ndim; cout << endl; Float_t RtableIndex=tableIndex[m]; Float_t Rm=m; Float_t Rndim=ndim; fout << " QAInfo: branch "; fout.width(2); fout << RtableIndex << " = "; fout.width(10); fout << ((TNamed*)tagTable->UncheckedAt(tableIndex[m]))->GetName(); fout << ", leaf "; fout.width(3); fout << Rm << " = "; fout.width(24); fout << leaf->GetName(); fout << ", #tags = "; fout.width(1); fout << Rndim; fout << endl; } } cout << endl << endl; fout << endl << endl; // loop over leaves again for printout at end of averages cout << " QAInfo: each leaf's avg over all tags,evts: " << endl; fout << " QAInfo: each leaf's avg over all tags,evts: " << endl; for (Int_t m=0; m<nLeaves; m++){ leaf = (TLeaf*)leaves->UncheckedAt(m); sumTagsLeaf[m]/=countTagsLeaf[m]*nEntries; cout << " QAInfo: avg leaf #"; cout.width(2); cout << m << ", "; cout.width(23); cout << leaf->GetName() << " = "; cout.width(12); cout << sumTagsLeaf[m]; cout << endl; Float_t Rm=m; fout << " QAInfo: avg leaf #"; fout.width(2); fout << Rm << ", "; fout.width(23); fout << leaf->GetName() << " = "; fout.width(12); fout << sumTagsLeaf[m]; fout << endl; } cout << endl << endl; fout << endl << endl; // loop over all tables for (Int_t m=0; m<tableCount; m++){ cout << " QAInfo: branch(table) "; cout.width(10); cout << ((TNamed*)tagTable->UncheckedAt(m))->GetName() << " has "; cout.width(4); cout << countLeavesTable[m] << " leaves,"; cout.width(4); cout << countTagsTable[m] << " tags" << endl; Float_t RcountLeavesTable=countLeavesTable[m]; Float_t RcountTagsTable=countTagsTable[m]; fout << " QAInfo: branch(table) "; fout.width(10); fout << ((TNamed*)tagTable->UncheckedAt(m))->GetName() << " has "; fout.width(4); fout << RcountLeavesTable << " leaves,"; fout.width(4); fout << RcountTagsTable << " tags" << endl; } cout << endl << endl; fout << endl << endl; Float_t RnEntries=nEntries; Float_t RtableCount=tableCount; Float_t RnLeaves=nLeaves; Float_t RtagCount=tagCount; cout << " QAInfo: tot num events = " << nEntries << endl; fout << " QAInfo: tot num events = " << RnEntries << endl; cout << " QAInfo: tot num branches = " << tableCount << endl; fout << " QAInfo: tot num branches = " << RtableCount << endl; cout << " QAInfo: tot num leaves = " << nLeaves << endl; fout << " QAInfo: tot num leaves = " << RnLeaves << endl; cout << " QAInfo: tot num tags = " << tagCount << endl; fout << " QAInfo: tot num tags = " << RtagCount << endl; // stop timer and print results timer.Stop(); cout<< endl << endl <<"RealTime="<<timer.RealTime()<< " seconds, CpuTime="<<timer.CpuTime()<<" seconds"<<endl; //cleanup file->Close(); fout.close(); }