void pv_dist(const string& fFile, const string& fTitle, const string& fNameExt) { TH1F *h; TFile file(fFile.c_str()); TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis"); TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices"); h = (TH1F*)subDir->Get("h_NofPVs"); string name = h->GetName(); string fileName = name + "__" + fNameExt + ".png"; h->SetTitle(fTitle.c_str()); TCanvas *c = new TCanvas("c","",1120,800); c->cd(); h->SetLineWidth(2); h->Draw(); c->SetLogy(); c->SaveAs(fileName.c_str()); delete c; }
std::pair<TH3F*,TH3F*> getEffHists(const char *file, const char *dirC, const char *histN, const char *histD){ TFile *efile = new TFile(file,"read"); TDirectoryFile *efileDIR = (TDirectoryFile*) efile->GetDirectory(dirC); TIter next(efileDIR->GetListOfKeys()); TKey *key; Char_t name[100]; TH3F *hpneff3d=0; TH3F *hpdeff3d=0; while ((key=(TKey*)next())) { sprintf(name,"%s",key->GetName()); if(strcmp((key->GetName()),(histN))==0){ //cout<<"[getEffHists] Your numerator for Eff "<<name<<endl; hpneff3d = (TH3F*) efileDIR->Get(name); } if(strcmp((key->GetName()),(histD))==0){ //cout<<"[getEffHists] Your denominator for Eff "<<name<<endl; hpdeff3d = (TH3F*) efileDIR->Get(name); } } //efileDIR->Close(); //efile->Close(); return std::pair<TH3F*,TH3F*>(hpneff3d,hpdeff3d); }
void overlay_plots(const string& fFile0, const string& fFile1, const double fYmax, const string& fPlot, const string& fLegendEnt1, const string& fLegendEnt2, const string& fName) { TProfile *p[2]; TFile file0(fFile0.c_str()); TDirectoryFile *subDir = (TDirectoryFile*)file0.Get("offsetAnalysis"); p[0] = (TProfile*)subDir->Get(fPlot.c_str()); TFile file1(fFile1.c_str()); subDir = (TDirectoryFile*)file1.Get("offsetAnalysis"); p[1] = (TProfile*)subDir->Get(fPlot.c_str()); p[0]->SetTitleOffset(1.5,"Y"); p[0]->GetXaxis()->SetTitleSize(0.04); p[0]->GetYaxis()->SetTitleSize(0.04); double ymax = ((p[0]->GetMaximum())>(p[1]->GetMaximum())) ? p[0]->GetMaximum() : p[1]->GetMaximum(); p[0]->GetYaxis()->SetRangeUser(0.,fYmax); TCanvas *c = new TCanvas("c","",800,800); c->cd(); p[0]->SetLineWidth(3); p[0]->SetLineColor(kRed); p[0]->SetFillColor(kRed); p[0]->Draw("hist"); p[1]->SetLineWidth(3); p[1]->SetLineColor(kBlack); p[1]->SetMarkerStyle(20); p[1]->SetMarkerColor(kBlack); p[1]->Draw("sames"); TLegend *legend = new TLegend(.57,.77,.9,.87); legend->SetBorderSize(1); legend->SetFillColor(0); // legend->SetFillStyle(0); legend->SetMargin(0.12); legend->AddEntry(p[0],fLegendEnt1.c_str(),"l"); legend->AddEntry(p[1],fLegendEnt2.c_str(),"l"); legend->Draw(); TLatex l; l.SetTextAlign(12); l.SetTextSize(0.04); l.SetTextFont(62); l.SetNDC(); l.DrawLatex(0.15,0.85,"CMS 2009 Preliminary"); string fileName = fName; c->SetGridy(); c->SaveAs(fileName.c_str()); delete legend; delete c; }
int main (int argc, char *argv[]) { map<string, string> opt; vector<string> argVector; parseOptions (argc, argv, opt, argVector); if (argVector.size () != 1 || opt.count ("help")) { printHelp (argv[0]); return 0; } TFile *fin; if (!(fin = TFile::Open (argVector.at (0).c_str (), "update"))) { cout << "Failed to open " << argVector.at (0) << "!" << endl; return 0; } TIter next0 (fin->GetListOfKeys ()); TObject *obj0; TH1D *cutFlow = 0; TDirectoryFile *dir = 0; while ((obj0 = next0 ())) { string obj0Class = ((TKey *) obj0)->GetClassName (), obj0Name = obj0->GetName (); if (obj0Class == "TDirectoryFile") { dir = (TDirectoryFile *) fin->Get (obj0Name.c_str ()); TIter next1 (dir->GetListOfKeys ()); TObject *obj1; while ((obj1 = next1 ())) { string obj1Class = ((TKey *) obj1)->GetClassName (), obj1Name = obj1->GetName (); if (obj1Class == "TH1D" && obj1Name.length () >= 7 && ((obj1Name.substr (obj1Name.length () - 7, 7) == "CutFlow" || obj1Name.substr (obj1Name.length () - 7, 7) == "cutFlow") || (obj1Name.length () >= 9 && (obj1Name.substr (obj1Name.length () - 9, 9) == "Selection" || obj1Name.substr (obj1Name.length () - 9, 9) == "selection")) || (obj1Name.length () >= 8 && (obj1Name.substr (obj1Name.length () - 8, 8) == "MinusOne" || obj1Name.substr (obj1Name.length () - 8, 8) == "minusOne"))) && !dir->Get ((obj1Name + "LowerLimit").c_str ()) && !dir->Get ((obj1Name + "UpperLimit").c_str ())) { cutFlow = (TH1D *) dir->Get (obj1Name.c_str ()); cutFlow->SetDirectory (0); getLimits (cutFlow, dir); } } } } fin->Close (); return 0; }
Double_t MakeHistsForSlides(TString goodFile, TString badFile, TString rootFile) { //Extracting the histogram TFile* f = TFile::Open(rootFile); TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal")); TList* list = (TList*)(dirFile->Get("histogram")); TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude")); //Getting a Good Cell TH1D* goodC = new TH1D(); ifstream myFile(goodFile); TString title = ""; const int num = 500; if(myFile.is_open()) { string line = ""; std::getline(myFile,line); int index = 0; double chi2 = 0.0; while(myFile >> index >> chi2 && index < num) { //cout << index << "\t" << chi2 << endl; title = Form("Energy distribution of Cell %d",index); TH1D* goodCell = cellVAmplitude->ProjectionY("goodCell", index+1,index+1); goodC = (TH1D*)goodCell->Clone(); } }
void plotProducer2(const string& fFile, const string& fPlot, const string& fNameExt, const string& fExt, const string& fSwitch) { TH2F *h; TFile file(fFile.c_str()); TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis"); TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices"); h = (TH2F*)subDir->Get(fPlot.c_str()); string name = h->GetName(); string fileName = name + "__" + fNameExt + "." + fExt; TCanvas *c = new TCanvas("c","",1120,800); c->cd(); h->Draw(fSwitch.c_str()); c->SaveAs(fileName.c_str()); delete c; }
void plotProducer(const string& fFile, const string& fPlot, const string& fNameExt, const string& fExt, const string& fSwitch) { TH1F *h; TFile file(fFile.c_str()); TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis"); TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices"); h = (TH1F*)subDir->Get(fPlot.c_str()); string name = h->GetName(); string fileName = name + "__" + fNameExt + "." + fExt; TCanvas *c = new TCanvas("c","",1120,800); c->cd(); //h->SetLineWidth(2); h->Draw(); if ( fSwitch.find("log") != string::npos ) c->SetLogy(); c->SaveAs(fileName.c_str()); delete c; }
int GetCoefficient(TString txtFile, TString rootFile) { //Extracting the histogram TFile* f = TFile::Open(rootFile); TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal")); TList* list = (TList*)(dirFile->Get("histogram")); TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude")); //cout << __FILE__ << __LINE__ << endl; //Cell Tower range to analyse const Int_t CVALow = 0; const Int_t CVAHigh = 17670; //cout << __FILE__ << __LINE__ << endl; //Obtaining a histogram of the Good cells. TList* goodHistList = new TList; ifstream goodFile(txtFile); int numCells = 0; if(goodFile.is_open()) { //cout << __FILE__ << __LINE__ << endl; string line = ""; std::getline(goodFile,line); int index = 0; double chi2 = 0.0; //cout << __FILE__ << __LINE__ << endl; //for(index = 0; index < 3; index++) while(goodFile >> index >> chi2) { //cout << Form("cell%d",index) << endl; TH1D* cell = cellVAmplitude->ProjectionY(Form("cell%d",index),index+1,index+1); goodHistList->Add(cell); numCells++; } }
// Noise section Stat_t AnalysisClass::doHisto(Char_t * Variable, Char_t *SubDetName, Char_t *Layer,Char_t *label){ TH1 *hHisto=0; if (debug) cout << d1->GetTitle() << " " << Variable << " " << SubDetName << endl; pPar[0]=0; pPar[1]=0; TIter it(d1->GetListOfKeys()); TObject * o; while ( (o = it())) { TObject * d = d1->Get(o->GetName()); if(d->IsA()->InheritsFrom("TDirectory") && strstr(d->GetName(),SubDetName)){ if (debug) cout << "Found SubDet " << SubDetName << endl; TIter it2(((TDirectoryFile * )d)->GetListOfKeys()); TObject *o2; while( ( o2 = it2()) ){ TObject *d2 = ((TDirectoryFile * )d)->Get(o2->GetName()); if(d2->IsA()->InheritsFrom("TDirectory") && strstr(d2->GetName(),Layer) ){ if (debug) cout << "Found Layer" << Layer << endl; TIter it3(((TDirectoryFile * )d2)->GetListOfKeys()); TObject *o3; while( ( o3 = it3()) ){ TObject *d3 = ((TDirectoryFile * )d2)->Get(o3->GetName()); if(strstr(d3->GetName(),Variable) && strstr(d3->GetName(),label)){ hHisto = (TH1*) d3; if(hHisto->GetEntries()!=0) { pPar[0]=hHisto->GetMean(); pPar[1]=hHisto->GetRMS(); if (debug) cout << "Histo Title " << hHisto->GetTitle() << " mean: " << hHisto->GetMean() << " rms: " << hHisto->GetRMS() << " " << hHisto->GetEntries() << endl; } else{ cout<<"Empty Histogram "<< hHisto->GetTitle() << endl; pPar[0]=-10; pPar[1]=-10; } } } } } } } return hHisto->GetEntries(); }
Stat_t AnalysisClass::doFit(Int_t RunNumber,Char_t *Variable, Char_t *SubDetName, Char_t *Layer,Char_t *label){ TH1 *htoFit=0; pLanGausS[0]=0; pLanGausS[1]=0; pLanGausS[2]=0; pLanGausS[3]=0; epLanGausS[0]=0; epLanGausS[1]=0; epLanGausS[2]=0; epLanGausS[3]=0; if (debug) cout << d1->GetTitle() << " " << Variable << " " << SubDetName << endl; pPar[0]=0; pPar[1]=0; TIter it(d1->GetListOfKeys()); TObject * o; while ( (o = it())) { TObject * d = d1->Get(o->GetName()); if(d->IsA()->InheritsFrom("TDirectory") && strstr(d->GetName(),SubDetName)){ if (debug) cout << "Found " << SubDetName << endl; TIter it2(((TDirectoryFile * )d)->GetListOfKeys()); TObject *o2; while( ( o2 = it2()) ){ TObject *d2 = ((TDirectoryFile * )d)->Get(o2->GetName()); if(d2->IsA()->InheritsFrom("TDirectory") && strstr(d2->GetName(),Layer) ){ if (debug) cout << "Found Layer" << Layer << endl; TIter it3(((TDirectoryFile * )d2)->GetListOfKeys()); TObject *o3; while( ( o3 = it3()) ){ TObject *d3 = ((TDirectoryFile * )d2)->Get(o3->GetName()); if(strstr(d3->GetName(),Variable) && strstr(d3->GetName(),label)){ htoFit = (TH1*) d3; if (debug) cout << "Found " << Variable << endl; if (htoFit->GetEntries()!=0) { cout<<"Fitting "<< htoFit->GetTitle() <<endl; // Setting fit range and start values Double_t fr[2]; Double_t sv[4], pllo[4], plhi[4]; fr[0]=0.5*htoFit->GetMean(); fr[1]=3.0*htoFit->GetMean(); // (EM) parameters setting good for signal only Int_t imax=htoFit->GetMaximumBin(); Double_t xmax=htoFit->GetBinCenter(imax); Double_t ymax=htoFit->GetBinContent(imax); Int_t i[2]; Int_t iArea[2]; i[0]=htoFit->GetXaxis()->FindBin(fr[0]); i[1]=htoFit->GetXaxis()->FindBin(fr[1]); iArea[0]=htoFit->GetXaxis()->FindBin(fr[0]); iArea[1]=htoFit->GetXaxis()->FindBin(fr[1]); Double_t AreaFWHM=htoFit->Integral(iArea[0],iArea[1],"width"); sv[1]=xmax; sv[2]=htoFit->Integral(i[0],i[1],"width"); sv[3]=AreaFWHM/(4*ymax); sv[0]=sv[3]; plhi[0]=25.0; plhi[1]=200.0; plhi[2]=1000000.0; plhi[3]=50.0; pllo[0]=1.5 ; pllo[1]=10.0 ; pllo[2]=1.0 ; pllo[3]= 1.0; // create different landau+gaussians for different runs Char_t FunName[100]; sprintf(FunName,"FitfcnLG_%s%d",htoFit->GetName(),fRun); TF1 *ffitold = (TF1*)gROOT->GetListOfFunctions()->FindObject(FunName); if (ffitold) delete ffitold; langausFit = new TF1(FunName,langaufun,fr[0],fr[1],4); langausFit->SetParameters(sv); langausFit->SetParNames("Width","MP","Area","GSigma"); for (Int_t i=0; i<4; i++) { langausFit->SetParLimits(i,pllo[i],plhi[i]); } htoFit->Fit(langausFit,"R0"); // "R" fit in a range,"0" quiet fit langausFit->SetRange(fr[0],fr[1]); pLanGausS=langausFit->GetParameters(); epLanGausS=langausFit->GetParErrors(); chi2GausS =langausFit->GetChisquare(); // obtain chi^2 nDofGausS = langausFit->GetNDF(); // obtain ndf Double_t sPeak, sFWHM; langaupro(pLanGausS,sPeak,sFWHM); pLanConv[0]=sPeak; pLanConv[1]=sFWHM; cout << "langaupro: max " << sPeak << endl; cout << "langaupro: FWHM " << sFWHM << endl; TCanvas *cAll = new TCanvas("Fit",htoFit->GetTitle(),1); Char_t fitFileName[60]; sprintf(fitFileName,"Fits/Run_%d/%s/Fit_%s.png",RunNumber,SubDetName,htoFit->GetTitle()); htoFit->Draw("pe"); htoFit->SetStats(100); langausFit->Draw("lsame"); gStyle->SetOptFit(1111111); cAll->Print(fitFileName,"png"); } else { pLanGausS[0]=-10; pLanGausS[1]=-10; pLanGausS[2]=-10; pLanGausS[3]=-10; epLanGausS[0]=-10; epLanGausS[1]=-10; epLanGausS[2]=-10; epLanGausS[3]=-10; pLanConv[0]=-10; pLanConv[1]=-10; chi2GausS=-10; nDofGausS=-10; } } } } } } } return htoFit->GetEntries(); }
void advancedNoiseAnalysis( unsigned int runNumber, unsigned int loop = 1) { string inputFileName = "./histo/run00" + toString( runNumber ) + "-ped-histo.root"; string outputFileName = "./histo/run00" + toString( runNumber ) + "-adv-noise.root"; // before opening the input and the output files, try to see if they // are not opened yet and in case close them before continue TList * listOfOpenedFile = (TList*) gROOT->GetListOfFiles(); for ( int i = 0; i < listOfOpenedFile->GetSize() ; ++i ) { TFile * file = (TFile*) listOfOpenedFile->At( i ) ; TString fileName(file->GetName()); TString inputFileName1( inputFileName.c_str() ); TString outputFileName1( outputFileName.c_str() ); if ( ( fileName.Contains( inputFileName1 ) ) || ( inputFileName1.Contains( fileName ) ) || ( fileName.Contains( outputFileName1 ) ) || ( outputFileName1.Contains( fileName ) ) ) { cout << "Closing " << fileName << " before reopen " << endl; file->Close(); } } // close also all the previously opened canvas TList * listOfOpenedCanvas = (TList*) gROOT->GetListOfCanvases(); for ( int i = 0 ; i < listOfOpenedCanvas->GetSize() ; ++i ) { TCanvas * canvas = (TCanvas*) listOfOpenedCanvas->At( i ); TString canvasName2 = canvas->GetName(); if ( canvasName2.Contains( "det" ) ) { canvas->Close(); } } // now safely open the file TFile * inputFile = TFile::Open( inputFileName.c_str() ) ; TFile * outputFile = TFile::Open( outputFileName.c_str(), "RECREATE") ; TList * outputHistoList = new TList; // look into the inputFile for a folder named string pedeProcessorFolderName = "PedestalAndNoiseCalculator"; TDirectoryFile * pedeProcessorFolder = (TDirectoryFile*) inputFile->Get( pedeProcessorFolderName.c_str() ); if ( pedeProcessorFolder == 0 ) { cerr << "No pedestal processor folder found in file " << inputFileName << endl; return ; } // this folder should contain one folder for each loop. string loopFolderName = "loop-" + toString( loop ); TDirectoryFile * loopFolder = (TDirectoryFile *) pedeProcessorFolder->Get( loopFolderName.c_str() ); if ( loopFolder == 0 ) { cerr << "No " << loopFolderName << " found in file " << inputFileName << endl; return ; } // guess the number of sensors from the number of subfolder in the loopfolder size_t nDetector = loopFolder->GetListOfKeys()->GetSize(); cout << "This file contains " << nDetector << " detectors" << endl; // prepare arrays to store the mean and the rms of the noise distribution if ( noiseMean == NULL ) { delete [] noiseMean; noiseMean = NULL; } if ( noiseRMS == NULL ) { delete [] noiseRMS; noiseRMS = NULL; } if ( channel == NULL ) { delete [] channel; channel = NULL; } noiseMean = new double[ nDetector * kNChan ]; noiseRMS = new double[ nDetector * kNChan ]; channel = new double[ kNChan ]; string canvasName = "comparison"; string canvasTitle = "Noise comparison"; TCanvas * comparisonCanvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); comparisonCanvas->Divide(1,2); TPad * topPad = (TPad*) comparisonCanvas->cd(1); topPad->Divide( nDetector ); TPad * middlePad = (TPad *) comparisonCanvas->cd(2); middlePad->Divide( kNChan ); // for each detector we have to get the noise map and to prepare 4 // separe histos and maps for ( unsigned int iDetector = 0; iDetector < nDetector; iDetector++ ) { // get the noise map. string noiseMapName = "detector-" + toString( iDetector ) ; noiseMapName += "/NoiseMap-d" + toString( iDetector ) ; noiseMapName += "-l" + toString( loop ) ; TH2D * noiseMap = ( TH2D* ) loopFolder->Get( noiseMapName.c_str() ); // create a folder in the output file TDirectory * subfolder = outputFile->mkdir( string( "detector_" + toString( iDetector ) ).c_str(), string( "detector_" + toString( iDetector ) ).c_str() ); subfolder->cd(); string canvasName = "det" + toString( iDetector ); string canvasTitle = "Detector " + toString( iDetector ); TCanvas * canvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); canvas->Divide( kNChan, 2 ); // ok now start the loop on channels for ( size_t iChan = 0 ; iChan < kNChan ; ++iChan ) { if ( iDetector == 0 ) channel[iChan] = iChan - 0.5; string tempName = "NoiseMap_d" + toString( iDetector ) + "_l" + toString( loop ) + "_ch" + toString( iChan ) ; string tempTitle = "NoiseMap Det. " + toString( iDetector ) + " - Ch. " + toString( iChan ) ; TH2D * noiseMapCh = new TH2D ( tempName.c_str() , tempTitle.c_str(), kXPixel / kNChan , -0.5 + xLimit[ iChan ] , -0.5 + xLimit[ iChan + 1 ], kYPixel, -0.5, -0.5 + kYPixel ); noiseMapCh->SetXTitle("X [pixel]"); noiseMapCh->SetYTitle("Y [pixel]"); noiseMapCh->SetZTitle("Noise [ADC]"); noiseMapCh->SetStats( false ); outputHistoList->Add( noiseMapCh ) ; tempName = "NoiseDist_d" + toString( iDetector ) + "_l" + toString( loop ) + "_ch" + toString( iChan ) ; tempTitle = "NoiseDist Det. " + toString( iDetector ) + " - Ch. " + toString( iChan ) ; TH1D * noiseDistCh = new TH1D( tempName.c_str(), tempTitle.c_str(), 50, 0., 10. ); noiseDistCh->SetXTitle("Noise [ADC]"); noiseDistCh->SetLineColor( kColor[iDetector] ); noiseDistCh->SetLineStyle( iChan + 2 ); noiseDistCh->SetLineWidth( 2 ); outputHistoList->Add( noiseDistCh ); // let's start looping on pixels now for ( size_t yPixel = 1 ; yPixel <= kYPixel ; ++yPixel ) { for ( size_t xPixel = xLimit[ iChan ] + 1; xPixel <= xLimit[ iChan +1 ] ; ++xPixel ) { double noise = noiseMap->GetBinContent( xPixel , yPixel ); noiseMapCh->Fill( xPixel - 1 , yPixel - 1, noise ); noiseDistCh->Fill( noise ); } } canvas->cd( iChan + 1 ) ; noiseMapCh->Draw("colz"); canvas->cd( iChan + kNChan + 1 ); noiseDistCh->Draw(); topPad->cd( iDetector + 1 ); if ( iChan == 0 ) { noiseDistCh->Draw(); } else { noiseDistCh->Draw("same"); } middlePad->cd( iChan + 1 ); if ( iDetector == 0 ) { noiseDistCh->Draw(); } else { noiseDistCh->Draw("same"); } noiseMean[ kNChan * iDetector + iChan ] = noiseDistCh->GetMean(); noiseRMS[ kNChan * iDetector + iChan ] = noiseDistCh->GetRMS(); } canvas->Write(); } canvasName = "summary"; canvasTitle = "Noise summary"; TCanvas * summaryCanvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); summaryCanvas->SetGridx(1); TLegend * legend = new TLegend(0.5, 4.8, 1.5, 4.3,"","br");; for ( size_t iDetector = 0 ; iDetector < nDetector ; ++iDetector ) { TGraphErrors * gr = new TGraphErrors( kNChan, channel, &noiseMean[ iDetector * kNChan ], NULL, &noiseRMS[ iDetector * kNChan ] ); gr->SetName( string( "NoisePerChannel_d" + toString( iDetector )).c_str()); gr->SetTitle(string("Detector " + toString( iDetector )).c_str()); gr->GetXaxis()->SetTitle("Channel #"); gr->GetYaxis()->SetTitle("Noise [ADC]"); gr->GetXaxis()->SetNdivisions( 5 ); gr->GetXaxis()->SetLabelSize( 0 ); gr->SetMarkerStyle( iDetector + 1 ); gr->SetMarkerColor( kColor[iDetector] ); gr->SetLineColor( kColor[iDetector] ); gr->SetLineWidth( 2 ); legend->AddEntry( gr, string("Detector " + toString( iDetector )).c_str(), "LP"); if ( iDetector == 0 ) { gr->Draw("ALP"); } else { gr->Draw("LP"); } } legend->Draw(); for ( size_t iChan = 0 ; iChan < kNChan ; ++iChan ) { TPaveLabel * label = new TPaveLabel( iChan - 0.75 , 3.2 , iChan -0.25 , 3, string("Ch " + toString( iChan ) ).c_str()); label->Draw(); } summaryCanvas->Write(); comparisonCanvas->Write(); outputHistoList->Write(); }
void RebinCFContainer(const char *infile="AnalysisResults.root",Int_t rebinVar=0, Int_t myEff=3, const char * name="Nch"){ gSystem->SetIncludePath("-I. -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_PHYSICS -I$ALICE_PHYSICS/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/RAW -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_PHYSICS/PWGPP -g"); // gROOT->LoadMacro("AliSingleTrackEffCuts.cxx++g"); // gROOT->LoadMacro("AliCFSingleTrackEfficiencyTask.cxx++g"); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetPalette(1); gStyle->SetCanvasColor(0); gStyle->SetFrameFillColor(0); gStyle->SetOptTitle(0); TFile* file = TFile::Open(infile,"read"); TDirectoryFile *d = 0; AliCFContainer *dataIni = 0; d = (TDirectoryFile*)file->Get(Form("PWGPP_CFSingleTrack")); if(!d) { cout<<" no directory "<<endl; return; } dataIni = (AliCFContainer*) (d->Get(Form("container%s",name))); if(!dataIni){ cout <<" no container"<<endl; } // // Do an slice of the container to make sure to remove outliers // const UInt_t ipt = 0; const UInt_t ieta = 1; const UInt_t iphi = 2; const UInt_t itheta = 3; const UInt_t izvtx = 4; const UInt_t imult = 5; const UInt_t icent = 6; Int_t nvars = 7; Int_t* ivarSlice = new Int_t[nvars]; ivarSlice[0]= ipt; ivarSlice[1] = ieta; ivarSlice[2] = iphi; ivarSlice[3] = itheta; ivarSlice[4]= izvtx; ivarSlice[5] = imult; ivarSlice[6] = icent; Double_t *mins = new Double_t[nvars]; Double_t *maxs = new Double_t[nvars]; mins[ipt] = ptmin; maxs[ipt] = ptmax; mins[ieta] = etamin; maxs[ieta] = etamax; mins[iphi] = phimin; maxs[iphi] = phimax; mins[itheta] = thetamin; maxs[itheta] = thetamax; mins[izvtx] = zvtxmin; maxs[izvtx] = zvtxmax; mins[imult] = multmin; maxs[imult] = multmax; mins[icent] = centmin; maxs[icent] = centmax; AliCFContainer *data = (AliCFContainer*)dataIni->MakeSlice(nvars,ivarSlice,mins,maxs); cout<< " ... slice done"<<endl; cout<< " the new container has "<< data->GetNStep() << " steps"<<endl; // // *********** NUMERATOR // AliCFGridSparse* gridSparse = 0; if( myEff == 1 ) gridSparse = (AliCFGridSparse*)data->GetGrid(1); // GenAcc else if( myEff == 2 ) gridSparse = (AliCFGridSparse*)data->GetGrid(6); // Rec (acc + cuts) draw reco properties else if( myEff == 3 ) gridSparse = (AliCFGridSparse*)data->GetGrid(7); // RecPID else if( myEff == 4 ) gridSparse = (AliCFGridSparse*)data->GetGrid(3); // Rec (no cuts) else if( myEff == 5 ) gridSparse = (AliCFGridSparse*)data->GetGrid(4); // RecAcc else if( myEff == 6 ) gridSparse = (AliCFGridSparse*)data->GetGrid(5); // Rec (acc + cuts) draw kine properties THnSparse* numData = (THnSparse*)gridSparse->GetGrid(); // method 2: defining a new THnSparse changing only the axis of interest Printf("Method 2 "); THnSparse* newnumData = (THnSparse*)numData->Clone("numNew"); newnumData->Reset(); Int_t nLimits=0; Double_t* newLimits =0; TString varname=""; if(rebinVar==0) { varname="pt"; nLimits = 17; newLimits = new Double_t[nLimits+1]; newLimits[0]=0; newLimits[1]=0.25; newLimits[2]=0.5; newLimits[3]=0.75; newLimits[4]=1; newLimits[5]=1.5; newLimits[6]=2; newLimits[7]=2.5; newLimits[8]=3; newLimits[9]=4; newLimits[10]=5; newLimits[11]=6; newLimits[12]=7; newLimits[13]=8; newLimits[14]=10; newLimits[15]=12; newLimits[16]=14; newLimits[17]=16; } else if (rebinVar==1) { varname="eta"; nLimits = 9; newLimits = new Double_t[nLimits+1]; newLimits[0]=-0.9; newLimits[1]=-0.7; newLimits[2]=-0.5; newLimits[3]=-0.3; newLimits[4]=-0.1; newLimits[5]=0.1; newLimits[6]=0.3; newLimits[7]=0.5; newLimits[8]=0.7; newLimits[9]=0.9; } else if (rebinVar==2) { varname="phi"; nLimits = 9; newLimits = new Double_t[nLimits+1]; for(Int_t i=0; i<=nLimits; i++) newLimits[i]=(Double_t)phimin + (phimax-phimin)/nLimits*(Double_t)i ; } const Int_t nnewLimits = nLimits; TAxis* axis = (TAxis*)newnumData->GetAxis(rebinVar); axis->Set(nnewLimits,newLimits); newnumData->SetBinEdges(rebinVar,newLimits); newnumData->RebinnedAdd(numData, 1); // checking the bin contents TH1D* h1 = (TH1D*)numData->Projection(rebinVar); Float_t sum = 0; Float_t sumnew = 0; Printf("Original THnSparse"); for (Int_t ibin = 1; ibin<=h1->GetNbinsX(); ibin++){ Printf("ibin = %d, low edge = %f, content = %f",ibin,h1->GetBinLowEdge(ibin),h1->GetBinContent(ibin)); sum+=h1->GetBinContent(ibin); } Printf("THnSparse changing only one axis"); TH1D* h2num = (TH1D*)newnumData->Projection(rebinVar); for (Int_t ibin = 1; ibin<=h2num->GetNbinsX(); ibin++){ Printf("ibin = %d, low edge = %f, content = %f",ibin,h2num->GetBinLowEdge(ibin),h2num->GetBinContent(ibin)); sumnew+=h2num->GetBinContent(ibin); } Printf("sum = %f, sumnew = %f",sum, sumnew); // // *********** DENOMINATOR RECPID // Printf("DENOMINATOR"); AliCFGridSparse* gridSparse2 = 0; if( myEff == 1 ) gridSparse2 = (AliCFGridSparse*)data->GetGrid(0); // LimAcc else gridSparse2 = (AliCFGridSparse*)data->GetGrid(1); // GenAcc THnSparse* denData = (THnSparse*)gridSparse2->GetGrid(); // method 2: defining a new THnSparse changing only the axis of interest Printf("Method 2 "); THnSparse* newdenData = (THnSparse*)denData->Clone("denNew"); newdenData->Reset(); TAxis* axis2 = (TAxis*)newdenData->GetAxis(rebinVar); axis2->Set(nnewLimits,newLimits); newdenData->SetBinEdges(rebinVar,newLimits); newdenData->RebinnedAdd(denData, 1); // checking the bin contents TH1D* h1d = (TH1D*)denData->Projection(rebinVar); sum = 0; sumnew = 0; Printf("Original THnSparse"); for (Int_t ibin = 1; ibin<=h1d->GetNbinsX(); ibin++){ Printf("ibin = %d, low edge = %f, content = %f",ibin,h1d->GetBinLowEdge(ibin),h1d->GetBinContent(ibin)); sum+=h1d->GetBinContent(ibin); } Printf("THnSparse changing only one axis"); TH1D* h2 = (TH1D*)newdenData->Projection(rebinVar); for (Int_t ibin = 1; ibin<=h2->GetNbinsX(); ibin++){ Printf("ibin = %d, low edge = %f, content = %f",ibin,h2->GetBinLowEdge(ibin),h2->GetBinContent(ibin)); sumnew+=h2->GetBinContent(ibin); } Printf("sum = %f, sumnew = %f",sum, sumnew); TH1D* heff = (TH1D*)h2num->Clone("heff"); heff->Divide(h2num, h2,1,1,"B"); // heff->GetXaxis()->SetRangeUser(0,23.5); TFile* fout = NULL; if( myEff == 1 ) { fout = new TFile(Form("efficiency_STE_GenAcc_over_LimAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE"); heff->Write(Form("h_%s_effCFLimAccGenAcc",varname.Data())); h2num->Write(Form("h_%s_LimAcc",varname.Data())); h2->Write(Form("h_%s_GenAcc",varname.Data())); } else if( myEff == 2 ) { fout = new TFile(Form("efficiency_STE_RecPPR_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE"); heff->Write(Form("h_%s_effCFRecPPRGenAcc",varname.Data())); h2num->Write(Form("h_%s_RecPPR",varname.Data())); h2->Write(Form("h_%s_GenAcc",varname.Data())); } else if( myEff == 3 ) { fout = new TFile(Form("efficiency_STE_RecPID_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE"); heff->Write(Form("h_%s_effCFRecPIDGenAcc",varname.Data())); h2num->Write(Form("h_%s_RecPID",varname.Data())); h2->Write(Form("h_%s_GenAcc",varname.Data())); } else if( myEff == 4 ) { fout = new TFile(Form("efficiency_STE_Rec_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE"); heff->Write(Form("h_%s_effCFRecGenAcc",varname.Data())); h2num->Write(Form("h_%s_Rec",varname.Data())); h2->Write(Form("h_%s_GenAcc",varname.Data())); } else if( myEff == 5 ) { fout = new TFile(Form("efficiency_STE_RecAcc_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE"); heff->Write(Form("h_%s_effCFRecAccGenAcc",varname.Data())); h2num->Write(Form("h_%s_RecAcc",varname.Data())); h2->Write(Form("h_%s_GenAcc",varname.Data())); } else if( myEff == 6 ) { fout = new TFile(Form("efficiency_STE_RecPPRKine_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE"); heff->Write(Form("h_%s_effCFRecPPRKineGenAcc",varname.Data())); h2num->Write(Form("h_%s_RecPPRKine",varname.Data())); h2->Write(Form("h_%s_GenAcc",varname.Data())); } fout->Close(); }
void readMCPerform(TString filename="QAresults_AOD.root", Int_t drawOnlyDzerDplus = 1, Int_t runNumber=-1) { const Int_t totTrending=5; Float_t vecForTrend[totTrending]; TString varForTrending[totTrending]={"nDzeroCandperEv","nDplusCandperEv","nDsCandperEv","nLcCandperEv","nDstarCandperEv"}; TTree* trtree=new TTree("trendingHF","tree of trending variables"); trtree->Branch("nrun",&runNumber,"nrun/I"); for(Int_t j=0; j<totTrending; j++){ trtree->Branch(varForTrending[j].Data(),&vecForTrend[j],Form("%s/F",varForTrending[j].Data())); vecForTrend[j]=-99.; } TFile *ff = new TFile(filename.Data()); Int_t color[5] = {kBlack, kRed, kGreen, kBlue, kOrange}; TDirectoryFile *dirD2H = (TDirectoryFile *)ff->Get("PWG3_D2H_QA"); if(!dirD2H){ printf("Directory PWG3_D2H_QA not found in file %s\n",filename.Data()); return; } TList *listD2H = (TList *)dirD2H->Get("nEntriesQA"); if(!listD2H){ printf("TList nEntriesQA not found in file %s\n",filename.Data()); return; } TH1F *hNentries = (TH1F *)listD2H->FindObject("hNentries"); TH2F *hHasSelBit = (TH2F *)listD2H->FindObject("HasSelBit"); TCanvas *cqa = new TCanvas("cqa", "cqa", 800, 500); cqa->Divide(2, 1); cqa->cd(1); hNentries->Draw(); cqa->cd(2); hHasSelBit->Draw("colz"); cqa->SaveAs("plot_D2HQA.png"); Double_t nEv=hNentries->GetBinContent(10); vecForTrend[0]=hHasSelBit->GetBinContent(1)/nEv; vecForTrend[1]=hHasSelBit->GetBinContent(2)/nEv; vecForTrend[2]=hHasSelBit->GetBinContent(3)/nEv; vecForTrend[3]=hHasSelBit->GetBinContent(4)/nEv; vecForTrend[4]=hHasSelBit->GetBinContent(5)/nEv; TDirectoryFile *dir = (TDirectoryFile *)ff->Get("PWGHF_D2H_MCPerform"); TList* list = 0x0; if (dir) { list = (TList *)dir->Get("coutputDperfQA"); if(list){ TH1F *hn = (TH1F *)list->FindObject("fHistNEvents"); TH1F *hnGenD = (TH1F *)list->FindObject("fHistNGenD"); Int_t entries = hn->GetBinContent(3); TH2F *fHistNCand = (TH2F *)list->FindObject("fHistNCand"); TH1F *fHistNCandDzero = (TH1F *)fHistNCand->ProjectionY("fHistNCandDzero", 1, 1); TH1F *fHistNCandDplus = (TH1F *)fHistNCand->ProjectionY("fHistNCandDplus", 2, 2); TH1F *fHistNCandDstar = (TH1F *)fHistNCand->ProjectionY("fHistNCandDstar", 3, 3); TH1F *fHistNCandDs = (TH1F *)fHistNCand->ProjectionY("fHistNCandDs", 4, 4); TH1F *fHistNCandLc = (TH1F *)fHistNCand->ProjectionY("fHistNCandLc", 5, 5); TString names[5] = {"Dzero", "Dplus", "Dstar", "Ds", "Lc2pkpi"}; TString type[2] = {"Prompt", "Feeddown"}; const Int_t nDecays = 5; TH2F *fHistXvtxResVsPt[2 * nDecays]; TH2F *fHistYvtxResVsPt[2 * nDecays]; TH2F *fHistZvtxResVsPt[2 * nDecays]; TH2F *fHistInvMassVsPt[2 * nDecays]; TH2F *fHistDecLenVsPt[2 * nDecays]; TH2F *fHistNormDLxyVsPt[2 * nDecays]; TH2F *fHistCosPointVsPt[2 * nDecays]; TH3F *fHistPtYMultGenDauInAcc[2 * nDecays]; TH3F *fHistPtYMultRecoFilt[2 * nDecays]; TProfile *fHistXvtxRes[2 * nDecays]; TProfile *fHistYvtxRes[2 * nDecays]; TProfile *fHistZvtxRes[2 * nDecays]; TProfile *fHistXvtxMean[2 * nDecays]; TProfile *fHistYvtxMean[2 * nDecays]; TProfile *fHistZvtxMean[2 * nDecays]; TH1F *fHistXvtxRes2[2 * nDecays]; TH1F *fHistYvtxRes2[2 * nDecays]; TH1F *fHistZvtxRes2[2 * nDecays]; TProfile *fHistInvMass[2 * nDecays]; TProfile *fHistDecLen[2 * nDecays]; TProfile *fHistCosp[2 * nDecays]; TH1F *fHistInvMassRes[2 * nDecays]; TH1F *hEffPt[2 * nDecays]; TH1F *htemp; for (Int_t j = 0; j < 5; j++) { //decays for (Int_t i = 0; i < 2; i++) { //prompt and fd Int_t index = j * 2 + i; fHistXvtxResVsPt[index] = (TH2F *)list->FindObject(Form("hXvtxResVsPt%s%s", type[i].Data(), names[j].Data())); fHistYvtxResVsPt[index] = (TH2F *)list->FindObject(Form("hYvtxResVsPt%s%s", type[i].Data(), names[j].Data())); fHistZvtxResVsPt[index] = (TH2F *)list->FindObject(Form("hZvtxResVsPt%s%s", type[i].Data(), names[j].Data())); fHistInvMassVsPt[index] = (TH2F *)list->FindObject(Form("hInvMassVsPt%s%s", type[i].Data(), names[j].Data())); fHistDecLenVsPt[index] = (TH2F *)list->FindObject(Form("hDecLenVsPt%s%s", type[i].Data(), names[j].Data())); fHistCosPointVsPt[index] = (TH2F *)list->FindObject(Form("hCosPointVsPt%s%s", type[i].Data(), names[j].Data())); fHistPtYMultGenDauInAcc[index] = (TH3F *)list->FindObject(Form("hPtYMult%sGenDauInAcc%s", type[i].Data(), names[j].Data())); fHistPtYMultRecoFilt[index] = (TH3F *)list->FindObject(Form("hPtYMult%sRecoFilt%s", type[i].Data(), names[j].Data())); fHistXvtxMean[index] = (TProfile *)fHistXvtxResVsPt[index]->ProfileX(Form("hXvtxMean%s%s", type[i].Data(), names[j].Data())); fHistXvtxMean[index]->SetLineColor(color[j]); fHistXvtxMean[index]->SetLineWidth(2); fHistXvtxMean[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistXvtxMean[index]->GetYaxis()->SetTitle("Xvtx (reco-true) mean (#mum)"); fHistXvtxMean[index]->SetTitle("Xvtx residual vs pT"); fHistYvtxMean[index] = (TProfile *)fHistYvtxResVsPt[index]->ProfileX(Form("hYvtxMean%s%s", type[i].Data(), names[j].Data())); fHistYvtxMean[index]->SetLineColor(color[j]); fHistYvtxMean[index]->SetLineWidth(2); fHistYvtxMean[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistYvtxMean[index]->GetYaxis()->SetTitle("Yvtx (reco-true) mean (#mum)"); fHistYvtxMean[index]->SetTitle("Yvtx residual vs pT"); fHistZvtxMean[index] = (TProfile *)fHistZvtxResVsPt[index]->ProfileX(Form("hZvtxMean%s%s", type[i].Data(), names[j].Data())); fHistZvtxMean[index]->SetLineColor(color[j]); fHistZvtxMean[index]->SetLineWidth(2); fHistZvtxMean[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistZvtxMean[index]->GetYaxis()->SetTitle("Zvtx (reco-true) mean (#mum)"); fHistZvtxMean[index]->SetTitle("Zvtx residual vs pT"); fHistXvtxRes[index] = (TProfile *)fHistXvtxResVsPt[index]->ProfileX(Form("hXvtxRes%s%s", type[i].Data(), names[j].Data()), 1, -1, "s"); fHistYvtxRes[index] = (TProfile *)fHistYvtxResVsPt[index]->ProfileX(Form("hYvtxRes%s%s", type[i].Data(), names[j].Data()), 1, -1, "s"); fHistZvtxRes[index] = (TProfile *)fHistZvtxResVsPt[index]->ProfileX(Form("hZvtxRes%s%s", type[i].Data(), names[j].Data()), 1, -1, "s"); fHistXvtxRes2[index] = (TH1F *)fHistXvtxResVsPt[index]->ProjectionX(Form("hXvtxRes2%s%s", type[i].Data(), names[j].Data())); fHistYvtxRes2[index] = (TH1F *)fHistYvtxResVsPt[index]->ProjectionX(Form("hYvtxRes2%s%s", type[i].Data(), names[j].Data())); fHistZvtxRes2[index] = (TH1F *)fHistZvtxResVsPt[index]->ProjectionX(Form("hZvtxRes2%s%s", type[i].Data(), names[j].Data())); fHistXvtxRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistXvtxRes[index]->GetYaxis()->SetTitle("Xvtx (reco-true) RMS (#mum)"); fHistXvtxRes[index]->SetTitle("Xvtx resolution vs pT"); fHistYvtxRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistYvtxRes[index]->GetYaxis()->SetTitle("Yvtx (reco-true) RMS (#mum)"); fHistYvtxRes[index]->SetTitle("Yvtx resolution vs pT"); fHistZvtxRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistZvtxRes[index]->GetYaxis()->SetTitle("Zvtx (reco-true) RMS (#mum)"); fHistZvtxRes[index]->SetTitle("Zvtx resolution vs pT"); fHistXvtxRes2[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistXvtxRes2[index]->GetYaxis()->SetTitle("Xvtx (reco-true) RMS (#mum)"); fHistXvtxRes2[index]->SetTitle("Xvtx resolution vs pT"); fHistYvtxRes2[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistYvtxRes2[index]->GetYaxis()->SetTitle("Yvtx (reco-true) RMS (#mum)"); fHistYvtxRes2[index]->SetTitle("Yvtx resolution vs pT"); fHistZvtxRes2[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistZvtxRes2[index]->GetYaxis()->SetTitle("Zvtx (reco-true) RMS (#mum)"); fHistZvtxRes2[index]->SetTitle("Zvtx resolution vs pT"); fHistXvtxRes2[index]->SetLineColor(color[j]); fHistYvtxRes2[index]->SetLineColor(color[j]); fHistZvtxRes2[index]->SetLineColor(color[j]); fHistXvtxRes2[index]->SetMarkerColor(color[j]); fHistXvtxRes2[index]->SetMarkerStyle(20); fHistYvtxRes2[index]->SetMarkerColor(color[j]); fHistYvtxRes2[index]->SetMarkerStyle(20); fHistZvtxRes2[index]->SetMarkerColor(color[j]); fHistZvtxRes2[index]->SetMarkerStyle(20); fHistXvtxRes2[index]->SetLineWidth(2); fHistYvtxRes2[index]->SetLineWidth(2); fHistZvtxRes2[index]->SetLineWidth(2); fHistXvtxRes2[index]->Sumw2(); fHistYvtxRes2[index]->Sumw2(); fHistZvtxRes2[index]->Sumw2(); fHistInvMass[index] = (TProfile *)fHistInvMassVsPt[index]->ProfileX(Form("hInvMassVsPt%s%s", type[i].Data(), names[j].Data())); fHistInvMass[index]->SetLineColor(color[j]); fHistInvMass[index]->SetLineWidth(2); fHistInvMass[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistInvMass[index]->GetYaxis()->SetTitle("Inv Mass (GeV/c2)"); fHistInvMass[index]->SetTitle("Inv Mass vs pT"); fHistDecLen[index] = (TProfile *)fHistDecLenVsPt[index]->ProfileX(Form("hDecLenVsPt%s%s", type[i].Data(), names[j].Data())); fHistDecLen[index]->SetLineColor(color[j]); fHistDecLen[index]->SetLineWidth(2); fHistDecLen[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistDecLen[index]->GetYaxis()->SetTitle("Dec Len (#mum)"); fHistDecLen[index]->SetTitle("Prompt Dec Len vs pT"); fHistCosp[index] = (TProfile *)fHistCosPointVsPt[index]->ProfileX(Form("hCosPVsPt%s%s", type[i].Data(), names[j].Data())); fHistCosp[index]->SetLineColor(color[j]); fHistCosp[index]->SetLineWidth(2); fHistCosp[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistCosp[index]->GetYaxis()->SetTitle("Cos Point"); fHistCosp[index]->SetTitle("Prompt CosPoint vs pT"); if (index % 2 == 1) fHistDecLen[index]->SetTitle("FeedDown Dec Len vs pT"); htemp = (TH1F *)fHistPtYMultGenDauInAcc[index]->ProjectionX(Form("hPtDen%s%s", type[i].Data(), names[j].Data())); hEffPt[index] = (TH1F *)fHistPtYMultRecoFilt[index]->ProjectionX(Form("hPtNum%s%s", type[i].Data(), names[j].Data())); fHistPtYMultGenDauInAcc[index]->Sumw2(); fHistPtYMultRecoFilt[index]->Sumw2(); hEffPt[index]->Sumw2(); hEffPt[index]->Divide(htemp); hEffPt[index]->SetLineColor(color[j]); hEffPt[index]->SetLineWidth(2); hEffPt[index]->GetXaxis()->SetTitle("pT (GeV/c)"); hEffPt[index]->GetYaxis()->SetTitle("Prompt Efficiency"); hEffPt[index]->SetTitle("Prompt Efficiency"); hEffPt[index]->SetStats(0); fHistCosp[index]->SetStats(0); fHistDecLen[index]->SetStats(0); if (index % 2 == 1) { hEffPt[index]->GetYaxis()->SetTitle("Feeddown Efficiency"); hEffPt[index]->SetTitle("Feeddown Efficiency"); } fHistInvMassRes[index] = new TH1F(*hEffPt[index]); for (Int_t jj = 1; jj < hEffPt[index]->GetNbinsX() + 1; jj++) { TH1F *hTemp = (TH1F *)fHistInvMassVsPt[index]->ProjectionY("htemp", jj, jj); fHistInvMassRes[index]->SetBinContent(jj, hTemp->GetRMS()); fHistInvMassRes[index]->SetBinError(jj, hTemp->GetRMSError()); fHistInvMassRes[index]->SetLineColor(color[j]); fHistInvMassRes[index]->SetLineWidth(2); fHistInvMassRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistInvMassRes[index]->GetYaxis()->SetTitle("Inv Mass RMS (GeV/c2)"); fHistInvMassRes[index]->SetTitle("Inv Mass RMS vs pT"); if (index == 0) printf("D0: pt=%f, res=%f \n", fHistInvMassRes[index]->GetBinCenter(jj), fHistInvMassRes[index]->GetBinContent(jj)); TH1F *hTempX = (TH1F *)fHistXvtxResVsPt[index]->ProjectionY("htempX", jj, jj); TH1F *hTempY = (TH1F *)fHistYvtxResVsPt[index]->ProjectionY("htempY", jj, jj); TH1F *hTempZ = (TH1F *)fHistZvtxResVsPt[index]->ProjectionY("htempZ", jj, jj); fHistXvtxRes2[index]->SetBinContent(jj, hTempX->GetRMS()); fHistXvtxRes2[index]->SetBinError(jj, hTempX->GetRMSError()); fHistYvtxRes2[index]->SetBinContent(jj, hTempY->GetRMS()); fHistYvtxRes2[index]->SetBinError(jj, hTempY->GetRMSError()); fHistZvtxRes2[index]->SetBinContent(jj, hTempZ->GetRMS()); fHistZvtxRes2[index]->SetBinError(jj, hTempZ->GetRMSError()); } } } fHistNCandDplus->SetLineColor(2); fHistNCandDstar->SetLineColor(3); fHistNCandDs->SetLineColor(4); fHistNCandLc->SetLineColor(kOrange); fHistNCandDplus->SetLineWidth(2); fHistNCandDstar->SetLineWidth(2); fHistNCandDs->SetLineWidth(2); fHistNCandLc->SetLineWidth(2); fHistNCandDzero->GetXaxis()->SetTitle("pT (GeV/c)"); fHistNCandDzero->GetYaxis()->SetTitle("counts"); TLegend *leg = new TLegend(0.6, 0.7, 0.8, 0.9); leg->AddEntry(fHistNCandDzero, "Dzero", "l"); leg->AddEntry(fHistNCandDplus, "Dplus", "l"); leg->AddEntry(fHistNCandDstar, "Dstar", "l"); leg->AddEntry(fHistNCandDs, "Ds", "l"); leg->AddEntry(fHistNCandLc, "Lc", "l"); TLegend *leg1 = new TLegend(0.5, 0.7, 0.7, 0.9); leg1->AddEntry(fHistYvtxRes2[0], "Dzero", "pl"); leg1->AddEntry(fHistYvtxRes2[2], "Dplus", "pl"); if (drawOnlyDzerDplus == 0) leg1->AddEntry(fHistYvtxRes2[6], "Ds", "pl"); if (drawOnlyDzerDplus == 0) leg1->AddEntry(fHistYvtxRes2[8], "Lc", "pl"); TLegend *leg2 = new TLegend(0.5, 0.7, 0.7, 0.9); leg2->AddEntry(fHistYvtxMean[0], "Dzero", "l"); leg2->AddEntry(fHistYvtxMean[2], "Dplus", "l"); if (drawOnlyDzerDplus == 0) leg2->AddEntry(fHistYvtxMean[6], "Ds", "l"); if (drawOnlyDzerDplus == 0) leg2->AddEntry(fHistYvtxMean[8], "Lc", "l"); TLegend *leg3 = new TLegend(0.2, 0.7, 0.4, 0.9); leg3->AddEntry(fHistNCandDzero, "Dzero", "l"); leg3->AddEntry(fHistNCandDplus, "Dplus", "l"); if (drawOnlyDzerDplus == 0) leg3->AddEntry(fHistNCandDstar, "Dstar", "l"); if (drawOnlyDzerDplus == 0) leg3->AddEntry(fHistNCandDs, "Ds", "l"); if (drawOnlyDzerDplus == 0) leg3->AddEntry(fHistNCandLc, "Lc", "l"); TLegend *leg4 = new TLegend(0.7, 0.7, 0.9, 0.9); leg4->AddEntry(fHistNCandDzero, "Dzero", "l"); leg4->AddEntry(fHistNCandDplus, "Dplus", "l"); if (drawOnlyDzerDplus == 0) leg4->AddEntry(fHistNCandDstar, "Dstar", "l"); if (drawOnlyDzerDplus == 0) leg4->AddEntry(fHistNCandDs, "Ds", "l"); if (drawOnlyDzerDplus == 0) leg4->AddEntry(fHistNCandLc, "Lc", "l"); TCanvas *c0_1 = new TCanvas("c0_1", "c0_1", 500, 500); hnGenD->SetTitle("number of generated D mesons"); hnGenD->Draw(); c0_1->SaveAs("plotDgen.png"); TCanvas *c0_2 = new TCanvas("c0_2", "c0_2", 500, 500); c0_2->SetLogy(); fHistNCandDs->SetTitle("Candidates passing filtering cuts"); fHistNCandDs->Draw(""); c0_2->Update(); TPaveStats *stats = (TPaveStats *)c0_2->GetPrimitive("stats"); stats->SetName("h1stats"); stats->SetY1NDC(0.5); stats->SetY2NDC(0.35); c0_2->Update(); fHistNCandDplus->Draw("sames"); c0_2->Update(); TPaveStats *stats2 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats2->SetName("h2stats"); stats2->SetY1NDC(0.8); stats2->SetY2NDC(.65); c0_2->Update(); fHistNCandDstar->Draw("sames"); c0_2->Update(); TPaveStats *stats3 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats3->SetName("h3stats"); stats3->SetY1NDC(0.65); stats3->SetY2NDC(.5); c0_2->Update(); fHistNCandDzero->Draw("sames"); c0_2->Update(); TPaveStats *stats4 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats4->SetName("h4stats"); stats4->SetY1NDC(0.95); stats4->SetY2NDC(.8); c0_2->Update(); fHistNCandLc->Draw("sames"); c0_2->Update(); TPaveStats *stats5 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats5->SetName("h1stats"); stats5->SetY1NDC(0.35); stats5->SetY2NDC(.2); c0_2->Update(); leg->Draw(); c0_2->SaveAs("plotDcandpt.png"); TCanvas *c0_3 = new TCanvas("c0_3", "c0_3", 500, 500); fHistInvMass[0]->SetMinimum(1.6); fHistInvMass[0]->SetMaximum(2.4); fHistInvMass[0]->Draw(); fHistInvMass[2]->Draw("sames"); fHistInvMass[4]->Draw("sames"); fHistInvMass[6]->Draw("sames"); fHistInvMass[8]->Draw("sames"); leg->Draw(); c0_3->SaveAs("plotDcandInvMass.png"); TCanvas *c0_4 = new TCanvas("c0_4", "c0_4", 500, 500); //fHistInvMassRes[0]->SetMinimum(1.6); //fHistInvMassRes[0]->SetMaximum(2.4); fHistInvMassRes[0]->GetYaxis()->SetTitleOffset(1.4); fHistInvMassRes[0]->SetTitle("D0 Inv Mass RMS vs pT"); fHistInvMassRes[0]->Draw(""); // fHistInvMassRes[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistInvMassRes[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistInvMassRes[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistInvMassRes[8]->Draw("sames"); //leg->Draw(); c0_4->SaveAs("plotD0candInvMassWidth.png"); fHistXvtxMean[0]->SetStats(0); fHistYvtxMean[0]->SetStats(0); fHistZvtxMean[0]->SetStats(0); fHistXvtxMean[2]->SetStats(0); fHistYvtxMean[2]->SetStats(0); fHistZvtxMean[2]->SetStats(0); fHistXvtxRes2[0]->SetStats(0); fHistYvtxRes2[0]->SetStats(0); fHistZvtxRes2[0]->SetStats(0); fHistXvtxRes2[2]->SetStats(0); fHistYvtxRes2[2]->SetStats(0); fHistZvtxRes2[2]->SetStats(0); TCanvas *cc = new TCanvas("cc", "cc", 1200, 500); cc->Divide(3, 1); cc->cd(1); fHistXvtxMean[0]->GetYaxis()->SetTitleOffset(1.4); fHistXvtxMean[0]->SetMinimum(-300.); fHistXvtxMean[0]->SetMaximum(300.); fHistXvtxMean[0]->Draw(); fHistXvtxMean[2]->Draw("sames"); leg2->Draw(); cc->cd(2); fHistYvtxMean[0]->GetYaxis()->SetTitleOffset(1.4); fHistYvtxMean[0]->SetMinimum(-300.); fHistYvtxMean[0]->SetMaximum(300.); fHistYvtxMean[0]->Draw(); fHistYvtxMean[2]->Draw("sames"); leg2->Draw(); cc->cd(3); fHistZvtxMean[0]->GetYaxis()->SetTitleOffset(1.4); fHistZvtxMean[0]->SetMinimum(-300.); fHistZvtxMean[0]->SetMaximum(300.); fHistZvtxMean[0]->Draw(); fHistZvtxMean[2]->Draw("sames"); leg2->Draw(); cc->SaveAs("plotXYZVtxMean.png"); ///////// TCanvas *ccr = new TCanvas("ccr", "ccr", 1200, 500); ccr->Divide(3, 1); ccr->cd(1); fHistXvtxRes2[0]->GetYaxis()->SetTitleOffset(1.4); fHistXvtxRes2[0]->SetMinimum(0.); fHistXvtxRes2[0]->SetMaximum(500.); fHistXvtxRes2[0]->Draw(); fHistXvtxRes2[2]->Draw("sames"); leg2->Draw(); ccr->cd(2); fHistYvtxRes2[0]->GetYaxis()->SetTitleOffset(1.4); fHistYvtxRes2[0]->SetMinimum(0.); fHistYvtxRes2[0]->SetMaximum(500.); fHistYvtxRes2[0]->Draw(); fHistYvtxRes2[2]->Draw("sames"); leg2->Draw(); ccr->cd(3); fHistZvtxRes2[0]->GetYaxis()->SetTitleOffset(1.4); fHistZvtxRes2[0]->SetMinimum(0.); fHistZvtxRes2[0]->SetMaximum(500.); fHistZvtxRes2[0]->Draw(); fHistZvtxRes2[2]->Draw("sames"); leg2->Draw(); ccr->SaveAs("plotXYZVtxRMS.png"); TCanvas *ccc = new TCanvas("ccc", "ccc", 1200, 800); ccc->Divide(3, 2); ccc->cd(1); fHistDecLen[0]->GetYaxis()->SetTitleOffset(1.45); fHistDecLen[0]->Draw(); fHistDecLen[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[8]->Draw("sames"); leg3->Draw(); ccc->cd(2); fHistCosp[0]->GetYaxis()->SetTitleOffset(1.45); fHistCosp[0]->Draw(); fHistCosp[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[8]->Draw("sames"); leg4->Draw(); ccc->cd(3); hEffPt[0]->GetYaxis()->SetTitleOffset(1.45); hEffPt[0]->Draw(); hEffPt[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[8]->Draw("sames"); leg3->Draw(); ccc->cd(4); fHistDecLen[1]->GetYaxis()->SetTitleOffset(1.45); fHistDecLen[1]->Draw(); fHistDecLen[3]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[5]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[7]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[9]->Draw("sames"); leg3->Draw(); ccc->cd(5); fHistCosp[1]->GetYaxis()->SetTitleOffset(1.45); fHistCosp[1]->Draw(); fHistCosp[3]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[5]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[7]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[9]->Draw("sames"); leg4->Draw(); ccc->cd(6); hEffPt[1]->GetYaxis()->SetTitleOffset(1.45); hEffPt[1]->Draw(); hEffPt[3]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[5]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[7]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[9]->Draw("sames"); leg3->Draw(); ccc->SaveAs("plot_DL_cosp_Eff_prompt_fd.png"); } } trtree->Fill(); if(runNumber>0){ TFile* foutfile=new TFile("trendingHF.root","recreate"); trtree->Write(); TDirectory* outdir=foutfile->mkdir(dirD2H->GetName()); outdir->cd(); listD2H->Write(listD2H->GetName(),1); foutfile->cd(); if(dir && list){ TDirectory* outdir2=foutfile->mkdir(dir->GetName()); outdir2->cd(); list->Write(list->GetName(),1); } foutfile->Close(); delete foutfile; } }
void makeMuonTimingPlot (std::string fname) { TFile file(fname.c_str()); TDirectoryFile *dir = (TDirectoryFile*)file.Get("Muons"); TList *hlist = dir->GetListOfKeys(); TH1F *h1; bool foundHist = false; for (auto hist : *hlist) { TString name = hist->GetName(); if (!name.Contains("hMuTimeP")) continue; TH1F *h0 = (TH1F*)dir->Get(name.Data()); if (!foundHist) { h1 = (TH1F*)h0->Clone(); h1->Sumw2(); foundHist = true; } else { h1->Add(h0); } } TH1F *h2 = new TH1F("h2", "h2", 200, -100, 100); h2->GetXaxis()->SetTitle("muon time (ns)"); h2->GetYaxis()->SetTitle("Fraction of Muons/ns"); h2->GetYaxis()->SetTitleOffset(1.1); h2->GetXaxis()->SetTitleOffset(0.8); h2->SetTitle("CSC Muon Time"); h2->SetTitleFont(42); h2->SetTitleSize(0.052); h2->Sumw2(); h2->SetLineColor(kCyan+3); h2->SetFillColor(kCyan+3); for (int ibin = 1; ibin <= 200; ibin++) { h2->SetBinContent(ibin, h1->GetBinContent(ibin)); h2->SetBinError(ibin, h1->GetBinError(ibin)); if (ibin == 200) h2->SetEntries(h1->GetEntries()); } TCanvas c1("c1", "c1", 600, 400); gStyle->SetOptStat(""); double rms = h2->GetRMS(); double avg = h2->GetMean(); TLatex cms(0.17, 0.83, "CMS"); cms.SetNDC(); cms.SetTextFont(61); cms.SetTextSize(0.06); TLatex prelim(0.17, 0.81, "Preliminary"); prelim.SetNDC(); prelim.SetTextAlign(13); prelim.SetTextFont(52); prelim.SetTextSize(0.0456); TLatex data(0.17, 0.76, "Data 2016"); data.SetNDC(); data.SetTextAlign(13); data.SetTextFont(52); data.SetTextSize(0.0456); TLatex lumi(0.9, 0.93, "4.0 fb^{-1} (13 TeV)"); lumi.SetNDC(); lumi.SetTextAlign(31); lumi.SetTextFont(42); lumi.SetTextSize(0.052); TLatex mean(0.7, 0.81, Form("Mean %2.1f", avg)); mean.SetNDC(); mean.SetTextAlign(11); mean.SetTextFont(61); mean.SetTextSize(0.06); TLatex stdev(0.7, 0.76, Form("RMS %2.1f", rms)); stdev.SetNDC(); stdev.SetTextAlign(11); stdev.SetTextFont(61); stdev.SetTextSize(0.06); h2->GetXaxis()->SetRangeUser(-6*rms,6*rms); TH1F* h2norm = (TH1F*)h2->DrawNormalized("hist"); gPad->Update(); cms.Draw(); prelim.Draw(); data.Draw(); lumi.Draw(); mean.Draw(); stdev.Draw(); TPaveText *title = (TPaveText*)gPad->GetPrimitive("title"); title->SetBorderSize(0); title->SetFillColor(0); title->SetFillStyle(0); title->SetX1NDC(0.13); title->SetY1NDC(0.88); title->SetX2NDC(0.9); title->SetY2NDC(0.98); title->SetTextFont(42); title->SetTextSize(0.052); title->SetTextAlign(11); c1.Print("plots/muon_time_all.pdf"); c1.Print("plots/muon_time_all.png"); c1.Print("plots/muon_time_all.root"); }
//Noise section Stat_t AnalysisClass::doNoiseFit(Int_t RunNumber, Char_t *Variable, Char_t *SubDetName, Char_t *Layer, Char_t *label){ TH1 *hNtoFit=0; if (debug) cout << d1->GetTitle() << " " << Variable << " " << SubDetName << endl; pPar[0]=0; pPar[1]=0; TIter it(d1->GetListOfKeys()); TObject * o; while ( (o = it())) { TObject * d = d1->Get(o->GetName()); if(d->IsA()->InheritsFrom("TDirectory") && strstr(d->GetName(),SubDetName)){ if (debug) cout << "Found " << SubDetName << endl; TIter it2(((TDirectoryFile * )d)->GetListOfKeys()); TObject *o2; while( ( o2 = it2()) ){ TObject *d2 = ((TDirectoryFile * )d)->Get(o2->GetName()); if(d2->IsA()->InheritsFrom("TDirectory") && strstr(d2->GetName(),Layer) ){ if (debug) cout << "Found Layer" << Layer << endl; TIter it3(((TDirectoryFile * )d2)->GetListOfKeys()); TObject *o3; while( ( o3 = it3()) ){ TObject *d3 = ((TDirectoryFile * )d2)->Get(o3->GetName()); if(strstr(d3->GetName(),Variable) && strstr(d3->GetName(),label)){ hNtoFit = (TH1*) d3; if (debug) cout << "Found " << Variable << endl; if (hNtoFit->GetEntries()!=0) { cout<<"Fitting "<< hNtoFit->GetTitle() <<endl; // Setting fit range and start values Double_t fr[2]; Double_t sv[3], pllo[3], plhi[3]; fr[0]=hNtoFit->GetMean()-5*hNtoFit->GetRMS(); fr[1]=hNtoFit->GetMean()+5*hNtoFit->GetRMS(); Int_t imax=hNtoFit->GetMaximumBin(); Double_t xmax=hNtoFit->GetBinCenter(imax); Double_t ymax=hNtoFit->GetBinContent(imax); Int_t i[2]; Int_t iArea[2]; i[0]=hNtoFit->GetXaxis()->FindBin(fr[0]); i[1]=hNtoFit->GetXaxis()->FindBin(fr[1]); iArea[0]=hNtoFit->GetXaxis()->FindBin(fr[0]); iArea[1]=hNtoFit->GetXaxis()->FindBin(fr[1]); Double_t AreaFWHM=hNtoFit->Integral(iArea[0],iArea[1],"width"); sv[2]=AreaFWHM/(4*ymax); sv[1]=xmax; sv[0]=hNtoFit->Integral(i[0],i[1],"width"); plhi[0]=1000000.0; plhi[1]=10.0; plhi[2]=10.; pllo[0]=1.5 ; pllo[1]=0.1; pllo[2]=0.3; Char_t FunName[100]; sprintf(FunName,"FitfcnLG_%s%d",hNtoFit->GetName(),fRun); TF1 *ffitold = (TF1*)gROOT->GetListOfFunctions()->FindObject(FunName); if (ffitold) delete ffitold; gausFit = new TF1(FunName,Gauss,fr[0],fr[1],3); gausFit->SetParameters(sv); gausFit->SetParNames("Constant","GaussPeak","Sigma"); for (Int_t i=0; i<3; i++) { gausFit->SetParLimits(i,pllo[i],plhi[i]); } hNtoFit->Fit(gausFit,"R0"); gausFit->SetRange(fr[0],fr[1]); pGausS=gausFit->GetParameters(); epGausS=gausFit->GetParErrors(); chi2GausS =langausFit->GetChisquare(); // obtain chi^2 nDofGausS = langausFit->GetNDF();// obtain ndf TCanvas *cAllN = new TCanvas("NoiseFit",hNtoFit->GetTitle(),1); Char_t fitFileName[60]; sprintf(fitFileName,"Fits/Run_%d/%s/Fit_%s.png",RunNumber,SubDetName,hNtoFit->GetTitle()); hNtoFit->Draw("pe"); gStyle->SetOptFit(1111111); gausFit->Draw("lsame"); cAllN->Print(fitFileName,"png"); }else { pGausS[0]=-10; pGausS[1]=-10; pGausS[2]=-10; epGausS[0]=-10; epGausS[1]=-10; epGausS[2]=-10; } } } } } } } return hNtoFit->GetEntries(); }
void drawDCAcontamination(){ gStyle->SetOptStat(0); TFile * file = TFile::Open("/Users/sandrobjelogrlic/Analysis/HFCorrelations/Results/MCCE/83_12022015/10f7a/AnalysisResults.root"); TDirectoryFile * dir = (TDirectoryFile*)file->Get("PWGHF_HFCJ_SE_EffY_DEffY_vsPt_32_bins_SE_RECO_reco_2_348_sigmas"); TList * list = (TList*)dir->Get("OutputMCSE_RECO"); TH1D * isPhysPrimDCA = (TH1D*)list->FindObject("isPhysPrimDCA"); TH1D * isSecondaryDCA = (TH1D*)list->FindObject("isSecondaryDCA"); isPhysPrimDCA->GetXaxis()->SetRangeUser(0,2); isPhysPrimDCA->SetLineColor(2); isSecondaryDCA->SetLineColor(4); isPhysPrimDCA->SetTitle("; DCA_{XY} (cm); Counts"); isPhysPrimDCA->GetYaxis()->SetTitleOffset(1.2); TPaveText * PaveText = new TPaveText(0.5,0.55,0.8,0.7,"NDC"); PaveText->SetBorderSize(0); PaveText->SetFillColor(0); PaveText->SetName("pave"); // PaveText->AddText("THIS THESIS"); // PaveText->AddText(" "); PaveText->AddText("Phytia, pp #sqrt{s} = 7 TeV"); //PaveText->AddText(" "); // PaveText->AddText("Fraction of Primary tracks as funct"); TLine * cut = new TLine(0.25,0,0.25,10000000); cut->SetLineStyle(2); TLegend * legend = new TLegend(0.4,0.7,0.8,0.85); // TLegend * legend = new TLegend(0.1, 1.2*DStarPeak->GetBinContent(DStarPeak->GetMaximumBin()),0.4, 1.6*DStarPeak->GetBinContent(DStarPeak->GetMaximumBin())); legend->SetFillColor(0); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->AddEntry(isPhysPrimDCA,"Primary tracks","l"); legend->AddEntry(isSecondaryDCA,"Secondary tracks","l"); legend->AddEntry(cut,"Standard cut, DCA_{XY} < 0.25 cm","l"); //legend->AddEntry(h_Perugia2011,"Pythia, Perugia 2011 tune","lep"); TCanvas * c1 = new TCanvas("c1","c1",0,0,1000,1000); c1->cd(); c1->SetLogy(); isPhysPrimDCA->Draw(); isSecondaryDCA->Draw("same"); legend->Draw("same"); PaveText->Draw("same"); cut->Draw("same"); // cout << "Integral is " << getIntegral(DCA,isPhysPrimDCA) << endl; TLegend * legend2 = new TLegend(0.4,0.7,0.8,0.85); // TLegend * legend = new TLegend(0.1, 1.2*DStarPeak->GetBinContent(DStarPeak->GetMaximumBin()),0.4, 1.6*DStarPeak->GetBinContent(DStarPeak->GetMaximumBin())); legend2->SetFillColor(0); legend2->SetTextSize(0.03); legend2->SetBorderSize(0); legend2->AddEntry(cut,"Standard cut, DCA_{XY} < 0.25 cm","l"); TPaveText * PaveText2 = new TPaveText(0.5,0.3,0.8,0.5,"NDC"); PaveText2->SetBorderSize(0); PaveText2->SetFillColor(0); PaveText2->SetName("pave2"); // PaveText->AddText("THIS THESIS"); // PaveText->AddText(" "); PaveText2->AddText("PYTHIA, pp #sqrt{s} = 7 TeV"); TH1D * contamination = (TH1D*)isPhysPrimDCA->Clone("contamination"); contamination->Reset(); contamination->SetTitle("; DCA_{XY} (cm); Purity"); contamination->GetYaxis()->SetRangeUser(0.8,1.05); contamination->GetXaxis()->SetRangeUser(0,1); contamination->SetLineColor(1); contamination->SetLineWidth(2); contamination->GetYaxis()->SetTitleOffset(1.4); Double_t dcavalue = 0; for(Int_t k=0; k<2000; k++){ dcavalue += 0.001; contamination->SetBinContent(k+1,getPurity(dcavalue,isPhysPrimDCA,isSecondaryDCA)); } TLine * cut2 = new TLine(0.25,0.8,0.25,1.05); cut2->SetLineStyle(2); TCanvas * c2 = new TCanvas("c2","c2",0,0,1000,1000); c2->cd(); contamination->Draw(); PaveText2->Draw("same"); cut2->Draw("same"); legend2->Draw("same"); c1->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/DCADistrib.pdf"); c1->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/DCADistrib.eps"); c1->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/DCADistrib.png"); c1->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/DCADistrib.root"); c2->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/purity.pdf"); c2->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/purity.png"); c2->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/purity.eps"); c2->SaveAs("/Users/sandrobjelogrlic/PhD_Thesis/Figures/Chapter_3/purity.root"); }
void DrawEfficiency(const char* channel, Int_t selection = 0, Int_t ieff = 7){ gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetPalette(1); gStyle->SetCanvasColor(0); gStyle->SetFrameFillColor(0); gStyle->SetOptTitle(0); gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ROOTSYS/include"); gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); gSystem->Load("$ALICE_ROOT/CORRFW/libCORRFW") ; gSystem->Load("libPWGHFbase"); gSystem->Load("libPWGHFvertexingHF"); Int_t mcAcc_over_mcLimAcc = 0x001; Int_t recPPR_over_mcAcc = 0x002; Int_t recPID_over_mcAcc = 0x004; // pt index Int_t ipt =0; Int_t stepNum = -1; Int_t stepDen = -1; // Read the container from file TFile* f = new TFile("AnalysisResults.root"); TString directoryName; TString containerName; TString cutName; TString outfileName; if (channel == "D0") { if (selection == 0){ directoryName = "PWG3_D2H_CFtaskD0toKpi"; containerName = "CFHFccontainer0"; cutName = "Cuts"; outfileName = "fileEff_D0_from_c.root"; } else if (selection == 1){ directoryName = "PWG3_D2H_CFtaskD0toKpiKeepD0fromBOnly"; containerName = "CFHFccontainer0D0fromB"; cutName = "Cuts"; outfileName = "fileEff_D0_from_b.root"; } else if (selection == 2){ directoryName = "PWG3_D2H_CFtaskD0toKpiKeepD0fromB"; containerName = "CFHFccontainer0allD0"; cutName = "Cuts"; outfileName = "fileEff_D0_from_c_and_b.root"; } else { Printf("not a valid selection, return"); return; } } else if (channel == "D0_New"){ if (selection == 0){ directoryName = "PWG3_D2H_CFtaskD0toKpi_NEW"; containerName = "CFHFccontainer0_New"; cutName = "Cuts_New"; //directoryName = "PWG3_D2H_CFtaskD0toKpi_CommonFramework"; //containerName = "CFHFccontainer0_CommonFramework"; //cutName = "Cuts_CommonFramework"; outfileName = "fileEff_D0_CommonFramework_from_c.root"; } else if (selection == 1){ directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromBOnly"; containerName = "CFHFccontainer0DfromB_New"; cutName = "Cuts_New"; //directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromBOnly_CommonFramework"; //containerName = "CFHFccontainer0DfromB_CommonFramework"; //cutName = "Cuts_CommonFramework"; outfileName = "fileEff_D0_CommonFramework_from_b.root"; } else if (selection == 2){ directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromB_NEW"; containerName = "CFHFccontainer0allD_New"; cutName = "Cuts_New"; //directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromB_CommonFramework"; //containerName = "CFHFccontainer0allD_CommonFramework"; //cutName = "Cuts_CommonFramework"; outfileName = "fileEff_D0_CommonFramework_from_c_and_b.root"; } else { Printf("not a valid selection, return"); return; } } else if (channel == "Dplus_New"){ if (selection == 0){ directoryName = "PWG3_D2H_CFtaskDplustoKpipi_NEW"; containerName = "CFHFccontainer0_New_3Prong"; cutName = "Cuts_3Prong"; //directoryName = "PWG3_D2H_CFtaskDplustoKpipi_CommonFramework"; //containerName = "CFHFccontainer0_3Prong_CommonFramework"; //cutName = "Cuts_3Prong_CommonFramework"; outfileName = "fileEff_Dplus_CommonFramework_from_c.root"; } else if (selection == 1){ directoryName = "PWG3_D2H_CFtaskDplustoKpipiKeepDfromBOnly"; containerName = "CFHFccontainer0DfromB_New_3Prong"; cutName = "Cuts_3Prong"; //directoryName = "PWG3_D2H_CFtaskDplustoKpipiKeepDfromBOnly_CommonFramework"; //containerName = "CFHFccontainer0DfromB_3Prong_CommonFramework"; //cutName = "Cuts_3Prong_CommonFramework"; outfileName = "fileEff_Dplus_CommonFramework_from_b.root"; } else if (selection == 2){ directoryName = "PWG3_D2H_CFtaskDplustoKpipiKeepDfromB_NEW"; containerName = "CFHFccontainer0allD_New_3Prong"; cutName = "Cuts_3Prong"; //directoryName = "PWG3_D2H_CFtaskDplustoKpipiKeepDfromB_CommonFramework"; //containerName = "CFHFccontainer0allD_3Prong_CommonFramework"; //cutName = "Cuts_3Prong_CommonFramework"; outfileName = "fileEff_Dplus_CommonFramework_from_c_and_b.root"; } else { Printf("not a valid selection, return"); return; } } else { Printf("not a valid channel, return"); return; } Printf("Opening file Analysisresults.root"); Printf("Reading Directory \"%s\"",directoryName.Data()); Printf("Getting CF Container \"%s\"",containerName.Data()); Printf("Getting Cut Object \"%s\"",cutName.Data()); TDirectoryFile* d = (TDirectoryFile*)f->Get(directoryName.Data()); if (!d){ Printf("Directory does not exist! Check directory name (%s) in file AnalysisResults.root - returning...", directoryName.Data()); return; } AliCFContainer *data = (AliCFContainer*) (d->Get(containerName.Data())); AliRDHFCuts *cutsRDHF = (AliRDHFCuts*)(d->Get(cutName.Data())); if (!data){ Printf("Container does not exist! Check container name (%s) in directory %s - returning...", containerName.Data(), directoryName.Data()); return; } TFile* fileEff = new TFile(outfileName.Data(), "RECREATE"); TString plotDir(Form("EffPlots/%s",channel)); gSystem->Exec(Form("mkdir EffPlots")); gSystem->Exec(Form("mkdir %s",plotDir.Data())); //construct the efficiency grid from the data container AliCFEffGrid *eff = new AliCFEffGrid("eff"," The efficiency",*data); TCanvas *ceffpt = new TCanvas("ceffpt","Efficiency vs pt",50,50,550,550); ceffpt->cd(); ceffpt->SetLeftMargin(0.15); ceffpt->SetRightMargin(0.05); TH1D *hpteffCF = 0x0; //the efficiency vs pt if (ieff & mcAcc_over_mcLimAcc){ AliCFEffGrid *eff = new AliCFEffGrid("eff"," The efficiency",*data); stepDen = (Int_t)(AliCFTaskVertexingHF::kStepGeneratedLimAcc); stepNum = (Int_t)(AliCFTaskVertexingHF::kStepAcceptance); printf("Calculating efficiency for mcAcc_over_mcLimAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum); eff->CalculateEfficiency(stepNum,stepDen); //eff= step1/step0 //canvas ceffpt->cd(); //The efficiency along the variables hpteffCF = eff->Project(ipt); SetHistoEff(hpteffCF,8,20,"mcAcc_over_mcLimAcc"); hpteffCF->Draw("hist"); hpteffCF->Draw("err same"); fileEff->cd(); hpteffCF->Write("hpteffCF_mcAcc_over_mcLimAcc"); // printing png files ceffpt->Print(Form("%s/effpt_mcAcc_over_mcLimAcc.png", plotDir.Data())); ceffpt->Print(Form("%s/effpt_mcAcc_over_mcLimAcc.eps", plotDir.Data())); ceffpt->Print(Form("%s/effpt_mcAcc_over_mcLimAcc.gif", plotDir.Data())); delete eff; eff = 0x0; } if (ieff & recPPR_over_mcAcc){ AliCFEffGrid *eff = new AliCFEffGrid("eff"," The efficiency",*data); stepDen = (Int_t)(AliCFTaskVertexingHF::kStepAcceptance); stepNum = (Int_t)(AliCFTaskVertexingHF::kStepRecoPPR); printf("Calculating efficiency for RecPPR_over_mcAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum); eff->CalculateEfficiency(stepNum,stepDen); //eff= step1/step0 //canvas ceffpt->cd(); //The efficiency along the variables hpteffCF = eff->Project(ipt); SetHistoEff(hpteffCF,8,20, "recAnCuts_over_mcAcc"); hpteffCF->Draw("hist"); hpteffCF->Draw("err same"); fileEff->cd(); hpteffCF->Write("hpteffCF_RecAnCut_over_mcAcc"); // printing png files ceffpt->Print(Form("%s/effpt_RecAnCut_over_mcAcc.png", plotDir.Data())); ceffpt->Print(Form("%s/effpt_RecAnCut_over_mcAcc.eps", plotDir.Data())); ceffpt->Print(Form("%s/effpt_RecAnCut_over_mcAcc.gif", plotDir.Data())); delete eff; eff = 0x0; } if (ieff & recPID_over_mcAcc){ AliCFEffGrid *eff = new AliCFEffGrid("eff"," The efficiency",*data); stepDen = (Int_t)(AliCFTaskVertexingHF::kStepAcceptance); stepNum = (Int_t)(AliCFTaskVertexingHF::kStepRecoPID); printf("Calculating efficiency for RecPID_over_mcAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum); eff->CalculateEfficiency(stepNum,stepDen); //eff= step1/step0 //canvas ceffpt->cd(); //The efficiency along the variables hpteffCF = eff->Project(ipt); SetHistoEff(hpteffCF,8,20,"recPID_over_mcAcc"); hpteffCF->Draw("hist"); hpteffCF->Draw("err same"); fileEff->cd(); hpteffCF->Write("hpteffCF_RecPID_over_mcAcc"); // printing png files ceffpt->Print(Form("%s/effpt_RecPID_over_mcAcc.png", plotDir.Data())); ceffpt->Print(Form("%s/effpt_RecPID_over_mcAcc.eps", plotDir.Data())); ceffpt->Print(Form("%s/effpt_RecPID_over_mcAcc.gif", plotDir.Data())); delete eff; eff = 0x0; } cutsRDHF->Write("Cuts"); // writing single distributions TH1D *hMCAccpt = data->ShowProjection(ipt, AliCFTaskVertexingHF::kStepAcceptance); SetHistoDistribution(hMCAccpt, 1, 20); hMCAccpt->Draw(); TH1D *hMCLimAccpt = data->ShowProjection(ipt, AliCFHeavyFlavourTaskMultiVarMultiStep::kStepGeneratedLimAcc); SetHistoDistribution(hMCLimAccpt, 4, 20); TH1D *hRecoAnCutspt = data->ShowProjection(ipt, AliCFTaskVertexingHF::kStepRecoPPR); SetHistoDistribution(hRecoAnCutspt, 8, 20); TH1D *hRecoPIDpt = data->ShowProjection(ipt, AliCFTaskVertexingHF::kStepRecoPID); SetHistoDistribution(hRecoPIDpt, 6, 20); hMCAccpt->Write("hMCAccpt"); hMCLimAccpt->Write("hMCLimAccpt"); hRecoAnCutspt->Write("hRecoAnCutspt"); hRecoPIDpt->Write("hRecoPIDpt"); // fileEff->Close(); // commented out to see the canvas on the screen.... }
void drawCorrection(const char* filenameEffCont = "mergedAnalysisResults_proofPbPb_128.root"){ gStyle->SetOptTitle(1); gStyle->SetOptStat(0); //gSystem->Load("libANALYSIS"); //gSystem->Load("libANALYSISalice"); Int_t markerStyle = 20; Int_t markerColor = 1; Int_t fillColor = 9; //_______________________________________________________________// //Open the input file TFile *f = TFile::Open(filenameEffCont); if(!f->IsOpen()) { Printf("File not found!!!"); break; } //_______________________________________________________________// //Get the TDirectoryFile TDirectoryFile *dirEffCont = dynamic_cast<TDirectoryFile *>(f->Get("PWGCFEbyE.outputBalanceFunctionEffContAnalysis")); if(!dirEffCont) { Printf("TDirectoryFile not found!!!"); break; } //_______________________________________________________________// TList *listEffCont[nCentralityBins]; TString listName; TString listName1; TString histName; TString histName1; TH3D* h1d[nCentralityBins]; TH3D* h1n[nCentralityBins]; TH3D* h2d[nCentralityBins]; TH3D* h2n[nCentralityBins]; TH3F* h3d[nCentralityBins]; TH3F* h4d[nCentralityBins]; TH3F* fHistCorrectionPlus[nCentralityBins]; TH3F* fHistCorrectionMinus[nCentralityBins]; TCanvas *correctionMatrix[nCentralityBins]; TString canvasName; for(Int_t iBin = 0; iBin < nCentralityBins; iBin++) { Printf("================Centrality: %s================", strCentrality[iBin].Data()); listName = "listEffContBF_V0M_"; listName += strCentrality[iBin].Data(); listName +="_10"; listName1 = "listQA_V0M_"; listName1 += strCentrality[iBin].Data(); listName1 +="_10"; listEffCont[iBin] = dynamic_cast<TList *>(dirEffCont->Get(listName.Data())); listEffCont[iBin]->ls(); //____________Efficiency Plus //correction->cd(1); h1d[iBin] = dynamic_cast<TH3D*>(listEffCont[iBin]->FindObject("fHistGeneratedEtaPtPhiPlus")); h1d[iBin]->Sumw2(); h1n[iBin] = dynamic_cast<TH3D*>(listEffCont[iBin]->FindObject("fHistSurvivedEtaPtPhiPlus")); h1n[iBin]->Sumw2(); h1n[iBin]->Divide(h1d[iBin]); //h1d->GetYaxis()->SetTitleOffset(1.5); //h1d->SetTitle("Efficiency (+)"); //h1d->SetName("fHistEfficiencyPlus"); //h1d->Draw("P"); //____________Efficiency Minus //correction->cd(2); h2d[iBin] = dynamic_cast<TH3D*>(listEffCont[iBin]->FindObject("fHistGeneratedEtaPtPhiMinus")); h2d[iBin]->Sumw2(); h2n[iBin] = dynamic_cast<TH3D*>(listEffCont[iBin]->FindObject("fHistSurvivedEtaPtPhiMinus")); h2n[iBin]->Sumw2(); h2n[iBin]->Divide(h2d[iBin]); //h2d->GetYaxis()->SetTitleOffset(1.5); //h2d->SetTitle("Efficiency (-)"); //h2d->SetName("fHistEfficiencyMinus"); //h2d->Draw("P"); //__________Contamination //correction->cd(3); h4d[iBin] = dynamic_cast<TH3F*>(listEffCont[iBin]->FindObject("fHistContaminationPrimaries")); h4d[iBin]->SetName("fHistContaminationPrimaries"); h4d[iBin]->Sumw2(); h3d[iBin] = dynamic_cast<TH3F*>(listEffCont[iBin]->FindObject("fHistContaminationSecondaries")); h3d[iBin]->SetName("fHistContaminationSecondaries"); h3d[iBin]->Sumw2(); h4d[iBin]->Add(h3d[iBin]); h3d[iBin]->Divide(h4d[iBin]); //h3d->GetYaxis()->SetTitleOffset(2.0); //h3d->GetXaxis()->SetTitleOffset(1.5); //h3d->SetTitle("Contamination Secondaries"); //h3d->Draw("P"); //_____________________________________________________________ //CORRECTION Int_t binsX = h3d[0]->GetNbinsX(); Int_t binsY = h3d[0]->GetNbinsY(); Int_t binsZ = h3d[0]->GetNbinsZ(); for (Int_t iHistBinsX = 1; iHistBinsX <binsX+1 ; iHistBinsX++) { for (Int_t iHistBinsY = 1; iHistBinsY <binsY+1 ; iHistBinsY++) { for (Int_t iHistBinsZ = 1; iHistBinsZ <binsZ+1 ; iHistBinsZ++) { h3d[iBin]->SetBinContent(iHistBinsX,iHistBinsY,iHistBinsZ,1 - h3d[iBin]->GetBinContent(iHistBinsX,iHistBinsY,iHistBinsZ)); } } } correctionMatrix[iBin] = new TCanvas(canvasName.Data(),canvasName.Data(),0,0+iBin*50,1400,1000); correctionMatrix[iBin]->Divide(2,1); //Correction Maps Plus histName = "fHistCorrectionPlus"; histName += strCentrality[iBin].Data(); correctionMatrix[iBin]->cd(1); fHistCorrectionPlus[iBin] = dynamic_cast<TH3F *>(h3d[iBin]->Clone()); fHistCorrectionPlus[iBin]->Divide(h1n[iBin]); fHistCorrectionPlus[iBin]->SetName(histName.Data()); fHistCorrectionPlus[iBin]->GetYaxis()->SetTitleOffset(2.0); fHistCorrectionPlus[iBin]->GetXaxis()->SetTitleOffset(1.5); fHistCorrectionPlus[iBin]->GetZaxis()->SetTitleOffset(2.0); fHistCorrectionPlus[iBin]->SetTitle("Correction Plus"); fHistCorrectionPlus[iBin]->DrawCopy(""); //Correction Maps Minus histName1 = "fHistCorrectionMinus"; histName1 += strCentrality[iBin].Data(); correctionMatrix[iBin]->cd(2); fHistCorrectionMinus[iBin] = dynamic_cast<TH3F *>(h3d[iBin]->Clone()); fHistCorrectionMinus[iBin]->Divide(h2n[iBin]); fHistCorrectionMinus[iBin]->SetName(histName1.Data()); fHistCorrectionMinus[iBin]->GetYaxis()->SetTitleOffset(2.0); fHistCorrectionMinus[iBin]->GetXaxis()->SetTitleOffset(1.5); fHistCorrectionMinus[iBin]->GetZaxis()->SetTitleOffset(2.0); fHistCorrectionMinus[iBin]->SetTitle("Correction Minus"); fHistCorrectionMinus[iBin]->DrawCopy(""); } //____________________________________________________________ //Output files TFile *fCorrectionMaps = TFile::Open("CorrectionMaps.root", "recreate"); for(Int_t iBin = 0; iBin < nCentralityBins; iBin++) { fHistCorrectionPlus[iBin]->Write(); fHistCorrectionMinus[iBin]->Write(); } fCorrectionMaps->Close(); }
void stack_in_cone_contribs(const string& fFile, const double fYmax, const string& fTitleExt, const string& fNameExt) { string title = "<E> in R_{cone}=0.5 -- "+ fTitleExt +";#eta;<E> [GeV]"; TFile file(fFile.c_str()); TDirectoryFile *subDir = (TDirectoryFile*)file.Get("offsetAnalysis"); TProfile *p_AEC5EB = (TProfile*)subDir->Get("p_AvgEinC5EB"); TProfile *p_AEC5EE = (TProfile*)subDir->Get("p_AvgEinC5EE"); TProfile *p_AEC5HB = (TProfile*)subDir->Get("p_AvgEinC5HB"); TProfile *p_AEC5HE = (TProfile*)subDir->Get("p_AvgEinC5HE"); TProfile *p_AEC5HFl = (TProfile*)subDir->Get("p_AvgEinC5HFl"); TProfile *p_AEC5HFs = (TProfile*)subDir->Get("p_AvgEinC5HFs"); // TProfile *p_AEC5HO = (TProfile*)subDir->Get("p_AvgEinC5HO"); TH1D *h_AEC5EB = p_AEC5EB->ProjectionX(); TH1D *h_AEC5EE = p_AEC5EE->ProjectionX(); TH1D *h_AEC5HB = p_AEC5HB->ProjectionX(); TH1D *h_AEC5HE = p_AEC5HE->ProjectionX(); TH1D *h_AEC5HFl = p_AEC5HFl->ProjectionX(); TH1D *h_AEC5HFs = p_AEC5HFs->ProjectionX(); //TH1D *h_AEC5HO = p_AEC5HO->ProjectionX(); h_AEC5EB->SetFillColor(50); h_AEC5EE->SetFillColor(8); h_AEC5HB->SetFillColor(4); h_AEC5HE->SetFillColor(6); h_AEC5HFl->SetFillColor(16); h_AEC5HFs->SetFillColor(12); //h_AEC5HO->SetFillColor(7); // TCanvas *c = new TCanvas("c", "",1120,800); TCanvas *c = new TCanvas("c", "",800,800); c->cd(); TH2F *h_bg = new TH2F("h_bg",title.c_str(),100,-5.,5.,100,0.,fYmax); h_bg->GetXaxis()->SetTitleSize(0.05); h_bg->GetYaxis()->SetTitleSize(0.05); h_bg->SetTitleOffset(1.,"X"); h_bg->SetTitleOffset(1.3,"Y"); h_bg->Draw(); THStack *hs = new THStack("hs",""); hs->Add(h_AEC5EB); hs->Add(h_AEC5EE); hs->Add(h_AEC5HB); hs->Add(h_AEC5HE); hs->Add(h_AEC5HFl); hs->Add(h_AEC5HFs); //hs->Add(h_AEC5HO); hs->Draw("histsame"); TLegend *legend = new TLegend(.65,.6,.75,.85); legend->SetBorderSize(1); legend->SetFillColor(0); // legend->SetFillStyle(0); // legend->SetTextFont(42); legend->AddEntry(h_AEC5EB,"EB","f"); legend->AddEntry(h_AEC5HB,"HB","f"); legend->AddEntry(h_AEC5EE,"EE","f"); legend->AddEntry(h_AEC5HE,"HE","f"); legend->AddEntry(h_AEC5HFl,"HFl","f"); legend->AddEntry(h_AEC5HFs,"HFs","f"); //legend->AddEntry(h_AEC5HO,"HO","f"); legend->Draw(); string fileName = "h_AvgEinC5_stacked_" + fNameExt; c->SetGridy(); gPad->Modified(); gPad->Update(); c->SaveAs(fileName.c_str()); delete legend; delete hs; delete c; }