+++ /dev/null
-/* $Id$ */
-/* $Log$ */
-
-//------------------------------------
-// Configuration macro GENERAL example:
-//
-// Contains most of the analysis possible cases in the commented lines
-// Set to do prompt photon and hadron correlation
-//
-// Author : Gustavo Conesa Balbastre (INFN-LNF)
-//------------------------------------
-
-AliAnaGamma* ConfigGammaAnalysis()
-{
- //
- // Configuration goes here
- //
- printf("ConfigGammaAnalysis() \n");
-
-
- //-----------------------------------------------------------
- // Define reader , uncomment 1 of the 2 options
- //-----------------------------------------------------------
-
-
- // -----Option 1------ Data, ESDs
- // AliGammaDataReader *reader = new AliGammaDataReader();
- // AliGammaMCDataReader *reader = new AliGammaMCDataReader(); //Copy of AliGammaDataReader + Montecarlo Information
-
- // Set detectors acceptance (in real and montecarlo data)
-// reader->SetCTSEtaCut(1); reader->SetEMCALEtaCut(1); reader->SetPHOSEtaCut(0.2);
-// reader->SetPhiEMCALCut(40*TMath::DegToRad(), 200*TMath::DegToRad());
-// reader->SetPhiPHOSCut(200*TMath::DegToRad(), 350*TMath::DegToRad());
-
- // Set minimum pt for particles in analysis (in real and montecarlo data)
-// reader->SetNeutralPtCut(0.4); reader->SetChargedPtCut(0.4);
-
- //pid of measured particles
- //reader->SetEMCALPIDOn(kTRUE); reader->SetPHOSPIDOn(kTRUE); //No pid, accept all particles
- // if previous kTrue
-// reader->SetPHOSPhotonWeight(0.7); reader->SetPHOSPi0Weight(0.7);
-// reader->SetEMCALPhotonWeight(0.7); reader->SetEMCALPi0Weight(0.7);
-// reader->UsePHOSPIDWeightFormula(kTRUE);
-// TFormula * photonF = new TFormula("photonWeight","0.98*(x<40)+ 0.68*(x>=100)+(x>=40 && x<100)*(0.98+x*(6e-3)-x*x*(2e-04)+x*x*x*(1.1e-06))");
-// TFormula * pi0F = new TFormula("pi0Weight","0.98*(x<65)+ 0.915*(x>=100)+(x>=65 && x-x*(1.95e-3)-x*x*(4.31e-05)+x*x*x*(3.61e-07))");
-// reader->SetPHOSPhotonWeightFormula(photonF);
-// reader->SetPHOSPi0WeightFormula(pi0F);
-
- // -----Option 2------ Kinematics
- AliGammaMCReader *reader = new AliGammaMCReader();
- // Set detectors acceptance (in real and montecarlo data)
-// reader->SetCTSEtaCut(1); reader->SetEMCALEtaCut(1); reader->SetPHOSEtaCut(0.2);
-// reader->SetPhiEMCALCut(40*TMath::DegToRad(), 200*TMath::DegToRad());
-// reader->SetPhiPHOSCut(200*TMath::DegToRad(), 350*TMath::DegToRad());
-
- // Set minimum pt for particles in analysis (in real and montecarlo data)
-// reader->SetNeutralPtCut(0.4); reader->SetChargedPtCut(0.4);
-
- reader->SetDecayPi0Flag(AliGammaMCReader::kGeantDecay) ; //Options
- //kNoDecay :Do not decay pi0, keep them in the list as they are
- //kGeantDecay: Look for gamma decayed by GEANT
- //kDecay: Decay pi0 by hand (geant was not used)
- //kDecayGamma: Pi0 is decayed by PYTHIA, pi0 is not final check if photons overlapp
-
- //parameters to study if decay is overlapped:
-// reader->SetEMCALIPDistance(450.); reader->SetPHOSIPDistance(460.);
-// reader->SetEMCALMinDistance(3.6); reader->SetPHOSMinDistance(11.); //Miimum overlapp distance
- reader->SetCheckOverlapping(kTRUE);
-
- //----------------------------------------------------
- //Define analysis algorithms
- //----------------------------------------------------
-
- //3 analysis types
- //kPrompt: Find prompt gamma for a fixed cone and pt cut value
- //kIsolationCut: Find prompt gamma for several cones and pt cuts values
- //kCorrelation: Do prompt gamma - something correlation. Something can be
- // kParton: Gamma-Parton correlation
- // kHadron: Gamma-Hadron correlation
- // kJetLeadCone: Gamma-Jet correlation : constructed in cone around leading particle
- // kJetFinder: Gamma-Jet correlation : Jet reconstructed with standard algorithms. --Still not implemented--
- //One of the first 3 analysis types is selected in the end with ana->SetAnalysisType(AliAnaGamma::kCorrelation);
- //The 4 correlation analysis are selected when the corresponding class is initialized
-
- //============================
- //First initialize prompt photon algoritm
- //==============================
- AliAnaGammaDirect *gd = new AliAnaGammaDirect();
- gd->SetMinGammaPt(1.);
- //not used in option kIsolationCut
- //gd->SetConeSize(0.5); gd->SetPtThreshold(0.); gd->SetPtSumThreshold(0.);
- gd->SetICMethod(AliAnaGammaDirect::kPtIC) ;//Options:
- //kNoIC: Accept all photons, no isolation used
- //kPtIC: IC with cut on pT
- //kSumPtIC: IC with cut on pT sum in cone
- //kSeveralIC: Not allowed in kCorrelation analysis
- //for option kSeveralIC:
-// gd->SetNCones(2); gd->SetNPtThresholds(3);
-// gd->SetConeSizes(0,0.2); gd->SetConeSizes(1,0.3); //gd->SetConeSizes(2,0.4);
-// gd->SetPtThresholds(0,0); gd->SetPtThresholds(1,1.); gd->SetPtThresholds(2,2);
-
- //============================
- //Second, select the correlation algoritm
- //==============================
- //Uncomment 1 of the 4 options
-
- //--- Option 1 ---
- //AliAnaGammaParton *gc = new AliAnaGammaParton();
- //No associated setters and getters for the moment.
-
- //--- Option 2 ---
- AliAnaGammaHadron *gc = new AliAnaGammaHadron();
-// gc->SetDeltaPhiCutRange(1,4); //Correlation in delta phi (gamma-particle), radians
-// gc->SetMinPtHadron(5.);
-// gc->SetJetsOnlyInCTS(kFALSE); // Don't consider particles in opposite calorimeter
-
- //--- Option 3 ---
- // AliAnaGammaJetLeadCone *gc = new AliAnaGammaJetLeadCone();
-// gc->SetDeltaPhiCutRange(2.8,3.5); //Correlation with leading particle delta phi (gamma-particle), radians
-// gc->SetRatioCutRange(0.1,1.2);
-// gc->SetJetsOnlyInCTS(kFALSE); // Don't consider particles in opposite calorimeter
-// //and many more setters and getters
-
- //--- Option 4 ---
- // AliAnaGammaJetFinder *gc = new AliAnaGammaJetFinder();
- //It does nothing for the moment
-
- //In case of option 1 or 2, we need to select pairs to be candidate to pi0
- //correlated with the opposite prompt photon. Need to play with this class
- AliNeutralMesonSelection *nms = new AliNeutralMesonSelection();
- nms->SetInvMassCutRange(0.1,0.17);
- nms->KeepNeutralMesonSelectionHistos(kTRUE); //keep in file several histograms or not.
- // and other parameters
-
- //---------------------------------------------------------------------
- // Finally: Set analysis algorithm and reader
- //---------------------------------------------------------------------
- ana = new AliAnaGamma();
- ana->SetReader(reader);//pointer to reader
- ana->SetAnalysisType(AliAnaGamma::kCorrelation); //set kPrompt, kCorrelation
- ana->SetGammaDirect(gd);//pointer to direct photon algorithm
- ana->SetGammaCorrelation(gc);//pointer to correlation algorithm
- ana->SetNeutralMesonSelection(nms); //pi0 pair selection
- ana->SetCalorimeter("EMCAL"); //Prompt photon calorimeter
-
- //
- return ana ;
-}
+++ /dev/null
-/* $Id$ */
-/* $Log$
-/* Revision 1.2 2007/12/13 09:45:45 gustavo
-/* Scaling option and more comentaries added
-/*
-/* Revision 1.1 2007/12/07 14:13:02 gustavo
-/* Example macros for execution and configuration of the analysis
-/* */
-
-//---------------------------------------------------
-// Example macro to do analysis with the
-// analysis classes in PWG4Gamma
-// Can be executed with Root and AliRoot
-//
-// Pay attention to the options and definitions
-// set in the lines below
-//
-// Author : Gustavo Conesa Balbastre (INFN-LNF)
-//
-//-------------------------------------------------
-enum anaModes {mLocal, mLocalCAF,mPROOF,mGRID};
-//mLocal: Analyze locally files in your computer
-//mLocalCAF: Analyze locally CAF files
-//mPROOF: Analyze CAF files with PROOF
-
-//---------------------------------------------------------------------------
-//Settings to read locally several files, only for "mLocal" mode
-//The different values are default, they can be set with environmental
-//variables: INDIR, PATTERN, NEVENT, respectivelly
-char * kInDir = "/home/group/alice/schutz/analysis/PWG4/data";
-char * kPattern = ""; // Data are in diles /data/Run0,
-// /Data/Run1 ...
-Int_t kEvent = 1; // Number of files
-//---------------------------------------------------------------------------
-//Collection file for grid analysis
-char * kXML = "collection.xml";
-//---------------------------------------------------------------------------
-//Scale histograms from file. Change to kTRUE when xsection file exists
-//Put name of file containing xsection
-//Put number of events per ESD file
-//This is an specific case for normalization of Pythia files.
-const Bool_t kGetXSectionFromFileAndScale = kTRUE ;
-const char * kXSFileName = "pyxsec.root";
-const Int_t kNumberOfEventsPerFile = 100;
-//---------------------------------------------------------------------------
-
-const Bool_t kMC = kTRUE; //With real data kMC = kFALSE
-
-void anaGammaAnalysis(Int_t mode=mLocal, TString configName = "ConfigKineGammaDirect")
-{
- // Main
-
- //--------------------------------------------------------------------
- // Load analysis libraries
- // Look at the method below,
- // change whatever you need for your analysis case
- // ------------------------------------------------------------------
- LoadLibraries(mode) ;
-
- //-------------------------------------------------------------------------------------------------
- //Create chain from ESD and from cross sections files, look below for options.
- //-------------------------------------------------------------------------------------------------
- TChain *chain = new TChain("esdTree") ;
- TChain * chainxs = new TChain("Xsection") ;
- CreateChain(mode, chain, chainxs);
-
- if(chain){
- AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
-
- //--------------------------------------
- // Make the analysis manager
- //-------------------------------------
- AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
- // MC handler
- if(kMC){
- AliMCEventHandler* mcHandler = new AliMCEventHandler();
- mgr->SetMCtruthEventHandler(mcHandler);
- }
- // AOD output handler
- AliAODHandler* aodHandler = new AliAODHandler();
- aodHandler->SetOutputFileName("aod.root");
- mgr->SetOutputEventHandler(aodHandler);
- // ESD handler
- AliESDInputHandler *esdHandler = new AliESDInputHandler();
- mgr->SetInputEventHandler(esdHandler);
-
- //mgr->SetDebugLevel(10); // For debugging
-
- //-------------------------------------------------------------------------
- //Define task, put here any other task that you want to use.
- //-------------------------------------------------------------------------
- AliAnalysisTaskGamma * taskgamma = new AliAnalysisTaskGamma ("Gamma");
- taskgamma->SetConfigFileName(configName); //Default name is ConfigGammaAnalysis
- mgr->AddTask(taskgamma);
-
- // Create containers for input/output
- AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(),
- AliAnalysisManager::kInputContainer);
- AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),
- AliAnalysisManager::kOutputContainer, "default");
- AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("gammahistos", TList::Class(),
- AliAnalysisManager::kOutputContainer, "gammahistos.root");
-
- mgr->ConnectInput (taskgamma, 0, cinput1);
- mgr->ConnectOutput (taskgamma, 0, coutput1 );
- mgr->ConnectOutput (taskgamma, 1, coutput2 );
-
- //------------------------
- //Scaling task
- //-----------------------
- Int_t nfiles = chainxs->GetEntries();
- if(kGetXSectionFromFileAndScale && nfiles > 0){
- //Get the cross section
- Double_t xsection=0;
- Float_t ntrials = 0;
- GetAverageXsection(chainxs, xsection, ntrials);
-
- AliAnaScale * scale = new AliAnaScale("scale") ;
- scale->Set(xsection/ntrials/kNumberOfEventsPerFile/nfiles) ;
- mgr->AddTask(scale);
-
- AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("gammahistosscaled", TList::Class(),
- AliAnalysisManager::kOutputContainer, "gammahistosscaled.root");
- mgr->ConnectInput (scale, 0, coutput2);
- mgr->ConnectOutput (scale, 0, coutput3 );
- }
-
- //-----------------------
- // Run the analysis
- //-----------------------
- TString smode = "";
- if (mode==mLocal || mode == mLocalCAF)
- smode = "local";
- else if (mode==mPROOF)
- smode = "proof";
- else if (mode==mGRID)
- smode = "grid";
-
- mgr->InitAnalysis();
- mgr->PrintStatus();
- mgr->StartAnalysis(smode.Data(),chain);
- }
- else cout << "Chain was not produced ! "<<endl;
-
-}
-
-void LoadLibraries(const anaModes mode) {
-
- //--------------------------------------
- // Load the needed libraries most of them already loaded by aliroot
- //--------------------------------------
- gSystem->Load("libTree.so");
- gSystem->Load("libGeom.so");
- gSystem->Load("libVMC.so");
- gSystem->Load("libXMLIO.so");
-
- //----------------------------------------------------------
- // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
- //----------------------------------------------------------
- if (mode==mLocal || mode == mLocalCAF || mode == mGRID) {
- //--------------------------------------------------------
- // If you want to use already compiled libraries
- // in the aliroot distribution
- //--------------------------------------------------------
- //gSystem->Load("libSTEERBase");
- //gSystem->Load("libESD");
- //gSystem->Load("libAOD");
- //gSystem->Load("libANALYSIS");
- //gSystem->Load("libANALYSISalice");
- //gSystem->Load("libPWG4Gamma");
-
- //--------------------------------------------------------
- //If you want to use root and par files from aliroot
- //--------------------------------------------------------
- SetupPar("STEERBase");
- SetupPar("ESD");
- SetupPar("AOD");
- SetupPar("ANALYSIS");
- SetupPar("ANALYSISalice");
- SetupPar("PWG4Gamma");
-
- }
-
- //---------------------------------------------------------
- // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
- //---------------------------------------------------------
- else if (mode==mPROOF) {
- //
- // Connect to proof
- // Put appropriate username here
- // TProof::Reset("proof://mgheata@lxb6046.cern.ch");
- TProof::Open("proof://mgheata@lxb6046.cern.ch");
-
- // gProof->ClearPackages();
- // gProof->ClearPackage("ESD");
- // gProof->ClearPackage("AOD");
- // gProof->ClearPackage("ANALYSIS");
- // gProof->ClearPackage("PWG4Gamma");
-
- // Enable the STEERBase Package
- gProof->UploadPackage("STEERBase.par");
- gProof->EnablePackage("STEERBase");
- // Enable the ESD Package
- gProof->UploadPackage("ESD.par");
- gProof->EnablePackage("ESD");
- // Enable the AOD Package
- gProof->UploadPackage("AOD.par");
- gProof->EnablePackage("AOD");
- // Enable the Analysis Package
- gProof->UploadPackage("ANALYSIS.par");
- gProof->EnablePackage("ANALYSIS");
- // Enable gamma jet analysis
- gProof->UploadPackage("PWG4Gamma.par");
- gProof->EnablePackage("PWG4Gamma");
- //
- gProof->ShowEnabledPackages();
- }
-
-}
-
-void SetupPar(char* pararchivename)
-{
- //Load par files, create analysis libraries
- //For testing, if par file already decompressed and modified
- //classes then do not decompress.
-
- TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
- TString parpar(Form("%s.par", pararchivename)) ;
- if ( gSystem->AccessPathName(parpar.Data()) ) {
- gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
- TString processline(Form(".! make %s", parpar.Data())) ;
- gROOT->ProcessLine(processline.Data()) ;
- gSystem->ChangeDirectory(cdir) ;
- processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
- gROOT->ProcessLine(processline.Data()) ;
- }
- if ( gSystem->AccessPathName(pararchivename) ) {
- TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
- gROOT->ProcessLine(processline.Data());
- }
-
- TString ocwd = gSystem->WorkingDirectory();
- gSystem->ChangeDirectory(pararchivename);
-
- // check for BUILD.sh and execute
- if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
- printf("*******************************\n");
- printf("*** Building PAR archive ***\n");
- cout<<pararchivename<<endl;
- printf("*******************************\n");
-
- if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
- Error("runProcess","Cannot Build the PAR Archive! - Abort!");
- return -1;
- }
- }
- // check for SETUP.C and execute
- if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
- printf("*******************************\n");
- printf("*** Setup PAR archive ***\n");
- cout<<pararchivename<<endl;
- printf("*******************************\n");
- gROOT->Macro("PROOF-INF/SETUP.C");
- }
-
- gSystem->ChangeDirectory(ocwd.Data());
- printf("Current dir: %s\n", ocwd.Data());
-}
-
-
-
-void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs){
- //Fills chain with data
- TString ocwd = gSystem->WorkingDirectory();
-
- //-----------------------------------------------------------
- //Analysis of CAF data locally and with PROOF
- //-----------------------------------------------------------
- if(mode ==mPROOF || mode ==mLocalCAF){
- // Chain from CAF
- gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
- // The second parameter is the number of input files in the chain
- chain = CreateESDChain("ESD12001.txt", 5);
- }
-
- //---------------------------------------
- //Local files analysis
- //---------------------------------------
- else if(mode == mLocal){
- //If you want to add several ESD files sitting in a common directory INDIR
- //Specify as environmental variables the directory (INDIR), the number of files
- //to analyze (NEVENT) and the pattern name of the directories with files (PATTERN)
-
- if(gSystem->Getenv("INDIR"))
- kInDir = gSystem->Getenv("INDIR") ;
- else cout<<"INDIR not set, use default: "<<kInDir<<endl;
-
- if(gSystem->Getenv("PATTERN"))
- kPattern = gSystem->Getenv("PATTERN") ;
- else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
-
- if(gSystem->Getenv("NEVENT"))
- kEvent = atoi(gSystem->Getenv("NEVENT")) ;
- else cout<<"NEVENT not set, use default: "<<kEvent<<endl;
-
- //Check if env variables are set and are correct
- if ( kInDir && kEvent) {
- printf("Get %d files from directory %s\n",kEvent,kInDir);
- if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
- printf("%s does not exist\n", kInDir) ;
- return ;
- }
- cout<<"INDIR : "<<kInDir<<endl;
- cout<<"NEVENT : "<<kEvent<<endl;
- cout<<"PATTERN: " <<kPattern<<endl;
-
- //Loop on ESD files, add them to chain
- Int_t event =0;
- Int_t skipped=0 ;
- char file[120] ;
- char filexs[120] ;
-
- for (event = 0 ; event < kEvent ; event++) {
- sprintf(file, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
- sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
- TFile * fESD = 0 ;
- //Check if file exists and add it, if not skip it
- if ( fESD = TFile::Open(file)) {
- if ( fESD->Get("esdTree") ) {
- printf("++++ Adding %s\n", file) ;
- chain->AddFile(file);
- chainxs->Add(filexs) ;
- }
- }
- else {
- printf("---- Skipping %s\n", file) ;
- skipped++ ;
- }
- }
- printf("number of entries # %lld, skipped %d\n", chain->GetEntries(), skipped*100) ;
- }
- else {
- TString input = "AliESDs.root" ;
- cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
- chain->AddFile(input);
- }
-
- }// local files analysis
-
- //------------------------------
- //GRID xml files
- //-----------------------------
- else if(mode == mGRID){
- //Get colection file. It is specified by the environmental
- //variable XML
-
- if(gSystem->Getenv("XML") )
- kXML = gSystem->Getenv("XML");
- else
- sprintf(kXML, "collection.xml") ;
-
- if (!TFile::Open(kXML)) {
- printf("No collection file with name -- %s -- was found\n",kXML);
- return ;
- }
- else cout<<"XML file "<<kXML<<endl;
-
- //Load necessary libraries and connect to the GRID
- gSystem->Load("libNetx.so") ;
- gSystem->Load("libRAliEn.so");
- TGrid::Connect("alien://") ;
-
- //Feed Grid with collection file
- //TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML));
- TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
- if (! collection) {
- AliError(Form("%s not found", kXML)) ;
- return kFALSE ;
- }
- TGridResult* result = collection->GetGridResult("",0 ,0);
-
- // Makes the ESD chain
- printf("*** Getting the Chain ***\n");
- for (Int_t index = 0; index < result->GetEntries(); index++) {
- TString alienURL = result->GetKey(index, "turl") ;
- cout << "================== " << alienURL << endl ;
- chain->Add(alienURL) ;
- alienURL.ReplaceAll("AliESDs.root",kXSFileName);
- chainxs->Add(alienURL) ;
- }
- }// xml analysis
-
- gSystem->ChangeDirectory(ocwd.Data());
-}
-
-//________________________________________________
-void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
-{
- // Read the PYTHIA statistics from the file pyxsec.root created by
- // the function WriteXsection():
- // integrated cross section (xsection) and
- // the number of Pyevent() calls (ntrials)
- // and calculate the weight per one event xsection/ntrials
- // The spectrum calculated by a user should be
- // multiplied by this weight, something like this:
- // TH1F *userSpectrum ... // book and fill the spectrum
- // userSpectrum->Scale(weight)
- //
- // Yuri Kharlov 19 June 2007
- // Gustavo Conesa 15 April 2008
- Double_t xsection = 0;
- UInt_t ntrials = 0;
- xs = 0;
- ntr = 0;
-
- Int_t nfiles = tree->GetEntries() ;
- if (tree && nfiles > 0) {
- tree->SetBranchAddress("xsection",&xsection);
- tree->SetBranchAddress("ntrials",&ntrials);
- for(Int_t i = 0; i < nfiles; i++){
- tree->GetEntry(i);
- xs += xsection ;
- ntr += ntrials ;
- cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
- }
-
- xs = xs / nfiles;
- ntr = ntr / nfiles;
- cout << "-----------------------------------------------------------------"<<endl;
- cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
- cout << "-----------------------------------------------------------------"<<endl;
- }
- else cout << " >>>> Empty tree !!!! <<<<< "<<endl;
-
-}
-
-
-