]> 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    Double_t    dcaProduct = -1E-4,
48    Float_t     maxDiffVzMix = 1.0,
49    Float_t     maxDiffMultMix = 10.0,
50    Float_t     maxDiffAngleMixDeg = 20.0,
51    Int_t       aodN = 0,
52    TString     outNameSuffix = "D0"
53 )
54 {  
55   //
56   // -- INITIALIZATION ----------------------------------------------------------------------------
57   // retrieve analysis manager
58   //
59   
60   UInt_t trigger = 0;
61   
62   
63   
64   TString eventType = "";
65    if(triggerMask=="AliVEvent::kMB | AliVEvent::kCentral") {trigger = AliVEvent::kMB | AliVEvent::kCentral; eventType+="Central";}
66    else if(triggerMask=="AliVEvent::kMB | AliVEvent::kSemiCentral") {trigger = AliVEvent::kMB | AliVEvent::kSemiCentral; eventType+="SemiCentral";}
67    else if(triggerMask=="AliVEvent::kINT7") {trigger = AliVEvent::kINT7; eventType+="kINT7";}
68    else if(triggerMask=="AliVEvent::kMB") {trigger = AliVEvent::kMB; eventType+="MinimumBias";}
69
70   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
71    if (!mgr) {
72       ::Error("AddAnalysisTaskD0", "No analysis manager to connect to.");
73       return NULL;
74    } 
75
76    // create the task and configure 
77    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());
78    AliRsnMiniAnalysisTask *task = new AliRsnMiniAnalysisTask(taskName.Data(), isMC);
79    if (!isMC && !isPP){
80      Printf(Form("========== SETTING USE CENTRALITY PATCH AOD049 : %s", (aodN==49)? "yes" : "no"));
81      task->SetUseCentralityPatch(aodN==49);
82    }
83    
84    ::Info("AddAnalysisTaskD0", Form("TriggerMask: %i",trigger));
85
86    task->SelectCollisionCandidates(trigger);
87    task->SetMaxNDaughters(maxSisters);
88    task->SetCheckMomentumConservation(checkP);
89    task->SetCheckFeedDown(checkFeedDown);
90    task->SetRejectCandidateIfNotFromQuark(checkQuark);
91    task->SetDselection(originDselection);
92    
93       
94    ::Info("AddAnalysisTaskD0", Form("Maximum numbers of daughters allowed (-1 means cut not applied): %i",maxSisters));
95    ::Info("AddAnalysisTaskD0", Form("Are we checking the momentum conservation? %s", checkP? "yes" : "no"));
96    ::Info("AddAnalysisTaskD0", Form("Are we checking the feedown? %s", checkFeedDown? "yes" : "no"));
97    ::Info("AddAnalysisTaskD0", Form("Are we rejecting the Hijing generated? %s", checkQuark? "yes" : "no"));
98    ::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") ));
99
100
101    if (isPP) 
102      task->UseMultiplicity("QUALITY");
103    else
104      task->UseCentrality(centrality);   
105    // set event mixing options
106    task->UseContinuousMix();
107    //task->UseBinnedMix();
108    task->SetNMix(nmix);
109    task->SetMaxDiffVz(maxDiffVzMix);
110    task->SetMaxDiffMult(maxDiffMultMix);
111    if (!isPP && !ispPb) task->SetMaxDiffAngle(maxDiffAngleMixDeg*TMath::DegToRad()); //set angle diff in rad
112    ::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)));
113    
114    mgr->AddTask(task);
115    
116    //
117    // -- EVENT CUTS (same for all configs) ---------------------------------------------------------
118    //  
119    // cut on primary vertex:
120    // - 2nd argument --> |Vz| range
121    // - 3rd argument --> minimum required number of contributors
122    // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
123    AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", cutV, 0, kFALSE);
124    if (isPP || ispPb) cutVertex->SetCheckPileUp(kTRUE);   // set the check for pileup
125    
126    // define and fill cut set for event cut
127    AliRsnCutSet *eventCuts = new AliRsnCutSet("eventCuts", AliRsnTarget::kEvent);
128    eventCuts->AddCut(cutVertex);
129    eventCuts->SetCutScheme(cutVertex->GetName());
130    // set cuts in task
131    task->SetEventCuts(eventCuts);
132    
133    //
134    // -- EVENT-ONLY COMPUTATIONS -------------------------------------------------------------------
135    //   
136    //vertex
137    Int_t vtxID = task->CreateValue(AliRsnMiniValue::kVz, kFALSE);
138    AliRsnMiniOutput *outVtx = task->CreateOutput("eventVtx", "HIST", "EVENT");
139    outVtx->AddAxis(vtxID, 400, -20.0, 20.0);
140    
141    //multiplicity or centrality
142    Int_t multID = task->CreateValue(AliRsnMiniValue::kMult, kFALSE);
143    AliRsnMiniOutput *outMult = task->CreateOutput("eventMult", "HIST", "EVENT");
144    if (isPP) 
145      outMult->AddAxis(multID, 400, 0.0, 400.0);
146    else
147      outMult->AddAxis(multID, 100, 0.0, 100.0);
148    
149    //event plane (only for PbPb)
150    Int_t planeID = task->CreateValue(AliRsnMiniValue::kPlaneAngle, kFALSE);
151    AliRsnMiniOutput *outPlane = 0x0;
152    if (!isPP){
153      outPlane = task->CreateOutput("eventPlane", "HIST", "EVENT");
154      outPlane->AddAxis(planeID, 180, 0.0, TMath::Pi());
155      }
156      
157    TH2F* hvz=new TH2F("hVzVsCent","",100,0.,100., 220,-11.,11.);
158    task->SetEventQAHist("vz",hvz);//plugs this histogram into the fHAEventVz data member
159
160    TH2F* hmc=new TH2F("MultiVsCent","",100,0.,100.,4000,0.,4000.);
161    hmc->GetYaxis()->SetTitle("QUALITY");
162    task->SetEventQAHist("multicent",hmc);//plugs this histogram into the fHAEventMultiCent data member
163
164    TH2F* hep=new TH2F("hEventPlaneVsCent","",100,0.,100., 180,0.,TMath::Pi());
165    task->SetEventQAHist("eventplane",hep);//plugs this histogram into the fHAEventPlane data member
166    
167    //
168    // -- PAIR CUTS (common to all resonances) ------------------------------------------------------
169    //
170    AliRsnCutMiniPair *cutY = new AliRsnCutMiniPair("cutRapidity", AliRsnCutMiniPair::kRapidityRange);
171    cutY->SetRangeD(minYlab, maxYlab);
172    
173    AliRsnCutMiniPair *cutDCAproduct = new AliRsnCutMiniPair("cutDCAproduct", AliRsnCutMiniPair::kDCAproduct);
174    cutDCAproduct->SetRangeD(-1E20, dcaProduct);
175    
176    AliRsnCutSet *cutsPairY = new AliRsnCutSet("pairCutsY", AliRsnTarget::kMother);
177    cutsPairY->AddCut(cutY);
178    cutsPairY->UseMonitor(kTRUE);
179    cutsPairY->SetCutScheme("setPairD0_Y");
180    cutsPairY->ShowCuts();
181    cutsPairY->PrintSetInfo();
182    
183    AliRsnCutSet *cutsPair = new AliRsnCutSet("pairCuts", AliRsnTarget::kMother);
184    cutsPair->AddCut(cutY);
185    cutsPair->AddCut(cutDCAproduct);
186    cutsPair->UseMonitor(kTRUE);
187    cutsPair->SetCutScheme(Form("%s&%s", cutY->GetName(), cutDCAproduct->GetName()));
188    cutsPair->ShowCuts();
189    cutsPair->PrintSetInfo();
190    
191    //
192    // -- CONFIG ANALYSIS --------------------------------------------------------------------------
193    gROOT->LoadMacro("$ALICE_ROOT/PWGLF/RESONANCES/macros/mini/ConfigD0.C");
194
195    if (isMC) {
196        Printf("========================== MC analysis - PID cuts used");
197    } else 
198      Printf("========================== DATA analysis - PID cuts used");
199    if (!ConfigD0(task, isPP, isMC, nsigmaTPCPi, nsigmaTPCKa, nsigmaTOFPi, nsigmaTOFKa, aodFilterBit, trackDCAcutMax, trackDCAcutMin, trackDCAZcutMax, NTPCcluster, minpt, maxSisters, checkP,  minDCAcutFixed, maxDCAcutFixed, ptdepPIDcut, checkFeedDown, checkQuark, originDselection, "", cutsPairY, cutsPair)) return 0x0;
200    
201    //
202    // -- CONTAINERS --------------------------------------------------------------------------------
203    //
204    TString outputFileName = AliAnalysisManager::GetCommonFileName();
205    Printf("AddAnalysisTaskD0 - Set OutputFileName : \n %s\n", outputFileName.Data() );
206    
207    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()), 
208                                                            TList::Class(), 
209                                                            AliAnalysisManager::kOutputContainer, 
210                                                            outputFileName);
211    mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
212    mgr->ConnectOutput(task, 1, output);
213    
214    return task;
215 }