]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/macros/train/LHC2010-7TeV-kstar/RsnConfig.C
Added macros for K* analysis
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / train / LHC2010-7TeV-kstar / RsnConfig.C
1 /*
2 #include <TROOT.h>
3 #include <TString.h>
4 #include <AliAnalysisManager.h>
5 #include <AliRsnAnalysisSE.h>
6 #include <AliRsnCutESD2010.h>
7 #include <AliRsnCutValue.h>
8 #include <AliRsnPairFunctions.h>
9 #include <AliRsnFunction.h>
10 #include <AliRsnCutPrimaryVertex.h>
11
12 #include "config/QualityCutsITS.C"
13 #include "config/QualityCutsTPC.C"
14 */
15
16 //
17 // This function configures the entire task for all resonances the user is interested in.
18 // This is done by creating all configuration objects which are defined in the package.
19 //
20 // Generally speaking, one has to define the following objects for each resonance:
21 //
22 //  1 - an AliRsnPairDef to define the resonance decay channel to be studied
23 //  2 - an AliRsnPair{Ntuple|Functions} where the output is stored
24 //  3 - one or more AliRsnCut objects to define track selections
25 //      which will have then to be organized into AliRsnCutSet objects
26 //  4 - an AliRsnCutManager to include all cuts to be applied (see point 3)
27 //  5 - definitions to build the TNtuple or histograms which are returned
28 //
29 // The return value is used to know if the configuration was successful
30 //
31 Bool_t RsnConfig
32 (
33   const char *taskName, 
34   const char *options,
35   const char *config,
36   const char *path,
37   Int_t       multMin = 0,
38   Int_t       multMax = 0
39 )
40 {
41   // load useful macros
42   gROOT->LoadMacro(Form("%s/QualityCutsITS.C", path));
43   gROOT->LoadMacro(Form("%s/QualityCutsTPC.C", path));
44   
45   // interpret the useful information from second argument
46   TString opt(options);
47   Bool_t isSim  = opt.Contains("sim");
48   Bool_t isData = opt.Contains("data");
49   if (!isSim && !isData)
50   {
51     Error("RsnConfig", "Required to know if working on data or MC");
52     return kFALSE;
53   }
54   
55   // interpret the specific info from third argument
56   // which should be fixed in the various calls to this function
57   TString conf(config);
58   Bool_t addPID    = conf.Contains("pid");
59   Bool_t addITSSA  = conf.Contains("its");
60   Bool_t addDipCut = conf.Contains("dip");
61       
62   // generate a common suffix depending on chosen options
63   TString suffix;
64   if (addPID)    suffix += "_pid";
65   if (addITSSA)  suffix += "_its";
66   if (addDipCut) suffix += "_dip";
67   Info("RsnConfig", "=== Specific configuration: %s ====================================================", config);
68   Info("RsnConfig", "=== suffix used           : %s ====================================================", suffix.Data());
69
70   // retrieve analysis manager & task
71   AliAnalysisManager *mgr  = AliAnalysisManager::GetAnalysisManager();
72   AliRsnAnalysisSE   *task = (AliRsnAnalysisSE*)mgr->GetTask(taskName);
73
74   // for safety, return if no task is passed
75   if (!task)
76   {
77     Error("RsnConfig2010PhiFcn", "Task not found");
78     return kFALSE;
79   }
80   
81   //
82   // -- Setup event cuts (added directly to task) ---------------------------------------------------
83   //
84   
85   // define a common cut on primary vertex, which also checks pile-up
86   AliRsnCutPrimaryVertex *cutVertex  = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE);
87   cutVertex->SetCheckPileUp(kTRUE);
88   task->GetEventCuts()->AddCut(cutVertex);
89   
90   // if at least one of last two arguments is not zero, 
91   // add a multiplicity cut using those arguments as range limits
92   if (multMin > 0 || multMax > 0)
93   {
94     ::Info("RsnConfig.C", "Adding multiplicity cut: %d --> %d", multMin, multMax);
95     AliRsnCutValue *cutMult = new AliRsnCutValue(Form("cutMult_%d-%d", multMin, multMax), AliRsnValue::kEventMultESDCuts, (Double_t)multMin, (Double_t)multMax);
96     
97     // initialize the support object: AliESDtrackCuts
98     // configured using the standard values
99     AliESDtrackCuts *cuts = new AliESDtrackCuts(QualityCutsTPC());
100     cutMult->GetValueObj()->SetSupportObject(cuts);
101     
102     // add the cut and set the cut string
103     task->GetEventCuts()->AddCut(cutMult);
104     task->GetEventCuts()->SetCutScheme(Form("cutVertex&%s", cutMult->GetName()));
105   }
106   else
107   {
108     // if no mult cut is added, only primary vertex cut is used
109     task->GetEventCuts()->SetCutScheme("cutVertex");
110   }
111
112   //
113   // -- Setup pairs ---------------------------------------------------------------------------------
114   //
115
116   // decay channels
117   AliRsnPairDef *pairDefPM = new AliRsnPairDef(AliPID::kPion, '+', AliPID::kKaon, '-', 313, 0.896);
118   AliRsnPairDef *pairDefMP = new AliRsnPairDef(AliPID::kPion, '-', AliPID::kKaon, '+', 313, 0.896);
119   AliRsnPairDef *pairDefPP = new AliRsnPairDef(AliPID::kPion, '+', AliPID::kKaon, '+', 313, 0.896);
120   AliRsnPairDef *pairDefMM = new AliRsnPairDef(AliPID::kPion, '-', AliPID::kKaon, '-', 313, 0.896);
121
122   // computation objects
123   AliRsnPairFunctions *pairPM = new AliRsnPairFunctions(Form("PairPM%s", suffix.Data()), pairDefPM);
124   AliRsnPairFunctions *pairMP = new AliRsnPairFunctions(Form("PairMP%s", suffix.Data()), pairDefMP);
125   AliRsnPairFunctions *truePM = new AliRsnPairFunctions(Form("TruePM%s", suffix.Data()), pairDefPM);
126   AliRsnPairFunctions *trueMP = new AliRsnPairFunctions(Form("TrueMP%s", suffix.Data()), pairDefMP);
127   AliRsnPairFunctions *pairPP = new AliRsnPairFunctions(Form("PairPP%s", suffix.Data()), pairDefPP);
128   AliRsnPairFunctions *pairMM = new AliRsnPairFunctions(Form("PairMM%s", suffix.Data()), pairDefMM);
129
130   //
131   // -- Setup cuts ----------------------------------------------------------------------------------
132   //
133
134   // track cut -----------------------
135   // --> global cuts for 2010 analysis
136   // --> most options are set to right values by default
137   // --> second argument in constructor tells if we are working in simulation or not
138   AliRsnCutESD2010 *cuts2010_kaon = new AliRsnCutESD2010(Form("cuts2010%s_kaon", suffix.Data()), isSim);
139   AliRsnCutESD2010 *cuts2010_pion = new AliRsnCutESD2010(Form("cuts2010%s_pion", suffix.Data()), isSim);
140   // --> set the reference particle for PID
141   cuts2010_kaon->SetPID(AliPID::kKaon);
142   cuts2010_pion->SetPID(AliPID::kPion);
143   // --> include or not the ITS standalone (TPC is always in)
144   cuts2010_kaon->SetUseITSTPC(kTRUE);
145   cuts2010_pion->SetUseITSTPC(kTRUE);
146   cuts2010_kaon->SetUseITSSA (addITSSA);
147   cuts2010_pion->SetUseITSSA (addITSSA);
148   // --> set the quality cuts using the general macro and using the 'Copy()' method in AliESDtrackCuts
149   cuts2010_kaon->CopyCutsTPC(QualityCutsTPC());
150   cuts2010_pion->CopyCutsTPC(QualityCutsTPC());
151   cuts2010_kaon->CopyCutsITS(QualityCutsITS());
152   cuts2010_pion->CopyCutsITS(QualityCutsITS());
153   // --> set values for PID flags, depending on the choice expressed in the options
154   cuts2010_kaon->SetCheckITS(addPID);
155   cuts2010_kaon->SetCheckTPC(addPID);
156   cuts2010_kaon->SetCheckTOF(addPID);
157   cuts2010_pion->SetCheckITS(addPID);
158   cuts2010_pion->SetCheckTPC(addPID);
159   cuts2010_pion->SetCheckTOF(addPID);
160   // --> set the ITS PID-related variables
161   cuts2010_kaon->SetITSband(3.0);
162   cuts2010_pion->SetITSband(3.0);
163   // --> set the TPC PID-related variables
164   Double_t bbPar[5];
165   if (isSim)
166   {
167     bbPar[0] = 2.15898 / 50.0;
168     bbPar[1] = 1.75295E1;
169     bbPar[2] = 3.40030E-9;
170     bbPar[3] = 1.96178;
171     bbPar[4] = 3.91720;
172   }
173   else
174   {
175     bbPar[0] = 1.41543 / 50.0;
176     bbPar[1] = 2.63394E1;
177     bbPar[2] = 5.0411E-11;
178     bbPar[3] = 2.12543;
179     bbPar[4] = 4.88663;
180   }
181   cuts2010_kaon->SetTPCrange(3.0, 5.0);
182   cuts2010_kaon->SetTPCpLimit(0.35);
183   cuts2010_kaon->GetESDpid()->GetTPCResponse().SetBetheBlochParameters(bbPar[0], bbPar[1], bbPar[2], bbPar[3], bbPar[4]);
184   cuts2010_pion->SetTPCrange(3.0, 5.0);
185   cuts2010_pion->SetTPCpLimit(0.35);
186   cuts2010_pion->GetESDpid()->GetTPCResponse().SetBetheBlochParameters(bbPar[0], bbPar[1], bbPar[2], bbPar[3], bbPar[4]);
187   // --> set the TOF PID-related variables
188   cuts2010_kaon->SetTOFrange(-3.0, 3.0);
189   cuts2010_pion->SetTOFrange(-3.0, 3.0);
190   
191   // pair cut ----------------------------------------
192   // --> dip angle between daughters: (it is a cosine)
193   AliRsnCutValue *cutDip = new AliRsnCutValue("cutDip", AliRsnValue::kPairDipAngle, 0.02, 1.01);
194
195   // setup cut set for tracks------------------------------------------------------------
196   // --> apply pion cuts to daughter #1
197   pairPM->GetCutManager()->GetDaughter1Cuts()->AddCut(cuts2010_pion);
198   pairMP->GetCutManager()->GetDaughter1Cuts()->AddCut(cuts2010_pion);
199   truePM->GetCutManager()->GetDaughter1Cuts()->AddCut(cuts2010_pion);
200   trueMP->GetCutManager()->GetDaughter1Cuts()->AddCut(cuts2010_pion);
201   pairPP->GetCutManager()->GetDaughter1Cuts()->AddCut(cuts2010_pion);
202   pairMM->GetCutManager()->GetDaughter1Cuts()->AddCut(cuts2010_pion);
203   pairPM->GetCutManager()->GetDaughter1Cuts()->SetCutScheme(cuts2010_pion->GetName());
204   pairMP->GetCutManager()->GetDaughter1Cuts()->SetCutScheme(cuts2010_pion->GetName());
205   truePM->GetCutManager()->GetDaughter1Cuts()->SetCutScheme(cuts2010_pion->GetName());
206   trueMP->GetCutManager()->GetDaughter1Cuts()->SetCutScheme(cuts2010_pion->GetName());
207   pairPP->GetCutManager()->GetDaughter1Cuts()->SetCutScheme(cuts2010_pion->GetName());
208   pairMM->GetCutManager()->GetDaughter1Cuts()->SetCutScheme(cuts2010_pion->GetName());
209   // --> apply kaon cuts to daughter #2
210   pairPM->GetCutManager()->GetDaughter2Cuts()->AddCut(cuts2010_kaon);
211   pairMP->GetCutManager()->GetDaughter2Cuts()->AddCut(cuts2010_kaon);
212   truePM->GetCutManager()->GetDaughter2Cuts()->AddCut(cuts2010_kaon);
213   trueMP->GetCutManager()->GetDaughter2Cuts()->AddCut(cuts2010_kaon);
214   pairPP->GetCutManager()->GetDaughter2Cuts()->AddCut(cuts2010_kaon);
215   pairMM->GetCutManager()->GetDaughter2Cuts()->AddCut(cuts2010_kaon);
216   pairPM->GetCutManager()->GetDaughter2Cuts()->SetCutScheme(cuts2010_kaon->GetName());
217   pairMP->GetCutManager()->GetDaughter2Cuts()->SetCutScheme(cuts2010_kaon->GetName());
218   truePM->GetCutManager()->GetDaughter2Cuts()->SetCutScheme(cuts2010_kaon->GetName());
219   trueMP->GetCutManager()->GetDaughter2Cuts()->SetCutScheme(cuts2010_kaon->GetName());
220   pairPP->GetCutManager()->GetDaughter2Cuts()->SetCutScheme(cuts2010_kaon->GetName());
221   pairMM->GetCutManager()->GetDaughter2Cuts()->SetCutScheme(cuts2010_kaon->GetName());
222   
223   // cut set for pairs---------------------
224   // --> add dip angle cut only if required
225   if (addDipCut)
226   {
227     pairPM->GetCutManager()->GetMotherCuts()->AddCut(cutDip);
228     truePM->GetCutManager()->GetMotherCuts()->AddCut(cutDip);
229     pairMP->GetCutManager()->GetMotherCuts()->AddCut(cutDip);
230     trueMP->GetCutManager()->GetMotherCuts()->AddCut(cutDip);
231     pairPP->GetCutManager()->GetMotherCuts()->AddCut(cutDip);
232     pairMM->GetCutManager()->GetMotherCuts()->AddCut(cutDip);
233     
234     pairPM->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName());
235     truePM->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName());
236     pairMP->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName());
237     trueMP->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName());
238     pairPP->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName());
239     pairMM->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName());
240   }
241   
242   // set additional option for true pairs
243   truePM->SetOnlyTrue  (kTRUE);
244   trueMP->SetOnlyTrue  (kTRUE);
245   truePM->SetCheckDecay(kTRUE);
246   trueMP->SetCheckDecay(kTRUE);
247
248   //
249   // -- Setup functions -----------------------------------------------------------------------------
250   //
251
252   // axis definition
253   // 0) invariant mass
254   // 1) transverse momentum
255   // 2) rapidity
256   AliRsnValue *axisIM = new AliRsnValue("IM", AliRsnValue::kPairInvMass,  0.9,  1.3, 0.001);
257   AliRsnValue *axisPt = new AliRsnValue("PT", AliRsnValue::kPairPt     ,  0.0, 10.0, 0.100);
258   AliRsnValue *axisY  = new AliRsnValue("Y" , AliRsnValue::kPairY      , -1.1,  1.1, 0.100);
259
260   // create function and add axes
261   AliRsnFunction *fcn = new AliRsnFunction;
262   if ( !fcn->AddAxis(axisIM  ) ) return kFALSE;
263   if ( !fcn->AddAxis(axisPt  ) ) return kFALSE;
264   if ( !fcn->AddAxis(axisY   ) ) return kFALSE;
265
266   // add functions to pairs
267   pairPM->AddFunction(fcn);
268   truePM->AddFunction(fcn);
269   pairMP->AddFunction(fcn);
270   trueMP->AddFunction(fcn);
271   pairPP->AddFunction(fcn);
272   pairMM->AddFunction(fcn);
273
274   //
275   // -- Conclusion ----------------------------------------------------------------------------------
276   //
277
278   // add all created AliRsnPair objects to the AliRsnAnalysisManager in the task
279   task->GetAnalysisManager()->Add(pairPM);
280   task->GetAnalysisManager()->Add(pairMP);
281   task->GetAnalysisManager()->Add(pairPP);
282   task->GetAnalysisManager()->Add(pairMM);
283   if (isSim) 
284   {
285     task->GetAnalysisManager()->Add(truePM);
286     task->GetAnalysisManager()->Add(trueMP);
287   }
288
289   return kTRUE;
290 }