]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/macros/mini/AddAnalysisTaskD0.C
Updated macros from Massimo
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / mini / AddAnalysisTaskD0.C
1 /***************************************************************************
2               fbellini@cern.ch - last modified on 06/08/2012
3 //
4 // General macro to configure the RSN analysis task.
5 // It calls all configs desired by the user, by means
6 // of the boolean switches defined in the first lines.
7 // ---
8 // Inputs:
9 //  1) flag to know if running on MC or data
10 //  2) path where all configs are stored
11 // ---
12 // Returns:
13 //  kTRUE  --> initialization successful
14 //  kFALSE --> initialization failed (some config gave errors)
15 //
16 ****************************************************************************/
17
18 AliRsnMiniAnalysisTask * AddAnalysisTaskD0
19 (
20    Bool_t      isMC,
21    Bool_t      isPP,
22    Bool_t      ispPb,
23    TString     centrality = "V0M",
24    Float_t     cutV = 10.0,
25    Int_t       aodFilterBit = 5,  
26    Float_t     nsigmaTPCPi = 3.0,
27    Float_t     nsigmaTPCKa = 3.0,
28    Float_t     nsigmaTOFPi = 2.0,
29    Float_t     nsigmaTOFKa = 2.0,
30    Float_t     trackDCAcutMax = 7.0,
31    Float_t     trackDCAcutMin = 0.0,
32    Float_t     trackDCAZcutMax = 2.0,
33    Int_t       NTPCcluster = 70,
34    Double_t    minpt = 0.15,
35    TString     triggerMask = AliVEvent::kMB,
36    Short_t     maxSisters = 2,
37    Bool_t      checkP = kTRUE,
38    Bool_t      minDCAcutFixed = kFALSE,
39    Bool_t      maxDCAcutFixed = kFALSE,
40    Bool_t      ptdepPIDcut = kFALSE,
41    Bool_t      checkFeedDown = kTRUE,
42    Bool_t      checkQuark = kTRUE,
43    UShort_t    originDselection = 0,
44    Int_t       nmix = 5,
45    Double_t    minYlab =  -0.5,
46    Double_t    maxYlab =  0.5,
47    Float_t     mineta = -0.8,
48    Float_t     maxeta = 0.8,
49    Float_t     min_inv_mass = 0.6,
50    Float_t     max_inv_mass = 2.2,
51    Int_t       bins = 320,
52    Double_t    dcaProduct = -1E-4,
53    Float_t     maxDiffVzMix = 1.0,
54    Float_t     maxDiffMultMix = 10.0,
55    Float_t     maxDiffAngleMixDeg = 20.0,
56    Int_t       aodN = 0,
57    TString     outNameSuffix = "D0"
58 )
59 {  
60   //
61   // -- INITIALIZATION ----------------------------------------------------------------------------
62   // retrieve analysis manager
63   //
64   
65   UInt_t trigger = 0;
66   
67   
68   
69   TString eventType = "";
70    if(triggerMask=="AliVEvent::kMB | AliVEvent::kCentral") {trigger = AliVEvent::kMB | AliVEvent::kCentral; eventType+="Central";}
71    else if(triggerMask=="AliVEvent::kMB | AliVEvent::kSemiCentral") {trigger = AliVEvent::kMB | AliVEvent::kSemiCentral; eventType+="SemiCentral";}
72    else if(triggerMask=="AliVEvent::kINT7") {trigger = AliVEvent::kINT7; eventType+="kINT7";}
73    else if(triggerMask=="AliVEvent::kMB") {trigger = AliVEvent::kMB; eventType+="MinimumBias";}
74
75   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
76    if (!mgr) {
77       ::Error("AddAnalysisTaskD0", "No analysis manager to connect to.");
78       return NULL;
79    } 
80
81    // create the task and configure 
82    TString taskName = Form("D0%s%s_%.1f_%d_%.1f_%.1f_%.1f_%.1f_%.1f_%.4f_%.1f_%.5f_%.2f_%s", (isPP? "pp" : ispPb? "pPB": "PbPb"), (isMC ? "MC" : "Data"), cutV, NTPCcluster, nsigmaTPCPi, nsigmaTPCKa, nsigmaTOFPi, nsigmaTOFKa, trackDCAcutMax, trackDCAcutMin, trackDCAZcutMax, dcaProduct, minpt, eventType.Data());
83    AliRsnMiniAnalysisTask *task = new AliRsnMiniAnalysisTask(taskName.Data(), isMC);
84    if (!isMC && !isPP){
85      Printf(Form("========== SETTING USE CENTRALITY PATCH AOD049 : %s", (aodN==49)? "yes" : "no"));
86      task->SetUseCentralityPatch(aodN==49);
87    }
88    
89    ::Info("AddAnalysisTaskD0", Form("TriggerMask: %i",trigger));
90
91    task->SelectCollisionCandidates(trigger);
92    task->SetMaxNDaughters(maxSisters);
93    task->SetCheckMomentumConservation(checkP);
94    task->SetCheckFeedDown(checkFeedDown);
95    task->SetRejectCandidateIfNotFromQuark(checkQuark);
96    task->SetDselection(originDselection);
97    
98       
99    ::Info("AddAnalysisTaskD0", Form("Maximum numbers of daughters allowed (-1 means cut not applied): %i",maxSisters));
100    ::Info("AddAnalysisTaskD0", Form("Are we checking the momentum conservation? %s", checkP? "yes" : "no"));
101    ::Info("AddAnalysisTaskD0", Form("Are we checking the feedown? %s", checkFeedDown? "yes" : "no"));
102    ::Info("AddAnalysisTaskD0", Form("Are we rejecting the Hijing generated? %s", checkQuark? "yes" : "no"));
103    ::Info("AddAnalysisTaskD0", Form("Which D0 are we keeping? %s", (originDselection==0? "only from c quark" : originDselection==1? "only from b quark" : "both from c and b quark") ));
104
105
106    if (isPP) 
107      task->UseMultiplicity("QUALITY");
108    else
109      task->UseCentrality(centrality);   
110    // set event mixing options
111    task->UseContinuousMix();
112    //task->UseBinnedMix();
113    task->SetNMix(nmix);
114    task->SetMaxDiffVz(maxDiffVzMix);
115    task->SetMaxDiffMult(maxDiffMultMix);
116    if (!isPP && !ispPb) task->SetMaxDiffAngle(maxDiffAngleMixDeg*TMath::DegToRad()); //set angle diff in rad
117    ::Info("AddAnalysisTaskD0", Form("Event mixing configuration: \n events to mix = %i \n max diff. vtxZ = cm %5.3f \n max diff multi = %5.3f \n max diff EP angle = %5.3f deg", nmix, maxDiffVzMix, maxDiffMultMix, (isPP ? 0.0 : ispPb ? 0.0 : maxDiffAngleMixDeg)));
118    
119    mgr->AddTask(task);
120    
121    //
122    // -- EVENT CUTS (same for all configs) ---------------------------------------------------------
123    //  
124    // cut on primary vertex:
125    // - 2nd argument --> |Vz| range
126    // - 3rd argument --> minimum required number of contributors
127    // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
128    AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", cutV, 0, kFALSE);
129    if (isPP || ispPb) cutVertex->SetCheckPileUp(kTRUE);   // set the check for pileup
130    
131    // define and fill cut set for event cut
132    AliRsnCutSet *eventCuts = new AliRsnCutSet("eventCuts", AliRsnTarget::kEvent);
133    eventCuts->AddCut(cutVertex);
134    eventCuts->SetCutScheme(cutVertex->GetName());
135    // set cuts in task
136    task->SetEventCuts(eventCuts);
137    
138    //
139    // -- EVENT-ONLY COMPUTATIONS -------------------------------------------------------------------
140    //   
141    //vertex
142    Int_t vtxID = task->CreateValue(AliRsnMiniValue::kVz, kFALSE);
143    AliRsnMiniOutput *outVtx = task->CreateOutput("eventVtx", "HIST", "EVENT");
144    outVtx->AddAxis(vtxID, 400, -20.0, 20.0);
145    
146    //multiplicity or centrality
147    Int_t multID = task->CreateValue(AliRsnMiniValue::kMult, kFALSE);
148    AliRsnMiniOutput *outMult = task->CreateOutput("eventMult", "HIST", "EVENT");
149    if (isPP) 
150      outMult->AddAxis(multID, 400, 0.0, 400.0);
151    else
152      outMult->AddAxis(multID, 100, 0.0, 100.0);
153    
154    //event plane (only for PbPb)
155    Int_t planeID = task->CreateValue(AliRsnMiniValue::kPlaneAngle, kFALSE);
156    AliRsnMiniOutput *outPlane = 0x0;
157    if (!isPP){
158      outPlane = task->CreateOutput("eventPlane", "HIST", "EVENT");
159      outPlane->AddAxis(planeID, 180, 0.0, TMath::Pi());
160      }
161      
162    TH2F* hvz=new TH2F("hVzVsCent","",100,0.,100., 220,-11.,11.);
163    task->SetEventQAHist("vz",hvz);//plugs this histogram into the fHAEventVz data member
164
165    TH2F* hmc=new TH2F("MultiVsCent","",100,0.,100.,4000,0.,4000.);
166    hmc->GetYaxis()->SetTitle("QUALITY");
167    task->SetEventQAHist("multicent",hmc);//plugs this histogram into the fHAEventMultiCent data member
168
169    TH2F* hep=new TH2F("hEventPlaneVsCent","",100,0.,100., 180,0.,TMath::Pi());
170    task->SetEventQAHist("eventplane",hep);//plugs this histogram into the fHAEventPlane data member
171    
172    //
173    // -- PAIR CUTS (common to all resonances) ------------------------------------------------------
174    //
175    AliRsnCutMiniPair *cutY = new AliRsnCutMiniPair("cutRapidity", AliRsnCutMiniPair::kRapidityRange);
176    cutY->SetRangeD(minYlab, maxYlab);
177    
178    AliRsnCutMiniPair *cutDCAproduct = new AliRsnCutMiniPair("cutDCAproduct", AliRsnCutMiniPair::kDCAproduct);
179    cutDCAproduct->SetRangeD(-1E20, dcaProduct);
180    
181    AliRsnCutSet *cutsPairY = new AliRsnCutSet("pairCutsY", AliRsnTarget::kMother);
182    cutsPairY->AddCut(cutY);
183    cutsPairY->UseMonitor(kTRUE);
184    cutsPairY->SetCutScheme("setPairD0_Y");
185    cutsPairY->ShowCuts();
186    cutsPairY->PrintSetInfo();
187    
188    AliRsnCutSet *cutsPair = new AliRsnCutSet("pairCuts", AliRsnTarget::kMother);
189    cutsPair->AddCut(cutY);
190    cutsPair->AddCut(cutDCAproduct);
191    cutsPair->UseMonitor(kTRUE);
192    cutsPair->SetCutScheme(Form("%s&%s", cutY->GetName(), cutDCAproduct->GetName()));
193    cutsPair->ShowCuts();
194    cutsPair->PrintSetInfo();
195    
196    //
197    // -- CONFIG ANALYSIS --------------------------------------------------------------------------
198    gROOT->LoadMacro("$ALICE_ROOT/PWGLF/RESONANCES/macros/mini/ConfigD0.C");
199
200    if (isMC) {
201        Printf("========================== MC analysis - PID cuts used");
202    } else 
203      Printf("========================== DATA analysis - PID cuts used");
204    if (!ConfigD0(task, isPP, isMC, nsigmaTPCPi, nsigmaTPCKa, nsigmaTOFPi, nsigmaTOFKa, aodFilterBit, trackDCAcutMax, trackDCAcutMin, trackDCAZcutMax, NTPCcluster, minpt, maxSisters, checkP,  minDCAcutFixed, maxDCAcutFixed, ptdepPIDcut, checkFeedDown, checkQuark, originDselection, mineta, maxeta, min_inv_mass, max_inv_mass, bins, "", cutsPairY, cutsPair)) return 0x0;
205    
206    //
207    // -- CONTAINERS --------------------------------------------------------------------------------
208    //
209    TString outputFileName = AliAnalysisManager::GetCommonFileName();
210    Printf("AddAnalysisTaskD0 - Set OutputFileName : \n %s\n", outputFileName.Data() );
211    
212    AliAnalysisDataContainer *output = mgr->CreateContainer(Form("%s_%.1f_%d_%.1f_%.1f_%.1f_%.1f_%.1f_%.4f_%.1f_%.5f_%.2f_%s",outNameSuffix.Data(),cutV,NTPCcluster,nsigmaTPCPi,nsigmaTPCKa,nsigmaTOFPi,nsigmaTOFKa,trackDCAcutMax,trackDCAcutMin,trackDCAZcutMax,dcaProduct,minpt,eventType.Data()), 
213                                                            TList::Class(), 
214                                                            AliAnalysisManager::kOutputContainer, 
215                                                            outputFileName);
216    mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
217    mgr->ConnectOutput(task, 1, output);
218    
219    return task;
220 }