AddTask macro commit for 4-pion femto
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / macros / AddTaskFourPion.C
1 AliFourPion *AddTaskFourPion(
2                                  Bool_t LEGO=kTRUE, 
3                                  Bool_t MCcase=kFALSE, 
4                                  Bool_t PbPbcase=kTRUE, 
5                                  Bool_t GenerateSignal=kFALSE, 
6                                  Bool_t TabulatePairs=kFALSE, 
7                                  Int_t CentBinLowLimit=0, 
8                                  Int_t CentBinHighLimit=1,
9                                  Int_t RMax=11,
10                                  Float_t fcSq=0.7,
11                                  UInt_t FilterBit=7,
12                                  Float_t MaxChi2NDF=10,
13                                  Int_t MinTPCncls=0,
14                                  Float_t MinSepPairEta=0.02,
15                                  Float_t MinSepPairPhi=0.045,
16                                  Float_t SigmaCutTPC=2.0,
17                                  Float_t SigmaCutTOF=2.0,
18                                  TString StWeightName="alien:///alice/cern.ch/user/d/dgangadh/WeightFile_FourPion.root",
19                                  TString StMomResName="alien:///alice/cern.ch/user/d/dgangadh/MomResFile_FourPion.root",
20                                  TString StKName="alien:///alice/cern.ch/user/d/dgangadh/KFile_FourPion.root"
21                                  ) {
22   
23   //===========================================================================
24   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
25   if (!mgr) {
26     ::Error("AddTaskFourPion", "No analysis manager to connect to.");
27     return NULL;
28   }
29  
30
31   //____________________________________________//
32   // Create task
33   AliFourPion *FourPionTask = new AliFourPion("FourPionTask");
34   if(!FourPionTask) return NULL;
35   FourPionTask->SetLEGOCase(LEGO);
36   FourPionTask->SetMCdecision(MCcase);
37   FourPionTask->SetPbPbCase(PbPbcase);
38   FourPionTask->SetGenerateSignal(GenerateSignal);
39   FourPionTask->SetTabulatePairs(TabulatePairs);
40   FourPionTask->SetCentBinRange(CentBinLowLimit, CentBinHighLimit);
41   FourPionTask->SetRMax(RMax);
42   FourPionTask->SetfcSq(fcSq);
43   FourPionTask->SetFilterBit(FilterBit);
44   FourPionTask->SetMaxChi2NDF(MaxChi2NDF);
45   FourPionTask->SetMinTPCncls(MinTPCncls);
46   FourPionTask->SetPairSeparationCutEta(MinSepPairEta);
47   FourPionTask->SetPairSeparationCutPhi(MinSepPairPhi);
48   FourPionTask->SetNsigmaTPC(SigmaCutTPC);
49   FourPionTask->SetNsigmaTOF(SigmaCutTOF);
50   mgr->AddTask(FourPionTask);
51
52
53   // Create ONLY the output containers for the data produced by the task.
54   // Get and connect other common input/output containers via the manager as below
55   //==============================================================================
56   TString outputFileName = AliAnalysisManager::GetCommonFileName();
57   outputFileName += ":PWGCF.outputFourPionAnalysis.root";
58   AliAnalysisDataContainer *coutFourPion = mgr->CreateContainer("FourPionOutput", TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
59   mgr->ConnectInput(FourPionTask, 0, mgr->GetCommonInputContainer());
60   mgr->ConnectOutput(FourPionTask, 1, coutFourPion);
61   
62
63   TFile *inputFileWeight = 0;
64   TFile *inputFileMomRes = 0;
65   TFile *inputFileFSI = 0;
66
67  
68   if(!TabulatePairs){
69     inputFileWeight = TFile::Open(StWeightName,"OLD");
70     if (!inputFileWeight){
71       cout << "Requested file:" << inputFileWeight << " was not opened. ABORT." << endl;
72       return NULL;
73     }
74     ////////////////////////////////////////////////////
75     // C2 Weight File
76     const Int_t ktbins_temp = FourPionTask->GetNumKtBins();
77     const Int_t cbins_temp = FourPionTask->GetNumCentBins(); 
78     const Int_t ktbins = ktbins_temp;
79     const Int_t cbins = cbins_temp;
80
81     TH3F *weightHisto[ktbins][cbins];
82     for(Int_t i=0; i<ktbins; i++){
83       for(Int_t j=0; j<cbins; j++){
84         TString name = "Weight_Kt_";
85         name += i;
86         name += "_Ky_0_M_";
87         name += j;
88         name += "_ED_0";
89         
90         weightHisto[i][j] = (TH3F*)inputFileWeight->Get(name);
91       }
92     }
93     FourPionTask->SetWeightArrays( kTRUE, weightHisto );
94     ////////////////////////////////////////////////////
95   }// TabulatePairs check
96   
97   if(!MCcase && !TabulatePairs){
98     
99     inputFileMomRes = TFile::Open(StMomResName,"OLD");
100     if (!inputFileMomRes){
101       cout << "Requested file:" << inputFileMomRes << " was not opened. ABORT." << endl;
102       return NULL;
103     }
104     ////////////////////////////////////////////////////
105     // Momentum Resolution File
106     TH2D *momResHisto2D = 0;
107     momResHisto2D = (TH2D*)inputFileMomRes->Get("MRC_C2_SC");
108     FourPionTask->SetMomResCorrections( kTRUE, momResHisto2D);
109     ////////////////////////////////////////////////////
110   }// MCcase and TabulatePairs check
111   
112
113   ////////////////////////////////////////////////////
114   // FSI File
115   inputFileFSI = TFile::Open(StKName,"OLD");
116   if (!inputFileFSI){
117     cout << "Requested file:" << inputFileFSI << " was not opened. ABORT." << endl;
118     return NULL;
119   }  
120   TH1D *FSIss[12];
121   TH1D *FSIos[12];
122   for(Int_t index=0; index<12; index++) {
123     TString *nameSS=new TString("K2ss_");
124     *nameSS += index;
125     FSIss[index] = (TH1D*)inputFileFSI->Get(nameSS->Data());
126     TString *nameOS=new TString("K2os_");
127     *nameOS += index;
128     FSIos[index] = (TH1D*)inputFileFSI->Get(nameOS->Data());
129     //
130     FSIss[index]->SetDirectory(0);
131     FSIos[index]->SetDirectory(0);
132   }
133   //
134   FourPionTask->SetFSICorrelations( kTRUE, FSIss, FSIos );
135   ////////////////////////////////////////////////////
136   
137   
138   // Return the task pointer
139   return FourPionTask;
140 }