]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/macros/train/RsnConfigPhiTest.C
PWG2/SPECTRA -> PWGLF/SPECTRA migration
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / train / RsnConfigPhiTest.C
1 //
2 // *** Configuration script for phi->KK analysis with 2010 runs ***
3 // 
4 // A configuration script for RSN package needs to define the followings:
5 //
6 // (1) decay tree of each resonance to be studied, which is needed to select
7 //     true pairs and to assign the right mass to all candidate daughters
8 // (2) cuts at all levels: single daughters, tracks, events
9 // (3) output objects: histograms or trees
10 //
11 Bool_t RsnConfigPhi
12 (
13    AliRsnAnalysisTask *task,
14    Bool_t              isMC,
15    Bool_t              isMix,
16    const char         *options
17 )
18 {
19    void myError  (const char *msg) {::Error  ("RsnConfigPhi", msg);}
20    void myWarning(const char *msg) {::Warning("RsnConfigPhi", msg);}
21    void myInfo   (const char *msg) {::Info   ("RsnConfigPhi", msg);}
22
23    if (!task) myError("NULL task");
24    
25    // ==================================================================================================================
26    // == OPTIONS =======================================================================================================
27    // ==================================================================================================================
28    
29    // Instead or getting confused with plenty of arguments in the macro (with default values),
30    // we use a unique string of options with a set of conventional strings to set up the job:
31    // -- "MC"/"DATA" --> what kind of sample
32    // -- "ITS"/"TPC" --> what tracks to use (ITS standalone and/or TPC+ITS)
33    // -- "xxxPID"    --> add the PID cuts for the detector xxx.
34    // -- "MULT"      --> add axes for multiplicity
35    //
36    // In this point, these options are converted into boolean variables.
37    
38    TString opt(options);
39    opt.ToUpper();
40    opt.ReplaceAll(" ", "");
41    
42    Bool_t addITS  = opt.Contains("ITS");
43    Bool_t addTPC  = opt.Contains("TPC");
44    Bool_t useITS  = opt.Contains("ITSPID");
45    Bool_t useTPC  = opt.Contains("TPCPID");
46    Bool_t useTOF  = opt.Contains("TOFPID");
47    Bool_t useMult = opt.Contains("MULT");
48    
49    // correct options when needed
50    if (!addITS) useITS = kFALSE;
51    if (!addTPC) useTPC = useTOF = kFALSE;
52    
53    // ==================================================================================================================
54    // == DEFINITIONS ===================================================================================================
55    // ==================================================================================================================
56    
57    // daughter definitions
58    AliRsnDaughterDef *defKaonP = new AliRsnDaughterDef(AliRsnDaughter::kKaon, '+');
59    AliRsnDaughterDef *defKaonM = new AliRsnDaughterDef(AliRsnDaughter::kKaon, '-');
60    
61    // pair definitions --> decay channels:
62    // in our case, unlike-charged KK pairs for the signal, and like-charged ones for background
63    AliRsnPairDef *pairDef[3];
64    pairDef[0] = new AliRsnPairDef(defKaonP, defKaonM, 333, 1.019455); // unlike
65    pairDef[1] = new AliRsnPairDef(defKaonP, defKaonP, 333, 1.019455); // like ++
66    pairDef[2] = new AliRsnPairDef(defKaonM, defKaonM, 333, 1.019455); // like --
67
68    // computation objects:
69    // these are the objects which drive the computations, whatever it is (histos or tree filling)
70    // and all tracks passed to them will be given the mass according to the reference pair definition
71    // we create two unlike-sign pair computators, one for all pairs and another for true pairs (useful in MC)
72    AliRsnLoopPair *pair[4];
73    pair[0] = new AliRsnLoopPair(Form("%s_kaonP_kaonM_phi", opt.Data()), 0, 0, pairDef[0]); // unlike - true
74    pair[1] = new AliRsnLoopPair(Form("%s_kaonP_kaonM_all", opt.Data()), 0, 0, pairDef[0]); // unlike - all
75    pair[2] = new AliRsnLoopPair(Form("%s_kaonP_kaonP_all", opt.Data()), 0, 0, pairDef[1]); // like ++
76    pair[3] = new AliRsnLoopPair(Form("%s_kaonM_kaonM_all", opt.Data()), 0, 0, pairDef[2]); // like --
77    
78    // loop on events
79    AliRsnLoopEvent *event = new AliRsnLoopEvent(Form("%s_evt", opt.Data()));
80
81    // set additional option for true pairs (slot [0])
82    pair[0]->SetOnlyTrue(kTRUE);
83    pair[0]->SetCheckDecay(kTRUE);
84    
85    // assign the ID of the entry lists to be used by each pair to get selected daughters
86    // in our case, the AliRsnInputHandler contains only one list for selecting kaons
87    for (Int_t i = 0; i < 4; i++) pair[i]->SetListID(0, 0);
88    
89    // ==================================================================================================================
90    // == COMPUTED VALUES ===============================================================================================
91    // ==================================================================================================================
92    
93    // All values which should be computed are defined here and passed to the computation objects,
94    // since they define all that is computed bye each one, and, in case one output is a histogram
95    // they define the binning and range for that value
96    //
97    // NOTE:
98    // --> multiplicity bins have variable size
99    
100    Double_t mult[] = { 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11., 12., 13.,  14.,  15.,  16.,  17.,  18.,  19., 
101                       20., 21., 22., 23., 24., 25., 30., 35., 40., 50., 60., 70., 80., 90., 100., 120., 140., 160., 180., 200., 500.};
102    Int_t    nmult  = sizeof(mult) / sizeof(mult[0]);
103    
104    AliRsnValue *axisIM      = new AliRsnValue("IM"  , AliRsnValue::kPairInvMass   ,  0.9, 1.4, 0.001);
105    AliRsnValue *axisRes     = new AliRsnValue("RES" , AliRsnValue::kPairInvMassRes, -0.5, 0.5, 0.001);
106    AliRsnValue *axisPt      = new AliRsnValue("PT"  , AliRsnValue::kPairPt        ,  0.0, 5.0, 0.1  );
107    AliRsnValue *axisY       = new AliRsnValue("Y"   , AliRsnValue::kPairY         , -1.1, 1.1, 0.1  );
108    AliRsnValue *axisMultESD = new AliRsnValue("MESD", AliRsnValue::kEventMultESDCuts, nmult, mult);
109    AliRsnValue *axisMultSPD = new AliRsnValue("MSPD", AliRsnValue::kEventMultSPD    , nmult, mult);
110    AliRsnValue *axisMultMC  = new AliRsnValue("MMC" , AliRsnValue::kEventMultMC     , nmult, mult);
111
112    // add values to pairs
113    // NOTE: in previous package version, they were added to functions
114    for (Int_t i = 0; i < 4; i++) {
115       if (i == 0) pair[i]->AddValue(axisRes);
116       pair[i]->AddValue(axisIM);
117       pair[i]->AddValue(axisPt);
118       pair[i]->AddValue(axisY);
119       if (useMult) {
120          ::Info("RsnConfigPhi", "Adding multiplicity computations");
121          pair[i]->AddValue(axisMultESD);
122          pair[i]->AddValue(axisMultSPD);
123          if (isMC) pair[i]->AddValue(axisMultMC);
124          event->AddValue(axisMultESD);
125          event->AddValue(axisMultSPD);
126          if (isMC) event->AddValue(axisMultMC);
127       }
128    }
129       
130    // ==================================================================================================================
131    // == PAIR CUTS =====================================================================================================
132    // ==================================================================================================================
133    
134    // Rapidity cut
135    // Only thing to consider is that it needs a support object to define mass
136    AliRsnCutValue *cutRapidity = new AliRsnCutValue("cutY", AliRsnValue::kPairY, -0.5, 0.5);
137    cutRapidity->GetValueObj()->SetSupportObject(pairDef[0]);
138
139    // in this case, we add the cut to the specific cut sets of all pairs
140    // and we must then loop over all pairs, to add cuts to the related sets
141    for (Int_t ipair = 0; ipair < 4; ipair++) {
142       pair[ipair]->GetPairCuts()->AddCut(cutRapidity);
143       pair[ipair]->GetPairCuts()->SetCutScheme(cutRapidity->GetName());
144       ::Info("RsnConfigPhi", "Scheme for pair cuts: %s", pair[ipair]->GetPairCuts()->GetCutScheme().Data());
145    }
146    
147    // ==================================================================================================================
148    // == OUTPUTS =======================================================================================================
149    // ==================================================================================================================
150    
151    // now we define the outputs
152    // in the new version of package, we use same syntax as TNtuple:
153    // for each output object we define a name, and a list of variables
154    // which must contain a combination of names of the axes added to the pair
155    // and third argument is an enum to decide what kind of output we want
156
157    AliRsnOutput *ntpMult = new AliRsnOutput("ntp1", "MSPD:MESD", AliRsnOutput::kNtuple);
158    AliRsnOutput *ntpIMPt = new AliRsnOutput("ntp2", "IM:PT"    , AliRsnOutput::kNtuple);
159    AliRsnOutput *fcnIMPt = new AliRsnOutput("out1", "IM:PT"    , AliRsnOutput::kHistoDefault);
160    AliRsnOutput *fcnIM   = new AliRsnOutput("out2", "IM"       , AliRsnOutput::kHistoDefault);
161    AliRsnOutput *fcnPt   = new AliRsnOutput("out3", "PT"       , AliRsnOutput::kHistoDefault);
162    AliRsnOutput *fcnRes  = new AliRsnOutput("out4", "IM:PT:RES", AliRsnOutput::kHistoSparse);
163    
164    // add outputs to pairs
165    for (Int_t ipair = 0; ipair < 4; ipair++) {
166       if (!ipair) pair[ipair]->AddOutput(fcnRes);
167       pair[ipair]->AddOutput(ntpIMPt);
168       //pair[ipair]->AddOutput(fcnIMPt);
169       //pair[ipair]->AddOutput(fcnIM);
170       //pair[ipair]->AddOutput(fcnPt);
171    }
172    if (useMult) event->AddOutput(ntpMult);
173    
174    // ==================================================================================================================
175    // == CONCLUSION ====================================================================================================
176    // ==================================================================================================================
177    
178    // add all created objects to the task
179    for (Int_t i = 0; i < 4; i++) {
180       if (i == 0 && !isMC) continue;
181       if (isMix && i != 1) continue;
182       pair[i]->SetMixed(isMix);
183       task->Add(pair[i]);
184    }
185    if (useMult) task->Add(event);
186    
187    return kTRUE;
188 }