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