]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/macros/train/RsnConfigPhiKaonTest.C
PWG2/SPECTRA -> PWGLF/SPECTRA migration
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / train / RsnConfigPhiKaonTest.C
1 //
2 // Test config macro for RSN package.
3 // It configures:
4 // 1) a monitor for all tracks passing quality cuts
5 // 2) a monitor for all tracks passing quality + PID cuts
6 // 3) an unlike-sign invariant-mass + pt distribution for K+K- pairs
7 //
8 Bool_t RsnConfigPhiKaonTest
9 (
10    AliRsnAnalysisTask *task,
11    Bool_t              isMC
12 )
13 {
14    if (!task) {
15       ::Error("RsnConfigPhiKaonTest.C", "NULL task");
16       return kFALSE;
17    }
18    
19    const char *suffix = "test";
20       
21    // ----------------------------------------------------------------------------------------------
22    // -- DEFINITIONS -------------------------------------------------------------------------------
23    // ----------------------------------------------------------------------------------------------
24    
25    // daughter definition for monitor loops
26    // since it is intended to loop over all 'track' like objects (in the sense that we exclude V0s and cascades),
27    // we initialize it using the constructor that requires an AliRsnDaughter::EType and a charge, but since
28    // we want to loop over both charges, we set it to anything which is not '+' '-' or '0', which are tokens for
29    // selecting only positive, only negative or only neutral
30    AliRsnDaughterDef *tracks = new AliRsnDaughterDef(AliRsnDaughter::kTrack, 0);
31    
32    // definition of pair decay tree for phi resonance
33    // here we *must* specify a particle species and a charge, in order to check the decay tree
34    // last arguments are the PDG code and nominal mass of the resonance, which are needed when
35    // one wants to select true pairs only and/or he wants to compute rapidity or Mt 
36    AliRsnPairDef *pairDef = new AliRsnPairDef(AliRsnDaughter::kKaon, '+', AliRsnDaughter::kKaon, '-', 333, 1.019455);
37    
38    // definition of loop objects:
39    // (a) 1 monitor for all tracks passing quality cuts
40    // (b) 1 monitor for all tracks passing quality+PID cuts
41    // (c) 1 pair filled with all tracks passing same cuts as (b)
42    // (d) 1 pair like (c) but for mixing
43    // (e) 1 pair like (c) but with true pairs only
44    // NOTE: (c) and (d) are instantiated with same settings, they will be made
45    //       different after some settings done in second moment
46    AliRsnLoopDaughter *loopQuality = new AliRsnLoopDaughter(Form("%s_mon_quality", suffix), 0, tracks);
47    AliRsnLoopDaughter *loopPID     = new AliRsnLoopDaughter(Form("%s_mon_pid"    , suffix), 0, tracks);
48    AliRsnLoopPair     *loopPhi     = new AliRsnLoopPair    (Form("%s_unlike"     , suffix), pairDef);
49    AliRsnLoopPair     *loopPhiMix  = new AliRsnLoopPair    (Form("%s_unlike"     , suffix), pairDef);
50    AliRsnLoopPair     *loopPhiTrue = new AliRsnLoopPair    (Form("%s_trues"      , suffix), pairDef);
51    
52    // set additional option for true pairs (slot [0])
53    loopPhiTrue->SetOnlyTrue(kTRUE);
54    loopPhiTrue->SetCheckDecay(kTRUE);
55    
56    // set mixing options
57    loopPhi    ->SetMixed(kFALSE);
58    loopPhiMix ->SetMixed(kTRUE);
59    loopPhiTrue->SetMixed(kFALSE);
60    
61    // assign the ID of the entry lists to be used by each pair to get selected daughters
62    // in our case, the AliRsnInputHandler contains only one list for selecting kaons
63    Int_t idQuality, idPID;
64    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
65    AliMultiInputEventHandler *multi = dynamic_cast<AliMultiInputEventHandler*>(mgr->GetInputEventHandler());
66    if (!multi) {
67       myError("Needed a multi input handler!");
68       return kFALSE;
69    }
70    TObjArray *array = multi->InputEventHandlers();
71    AliRsnInputHandler *rsn = (AliRsnInputHandler*)array->FindObject("rsnInputHandler");
72    if (!rsn) {
73       myError("Needed an RSN event handler");
74       return kFALSE;
75    }
76    AliRsnDaughterSelector *sel = rsn->GetSelector();
77    idQuality = sel->GetID("qualityTPC", kTRUE);
78    idPID = sel->GetID("kaonTPC", kTRUE);
79    if (idQuality < 0 || idPID < 0) {
80       myError("List problems");
81       return kFALSE;
82    }
83    loopQuality->SetListID(idQuality);
84    loopPID    ->SetListID(idPID);
85    loopPhi    ->SetListID(0, idPID);
86    loopPhi    ->SetListID(1, idPID);
87    loopPhiMix ->SetListID(0, idPID);
88    loopPhiMix ->SetListID(1, idPID);
89    loopPhiTrue->SetListID(0, idPID);
90    loopPhiTrue->SetListID(1, idPID);
91    
92    // ----------------------------------------------------------------------------------------------
93    // -- EVENT CUTS --------------------------------------------------------------------------------
94    // ----------------------------------------------------------------------------------------------
95
96    // primary vertex:
97    // - 2nd argument --> |Vz| range
98    // - 3rd argument --> minimum required number of contributors
99    // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
100    // we switch on the check for pileup
101    AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE);
102    cutVertex->SetCheckPileUp(kTRUE);
103       
104    // primary vertex is always used
105    AliRsnCutSet *eventCuts = new AliRsnCutSet("eventCuts", AliRsnTarget::kEvent);
106    eventCuts->AddCut(cutVertex);
107    eventCuts->SetCutScheme(cutVertex->GetName());
108    
109    // add the event cuts to all loops
110    loopQuality->SetEventCuts(eventCuts);
111    loopPID    ->SetEventCuts(eventCuts);
112    loopPhi    ->SetEventCuts(eventCuts);
113    loopPhi    ->SetEventCuts(eventCuts);
114    loopPhiMix ->SetEventCuts(eventCuts);
115    loopPhiMix ->SetEventCuts(eventCuts);
116    loopPhiTrue->SetEventCuts(eventCuts);
117    loopPhiTrue->SetEventCuts(eventCuts);
118    
119    // ----------------------------------------------------------------------------------------------
120    // -- PAIR CUTS ---------------------------------------------------------------------------------
121    // ----------------------------------------------------------------------------------------------
122    
123    // for pairs we define a rapidity windows, defined through a cut
124    // --> NOTE: it needs a support AliRsnPairDef from which it takes the mass
125    AliRsnValueStd *valRapidity = new AliRsnValueStd("valY", AliRsnValueStd::kPairY);
126    AliRsnCutValue *cutRapidity = new AliRsnCutValue("cutY", -0.5, 0.5, isMC);
127    valRapidity->SetSupportObject(pairDef);
128    cutRapidity->SetValueObj(valRapidity);
129    
130    // cut set
131    AliRsnCutSet *pairCuts = new AliRsnCutSet("pairCuts", AliRsnTarget::kMother);
132    pairCuts->AddCut(cutRapidity);
133    pairCuts->SetCutScheme(cutRapidity->GetName());
134    
135    // add cut to pair loops only
136    loopPhi    ->SetPairCuts(pairCuts);
137    loopPhi    ->SetPairCuts(pairCuts);
138    loopPhiMix ->SetPairCuts(pairCuts);
139    loopPhiMix ->SetPairCuts(pairCuts);
140    loopPhiTrue->SetPairCuts(pairCuts);
141    loopPhiTrue->SetPairCuts(pairCuts);
142    
143    // ----------------------------------------------------------------------------------------------
144    // -- COMPUTED VALUES & OUTPUTS -----------------------------------------------------------------
145    // ----------------------------------------------------------------------------------------------
146    
147    AliRsnValueStd *axisIM     = new AliRsnValueStd("IM"  , AliRsnValueStd::kPairInvMass   , 0.9,   1.4, 0.001);
148    AliRsnValueStd *axisPt     = new AliRsnValueStd("PT"  , AliRsnValueStd::kPairPt        , 0.0,   5.0, 0.1  );
149    AliRsnValueStd *axisMomTPC = new AliRsnValueStd("pTPC", AliRsnValueStd::kTrackPtpc     , 0.0,   5.0, 0.01 );
150    AliRsnValueStd *axisSigTPC = new AliRsnValueStd("sTPC", AliRsnValueStd::kTrackTPCsignal, 0.0, 500.0, 2.0  );
151    
152    // output for monitors:
153    // 2D histogram with TPC signal vs TPC momentum
154    AliRsnListOutput *outMonitor = new AliRsnListOutput("mon", AliRsnListOutput::kHistoDefault);
155    outMonitor->AddValue(axisMomTPC);
156    outMonitor->AddValue(axisSigTPC);
157    
158    // output for pairs:
159    // 2D histogram with inv.mass vs pt
160    AliRsnListOutput *outPair = new AliRsnListOutput("pair", AliRsnListOutput::kHistoDefault);
161    outPair->AddValue(axisIM);
162    outPair->AddValue(axisPt);
163    
164    // add outputs to loops
165    loopQuality->AddOutput(outMonitor);
166    loopPID    ->AddOutput(outMonitor);
167    loopPhi    ->AddOutput(outPair);
168    loopPhiMix ->AddOutput(outPair);
169    loopPhiTrue->AddOutput(outPair);
170    
171    // ----------------------------------------------------------------------------------------------
172    // -- CONCLUSION --------------------------------------------------------------------------------
173    // ----------------------------------------------------------------------------------------------
174    
175    task->Add(loopQuality);
176    task->Add(loopPID    );
177    task->Add(loopPhi    );
178    task->Add(loopPhiMix );
179    task->Add(loopPhiTrue);
180    
181    return kTRUE;
182 }