fab5b0b75dd7b4e96f65ddf2c4efcd636542456b
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPYAOD / runPWG2AODCreation.C
1 void runPWG2AODCreation(const char *esdsource="ESD1503X_v1.txt", int nfiles=1)
2 {
3   producePWG2AOD(esdsource, nfiles);
4 }
5
6 void producePWG2AOD(const char *esdsource, int nfiles)
7 {
8     gSystem->Load("libTree.so");
9     gSystem->Load("libGeom.so");
10     gSystem->Load("libVMC.so");
11     gSystem->Load("libXMLIO.so");
12     SetupPar("STEERBase");
13     SetupPar("ESD");
14     SetupPar("AOD");
15     SetupPar("ANALYSIS");
16     SetupPar("PWG0base");
17     SetupPar("PWG2AOD");
18     // Make the analysis manager
19     //
20     // Chain from CAF
21     gROOT->LoadMacro("CreateESDChain.C");
22     TChain* chain = CreateESDChain(esdsource, nfiles);
23
24     AliAODHandler* aodHandler   = new AliAODHandler();
25     aodHandler->SetOutputFileName("aod.root");
26     AliESDInputHandler *esdHandler = new AliESDInputHandler();
27     esdHandler->SetInactiveBranches("FMD CaloCluster");
28     
29     AliMCEventHandler* mcHandler = new AliMCEventHandler();
30
31     AliAnalysisManager *mgr  = new AliAnalysisManager("esd to pwg2 aod", "testing aod analysis");
32     mgr->SetInputEventHandler(esdHandler);
33     mgr->SetOutputEventHandler(aodHandler);
34     mgr->SetMCtruthEventHandler(mcHandler);
35     mgr->SetDebugLevel(10);
36     AliLog::EnableDebug(kTRUE);
37     AliLog::SetGlobalLogLevel(2);
38
39
40     // Set of cuts
41     // 
42     // standard
43     AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");
44     esdTrackCutsL->SetMinNClustersTPC(50);
45     esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
46     esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
47     esdTrackCutsL->SetRequireTPCRefit(kTRUE);
48     esdTrackCutsL->SetMinNsigmaToVertex(3);
49     esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);
50     esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
51     //
52     // hard
53     AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("AliESDtrackCuts", "Hard");
54     esdTrackCutsH->SetMinNClustersTPC(95);
55     esdTrackCutsH->SetMaxChi2PerClusterTPC(2.0);
56     esdTrackCutsH->SetMaxChi2PerClusterITS(3.0);
57     esdTrackCutsH->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
58     esdTrackCutsH->SetRequireTPCRefit(kTRUE);
59     esdTrackCutsH->SetRequireITSRefit(kTRUE);
60     esdTrackCutsH->SetMinNsigmaToVertex(2);
61     esdTrackCutsH->SetRequireSigmaToVertex(kTRUE);
62     esdTrackCutsH->SetAcceptKingDaughters(kFALSE);
63     esdTrackCutsH->SetPtRange(0.1,1.5);
64     esdTrackCutsH->SetEtaRange(-1.0,1.0);
65     //
66     AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
67     trackFilter->AddCuts(esdTrackCutsL);
68     trackFilter->AddCuts(esdTrackCutsH);
69     //
70     AliAnalysisTaskPWG2ESDfilter *esdfilter = new AliAnalysisTaskPWG2ESDfilter("PWG2 ESD Filter");
71     esdfilter->SetTrackFilter(trackFilter);
72     esdfilter->SetDebugLevel(10);
73     mgr->AddTask(esdfilter);
74
75     // Create containers for input/output
76     // Top ESD container
77     AliAnalysisDataContainer *cin_esd = mgr->GetCommonInputContainer();
78
79     // Output AOD container
80     AliAnalysisDataContainer *cout_aod = mgr->GetCommonOutputContainer();
81
82     mgr->ConnectInput  (esdfilter,  0, cin_esd  );
83     mgr->ConnectOutput (esdfilter,  0, cout_aod );
84     //
85     // Run the analysis
86     //    
87     mgr->InitAnalysis();
88     mgr->PrintStatus();
89     mgr->StartAnalysis("local",chain);
90     delete mgr;
91 }
92
93 void SetupPar(char* pararchivename)
94 {
95     if (pararchivename) {
96         char processline[1024];
97         sprintf(processline,".! tar xvzf %s.par",pararchivename);
98         gROOT->ProcessLine(processline);
99         TString ocwd = gSystem->WorkingDirectory();
100         gSystem->ChangeDirectory(pararchivename);
101         
102         // check for BUILD.sh and execute
103         if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
104             printf("*******************************\n");
105             printf("*** Building PAR archive    ***\n");
106             printf("*******************************\n");
107             
108             if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
109                 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
110                 return -1;
111             }
112         }
113         // check for SETUP.C and execute
114         if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
115             printf("*******************************\n");
116             printf("*** Setup PAR archive       ***\n");
117             printf("*******************************\n");
118             gROOT->Macro("PROOF-INF/SETUP.C");
119         }
120         
121         gSystem->ChangeDirectory(ocwd.Data());
122    printf("Current dir: %s\n", ocwd.Data());
123     } 
124 }