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