]>
Commit | Line | Data |
---|---|---|
b425275c | 1 | // |
2 | // Class AliAnalysisTaskMixInfo | |
3 | // | |
4 | // AliAnalysisTaskMixInfo is task | |
5 | // for mixing info | |
6 | // | |
7 | // authors: | |
8 | // Martin Vala (martin.vala@cern.ch) | |
9 | // | |
10 | ||
11 | #include <TList.h> | |
f2db2f8e | 12 | #include <TObjString.h> |
b425275c | 13 | |
14 | #include "AliAnalysisManager.h" | |
15 | ||
16 | #include "AliMixInputEventHandler.h" | |
17 | #include "AliAnalysisTaskMixInfo.h" | |
18 | #include "AliMixInfo.h" | |
19 | #include "AliMixEventPool.h" | |
20 | ||
f2db2f8e | 21 | |
b425275c | 22 | ClassImp(AliAnalysisTaskMixInfo) |
23 | ||
24 | //________________________________________________________________________ | |
25 | AliAnalysisTaskMixInfo::AliAnalysisTaskMixInfo(const char *name) | |
26 | : AliAnalysisTaskSE(name), | |
27 | fOutputList(0), | |
28 | fMixInfo(0), | |
29 | fCurrentEntryTmp(-1), | |
30 | fLogType(AliLog::kInfo), | |
31 | fLogClassesString() | |
32 | { | |
33 | // | |
34 | // Constructor | |
35 | // | |
36 | DefineOutput(1, TList::Class()); | |
37 | } | |
38 | ||
39 | //________________________________________________________________________ | |
40 | AliAnalysisTaskMixInfo::~AliAnalysisTaskMixInfo() | |
41 | { | |
42 | // | |
43 | // Destructor | |
44 | // | |
45 | if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fOutputList; | |
46 | } | |
47 | ||
48 | //________________________________________________________________________ | |
49 | void AliAnalysisTaskMixInfo::UserCreateOutputObjects() | |
50 | { | |
51 | // Create histograms | |
52 | // Called once | |
53 | ||
54 | SetDebugForAllClasses(); | |
55 | fOutputList = new TList(); | |
56 | fOutputList->SetOwner(kTRUE); | |
57 | if (!fMixInfo) InitMixInfo(); | |
58 | ||
59 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
60 | AliMultiInputEventHandler *inEvHMain = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
61 | if (inEvHMain) { | |
62 | AliMixInputEventHandler *mixEH = dynamic_cast<AliMixInputEventHandler *>(inEvHMain->GetFirstMultiInputHandler()); | |
63 | if (mixEH) { | |
64 | AliMixEventPool *evPool = mixEH->GetEventPool(); | |
65 | if (evPool) { | |
66 | evPool->SetBufferSize(mixEH->BufferSize()); | |
67 | evPool->SetMixNumber(mixEH->MixNumber()); | |
68 | fMixInfo->SetEventPool(evPool); | |
69 | } | |
70 | } | |
71 | } | |
72 | ||
73 | if (fMixInfo) fOutputList->Add(fMixInfo); | |
74 | ||
75 | // Post output data. | |
76 | PostData(1, fOutputList); | |
77 | } | |
78 | ||
79 | //________________________________________________________________________ | |
80 | void AliAnalysisTaskMixInfo::UserExec(Option_t *) | |
81 | { | |
82 | // Main loop | |
83 | // Called for each event | |
84 | // if (fCurrentEntry != fCurrentEntryTmp) { | |
85 | // fCurrentEntryTmp = fCurrentEntry; | |
86 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
87 | AliMultiInputEventHandler *inEvHMain = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
88 | if (inEvHMain) { | |
89 | AliMixInputEventHandler *mixEH = dynamic_cast<AliMixInputEventHandler *>(inEvHMain->GetFirstMultiInputHandler()); | |
90 | if (fMixInfo && mixEH) { | |
91 | if (mixEH->BufferSize() > 1) { | |
92 | if (mixEH->NumberMixedTimes() >= mixEH->BufferSize()) | |
93 | fMixInfo->FillHistogram(AliMixInfo::kMainEvents, mixEH->CurrentBinIndex()); | |
94 | } else { | |
95 | fMixInfo->FillHistogram(AliMixInfo::kMainEvents, mixEH->CurrentBinIndex()); | |
96 | } | |
781b6757 | 97 | |
62e756a5 | 98 | // if (mixEH->CurrentEntryMix() >= 0) |
99 | AliDebug(AliLog::kDebug + 1, Form("Main %lld %d [%lld,%lld] %d", mixEH->CurrentEntry(), mixEH->CurrentBinIndex(), mixEH->CurrentEntryMain(), mixEH->CurrentEntryMix(), mixEH->NumberMixed())); | |
781b6757 | 100 | } |
b425275c | 101 | } |
102 | // Post output data. | |
103 | PostData(1, fOutputList); | |
104 | } | |
105 | ||
106 | //________________________________________________________________________ | |
107 | void AliAnalysisTaskMixInfo::UserExecMix(Option_t *) | |
108 | { | |
109 | // UserExecMix | |
110 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
111 | AliMultiInputEventHandler *inEvHMain = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
112 | if (inEvHMain) { | |
113 | AliMixInputEventHandler *mixEH = dynamic_cast<AliMixInputEventHandler *>(inEvHMain->GetFirstMultiInputHandler()); | |
781b6757 | 114 | if (!mixEH) return; |
b425275c | 115 | if (fMixInfo) fMixInfo->FillHistogram(AliMixInfo::kMixedEvents, mixEH->CurrentBinIndex()); |
781b6757 | 116 | if (mixEH->CurrentEntryMix() < 0) { |
b425275c | 117 | AliError("Mix entry is -1 and it should not happen !!!!!"); |
118 | return ; | |
119 | } | |
a86b14f8 | 120 | AliDebug(AliLog::kDebug, Form("Mixing %lld %d [%lld,%lld] %d", mixEH->CurrentEntry(), mixEH->CurrentBinIndex(), mixEH->CurrentEntryMain(), mixEH->CurrentEntryMix(), mixEH->NumberMixed())); |
b425275c | 121 | } |
122 | // Post output data. | |
123 | PostData(1, fOutputList); | |
124 | } | |
125 | ||
126 | //________________________________________________________________________ | |
127 | void AliAnalysisTaskMixInfo::FinishTaskOutput() | |
128 | { | |
129 | // FinishTaskOutput | |
130 | if (fMixInfo) fMixInfo->Print(); | |
131 | } | |
132 | ||
133 | ||
134 | //________________________________________________________________________ | |
135 | void AliAnalysisTaskMixInfo::Terminate(Option_t *) | |
136 | { | |
137 | // Draw result to the screen | |
138 | // Called once at the end of the query | |
139 | fOutputList = dynamic_cast<TList *>(GetOutputData(1)); | |
140 | if (!fOutputList) { | |
141 | AliError("fOutputList not available"); | |
142 | return; | |
143 | } | |
144 | fOutputList->Print(); | |
145 | fMixInfo = (AliMixInfo *) fOutputList->FindObject("mixInfo"); | |
146 | if (fMixInfo) { | |
147 | fMixInfo->Draw("HIST"); | |
148 | AliMixEventPool *evPool = (AliMixEventPool *) fMixInfo->GetEventPool("mixEventPool"); | |
149 | if (evPool) evPool->Print(); | |
150 | } | |
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | void AliAnalysisTaskMixInfo::SetLogType(AliLog::EType_t type, TString allClasses) | |
155 | { | |
156 | // | |
157 | // Set Log level for this and other classes (list of their names) | |
158 | // | |
159 | AliDebug(AliLog::kDebug + 10, "<-"); | |
160 | fLogType = type; | |
161 | fLogClassesString = allClasses; | |
162 | SetDebugForAllClasses(); | |
163 | AliDebug(AliLog::kDebug + 10, "->"); | |
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
167 | void AliAnalysisTaskMixInfo::SetDebugForAllClasses() | |
168 | { | |
169 | // | |
170 | // Set debug level for all classes for which it is required | |
171 | // | |
172 | AliDebug(AliLog::kDebug + 10, "<-"); | |
173 | TObjArray *array = fLogClassesString.Tokenize(":"); | |
174 | TObjString *str; | |
175 | TString strr; | |
176 | for (Int_t i = 0; i < array->GetEntriesFast(); i++) { | |
177 | str = (TObjString *) array->At(i); | |
178 | strr = str->GetString(); | |
179 | AliLog::SetClassDebugLevel(strr.Data(), fLogType); | |
180 | AliDebug(AliLog::kDebug + 5, Form("Setting Debug level %d to %s ...", (Int_t)fLogType - AliLog::kDebug, strr.Data())); | |
181 | } | |
182 | AliDebug(AliLog::kDebug + 10, "->"); | |
183 | } | |
184 | ||
185 | ||
186 | void AliAnalysisTaskMixInfo::InitMixInfo() | |
187 | { | |
188 | // | |
189 | // Init mixing info | |
190 | // | |
191 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
192 | AliMultiInputEventHandler *inEvHMain = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
193 | if (inEvHMain) { | |
b425275c | 194 | AliMixInputEventHandler *mixEH = dynamic_cast<AliMixInputEventHandler *>(inEvHMain->GetFirstMultiInputHandler()); |
195 | if (mixEH) { | |
196 | fMixInfo = new AliMixInfo("mixInfo", "Mix title"); | |
b425275c | 197 | AliMixEventPool *evPool = mixEH->GetEventPool(); |
198 | if (!evPool) { | |
199 | // TList *list = new TList; | |
200 | if (fMixInfo) fMixInfo->CreateHistogram(AliMixInfo::kMainEvents, 1, 1, 2); | |
201 | if (fMixInfo) fMixInfo->CreateHistogram(AliMixInfo::kMixedEvents, 1, 1, 2); | |
202 | } else { | |
203 | if (evPool->NeedInit()) evPool->Init(); | |
204 | Int_t num = evPool->GetListOfEntryLists()->GetEntriesFast(); | |
205 | if (fMixInfo) fMixInfo->CreateHistogram(AliMixInfo::kMainEvents, num, 1, num + 1); | |
206 | if (fMixInfo) fMixInfo->CreateHistogram(AliMixInfo::kMixedEvents, num, 1, num + 1); | |
207 | } | |
208 | } else { | |
209 | AliError("No mixEH"); | |
210 | } | |
211 | } else { | |
212 | AliError("No inEvHMain"); | |
213 | } | |
214 | } |