Updates to Trains. create a job-script to help
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / IdentifiedHighPt / grid / AddTaskHighPtDeDx.C
1 AliAnalysisTask* AddTask(Bool_t AnalysisMC, const Char_t* taskname, Int_t typerun, UInt_t kTriggerInt[], Float_t minc[], Float_t maxc[] )
2 {
3   // Creates a pid task and adds it to the analysis manager
4   
5   // Get the pointer to the existing analysis manager via the static
6   //access method
7   //=========================================================================
8   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
9   if (!mgr) {
10     Error("AddTaskHighPtDeDx", "No analysis manager to connect to.");
11     return NULL;
12   }  
13   
14   // Check the analysis type using the event handlers connected to the
15   // analysis manager The availability of MC handler can also be
16   // checked here.
17   // =========================================================================
18   if (!mgr->GetInputEventHandler()) {
19     Error("AddTaskHighPtDeDx", "This task requires an input event handler");
20     return NULL;
21   }  
22   
23
24
25   //
26   // Add track filters, with Golden Cuts
27   //
28   AliAnalysisFilter* trackFilterGolden = new AliAnalysisFilter("trackFilter");
29   AliESDtrackCuts* esdTrackCutsGolden = 
30     AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
31   trackFilterGolden->AddCuts(esdTrackCutsGolden);
32
33   
34   //old cuts without golden cut
35   AliAnalysisFilter* trackFilter0 = new AliAnalysisFilter("trackFilter");
36   Bool_t clusterCut=0;
37   Bool_t selPrimaries=kTRUE;
38   AliESDtrackCuts* esdTrackCutsL0 = new AliESDtrackCuts;
39  // TPC  
40   if(clusterCut == 0)  esdTrackCutsL0->SetMinNClustersTPC(70);
41   else if (clusterCut == 1) {
42     esdTrackCutsL0->SetMinNCrossedRowsTPC(70);
43     esdTrackCutsL0->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
44   }
45   else {
46     AliWarningClass(Form("Wrong value of the clusterCut parameter (%d), using cut on Nclusters",clusterCut));
47     esdTrackCutsL0->SetMinNClustersTPC(70);
48   }
49   esdTrackCutsL0->SetMaxChi2PerClusterTPC(4);
50   esdTrackCutsL0->SetAcceptKinkDaughters(kFALSE);
51   esdTrackCutsL0->SetRequireTPCRefit(kTRUE);
52   // ITS
53   esdTrackCutsL0->SetRequireITSRefit(kTRUE);
54   esdTrackCutsL0->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
55                                          AliESDtrackCuts::kAny);
56   if(selPrimaries) {
57     // 7*(0.0026+0.0050/pt^1.01)
58     esdTrackCutsL0->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
59   }
60   esdTrackCutsL0->SetMaxDCAToVertexZ(2);
61   esdTrackCutsL0->SetDCAToVertex2D(kFALSE);
62   esdTrackCutsL0->SetRequireSigmaToVertex(kFALSE);
63   esdTrackCutsL0->SetMaxChi2PerClusterITS(1e10);
64   esdTrackCutsL0->SetMaxChi2TPCConstrainedGlobal(1e10);
65
66
67   trackFilter0->AddCuts(esdTrackCutsL0);
68
69   
70   
71   AliAnalysisFilter* trackFilterTPC = new AliAnalysisFilter("trackFilterTPC");
72   AliESDtrackCuts* esdTrackCutsTPC = 
73     AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
74   trackFilterTPC->AddCuts(esdTrackCutsTPC);
75
76
77
78   // Create the task and configure it 
79   //========================================================================
80   if(typerun==2){//heavy ion analysis
81     
82     
83     AliAnalysisTaskHighPtDeDx* taskHighPtDeDx[6];
84     for( Int_t i=0; i<6; ++i ){
85       taskHighPtDeDx[i]=0;
86       Char_t TaskName[256]={0};
87       sprintf(TaskName,"%s_%1.0f_%1.0f",taskname,minc[i],maxc[i]);
88       
89       taskHighPtDeDx[i] = new AliAnalysisTaskHighPtDeDx(TaskName);
90       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
91       taskHighPtDeDx[i]->SetAnalysisType(type);
92       taskHighPtDeDx[i]->SetAnalysisMC(AnalysisMC);
93       taskHighPtDeDx[i]->SetAnalysisPbPb(kTRUE);
94       taskHighPtDeDx[i]->SetProduceTPCBranch(kFALSE);
95       taskHighPtDeDx[i]->SetDebugLevel(0);
96       taskHighPtDeDx[i]->SetEtaCut(0.8);
97       taskHighPtDeDx[i]->SetVtxCut(10.0);
98       taskHighPtDeDx[i]->SetMinPt(0.0); // default 2.0
99       taskHighPtDeDx[i]->SetLowPtFraction(0.01); // keep 1% of tracks below min pt
100       taskHighPtDeDx[i]->SetTreeOption(1);
101       taskHighPtDeDx[i]->SetTrigger1(kTriggerInt[0]);
102       taskHighPtDeDx[i]->SetTrigger2(kTriggerInt[1]);
103       taskHighPtDeDx[i]->SetMinCent(minc[i]);
104       taskHighPtDeDx[i]->SetMaxCent(maxc[i]);
105       //Set Filtesr
106       taskHighPtDeDx[i]->SetTrackFilterGolden(trackFilterGolden);
107       taskHighPtDeDx[i]->SetTrackFilter(trackFilter0);
108       taskHighPtDeDx[i]->SetTrackFilterTPC(trackFilterTPC);
109       
110       mgr->AddTask(taskHighPtDeDx[i]);
111       
112     }
113     
114     // Create ONLY the output containers for the data produced by the
115     // task.  Get and connect other common input/output containers via
116     // the manager as below
117     //=======================================================================
118     AliAnalysisDataContainer *cout_hist[6];
119     for( Int_t i=0; i<6; ++i ){
120       
121       cout_hist[i]=0;
122       Char_t outFileName[256]={0};
123       sprintf(outFileName,"%s_Tree_%1.0f_%1.0f.root",taskname,minc[i],maxc[i]);
124       //AliAnalysisDataContainer *cout_hist    = 0;
125       
126       cout_hist[i] = mgr->CreateContainer(Form("output_%1.0f_%1.0f",minc[i],maxc[i]), TList::Class(), AliAnalysisManager::kOutputContainer, outFileName);
127       mgr->ConnectInput (taskHighPtDeDx[i], 0, mgr->GetCommonInputContainer());
128       mgr->ConnectOutput(taskHighPtDeDx[i], 1, cout_hist[i]);
129       
130     }  
131     
132     // Return task pointer at the end
133     return taskHighPtDeDx[0];
134   }
135   if(typerun==3){//pp analysis
136   
137     
138     AliAnalysisTaskHighPtDeDx* taskHighPtDeDx = new AliAnalysisTaskHighPtDeDx("taskHighPtDeDxpp");
139     TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
140     taskHighPtDeDx->SetAnalysisType(type);
141     taskHighPtDeDx->SetAnalysisMC(AnalysisMC);
142     taskHighPtDeDx->SetAnalysisPbPb(kFALSE);
143     taskHighPtDeDx->SetProduceTPCBranch(kFALSE);
144     taskHighPtDeDx->SetDebugLevel(0);
145     taskHighPtDeDx->SetEtaCut(0.8);
146     taskHighPtDeDx->SetVtxCut(10.0);
147     taskHighPtDeDx->SetMinPt(0.0); // default 2.0
148     taskHighPtDeDx->SetLowPtFraction(0.01); // keep 1% of tracks below min pt
149     taskHighPtDeDx->SetTreeOption(1);
150     taskHighPtDeDx->SetTrigger1(kTriggerInt[0]);
151     taskHighPtDeDx->SetTrigger2(kTriggerInt[1]);
152     //Set Filtesr
153     taskHighPtDeDx->SetTrackFilterGolden(trackFilterGolden);
154     taskHighPtDeDx->SetTrackFilter(trackFilter0);
155     taskHighPtDeDx->SetTrackFilterTPC(trackFilterTPC);
156     
157     mgr->AddTask(taskHighPtDeDx);
158       
159     // Create ONLY the output containers for the data produced by the
160     // task.  Get and connect other common input/output containers via
161     // the manager as below
162     //=======================================================================
163   
164     AliAnalysisDataContainer *cout_histdedx;
165
166     cout_histdedx=0;
167     Char_t outFileName[256]={0};
168     sprintf(outFileName,"%s_Tree.root",taskname);
169     //AliAnalysisDataContainer *cout_hist    = 0;
170  
171     cout_histdedx = mgr->CreateContainer("outputdedx", TList::Class(), AliAnalysisManager::kOutputContainer, outFileName);
172     mgr->ConnectInput (taskHighPtDeDx, 0, mgr->GetCommonInputContainer());
173     mgr->ConnectOutput(taskHighPtDeDx, 1, cout_histdedx);
174  
175     // Return task pointer at the end
176     return taskHighPtDeDx;
177     
178
179     
180     
181     
182   }
183   
184   
185 }