]>
Commit | Line | Data |
---|---|---|
900e06e4 | 1 | #ifndef __CINT__ |
2 | #include <AliAnalysisManager.h> | |
3 | #include <AliMultiInputEventHandler.h> | |
4 | #include <ANALYSIS/EventMixing/AliMixEventPool.h> | |
5 | #include <ANALYSIS/EventMixing/AliMixEventCutObj.h> | |
6 | #include <PWG2/RESONANCES/AliRsnAnalysisTask.h> | |
7 | #include <PWG2/RESONANCES/AliRsnMiniAnalysisTask.h> | |
8 | #endif | |
9 | ||
10 | void AddMixingHandler ( AliMultiInputEventHandler *multiInputHandler,AliAnalysisTaskSE *task, TString format = "esd", Bool_t useMC = kFALSE,Bool_t isRsnMini=kFALSE,const Int_t mixNum = 10, TString opts = "" ) { | |
11 | ||
3248b3db | 12 | Bool_t valid = kTRUE; |
13 | Int_t isPP = AliAnalysisManager::GetGlobalInt("rsnIsPP",valid); | |
14 | ||
547e2d97 | 15 | if (isRsnMini) { |
900e06e4 | 16 | AliRsnMiniAnalysisTask *taskRsn = (AliRsnMiniAnalysisTask *) task; |
17 | ||
18 | // settings | |
19 | if (isPP) | |
20 | taskRsn->UseMultiplicity("QUALITY"); | |
21 | else | |
22 | taskRsn->UseCentrality("V0M"); | |
23 | ||
24 | // set mixing | |
25 | taskRsn->UseContinuousMix(); | |
26 | //task->UseBinnedMix(); | |
27 | taskRsn->SetNMix(mixNum); | |
28 | taskRsn->SetMaxDiffVz(1.0); | |
29 | taskRsn->SetMaxDiffMult(10.0); | |
30 | taskRsn->SetMaxDiffAngle(1E20); | |
31 | ||
32 | } else { | |
33 | if ( !multiInputHandler ) return; | |
34 | ||
35 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
36 | const Int_t bufferSize = 1; | |
37 | AliMixInputEventHandler *mixHandler = new AliMixInputEventHandler ( bufferSize, mixNum ); | |
38 | mixHandler->SetInputHandlerForMixing ( dynamic_cast<AliMultiInputEventHandler *> ( mgr->GetInputEventHandler() ) ); | |
39 | AliMixEventPool *evPool = new AliMixEventPool(); | |
40 | ||
41 | AliMixEventCutObj *multi = 0; | |
42 | ||
43 | if (isPP) { | |
44 | multi = new AliMixEventCutObj ( AliMixEventCutObj::kMultiplicity, 2, 102, 10 ); | |
45 | } else { | |
46 | multi = new AliMixEventCutObj ( AliMixEventCutObj::kCentrality, 0, 100, 10, "V0M" ); | |
47 | } | |
48 | AliMixEventCutObj *zvertex = new AliMixEventCutObj ( AliMixEventCutObj::kZVertex, -10, 10, 1 ); | |
49 | ||
50 | evPool->AddCut(multi); | |
51 | evPool->AddCut ( zvertex ); | |
52 | ||
53 | // adds event pool (comment it and u will have default mixing) | |
54 | mixHandler->SetEventPool ( evPool ); | |
55 | ||
56 | // mixHandler->SelectCollisionCandidates(AliVEvent::kAny); | |
57 | ||
58 | // mixHandler->DoMixIfNotEnoughEvents(kFALSE); | |
59 | ||
60 | multiInputHandler->AddInputEventHandler ( mixHandler ); | |
61 | ||
62 | // adds mixing info task | |
547e2d97 | 63 | RsnLoadMacroFromMixHandler( "AddAnalysisTaskMixInfo.C" ); |
900e06e4 | 64 | AddAnalysisTaskMixInfo (opts ); |
65 | ||
66 | } | |
67 | } | |
547e2d97 | 68 | |
69 | Bool_t RsnLoadMacroFromMixHandler(TString macro,TString path="") { | |
70 | ||
71 | Bool_t valid; | |
72 | TString lego_path = AliAnalysisManager::GetGlobalStr("rsnLegoTrainPath",valid); | |
73 | if (!valid) lego_path = "$ALICE_ROOT/PWG2/RESONANCES/macros/lego_train"; | |
74 | ||
75 | if (!gSystem->AccessPathName(macro.Data())) { | |
76 | gROOT->LoadMacro(macro.Data()); | |
77 | Printf("Macro loaded from %s/%s ...",gSystem->pwd(),macro.Data()); | |
78 | return kTRUE; | |
79 | } | |
80 | ||
81 | if (!gSystem->AccessPathName(gSystem->ExpandPathName(Form("%s/%s",lego_path.Data(),macro.Data())))) { | |
82 | gROOT->LoadMacro(gSystem->ExpandPathName(Form("%s/%s",lego_path.Data(),macro.Data()))); | |
83 | Printf("Macro loaded from %s ...",gSystem->ExpandPathName(Form("%s/%s",lego_path.Data(),macro.Data()))); | |
84 | return kTRUE; | |
85 | } | |
86 | ||
87 | Printf("Error loading %s",macro.Data()); | |
88 | ||
89 | return kFALSE; | |
90 | } |