]>
Commit | Line | Data |
---|---|---|
94b94be0 | 1 | ///////////////////////////////////////////////////////\r |
2 | //\r | |
3 | // Basic class for Performance/Calibration TRD tasks\r | |
4 | // \r | |
5 | // It performs generic tasks like :\r | |
6 | // - data file manegment\r | |
7 | // - reference container management\r | |
8 | // - debug container management\r | |
9 | // - interaction with AliAnalysisManager\r | |
10 | // - Plot functor loop\r | |
11 | //\r | |
12 | // Author: Alexandru Bercuci <A.Bercuci@gsi.de>, 10/09/2008\r | |
13 | //\r | |
14 | /////////////////////////////////////////////////////////\r | |
15 | \r | |
16 | #include "TClass.h"\r | |
17 | #include "TMethod.h"\r | |
18 | #include "TMethodCall.h"\r | |
19 | #include "TMethodArg.h"\r | |
20 | #include "TFile.h"\r | |
21 | #include "TChain.h"\r | |
22 | #include "TList.h"\r | |
23 | #include "TMap.h"\r | |
24 | #include "TH1.h"\r | |
eb05d549 | 25 | #include "TH2.h"\r |
26 | #include "TH3.h"\r | |
94b94be0 | 27 | #include "TF1.h"\r |
28 | #include "TObjArray.h"\r | |
29 | #include "TDirectory.h"\r | |
30 | #include "TTreeStream.h"\r | |
82e6e5dc | 31 | #include "TBox.h"\r |
5591f3d6 | 32 | #include "TLatex.h"\r |
82e6e5dc | 33 | #include "TVectorT.h"\r |
94b94be0 | 34 | \r |
35 | #include "AliLog.h"\r | |
36 | #include "AliAnalysisTask.h"\r | |
100f4577 | 37 | #include "AliAnalysisManager.h"\r |
3ceb45ae | 38 | #include "AliExternalTrackParam.h"\r |
94b94be0 | 39 | \r |
dffc3357 | 40 | #include "info/AliTRDchmbInfo.h"\r |
94b94be0 | 41 | #include "info/AliTRDeventInfo.h"\r |
847569f2 | 42 | #include "info/AliTRDtrendingManager.h"\r |
94b94be0 | 43 | #include "AliTRDrecoTask.h"\r |
3ceb45ae | 44 | #include "AliTRDtrackV1.h"\r |
45 | #include "AliTRDpidUtil.h"\r | |
94b94be0 | 46 | \r |
47 | ClassImp(AliTRDrecoTask)\r | |
48 | \r | |
95d47440 | 49 | Float_t AliTRDrecoTask::fgPt[AliTRDrecoTask::fgNPt+1] = {0.};\r |
94b94be0 | 50 | TTreeSRedirector* AliTRDrecoTask::fgDebugStream(NULL);\r |
95d47440 | 51 | TH1* AliTRDrecoTask::fgProjector(NULL);\r |
94b94be0 | 52 | //_______________________________________________________\r |
53 | AliTRDrecoTask::AliTRDrecoTask()\r | |
54 | : AliAnalysisTaskSE()\r | |
55 | ,fNRefFigures(0)\r | |
82e6e5dc | 56 | ,fDets(NULL)\r |
33056e04 | 57 | ,fDetsV(NULL)\r |
94b94be0 | 58 | ,fContainer(NULL)\r |
59 | ,fEvent(NULL)\r | |
60 | ,fTracks(NULL)\r | |
f073d500 | 61 | ,fClusters(NULL)\r |
62 | ,fkClusters(NULL)\r | |
94b94be0 | 63 | ,fkTrack(NULL)\r |
64 | ,fkMC(NULL)\r | |
65 | ,fkESD(NULL)\r | |
3ceb45ae | 66 | ,fSpecies(-6)\r |
5047978d | 67 | ,fTriggerSlot(0)\r |
3ceb45ae | 68 | ,fPt(-1.)\r |
69 | ,fPhi(0.)\r | |
70 | ,fEta(0.)\r | |
0f2c4c4f | 71 | ,fNpt(0)\r |
dffc3357 | 72 | ,fTriggerList(NULL)\r |
94b94be0 | 73 | ,fPlotFuncList(NULL)\r |
f073d500 | 74 | ,fDetFuncList(NULL)\r |
94b94be0 | 75 | ,fRunTerminate(kFALSE)\r |
76 | {\r | |
77 | // Default constructor\r | |
78 | snprintf(fNameId, 10, "no name");\r | |
79 | }\r | |
80 | \r | |
81 | //_______________________________________________________\r | |
82 | AliTRDrecoTask::AliTRDrecoTask(const char *name, const char *title)\r | |
83 | : AliAnalysisTaskSE(name)\r | |
84 | ,fNRefFigures(0)\r | |
82e6e5dc | 85 | ,fDets(NULL)\r |
33056e04 | 86 | ,fDetsV(NULL)\r |
94b94be0 | 87 | ,fContainer(NULL)\r |
88 | ,fEvent(NULL)\r | |
89 | ,fTracks(NULL)\r | |
f073d500 | 90 | ,fClusters(NULL)\r |
91 | ,fkClusters(NULL)\r | |
94b94be0 | 92 | ,fkTrack(NULL)\r |
93 | ,fkMC(NULL)\r | |
94 | ,fkESD(NULL)\r | |
3ceb45ae | 95 | ,fSpecies(-6)\r |
5047978d | 96 | ,fTriggerSlot(0)\r |
3ceb45ae | 97 | ,fPt(-1.)\r |
98 | ,fPhi(0.)\r | |
99 | ,fEta(0.)\r | |
0f2c4c4f | 100 | ,fNpt(0)\r |
dffc3357 | 101 | ,fTriggerList(NULL)\r |
94b94be0 | 102 | ,fPlotFuncList(NULL)\r |
f073d500 | 103 | ,fDetFuncList(NULL)\r |
94b94be0 | 104 | ,fRunTerminate(kFALSE)\r |
105 | {\r | |
106 | // Constructor for all derived performance tasks\r | |
107 | \r | |
108 | SetTitle(title);\r | |
109 | snprintf(fNameId, 10, "no name");\r | |
110 | DefineInput (1, TObjArray::Class()); // track list\r | |
111 | DefineInput (2, AliTRDeventInfo::Class()); // event info object\r | |
f073d500 | 112 | DefineInput (3, TObjArray::Class()); // cluster list object\r |
94b94be0 | 113 | DefineOutput(1, TObjArray::Class()); // histogram list\r |
114 | }\r | |
115 | \r | |
116 | //_______________________________________________________\r | |
117 | AliTRDrecoTask::~AliTRDrecoTask() \r | |
118 | {\r | |
119 | \r | |
120 | // Generic task destructor\r | |
121 | \r | |
122 | AliDebug(2, Form(" Ending task %s[%s]", GetName(), GetTitle()));\r | |
95d47440 | 123 | if(fgDebugStream){\r |
94b94be0 | 124 | delete fgDebugStream;\r |
125 | fgDebugStream = NULL;\r | |
126 | }\r | |
127 | \r | |
95d47440 | 128 | if(fgProjector){\r |
129 | delete fgProjector;\r | |
130 | fgProjector = NULL;\r | |
131 | }\r | |
132 | \r | |
94b94be0 | 133 | if(fPlotFuncList){\r |
134 | fPlotFuncList->Delete();\r | |
135 | delete fPlotFuncList;\r | |
136 | fPlotFuncList = NULL;\r | |
137 | }\r | |
f073d500 | 138 | if(fDetFuncList){\r |
139 | fDetFuncList->Delete();\r | |
140 | delete fDetFuncList;\r | |
141 | fDetFuncList = NULL;\r | |
142 | }\r | |
94b94be0 | 143 | \r |
82e6e5dc | 144 | if(fDets){\r |
145 | if(fDets->IsOwner()) fDets->Delete();\r | |
146 | delete fDets;\r | |
147 | fDets = NULL;\r | |
148 | }\r | |
33056e04 | 149 | if(fDetsV) delete fDetsV; fDetsV=NULL;\r |
dffc3357 | 150 | if(fTriggerList){fTriggerList->Delete(); delete fTriggerList;}\r |
82e6e5dc | 151 | \r |
f0857a6a | 152 | if(fContainer && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){\r |
94b94be0 | 153 | if(fContainer->IsOwner()) fContainer->Delete();\r |
154 | delete fContainer;\r | |
155 | fContainer = NULL;\r | |
156 | }\r | |
157 | \r | |
847569f2 | 158 | /* if(fgTrendPoint){\r |
94b94be0 | 159 | TFile::Open("TRD.PerformanceTrend.root", "UPDATE");\r |
160 | fgTrendPoint->Write();\r | |
161 | delete fgTrendPoint;\r | |
162 | fgTrendPoint=NULL;\r | |
163 | gFile->Close();\r | |
847569f2 | 164 | }*/\r |
94b94be0 | 165 | }\r |
166 | \r | |
167 | //_______________________________________________________\r | |
168 | Int_t AliTRDrecoTask::GetNRefFigures() const \r | |
169 | { \r | |
170 | if(!fNRefFigures) AliWarning("No reference plots available.");\r | |
171 | return fNRefFigures; \r | |
172 | } \r | |
173 | \r | |
33056e04 | 174 | //____________________________________________________________________\r |
0f2c4c4f | 175 | Int_t AliTRDrecoTask::GetPtBin(Float_t pt)\r |
33056e04 | 176 | {\r |
177 | // Get significant (very low, low, medium, high, very high) pt bin\r | |
178 | \r | |
179 | Int_t ipt(0);\r | |
0f2c4c4f | 180 | while(ipt<fNpt){\r |
181 | if(pt<fgPt[ipt]) break;\r | |
33056e04 | 182 | ipt++;\r |
183 | }\r | |
184 | return ipt-1;\r | |
185 | }\r | |
186 | \r | |
0f2c4c4f | 187 | //_______________________________________________________\r |
188 | Bool_t AliTRDrecoTask::MakeMomSegmentation()\r | |
189 | {\r | |
190 | switch(fNpt){\r | |
191 | case fgNPt:\r | |
95d47440 | 192 | fgPt[0]=0.3;\r |
0f2c4c4f | 193 | for(Int_t j(1); j<=fgNPt; j++) fgPt[j]=fgPt[j-1]+(TMath::Exp(j*j*2.e-3)-1.);\r |
194 | AliDebug(2, "Using debug momentum segmentation");\r | |
195 | break;\r | |
196 | case 4:\r | |
197 | fgPt[0]=0.5; fgPt[1]=0.8; fgPt[2]=1.5; fgPt[3]=5.;\r | |
198 | AliDebug(2, "Using default momentum segmentation");\r | |
199 | break;\r | |
200 | default:\r | |
201 | AliError(Form("Momentum segmentation %d not supported.", fNpt));\r | |
202 | fNpt=0;\r | |
203 | return kFALSE;\r | |
204 | }\r | |
205 | return kTRUE;\r | |
206 | }\r | |
207 | \r | |
94b94be0 | 208 | //_______________________________________________________\r |
209 | void AliTRDrecoTask::UserCreateOutputObjects()\r | |
210 | {\r | |
211 | if(!HasFunctorList()) InitFunctorList();\r | |
0f2c4c4f | 212 | if(DebugLevel()) fNpt = fgNPt;\r |
213 | else fNpt = 4;\r | |
214 | MakeMomSegmentation();\r | |
215 | \r | |
94b94be0 | 216 | fContainer = Histos();\r |
217 | PostData(1, fContainer);\r | |
218 | }\r | |
219 | \r | |
220 | //_______________________________________________________\r | |
221 | void AliTRDrecoTask::UserExec(Option_t *)\r | |
222 | {\r | |
223 | // Loop over Plot functors published by particular tasks\r | |
224 | \r | |
f073d500 | 225 | fTracks = dynamic_cast<TObjArray *>(GetInputData(1));\r |
226 | fEvent = dynamic_cast<AliTRDeventInfo *>(GetInputData(2));\r | |
dffc3357 | 227 | fTriggerSlot=0;\r |
8d065f1b | 228 | if(fTriggerList && fEvent){\r |
dffc3357 | 229 | for(Int_t itrig(0); itrig<fTriggerList->GetEntries(); itrig++){\r |
230 | if(!fEvent->GetFiredTriggerClasses().Contains(((TObjString*)(*fTriggerList)[itrig])->GetName())) continue;\r | |
231 | //printf("\"%s\" selected\n", ((TObjString*)(*fTriggerList)[itrig])->GetName());\r | |
232 | SETBIT(fTriggerSlot,itrig);\r | |
233 | }\r | |
234 | if(!fTriggerSlot){\r | |
235 | AliDebug(2, Form("Triggers[%s] not used for %s", fEvent->GetFiredTriggerClasses().Data(), GetName()));\r | |
236 | return;\r | |
237 | }\r | |
238 | }\r | |
f073d500 | 239 | fClusters = dynamic_cast<TObjArray*>(GetInputData(3));\r |
94b94be0 | 240 | \r |
241 | if(!fPlotFuncList){\r | |
f073d500 | 242 | AliWarning("No track functor list defined for the task");\r |
94b94be0 | 243 | return;\r |
244 | }\r | |
aebcb1ff | 245 | if(!fEvent || !fTracks) return;\r |
94b94be0 | 246 | if(!fTracks->GetEntriesFast()) return;\r |
247 | else AliDebug(2, Form("Tracks[%d] for %s", fTracks->GetEntriesFast(), GetName()));\r | |
248 | \r | |
178d284a | 249 | Int_t itrk(-1);\r |
250 | AliTRDtrackInfo *trackInfo(NULL);\r | |
94b94be0 | 251 | TIter plotIter(fPlotFuncList);\r |
252 | TObjArrayIter trackIter(fTracks);\r | |
253 | while((trackInfo = dynamic_cast<AliTRDtrackInfo*>(trackIter()))){\r | |
178d284a | 254 | itrk++; fPt=-1; fEta=0.; fPhi=0.; fSpecies=-6;\r |
94b94be0 | 255 | fkMC = trackInfo->GetMCinfo();\r |
256 | fkESD = trackInfo->GetESDinfo();\r | |
178d284a | 257 | if((fkTrack = trackInfo->GetTrack())){\r |
258 | // cache properties of the track at TRD entrance\r | |
259 | // check input track status\r | |
260 | AliExternalTrackParam *tin(NULL);\r | |
261 | if(!(tin = fkTrack->GetTrackIn())) AliDebug(2, Form("Missing TRD track[%d] :: entry point.", itrk));\r | |
262 | else {\r | |
263 | fPt = tin->Pt();\r | |
264 | fEta = tin->Eta();\r | |
265 | Double_t xyz[3];\r | |
266 | if(!tin->GetXYZ(xyz)) AliDebug(2, Form("Failed TRD track[%d] :: global track postion", itrk));\r | |
267 | else fPhi = TMath::ATan2(xyz[1], xyz[0]);\r | |
268 | fSpecies= fkTrack->Charge()*(AliTRDpidUtil::Mass2Pid(fkTrack->GetMass())+1);\r | |
269 | }\r | |
270 | } else AliDebug(2, Form("Missing TRD track[%d].", itrk));\r | |
271 | \r | |
272 | TMethodCall *plot(NULL);\r | |
94b94be0 | 273 | plotIter.Reset();\r |
178d284a | 274 | while((plot=dynamic_cast<TMethodCall*>(plotIter()))) plot->Execute(this);\r |
94b94be0 | 275 | }\r |
f073d500 | 276 | if(!fClusters) return;\r |
277 | if(!fDetFuncList){\r | |
178d284a | 278 | AliDebug(1, "No detector functor list defined for task");\r |
f073d500 | 279 | return;\r |
280 | }\r | |
281 | TIter detIter(fDetFuncList);\r | |
282 | for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){\r | |
283 | if(!(fkClusters = (TObjArray*)fClusters->At(idet))) continue;\r | |
284 | TMethodCall *det(NULL);\r | |
285 | detIter.Reset();\r | |
178d284a | 286 | while((det=dynamic_cast<TMethodCall*>(detIter()))) det->Execute(this);\r |
f073d500 | 287 | }\r |
94b94be0 | 288 | }\r |
289 | \r | |
290 | //_______________________________________________________\r | |
291 | Bool_t AliTRDrecoTask::GetRefFigure(Int_t /*ifig*/)\r | |
292 | {\r | |
293 | AliWarning("Retrieving reference figures not implemented.");\r | |
294 | return kFALSE;\r | |
295 | }\r | |
296 | \r | |
297 | //_______________________________________________________\r | |
847569f2 | 298 | Bool_t AliTRDrecoTask::PutTrendValue(const Char_t *name, Double_t val, Double_t err)\r |
94b94be0 | 299 | {\r |
300 | // Generic publisher for trend values\r | |
301 | \r | |
847569f2 | 302 | AliTRDtrendingManager *tm = AliTRDtrendingManager::Instance();\r |
0854b067 | 303 | if(!tm){\r |
304 | AliError("Wrong usage of the trending functionality. Could not instantiate AliTRDtrendingManager singleton.");\r | |
305 | return kFALSE;\r | |
306 | }\r | |
847569f2 | 307 | tm->AddValue(Form("%s_%s", GetName(), name), val, err);\r |
94b94be0 | 308 | return kTRUE;\r |
309 | }\r | |
310 | \r | |
311 | //_______________________________________________________\r | |
312 | void AliTRDrecoTask::InitFunctorList()\r | |
313 | {\r | |
314 | // Initialize list of functors\r | |
315 | \r | |
316 | TClass *c = this->IsA();\r | |
3ed01fbe | 317 | if(fPlotFuncList) fPlotFuncList->Clear();\r |
f073d500 | 318 | if(fDetFuncList) fDetFuncList->Clear();\r |
94b94be0 | 319 | \r |
f073d500 | 320 | TMethod *m(NULL);\r |
94b94be0 | 321 | TIter methIter(c->GetListOfMethods());\r |
322 | while((m=dynamic_cast<TMethod*>(methIter()))){\r | |
323 | TString name(m->GetName());\r | |
f073d500 | 324 | if(name.BeginsWith("Plot")){\r |
325 | if(!fPlotFuncList) fPlotFuncList = new TList();\r | |
326 | fPlotFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));\r | |
327 | } else if(name.BeginsWith("Det")){\r | |
328 | if(!fDetFuncList) fDetFuncList = new TList();\r | |
329 | fDetFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));\r | |
330 | }\r | |
94b94be0 | 331 | }\r |
332 | }\r | |
333 | \r | |
334 | //_______________________________________________________\r | |
335 | Bool_t AliTRDrecoTask::Load(const Char_t *file, const Char_t *dir)\r | |
336 | {\r | |
337 | // Generic container loader\r | |
338 | \r | |
339 | if(!TFile::Open(file)){\r | |
340 | AliWarning(Form("Couldn't open file %s.", file));\r | |
341 | return kFALSE;\r | |
342 | }\r | |
343 | if(!gFile->cd(dir)){\r | |
344 | AliWarning(Form("Couldn't cd to %s in %s.", dir, file));\r | |
95d47440 | 345 | gFile->Close();\r |
94b94be0 | 346 | return kFALSE;\r |
347 | }\r | |
95d47440 | 348 | if(!(fContainer = (TObjArray*)gDirectory->Get(GetName()))){\r |
94b94be0 | 349 | AliWarning("Missing histogram container.");\r |
95d47440 | 350 | gFile->Close();\r |
94b94be0 | 351 | return kFALSE;\r |
352 | }\r | |
94b94be0 | 353 | gFile->Close();\r |
354 | return kTRUE;\r | |
355 | }\r | |
356 | \r | |
82e6e5dc | 357 | //________________________________________________________\r |
358 | Bool_t AliTRDrecoTask::LoadDetectorMap(const Char_t *file, const Char_t *dir)\r | |
359 | {\r | |
360 | // Load detector map.\r | |
361 | \r | |
362 | if(!TFile::Open(file)){\r | |
363 | AliWarning(Form("Couldn't open file %s.", file));\r | |
364 | return kFALSE;\r | |
365 | }\r | |
366 | if(!gFile->cd(dir)){\r | |
367 | AliWarning(Form("Couldn't cd to %s in %s.", dir, file));\r | |
95d47440 | 368 | gFile->Close();\r |
82e6e5dc | 369 | return kFALSE;\r |
370 | }\r | |
371 | TObjArray *info = NULL;\r | |
372 | if(!(info = (TObjArray*)gDirectory->Get("TRDinfoGen"))){\r | |
373 | AliWarning("Missing TRDinfoGen container.");\r | |
95d47440 | 374 | gFile->Close();\r |
82e6e5dc | 375 | return kFALSE;\r |
376 | }\r | |
48a828ec | 377 | \r |
378 | if(info->FindObject("Chambers Status"))\r | |
379 | fDets = (TObjArray*)((TObjArray*)info->FindObject("Chambers Status"))->Clone();\r | |
380 | \r | |
95d47440 | 381 | if(!fDets){\r |
ff511aa7 | 382 | if(!info->At(4) || strcmp("TObjArray", info->At(4)->IsA()->GetName())) AliError("Looking for old style chamber status map. Failed.");\r |
dffc3357 | 383 | else {\r |
384 | AliWarning("Looking for old style chamber status map.");\r | |
95d47440 | 385 | fDetsV = (TObjArray*)((TObjArray*)info->At(4))->Clone();\r |
dffc3357 | 386 | }\r |
95d47440 | 387 | }\r |
82e6e5dc | 388 | gFile->Close();\r |
95d47440 | 389 | info->Delete(); delete info;\r |
82e6e5dc | 390 | return kTRUE;\r |
391 | }\r | |
392 | \r | |
393 | \r | |
94b94be0 | 394 | //________________________________________________________\r |
395 | Bool_t AliTRDrecoTask::Save(TObjArray * const results){\r | |
396 | //\r | |
397 | // Store the output graphs in a ROOT file\r | |
398 | // Input TObject array will not be written as Key to the file,\r | |
399 | // only content itself\r | |
400 | //\r | |
401 | \r | |
402 | TDirectory *cwd = gDirectory;\r | |
403 | if(!TFile::Open(Form("TRD.Result%s.root", GetName()), "RECREATE")) return kFALSE;\r | |
404 | \r | |
405 | TIterator *iter = results->MakeIterator();\r | |
406 | TObject *inObject = NULL, *outObject = NULL;\r | |
407 | while((inObject = iter->Next())){\r | |
408 | outObject = inObject->Clone();\r | |
409 | outObject->Write(NULL, TObject::kSingleKey);\r | |
410 | }\r | |
411 | delete iter;\r | |
412 | gFile->Close(); delete gFile;\r | |
413 | cwd->cd(); \r | |
414 | return kTRUE;\r | |
415 | }\r | |
416 | \r | |
417 | //_______________________________________________________\r | |
418 | Bool_t AliTRDrecoTask::PostProcess()\r | |
419 | {\r | |
420 | // To be implemented by particular tasks\r | |
421 | \r | |
422 | AliWarning("Post processing of reference histograms not implemented.");\r | |
423 | return kTRUE;\r | |
424 | }\r | |
425 | \r | |
82e6e5dc | 426 | //_______________________________________________________\r |
5591f3d6 | 427 | void AliTRDrecoTask::MakeDetectorPlot(Int_t ly, const Option_t *opt)\r |
82e6e5dc | 428 | {\r |
429 | // Draw chamber boundaries in eta/phi plots with misalignments\r | |
430 | // based on info collected by AliTRDinfoGen\r | |
431 | \r | |
432 | if(!fDets){\r | |
dffc3357 | 433 | AliWarning("NEW Detector map and status not available. Try OLD");\r |
434 | MakeDetectorPlotOLD(ly, opt);\r | |
82e6e5dc | 435 | return;\r |
436 | }\r | |
dffc3357 | 437 | AliTRDchmbInfo *ci(NULL);\r |
438 | for(Int_t idet(0); idet<fDets->GetEntriesFast(); idet++){\r | |
439 | if(!(ci = (AliTRDchmbInfo*)fDets->At(idet))) continue;\r | |
440 | if(AliTRDgeometry::GetLayer(ci->GetDetector()) != ly) continue;\r | |
441 | ci->Draw(opt);\r | |
82e6e5dc | 442 | }\r |
443 | }\r | |
444 | \r | |
33056e04 | 445 | //_______________________________________________________\r |
dffc3357 | 446 | void AliTRDrecoTask::MakeDetectorPlotOLD(Int_t ly, const Option_t *opt)\r |
33056e04 | 447 | {\r |
448 | // Draw chamber boundaries in eta/phi plots with misalignments\r | |
dffc3357 | 449 | // based on info collected by AliTRDinfoGen OLD data storage\r |
33056e04 | 450 | \r |
451 | if(!fDetsV){\r | |
dffc3357 | 452 | AliError("OLD Detector map and status not available.");\r |
453 | return;\r | |
454 | }\r | |
455 | if(!fDetsV->GetEntries()){\r | |
456 | AliError("OLD Detector map and status not filled.");\r | |
33056e04 | 457 | return;\r |
458 | }\r | |
dffc3357 | 459 | \r |
33056e04 | 460 | Float_t xmin(0.), xmax(0.);\r |
461 | TBox *gdet = new TBox();\r | |
462 | gdet->SetLineColor(kBlack);gdet->SetFillColor(kBlack);\r | |
463 | Int_t style[] = {0, 3003};\r | |
dffc3357 | 464 | for(Int_t idet(0); idet<540; idet++){\r |
33056e04 | 465 | if(idet%6 != ly) continue;\r |
dffc3357 | 466 | TVectorF *det((TVectorF*)fDetsV->At(idet));\r |
467 | if(!det) continue;\r | |
468 | Int_t iopt = Int_t((*det)[4]);\r | |
33056e04 | 469 | if(strcmp(opt, "eta")==0){\r |
dffc3357 | 470 | xmin=(*det)[0]; xmax=(*det)[2];\r |
33056e04 | 471 | } else if(strcmp(opt, "pad")==0){\r |
472 | Int_t stk(AliTRDgeometry::GetStack(idet));\r | |
473 | xmin=-0.6+16*(4-stk)-(stk<2?4:0); xmax=xmin+(stk==2?12:16)-0.2;\r | |
474 | } else continue;\r | |
dffc3357 | 475 | AliDebug(2, Form("det[%03d] 0[%+4.1f(%+4.1f) %+4.1f] 1[%+4.1f(%+4.1f) %+4.1f] opt[%d]", idet, xmin, (*det)[0], (*det)[1], xmax, (*det)[2], (*det)[3], iopt));\r |
33056e04 | 476 | if(iopt==1){\r |
477 | gdet->SetFillStyle(style[1]);gdet->SetFillColor(kBlack);\r | |
dffc3357 | 478 | gdet->DrawBox(xmin, (*det)[1], xmax, (*det)[3]);\r |
33056e04 | 479 | } else {\r |
480 | gdet->SetFillStyle(style[0]);\r | |
dffc3357 | 481 | gdet->DrawBox(xmin, (*det)[1], xmax, (*det)[3]);\r |
33056e04 | 482 | if(iopt==2){\r |
483 | gdet->SetFillStyle(style[1]);gdet->SetFillColor(kGreen);\r | |
dffc3357 | 484 | gdet->DrawBox(xmin, (*det)[1], xmax, 0.5*((*det)[3]+(*det)[1]));\r |
33056e04 | 485 | } else if(iopt==3){\r |
486 | gdet->SetFillStyle(style[1]);gdet->SetFillColor(kRed);\r | |
dffc3357 | 487 | gdet->DrawBox(xmin, 0.5*((*det)[3]+(*det)[1]), xmax, (*det)[3]);\r |
33056e04 | 488 | } else if(iopt!=0) AliError(Form("Wrong chmb. status[%d] for det[%03d]", iopt, idet));\r |
489 | }\r | |
490 | }\r | |
491 | Float_t dsm = TMath::TwoPi()/AliTRDgeometry::kNsector;\r | |
492 | xmin=0.;\r | |
493 | if(strcmp(opt, "pad")==0) xmin=38.;\r | |
dffc3357 | 494 | TLatex *sm = new TLatex(); sm->SetTextAlign(22);sm->SetTextColor(kBlack); sm->SetTextFont(32);sm->SetTextSize(0.03);\r |
33056e04 | 495 | for(Int_t is(0); is<AliTRDgeometry::kNsector; is++) sm->DrawLatex(xmin, -TMath::Pi()+(is+0.5)*dsm, Form("%02d", is>=9?(is-9):(is+9)));\r |
496 | }\r | |
497 | \r | |
82e6e5dc | 498 | \r |
94b94be0 | 499 | //_______________________________________________________\r |
500 | void AliTRDrecoTask::MakeSummary()\r | |
501 | {\r | |
502 | // To be implemented by particular tasks\r | |
503 | AliWarning("Summary not available");\r | |
504 | }\r | |
505 | \r | |
506 | //_______________________________________________________\r | |
507 | void AliTRDrecoTask::SetDebugLevel(Int_t level)\r | |
508 | {\r | |
509 | // Generic debug handler\r | |
510 | \r | |
511 | AliAnalysisTaskSE::SetDebugLevel(level);\r | |
aebcb1ff | 512 | if(DebugLevel()>=1 && !fgDebugStream){\r |
94b94be0 | 513 | AliInfo(Form("Debug Level for Task %s set to %d", GetName(), level));\r |
514 | TDirectory *savedir = gDirectory;\r | |
aebcb1ff | 515 | fgDebugStream = new TTreeSRedirector("TRD.DebugPerformance.root", "RECREATE");\r |
94b94be0 | 516 | savedir->cd();\r |
517 | }\r | |
518 | }\r | |
519 | \r | |
520 | //____________________________________________________________________\r | |
521 | void AliTRDrecoTask::Terminate(Option_t *)\r | |
522 | {\r | |
523 | //\r | |
524 | // Terminate\r | |
525 | //\r | |
526 | \r | |
527 | if(fgDebugStream){ \r | |
528 | delete fgDebugStream;\r | |
529 | fgDebugStream = NULL;\r | |
530 | }\r | |
531 | fContainer = dynamic_cast<TObjArray *>(GetOutputData(1));\r | |
532 | if(fContainer && fRunTerminate){\r | |
533 | PostProcess();\r | |
534 | MakeSummary();\r | |
535 | }\r | |
536 | }\r | |
537 | \r | |
eb05d549 | 538 | //________________________________________________________\r |
cc98ff07 | 539 | Float_t AliTRDrecoTask::SetNormZ(TH2 *h2, Int_t bxmin, Int_t bxmax, Int_t bymin, Int_t bymax, Float_t thr)\r |
eb05d549 | 540 | {\r |
541 | // Normalize histo content to the mean value in the range specified by bin ranges\r | |
542 | // [bxmin, bxmax] on the x axis and [bymin, bymax] on the y axis.\r | |
543 | // Optionally a threshold "thr" can be specified to disregard entries with no meaning\r | |
544 | \r | |
545 | Float_t s = 0., c=0.; Int_t is(0);\r | |
546 | for(Int_t ix(bxmin); ix<=(bxmax>0?bxmax:(h2->GetXaxis()->GetNbins())); ix++){\r | |
547 | for(Int_t iy(bymin); iy<=(bymax>0?bymax:(h2->GetYaxis()->GetNbins())); iy++){\r | |
548 | if((c = h2->GetBinContent(ix, iy))<thr) continue;\r | |
549 | s += c; is++;\r | |
550 | }\r | |
551 | }\r | |
ea90ffcd | 552 | s/= (is?is:1);\r |
eb05d549 | 553 | for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){\r |
554 | for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){\r | |
ea90ffcd | 555 | if((c = h2->GetBinContent(ix, iy))<thr) h2->SetBinContent(ix, iy, thr-1000);\r |
eb05d549 | 556 | else h2->SetBinContent(ix, iy, 100.*(c/s-1.));\r |
557 | }\r | |
558 | }\r | |
cc98ff07 | 559 | return s;\r |
eb05d549 | 560 | }\r |
561 | \r | |
562 | //________________________________________________________\r | |
563 | void AliTRDrecoTask::SetRangeZ(TH2 *h2, Float_t min, Float_t max, Float_t thr)\r | |
564 | {\r | |
565 | // Set range on Z axis such to avoid outliers\r | |
566 | \r | |
567 | Float_t c(0.), dz(1.e-3*(max-min));\r | |
568 | for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){\r | |
569 | for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){\r | |
570 | if((c = h2->GetBinContent(ix, iy))<thr) continue;\r | |
571 | if(c<=min) h2->SetBinContent(ix, iy, min+dz);\r | |
572 | }\r | |
573 | }\r | |
574 | h2->GetZaxis()->SetRangeUser(min, max);\r | |
575 | }\r | |
576 | \r | |
577 | //________________________________________________________\r | |
95d47440 | 578 | Float_t AliTRDrecoTask::GetMeanStat(TH1 *h, Float_t cut, Int_t opt, Float_t *sigma)\r |
eb05d549 | 579 | {\r |
95d47440 | 580 | // Return mean number of entries/bin of histogram "h".\r |
581 | // If optionally sigma is allocated than it is also filled with sigma paramter of the gauss fit \r | |
582 | //\r | |
583 | // Option "opt" is given the following values are accepted:\r | |
584 | // -1 : consider only entries less than "cut"\r | |
585 | // 1 : consider only entries greater than "cut"\r | |
586 | // 0 : no "cut" [dafault]\r | |
587 | // Error codes\r | |
588 | // -999. : statistics too low [20]\r | |
589 | // -998. : fit failed\r | |
590 | \r | |
591 | const Int_t kvd(100000);\r | |
592 | Float_t v[kvd];\r | |
eb05d549 | 593 | Int_t nbx(h->GetNbinsX()), nby(h->GetNbinsY()), nbz(h->GetNbinsZ());\r |
95d47440 | 594 | Int_t nv(0); Float_t xmin(1.e5), xmax(-xmin);\r |
595 | for(Int_t ix(1); ix<=nbx; ix++){\r | |
596 | for(Int_t iy(1); iy<=nby; iy++){\r | |
eb05d549 | 597 | for(Int_t iz(1); iz<=nbz; iz++){\r |
95d47440 | 598 | Float_t c = h->GetBinContent(ix, iy, iz);\r |
599 | if(opt*(c-cut)<0.) continue;\r | |
600 | v[nv++] = c;\r | |
601 | if(c<xmin) xmin = c;\r | |
602 | if(c>xmax) xmax = c;\r | |
603 | if(nv==kvd){\r | |
604 | printf("W - AliTRDrecoTask::GetMeanStat() :: Unreliable results for %s[%s]. Statical allocation exceeded.\n", h->GetName(), h->GetTitle());\r | |
605 | break;\r | |
eb05d549 | 606 | }\r |
607 | }\r | |
95d47440 | 608 | if(nv==kvd) break;\r |
609 | }\r | |
610 | if(nv==kvd) break;\r | |
611 | }\r | |
612 | if(nv<10){\r | |
613 | //printf("W - AliTRDrecoTask::GetMeanStat() :: Failed for %s[%s]. Statical undefined [%d].\n", h->GetName(), h->GetTitle(), nv);\r | |
614 | return -999.;\r | |
615 | }\r | |
616 | if(fgProjector) delete fgProjector;\r | |
617 | fgProjector = new TH1F("hProjector", "", 20, 0.5*(3*xmin-xmax), 0.5*(3*xmax - xmin));\r | |
618 | for(Int_t iv(0); iv<nv; iv++) fgProjector->Fill(v[iv]);\r | |
619 | TF1 f("f", "gaus", xmin, xmax);\r | |
620 | f.SetParameter(0, fgProjector->Integral());\r | |
621 | f.SetParameter(1, fgProjector->GetMean()); f.SetParLimits(1, xmin, xmax);\r | |
622 | f.SetParameter(2, fgProjector->GetRMS());\r | |
623 | if(fgProjector->Fit(&f, "WQ0", "goff")) return -998.;\r | |
624 | if(sigma) *sigma = f.GetParameter(2);\r | |
625 | return f.GetParameter(1);\r | |
626 | }\r | |
627 | \r | |
628 | //________________________________________________________\r | |
629 | Int_t AliTRDrecoTask::Rebin(TH2 *h, Int_t n, Int_t rebinX[], Int_t rebinY[], Int_t nstat)\r | |
630 | {\r | |
631 | // Rebin histo "h" according to "rebinning" strategy "n" steps such to obtain mean statistics per bin over "nstat"\r | |
632 | \r | |
633 | Int_t irebin(0);\r | |
634 | while(irebin<n && GetMeanStat(h, .5, 1)<nstat){\r | |
635 | h->Rebin2D(rebinX[irebin], rebinY[irebin]);\r | |
636 | irebin++;\r | |
637 | }\r | |
638 | return irebin;\r | |
eb05d549 | 639 | }\r |
640 | \r | |
641 | //________________________________________________________\r | |
642 | AliTRDrecoTask::AliTRDrecoProjection::AliTRDrecoProjection()\r | |
643 | :TNamed()\r | |
644 | ,fH(NULL)\r | |
645 | ,fNrebin(0)\r | |
eb05d549 | 646 | {\r |
647 | // constructor\r | |
95d47440 | 648 | fRebin[0] = NULL;fRebin[1] = NULL;\r |
eb05d549 | 649 | memset(fAx, 0, 3*sizeof(Int_t));\r |
650 | memset(fRange, 0, 4*sizeof(Float_t));\r | |
651 | }\r | |
652 | \r | |
653 | //________________________________________________________\r | |
654 | AliTRDrecoTask::AliTRDrecoProjection::~AliTRDrecoProjection()\r | |
655 | {\r | |
656 | // destructor\r | |
657 | if(fH) delete fH;\r | |
95d47440 | 658 | if(fRebin[0]) delete [] fRebin[0];\r |
659 | if(fRebin[1]) delete [] fRebin[1];\r | |
eb05d549 | 660 | }\r |
661 | \r | |
662 | //________________________________________________________\r | |
663 | void AliTRDrecoTask::AliTRDrecoProjection::Build(const Char_t *n, const Char_t *t, Int_t ix, Int_t iy, Int_t iz, TAxis *aa[])\r | |
664 | {\r | |
665 | // check and build (if neccessary) projection determined by axis "ix", "iy" and "iz"\r | |
666 | if(!aa[ix] || !aa[iy] || !aa[iz]) return;\r | |
667 | TAxis *ax(aa[ix]), *ay(aa[iy]), *az(aa[iz]);\r | |
668 | // check ax definiton to protect against older versions of the data\r | |
669 | if(ax->GetNbins()<=0 || (ax->GetXmax()-ax->GetXmin())<=0.){\r | |
670 | AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, ax->GetTitle(), ax->GetNbins(), ax->GetXmin(), ax->GetXmax()));\r | |
671 | return;\r | |
672 | }\r | |
673 | if(ay->GetNbins()<=0 || (ay->GetXmax()-ay->GetXmin())<=0.){\r | |
674 | AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, ay->GetTitle(), ay->GetNbins(), ay->GetXmin(), ay->GetXmax()));\r | |
675 | return;\r | |
676 | }\r | |
677 | if(az->GetNbins()<=0 || (az->GetXmax()-az->GetXmin())<=0.){\r | |
678 | AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, az->GetTitle(), az->GetNbins(), az->GetXmin(), az->GetXmax()));\r | |
679 | return;\r | |
680 | }\r | |
681 | SetNameTitle(n,t);\r | |
682 | fH = new TH3I(n, Form("%s;%s;%s;%s", t, ax->GetTitle(), ay->GetTitle(), az->GetTitle()),\r | |
683 | ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),\r | |
684 | ay->GetNbins(), ay->GetXmin(), ay->GetXmax(),\r | |
685 | az->GetNbins(), az->GetXmin(), az->GetXmax());\r | |
686 | fAx[0] = ix; fAx[1] = iy; fAx[2] = iz;\r | |
687 | fRange[0] = az->GetXmin()/3.; fRange[1] = az->GetXmax()/3.;\r | |
688 | AliDebug(2, Form("H3(%s, %s) :: %s[%3d %4.2f %4.2f]%s[%3d %4.2f %4.2f]%s[%3d %4.2f %4.2f]", n, t,\r | |
689 | ax->GetTitle(), ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),\r | |
690 | ay->GetTitle(), ay->GetNbins(), ay->GetXmin(), ay->GetXmax(),\r | |
691 | az->GetTitle(), az->GetNbins(), az->GetXmin(), az->GetXmax()));\r | |
692 | }\r | |
693 | \r | |
694 | //________________________________________________________\r | |
695 | AliTRDrecoTask::AliTRDrecoProjection& AliTRDrecoTask::AliTRDrecoProjection::operator=(const AliTRDrecoProjection& rhs)\r | |
696 | {\r | |
697 | // copy projections\r | |
698 | if(this == &rhs) return *this;\r | |
699 | \r | |
700 | TNamed::operator=(rhs);\r | |
95d47440 | 701 | if(fNrebin){fNrebin=0; delete [] fRebin[0]; delete [] fRebin[1];}\r |
702 | if(rhs.fNrebin) SetRebinStrategy(rhs.fNrebin, rhs.fRebin[0], rhs.fRebin[1]);\r | |
eb05d549 | 703 | memcpy(fAx, rhs.fAx, 3*sizeof(Int_t));\r |
704 | memcpy(fRange, rhs.fRange, 4*sizeof(Float_t));\r | |
705 | if(fH) delete fH;\r | |
706 | if(rhs.fH) fH=(TH3I*)rhs.fH->Clone(Form("%s_CLONE", rhs.fH->GetName()));\r | |
707 | return *this;\r | |
708 | }\r | |
709 | \r | |
710 | //________________________________________________________\r | |
711 | AliTRDrecoTask::AliTRDrecoProjection& AliTRDrecoTask::AliTRDrecoProjection::operator+=(const AliTRDrecoProjection& other)\r | |
712 | {\r | |
713 | // increment projections\r | |
714 | if(!fH || !other.fH) return *this;\r | |
715 | AliDebug(2, Form("%s+=%s [%s+=%s]", GetName(), other.GetName(), fH->GetName(), (other.fH)->GetName()));\r | |
716 | fH->Add(other.fH);\r | |
717 | return *this;\r | |
718 | }\r | |
719 | \r | |
720 | //________________________________________________________\r | |
721 | void AliTRDrecoTask::AliTRDrecoProjection::Increment(Int_t bin[], Double_t v)\r | |
722 | {\r | |
723 | // increment bin with value "v" pointed by general coord in "bin"\r | |
724 | if(!fH) return;\r | |
725 | AliDebug(4, Form(" %s[%2d]", fH->GetName(), Int_t(v)));\r | |
726 | fH->AddBinContent(fH->GetBin(bin[fAx[0]],bin[fAx[1]],bin[fAx[2]]), Int_t(v));\r | |
727 | }\r | |
728 | \r | |
668a0654 | 729 | //________________________________________________________\r |
95d47440 | 730 | Double_t AliTRDrecoTask::AliTRDrecoProjection::GetTrendValue(const Int_t mid, Double_t *e, Double_t *s, Double_t *se) const\r |
668a0654 | 731 | {\r |
732 | // Return result of fitting the main distribution (represented on the z axis) with the function selected\r | |
733 | // "mid". Optionally return the Mean and RMS of the distribution pointing to "m" and "s"\r | |
734 | \r | |
735 | if(!fH){\r | |
736 | AliDebug(1, Form("Missing 3D in %s", GetName()));\r | |
737 | return -999.;\r | |
738 | }\r | |
739 | TH1 *h1s(NULL);\r | |
f036f7ec | 740 | if(!(h1s = (TH1D*)fH->Project3D("z"))){\r |
668a0654 | 741 | AliDebug(1, Form("Failed Project3D(\"z\") in %s", GetName()));\r |
742 | return -999.;\r | |
743 | }\r | |
744 | Int_t ne((Int_t)h1s->Integral());\r | |
f036f7ec | 745 | if(ne<30){\r |
668a0654 | 746 | AliDebug(1, Form("Statistics too low[%2d] in %s", ne, GetName()));\r |
95d47440 | 747 | delete h1s;\r |
668a0654 | 748 | return -999.;\r |
749 | }\r | |
750 | TAxis *az(h1s->GetXaxis());\r | |
95d47440 | 751 | Float_t mn(h1s->GetMean()), rms(h1s->GetRMS()),\r |
752 | v(mn), // main trending value (mean, mu, MPV)\r | |
753 | ve(rms),// dispersion (RMS, sigma, landau 2nd param)\r | |
aebcb1ff | 754 | ev(h1s->GetMeanError()), // error on v\r |
755 | eve(h1s->GetRMSError());// error on ve\r | |
668a0654 | 756 | if(mid==1){\r |
757 | TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax());\r | |
95d47440 | 758 | fg.SetParameter(0, Float_t(ne)); fg.SetParameter(1, mn); fg.SetParameter(2, rms);\r |
668a0654 | 759 | h1s->Fit(&fg, "WQ0");\r |
95d47440 | 760 | v = fg.GetParameter(1); ev = fg.GetParError(1);\r |
aebcb1ff | 761 | ve= fg.GetParameter(2); eve= fg.GetParError(2);\r |
668a0654 | 762 | } else if (mid==2) {\r |
763 | TF1 fl("fl", "landau", az->GetXmin(), az->GetXmax());\r | |
95d47440 | 764 | fl.SetParameter(0, Float_t(ne)); fl.SetParameter(1, mn); fl.SetParameter(2, rms);\r |
668a0654 | 765 | h1s->Fit(&fl, "WQ0");\r |
95d47440 | 766 | v = fl.GetMaximumX(); ev = fl.GetParError(1);\r |
aebcb1ff | 767 | ve= fl.GetParameter(2);eve= fl.GetParError(2);\r |
668a0654 | 768 | }\r |
95d47440 | 769 | if(e) *e = ev;\r |
770 | if(s) *s = ve;\r | |
771 | if(se) *se = eve;\r | |
772 | AliDebug(2, Form("[%d] %s(%4d) = M{%f+-%f} S{%f+-%f}", mid, fH->GetName(), (Int_t)h1s->Integral(), v, ev, ve, eve));\r | |
f036f7ec | 773 | \r |
95d47440 | 774 | delete h1s;\r |
668a0654 | 775 | return v;\r |
776 | }\r | |
777 | \r | |
5047978d | 778 | //________________________________________________________\r |
95d47440 | 779 | TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2Dbin(Int_t bin, Bool_t mc)\r |
5047978d | 780 | {\r |
781 | // dumb 2D projection for bin including under/over flow. Default all [bin==-1]\r | |
782 | \r | |
783 | TAxis *ax(fH->GetXaxis()), *ay(fH->GetYaxis()), *az(fH->GetZaxis());\r | |
784 | Int_t nbins(az->GetNbins());\r | |
785 | TH2F *h2(NULL);\r | |
786 | if(bin<0) h2 = new TH2F(Form("%s_2D", fH->GetName()),\r | |
787 | Form("%s;%s;%s;Entries", fH->GetTitle(), ax->GetTitle(), ay->GetTitle()),\r | |
788 | ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),\r | |
789 | ay->GetNbins(), ay->GetXmin(), ay->GetXmax());\r | |
790 | else h2 = new TH2F(Form("%s%d_2D", fH->GetName(), bin),\r | |
95d47440 | 791 | Form("%s | #it{%4.2f<=p_{t}^{%s}[GeV/c]<%4.2f};%s;%s;Entries", fH->GetTitle(),\r |
792 | bin?fgPt[bin-1]:0., mc?"MC":"", bin>nbins?99.99:fgPt[bin], ax->GetTitle(), ay->GetTitle()),\r | |
5047978d | 793 | ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),\r |
794 | ay->GetNbins(), ay->GetXmin(), ay->GetXmax());\r | |
5047978d | 795 | for(Int_t ix(1); ix<=ax->GetNbins(); ix++){\r |
796 | for(Int_t iy(1); iy<=ay->GetNbins(); iy++){\r | |
797 | Int_t ibin = h2->GetBin(ix, iy);\r | |
798 | for(Int_t iz(0); iz<=az->GetNbins()+1; iz++){\r | |
799 | if(bin<0) h2->AddBinContent(ibin, fH->GetBinContent(ix, iy, iz));\r | |
800 | else if(bin==iz){\r | |
801 | h2->AddBinContent(ibin, fH->GetBinContent(ix, iy, iz));\r | |
802 | break;\r | |
803 | }\r | |
804 | }\r | |
805 | }\r | |
806 | }\r | |
807 | return h2;\r | |
808 | }\r | |
809 | \r | |
eb05d549 | 810 | //________________________________________________________\r |
811 | TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const Int_t ncol, const Int_t mid, Bool_t del)\r | |
812 | {\r | |
813 | // build the 2D projection and adjust binning\r | |
814 | \r | |
815 | const Char_t *title[] = {"Mean", "#mu", "MPV"};\r | |
ea90ffcd | 816 | if(!fH){\r |
817 | AliDebug(1, Form("Missing 3D in %s", GetName()));\r | |
818 | return NULL;\r | |
819 | }\r | |
eb05d549 | 820 | TAxis *ax(fH->GetXaxis()), *ay(fH->GetYaxis()), *az(fH->GetZaxis());\r |
821 | TH2D *h2s(NULL), *hyx(NULL);\r | |
ea90ffcd | 822 | if(!(h2s = (TH2D*)fH->Project3D("yx"))){\r |
823 | AliDebug(1, Form("Failed Project3D(\"yx\") in %s", GetName()));\r | |
824 | return NULL;\r | |
825 | }\r | |
eb05d549 | 826 | // save a copy of the original distribution\r |
827 | if(!del){\r | |
828 | hyx = (TH2D*)h2s->Clone();\r | |
829 | hyx->SetName(Form("%sEn", fH->GetName()));\r | |
830 | }\r | |
95d47440 | 831 | Int_t irebin(Rebin(h2s, fNrebin, fRebin[0], fRebin[1], nstat)), dxBin(1), dyBin(1);\r |
832 | for(Int_t ir(0); ir<irebin; ir++){dxBin*=fRebin[0][ir]; dyBin*=fRebin[1][ir];}\r | |
eb05d549 | 833 | Int_t nx(h2s->GetNbinsX()), ny(h2s->GetNbinsY());\r |
834 | delete h2s;\r | |
835 | if(mid<0) return NULL;\r | |
836 | \r | |
837 | // start projection\r | |
838 | TH1 *h(NULL); Int_t n(0);\r | |
839 | Float_t dz=(fRange[1]-fRange[1])/ncol;\r | |
840 | TString titlez(az->GetTitle()); TObjArray *tokenTitle(titlez.Tokenize(" "));\r | |
841 | Int_t nt(tokenTitle->GetEntriesFast());\r | |
f985021d | 842 | TH2 *h2(NULL);\r |
843 | if((h2 = (TH2*)gDirectory->Get(Form("%s_2D", fH->GetName())))) delete h2; // avoid ROOT warning messages\r | |
844 | h2 = new TH2F(Form("%s_2D", fH->GetName()),\r | |
eb05d549 | 845 | Form("%s;%s;%s;%s(%s) %s", fH->GetTitle(), ax->GetTitle(), ay->GetTitle(), title[mid], nt>0?(*tokenTitle)[0]->GetName():"", nt>1?(*tokenTitle)[1]->GetName():""),\r |
846 | nx, ax->GetXmin(), ax->GetXmax(), ny, ay->GetXmin(), ay->GetXmax());\r | |
dffc3357 | 847 | tokenTitle->Delete(); delete tokenTitle;\r |
eb05d549 | 848 | h2->SetContour(ncol);\r |
849 | h2->GetZaxis()->CenterTitle();\r | |
850 | h2->GetZaxis()->SetTitleOffset(1.4);\r | |
851 | h2->GetZaxis()->SetRangeUser(fRange[0], fRange[1]);\r | |
852 | AliDebug(2, Form("%s[%s] nx[%d] ny[%d]", h2->GetName(), h2->GetTitle(), nx, ny));\r | |
853 | for(Int_t iy(0); iy<ny; iy++){\r | |
854 | for(Int_t ix(0); ix<nx; ix++){\r | |
ea90ffcd | 855 | h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin);\r |
eb05d549 | 856 | Int_t ne((Int_t)h->Integral());\r |
ea90ffcd | 857 | //printf(" x[%2d %2d] y[%2d %2d] ne[%4d]\n", ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin, ne);\r |
eb05d549 | 858 | if(ne<nstat/2){\r |
859 | h2->SetBinContent(ix+1, iy+1, -999);\r | |
860 | h2->SetBinError(ix+1, iy+1, 1.);\r | |
861 | n++;\r | |
862 | }else{\r | |
ea90ffcd | 863 | // redo the projection by adding 1 bin @ left and 1 bin @ right for smoothing\r |
864 | h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin, (ix+1)*dxBin+1, iy*dyBin, (iy+1)*dyBin+1);\r | |
eb05d549 | 865 | Float_t v(h->GetMean()), ve(h->GetRMS());\r |
866 | if(mid==1){\r | |
867 | TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax());\r | |
868 | fg.SetParameter(0, Float_t(ne)); fg.SetParameter(1, v); fg.SetParameter(2, ve);\r | |
33056e04 | 869 | h->Fit(&fg, "WQ0");\r |
eb05d549 | 870 | v = fg.GetParameter(1); ve = fg.GetParameter(2);\r |
871 | } else if (mid==2) {\r | |
872 | TF1 fl("fl", "landau", az->GetXmin(), az->GetXmax());\r | |
873 | fl.SetParameter(0, Float_t(ne)); fl.SetParameter(1, v); fl.SetParameter(2, ve);\r | |
33056e04 | 874 | h->Fit(&fl, "WQ0");\r |
eb05d549 | 875 | v = fl.GetMaximumX(); ve = fl.GetParameter(2);\r |
876 | /* TF1 fgle("gle", "[0]*TMath::Landau(x, [1], [2], 1)*TMath::Exp(-[3]*x/[1])", az->GetXmin(), az->GetXmax());\r | |
877 | fgle.SetParameter(0, fl.GetParameter(0));\r | |
878 | fgle.SetParameter(1, fl.GetParameter(1));\r | |
879 | fgle.SetParameter(2, fl.GetParameter(2));\r | |
880 | fgle.SetParameter(3, 1.);fgle.SetParLimits(3, 0., 5.);\r | |
881 | h->Fit(&fgle, "WQ");\r | |
882 | v = fgle.GetMaximumX(); ve = fgle.GetParameter(2);*/\r | |
883 | }\r | |
884 | if(v<fRange[0]) h2->SetBinContent(ix+1, iy+1, fRange[0]+0.1*dz);\r | |
885 | else h2->SetBinContent(ix+1, iy+1, v);\r | |
886 | h2->SetBinError(ix+1, iy+1, ve);\r | |
887 | }\r | |
888 | }\r | |
889 | }\r | |
890 | if(h) delete h;\r | |
ea90ffcd | 891 | if(n==nx*ny){ // clean empty projections\r |
892 | AliDebug(1, Form("Empty projection in %s", GetName()));\r | |
893 | delete h2; h2=NULL;\r | |
894 | }\r | |
eb05d549 | 895 | return h2;\r |
896 | }\r | |
897 | \r | |
898 | //________________________________________________________\r | |
899 | void AliTRDrecoTask::AliTRDrecoProjection::SetRebinStrategy(Int_t n, Int_t rebx[], Int_t reby[])\r | |
900 | {\r | |
901 | // define rebinning strategy for this projection\r | |
902 | fNrebin = n;\r | |
95d47440 | 903 | fRebin[0] = new Int_t[n]; memcpy(fRebin[0], rebx, n*sizeof(Int_t));\r |
904 | fRebin[1] = new Int_t[n]; memcpy(fRebin[1], reby, n*sizeof(Int_t));\r | |
eb05d549 | 905 | }\r |
906 | \r | |
dffc3357 | 907 | //________________________________________________________\r |
908 | void AliTRDrecoTask::SetTriggerList(const Char_t *tl)\r | |
909 | {\r | |
910 | // Store list of triggers to be monitored\r | |
911 | TString stl(tl);\r | |
912 | if(fTriggerList){ fTriggerList->Delete(); delete fTriggerList;}\r | |
913 | TObjArray *atl = stl.Tokenize(" ");\r | |
914 | fTriggerList = (TObjArray*)atl->Clone("");\r | |
915 | atl->Delete(); delete atl;\r | |
916 | AliInfo("Running only for triggers::");\r | |
917 | fTriggerList->Print();\r | |
918 | }\r | |
eb05d549 | 919 | \r |
920 | \r |