]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEpidTRD.cxx
update package
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEpidTRD.cxx
CommitLineData
809a4336 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
50685501 15//
16// Class for TRD PID
17// Implements the abstract base class AliHFEpidbase
18// Make PID does the PID decision
19// Class further contains TRD specific cuts and QA histograms
20//
21// Authors:
22// Markus Fasel <M.Fasel@gsi.de>
23//
809a4336 24#include <TH1F.h>
75d81601 25#include <TH2F.h>
e3fc062d 26#include <THnSparse.h>
50685501 27#include <TList.h>
809a4336 28#include <TString.h>
809a4336 29
6555e2ad 30#include "AliAODPid.h"
722347d8 31#include "AliAODTrack.h"
32#include "AliAODMCParticle.h"
809a4336 33#include "AliESDtrack.h"
75d81601 34#include "AliLog.h"
722347d8 35#include "AliMCParticle.h"
8c1c76e9 36#include "AliOADBContainer.h"
809a4336 37#include "AliPID.h"
8c1c76e9 38#include "AliPIDResponse.h"
809a4336 39
8c1c76e9 40#include "AliHFEOADBThresholdsTRD.h"
3a72645a 41#include "AliHFEpidQAmanager.h"
809a4336 42#include "AliHFEpidTRD.h"
43
44ClassImp(AliHFEpidTRD)
45
faee3b18 46//___________________________________________________________________
47AliHFEpidTRD::AliHFEpidTRD() :
48 AliHFEpidBase()
8c1c76e9 49 , fOADBThresholds(NULL)
50 , fMinP(0.5)
51 , fNTracklets(6)
e17c1f86 52 , fCutNTracklets(0)
8c1c76e9 53 , fRunNumber(0)
54 , fElectronEfficiency(0.90)
e156c3bb 55 , fTotalChargeInSlice0(kFALSE)
b593c849 56 , fTRD2DPID(kFALSE)
faee3b18 57{
58 //
59 // default constructor
60 //
bf892a6a 61 memset(fThreshParams, 0, sizeof(Double_t) * kThreshParams);
faee3b18 62}
63
809a4336 64//___________________________________________________________________
65AliHFEpidTRD::AliHFEpidTRD(const char* name) :
66 AliHFEpidBase(name)
8c1c76e9 67 , fOADBThresholds(NULL)
68 , fMinP(0.5)
69 , fNTracklets(6)
e17c1f86 70 , fCutNTracklets(0)
8c1c76e9 71 , fRunNumber(0)
67fe7bd0 72 , fElectronEfficiency(0.91)
e156c3bb 73 , fTotalChargeInSlice0(kFALSE)
b593c849 74 , fTRD2DPID(kFALSE)
809a4336 75{
76 //
77 // default constructor
78 //
dbe3abbe 79 memset(fThreshParams, 0, sizeof(Double_t) * kThreshParams);
809a4336 80}
81
82//___________________________________________________________________
83AliHFEpidTRD::AliHFEpidTRD(const AliHFEpidTRD &ref):
84 AliHFEpidBase("")
8c1c76e9 85 , fOADBThresholds(NULL)
67fe7bd0 86 , fMinP(ref.fMinP)
8c1c76e9 87 , fNTracklets(ref.fNTracklets)
e17c1f86 88 , fCutNTracklets(ref.fCutNTracklets)
8c1c76e9 89 , fRunNumber(ref.fRunNumber)
67fe7bd0 90 , fElectronEfficiency(ref.fElectronEfficiency)
e156c3bb 91 , fTotalChargeInSlice0(ref.fTotalChargeInSlice0)
b593c849 92 , fTRD2DPID(ref.fTRD2DPID)
809a4336 93{
94 //
95 // Copy constructor
96 //
dbe3abbe 97 memset(fThreshParams, 0, sizeof(Double_t) * kThreshParams);
809a4336 98 ref.Copy(*this);
99}
100
101//___________________________________________________________________
102AliHFEpidTRD &AliHFEpidTRD::operator=(const AliHFEpidTRD &ref){
103 //
104 // Assignment operator
105 //
106 if(this != &ref){
107 ref.Copy(*this);
108 }
109 return *this;
110}
111
112//___________________________________________________________________
113void AliHFEpidTRD::Copy(TObject &ref) const {
114 //
115 // Performs the copying of the object
116 //
117 AliHFEpidTRD &target = dynamic_cast<AliHFEpidTRD &>(ref);
bf892a6a 118
e3fc062d 119 target.fMinP = fMinP;
8c1c76e9 120 target.fNTracklets = fNTracklets;
e17c1f86 121 target.fCutNTracklets = fCutNTracklets;
8c1c76e9 122 target.fRunNumber = fRunNumber;
e156c3bb 123 target.fTotalChargeInSlice0 = fTotalChargeInSlice0;
b593c849 124 target.fTRD2DPID = fTRD2DPID;
67fe7bd0 125 target.fElectronEfficiency = fElectronEfficiency;
dbe3abbe 126 memcpy(target.fThreshParams, fThreshParams, sizeof(Double_t) * kThreshParams);
809a4336 127 AliHFEpidBase::Copy(ref);
128}
129
130//___________________________________________________________________
131AliHFEpidTRD::~AliHFEpidTRD(){
132 //
133 // Destructor
134 //
809a4336 135}
136
137//______________________________________________________
8c1c76e9 138Bool_t AliHFEpidTRD::InitializePID(Int_t run){
b593c849 139 //
140 // InitializePID call different init function depending on TRD PID method
141 //
142 //
143
144 //if(fTRD2DPID) return Initialize2D(run);
145 if(fTRD2DPID) return kTRUE;
146 else return Initialize1D(run);
147
148
149
150}
151
152//______________________________________________________
153Bool_t AliHFEpidTRD::Initialize1D(Int_t run){
809a4336 154 //
155 // InitializePID: Load TRD thresholds and create the electron efficiency axis
156 // to navigate
157 //
8c1c76e9 158 AliDebug(1, Form("Initializing TRD PID for run %d", run));
159 if(InitParamsFromOADB(run)){
160 SetBit(kThresholdsInitialized);
161 return kTRUE;
bf892a6a 162 }
8c1c76e9 163 AliDebug(1, Form("Threshold Parameters for %d tracklets and an electron efficiency %f loaded:", fNTracklets, fElectronEfficiency));
164 AliDebug(1, Form("Params: [%f|%f|%f|%f]", fThreshParams[0], fThreshParams[1], fThreshParams[2], fThreshParams[3]));
165 fRunNumber = run;
166 return kFALSE;
809a4336 167}
168
b593c849 169/*
170//______________________________________________________
171Bool_t AliHFEpidTRD::Initialize2D(Int_t run){
172 //
173 // Initialize2DimPID
174 //
175 //
176
177 return kTRUE;
178
179}
180*/
181
809a4336 182//______________________________________________________
6555e2ad 183Int_t AliHFEpidTRD::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const {
b593c849 184 //
185 // Does PID for TRD alone:
186 // PID algorithm selected according to flag
187 //
188 //
189
190 if(fTRD2DPID) return IsSelected2D(track, pidqa);
191 else return IsSelected1D(track, pidqa);
192
193
194}
195
196//______________________________________________________
197Int_t AliHFEpidTRD::IsSelected1D(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const {
809a4336 198 //
199 // Does PID for TRD alone:
200 // PID thresholds based on 90% Electron Efficiency level approximated by a linear
201 // step function
202 //
8c1c76e9 203 if(!TestBit(kThresholdsInitialized)) {
204 AliDebug(1,"Threshold Parameters not available");
205 return 0;
206 }
207 AliDebug(2, "Applying TRD PID");
208 if(!fkPIDResponse){
209 AliDebug(2, "Cannot process track");
3a72645a 210 return 0;
211 }
722347d8 212
e17c1f86 213
8c1c76e9 214/*
215 const AliESDtrack *esdt = dynamic_cast<const AliESDtrack *>(track->GetRecTrack());
216 printf("checking IdentifiedAsElectronTRD, number of Tracklets: %d\n", esdt->GetTRDntrackletsPID());
217 if(fkPIDResponse->IdentifiedAsElectronTRD(dynamic_cast<const AliVTrack *>(track->GetRecTrack()), 0.8)) printf("Track identified as electron\n");
218 else printf("Track rejected\n");
219*/
3a72645a 220 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis: AliHFEpidObject::kAODanalysis;
221 Double_t p = GetP(track->GetRecTrack(), anatype);
222 if(p < fMinP){
8c1c76e9 223 AliDebug(2, Form("Track momentum below %f", fMinP));
3a72645a 224 return 0;
225 }
809a4336 226
3a72645a 227 if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTRDpid, AliHFEdetPIDqa::kBeforePID);
e17c1f86 228
229 if(fCutNTracklets > 0){
230 AliDebug(1, Form("Number of tracklets cut applied: %d\n", fCutNTracklets));
231 Int_t ntracklets = track->GetRecTrack() ? track->GetRecTrack()->GetTRDntrackletsPID() : 0;
232 if(TestBit(kExactTrackletCut)){
233 AliDebug(1, Form("Exact cut applied: %d tracklets found\n", ntracklets));
234 if(ntracklets != fCutNTracklets) return 0;
235 } else {
236 AliDebug(1, Form("Greater Equal cut applied: %d tracklets found\n", ntracklets));
237 if(ntracklets < fCutNTracklets) return 0;
238 }
239 }
240 AliDebug(1,"Track selected\n");
241
242 Double_t electronLike = GetElectronLikelihood(track->GetRecTrack(), anatype);
8c1c76e9 243 Double_t threshold;
244 if(TestBit(kSelectCutOnTheFly)){
e17c1f86 245 threshold = GetTRDthresholds(p, track->GetRecTrack()->GetTRDntrackletsPID());
8c1c76e9 246 } else {
247 threshold = GetTRDthresholds(p);
248 }
249 AliDebug(2, Form("Threshold: %f\n", threshold));
3a72645a 250 if(electronLike > threshold){
251 if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTRDpid, AliHFEdetPIDqa::kAfterPID);
0792aa82 252 return 11;
253 }
254 return 211;
3a72645a 255
809a4336 256}
257
b593c849 258//______________________________________________________
259Int_t AliHFEpidTRD::IsSelected2D(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const {
260 //
261 // 2D TRD PID
262 //
263 //
264 //
265 AliDebug(2, "Applying TRD PID");
266 if(!fkPIDResponse){
267 AliDebug(2, "Cannot process track");
268 return 0;
269 }
270
271 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis: AliHFEpidObject::kAODanalysis;
272 Double_t p = GetP(track->GetRecTrack(), anatype);
273 if(p < fMinP){
274 AliDebug(2, Form("Track momentum below %f", fMinP));
275 return 0;
276 }
277
278 if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTRDpid, AliHFEdetPIDqa::kBeforePID);
279
280 if(fCutNTracklets > 0){
281 AliDebug(1, Form("Number of tracklets cut applied: %d\n", fCutNTracklets));
282 Int_t ntracklets = track->GetRecTrack() ? track->GetRecTrack()->GetTRDntrackletsPID() : 0;
283 if(TestBit(kExactTrackletCut)){
284 AliDebug(1, Form("Exact cut applied: %d tracklets found\n", ntracklets));
285 if(ntracklets != fCutNTracklets) return 0;
286 } else {
287 AliDebug(1, Form("Greater Equal cut applied: %d tracklets found\n", ntracklets));
288 if(ntracklets < fCutNTracklets) return 0;
289 }
290 }
291 AliDebug(1,"Track selected\n");
292
84e1e407 293 Int_t centralitybin = track->IsPbPb() ? track->GetCentrality() : -2;
b593c849 294 Float_t fCentralityLimitsdefault[12]= {0.,5.,10., 20., 30., 40., 50., 60.,70.,80., 90., 100.};
d44e3c84 295 Float_t centrality=-1;
296 if(centralitybin>=0) centrality=fCentralityLimitsdefault[centralitybin]+1;
b593c849 297
b593c849 298 if(fkPIDResponse->IdentifiedAsElectronTRD(track->GetRecTrack(),fElectronEfficiency,centrality,AliTRDPIDResponse::kLQ2D)){
84e1e407 299 AliDebug(2, Form("Electron effi: %f %i %i %f\n", fElectronEfficiency,track->GetCentrality(),centralitybin,centrality));
b593c849 300 return 11;
301 } else return 211;
302
d44e3c84 303
304
b593c849 305}
306
809a4336 307//___________________________________________________________________
8c1c76e9 308Double_t AliHFEpidTRD::GetTRDthresholds(Double_t p, UInt_t nTracklets) const {
dbe3abbe 309 //
310 // Return momentum dependent and electron efficiency dependent TRD thresholds
8c1c76e9 311 // Determine threshold based on the number of tracklets on the fly, electron efficiency not modified
dbe3abbe 312 //
8c1c76e9 313 Double_t threshParams[4];
e17c1f86 314 AliDebug(1, Form("Select cut for %d tracklets\n", nTracklets));
8c1c76e9 315 // Get threshold paramters for the given number of tracklets from OADB container
316 AliHFEOADBThresholdsTRD *thresholds = dynamic_cast<AliHFEOADBThresholdsTRD *>(fOADBThresholds->GetObject(fRunNumber));
317 if(!thresholds){
318 AliDebug(1, Form("Thresholds for run %d not in the OADB", fRunNumber));
319 return 0.;
320 }
e17c1f86 321 if(!thresholds->GetThresholdParameters(nTracklets, fElectronEfficiency, threshParams)){
322 AliDebug(1, "loading thresholds failed\n");
323 return 0.;
324 }
8c1c76e9 325 Double_t threshold = 1. - threshParams[0] - threshParams[1] * p - threshParams[2] * TMath::Exp(-threshParams[3] * p);
0792aa82 326 return TMath::Max(TMath::Min(threshold, 0.99), 0.2); // truncate the threshold upperwards to 0.999 and lowerwards to 0.2 and exclude unphysical values
809a4336 327}
328
bf892a6a 329//___________________________________________________________________
8c1c76e9 330Double_t AliHFEpidTRD::GetTRDthresholds(Double_t p) const {
bf892a6a 331 //
8c1c76e9 332 // Return momentum dependent and electron efficiency dependent TRD thresholds
333 //
334 Double_t threshold = 1. - fThreshParams[0] - fThreshParams[1] * p - fThreshParams[2] * TMath::Exp(-fThreshParams[3] * p);
335 return TMath::Max(TMath::Min(threshold, 0.99), 0.2); // truncate the threshold upperwards to 0.999 and lowerwards to 0.2 and exclude unphysical values
bf892a6a 336}
337
809a4336 338
e3fc062d 339//___________________________________________________________________
8c1c76e9 340Bool_t AliHFEpidTRD::InitParamsFromOADB(Int_t run){
e3fc062d 341 //
8c1c76e9 342 // The name of the function says it all
e3fc062d 343 //
8c1c76e9 344 AliHFEOADBThresholdsTRD *thresholds = dynamic_cast<AliHFEOADBThresholdsTRD *>(fOADBThresholds->GetObject(run));
345 if(!thresholds){
346 AliDebug(1, Form("Thresholds for run %d not in the OADB", run));
347 return kFALSE;
348 }
349 return thresholds->GetThresholdParameters(fNTracklets, fElectronEfficiency, fThreshParams);
e3fc062d 350}
351
c2690925 352//___________________________________________________________________
353void AliHFEpidTRD::RenormalizeElPi(const Double_t * const likein, Double_t * const likeout) const {
354 //
355 // Renormalize likelihoods for electrons and pions neglecting the
356 // likelihoods for protons, kaons and muons
357 //
358 memset(likeout, 0, sizeof(Double_t) * AliPID::kSPECIES);
359 Double_t norm = likein[AliPID::kElectron] + likein[AliPID::kPion];
360 if(norm == 0.) norm = 1.; // Safety
361 likeout[AliPID::kElectron] = likein[AliPID::kElectron] / norm;
362 likeout[AliPID::kPion] = likein[AliPID::kPion] / norm;
363}
364
809a4336 365//___________________________________________________________________
8c1c76e9 366Double_t AliHFEpidTRD::GetElectronLikelihood(const AliVTrack *track, AliHFEpidObject::AnalysisType_t anaType) const {
3a72645a 367 //
368 // Get TRD likelihoods for ESD respectively AOD tracks
369 //
370 Double_t pidProbs[AliPID::kSPECIES]; memset(pidProbs, 0, sizeof(Double_t) * AliPID::kSPECIES);
371 if(anaType == AliHFEpidObject::kESDanalysis){
372 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
bf892a6a 373 if(esdtrack) esdtrack->GetTRDpid(pidProbs);
3a72645a 374 } else {
7a35b7aa 375 if(fTRD2DPID) fkPIDResponse->ComputeTRDProbability(track, AliPID::kSPECIES, pidProbs,AliTRDPIDResponse::kLQ2D);
376 else fkPIDResponse->ComputeTRDProbability(track, AliPID::kSPECIES, pidProbs,AliTRDPIDResponse::kLQ1D);
3a72645a 377 }
c2690925 378 if(!IsRenormalizeElPi()) return pidProbs[AliPID::kElectron];
379 Double_t probsNew[AliPID::kSPECIES];
380 RenormalizeElPi(pidProbs, probsNew);
381 return probsNew[AliPID::kElectron];
3a72645a 382}
383
384//___________________________________________________________________
6555e2ad 385Double_t AliHFEpidTRD::GetP(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anaType) const {
3a72645a 386 //
387 // Get the Momentum in the TRD
388 //
389 Double_t p = 0.;
390 if(anaType == AliHFEpidObject::kESDanalysis){
391 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
bf892a6a 392 if(esdtrack) p = esdtrack->GetOuterParam() ? esdtrack->GetOuterParam()->P() : esdtrack->P();
3a72645a 393 } else {
394 const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
bf892a6a 395 if(aodtrack) p = aodtrack->P();
3a72645a 396 }
397 return p;
398}
399
400//___________________________________________________________________
6555e2ad 401Double_t AliHFEpidTRD::GetChargeLayer(const AliVParticle *track, UInt_t layer, AliHFEpidObject::AnalysisType_t anaType) const {
402 //
403 // Get the Charge in a single TRD layer
404 //
405 if(layer >= 6) return 0.;
406 Double_t charge = 0.;
407 if(anaType == AliHFEpidObject::kESDanalysis){
408 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
e156c3bb 409 if(esdtrack){
410 // Distinction between old and new reconstruction: in the new reconstruction, the total charge is stored in slice 0, slices 1 to 8 are used for the slices for
411 // the neural network.
412 if(fTotalChargeInSlice0)
413 charge = esdtrack->GetTRDslice(static_cast<UInt_t>(layer), 0);
414 else
415 for(Int_t islice = 0; islice < esdtrack->GetNumberOfTRDslices(); islice++) charge += esdtrack->GetTRDslice(static_cast<UInt_t>(layer), islice);
416 }
6555e2ad 417 } else {
418 const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
bf892a6a 419 AliAODPid *aoddetpid = aodtrack ? aodtrack->GetDetPid() : NULL;
e156c3bb 420 if(aoddetpid){
421 if(fTotalChargeInSlice0)
6736efd5 422 charge = aoddetpid->GetTRDslices()[layer * aoddetpid->GetTRDnSlices()];
e156c3bb 423 else
6736efd5 424 for(Int_t islice = 0; islice < aoddetpid->GetTRDnSlices(); islice++) charge += aoddetpid->GetTRDslices()[layer * aoddetpid->GetTRDnSlices() + islice];
e156c3bb 425 }
6555e2ad 426 }
427 return charge;
428}
429
430//___________________________________________________________________
8c1c76e9 431void AliHFEpidTRD::GetTRDmomenta(const AliVTrack *track, Double_t *mom) const {
bf892a6a 432 //
433 // Fill Array with momentum information at the TRD tracklet
434 //
8c1c76e9 435 for(Int_t itl = 0; itl < 6; itl++)
436 mom[itl] = track->GetTRDmomentum(itl);
bf892a6a 437}
438
439//___________________________________________________________________
440Double_t AliHFEpidTRD::GetTRDSignalV1(const AliESDtrack *track, Float_t truncation) const {
75d81601 441 //
442 // Calculation of the TRD Signal via truncated mean
443 // Method 1: Take all Slices available
444 // cut out 0s
445 // Order them in increasing order
446 // Cut out the upper third
447 // Calculate mean over the last 2/3 slices
448 //
449 const Int_t kNSlices = 48;
11ff28c5 450 const Int_t kLastSlice = 6; // Slice 7 is taken out from the truncated mean calculation
3ccf8f4c 451 const Double_t kVerySmall = 1e-12;
bf892a6a 452 // Weight the slice to equalize the MPV of the dQ/dl-distribution per slice to the one in the first slice
453 // Pions are used as reference for the equalization
454 const Double_t kWeightSlice[8] = {1., 2.122, 1.8, 1.635, 1.595, 1.614, 1.16, 7.0};
11ff28c5 455 const Double_t kWeightSliceNo0[8] = {1., 1., 1.271, 1.451, 1.531, 1.543, 1.553, 2.163}; // Weighting factors in case slice 0 stores the total charge
456 const Double_t *kWeightFactor = fTotalChargeInSlice0 ? kWeightSliceNo0 : kWeightSlice;
bf892a6a 457 AliDebug(3, Form("Number of Tracklets: %d\n", track->GetTRDntrackletsPID()));
75d81601 458 Double_t trdSlices[kNSlices], tmp[kNSlices];
459 Int_t indices[48];
460 Int_t icnt = 0;
461 for(Int_t idet = 0; idet < 6; idet++)
11ff28c5 462 for(Int_t islice = fTotalChargeInSlice0 ? 1 : 0 ; islice <= kLastSlice; islice++){
75d81601 463 AliDebug(2, Form("Chamber[%d], Slice[%d]: TRDSlice = %f", idet, islice, track->GetTRDslice(idet, islice)));
3ccf8f4c 464 if(TMath::Abs(track->GetTRDslice(idet, islice)) < kVerySmall) continue;;
11ff28c5 465 trdSlices[icnt++] = track->GetTRDslice(idet, islice) * kWeightFactor[islice];
75d81601 466 }
467 AliDebug(1, Form("Number of Slices: %d\n", icnt));
468 if(icnt < 6) return 0.; // We need at least 6 Slices for the truncated mean
469 TMath::Sort(icnt, trdSlices, indices, kFALSE);
470 memcpy(tmp, trdSlices, sizeof(Double_t) * icnt);
471 for(Int_t ien = 0; ien < icnt; ien++)
472 trdSlices[ien] = tmp[indices[ien]];
bf892a6a 473 Double_t trdSignal = TMath::Mean(static_cast<Int_t>(static_cast<Float_t>(icnt) * truncation), trdSlices);
75d81601 474 Double_t mom = track->GetOuterParam() ? track->GetOuterParam()->P() : -1;
e3fc062d 475 AliDebug(3, Form("PID Meth. 1: p[%f], TRDSignal[%f]", mom, trdSignal));
75d81601 476 return trdSignal;
477}
478
479//___________________________________________________________________
bf892a6a 480Double_t AliHFEpidTRD::GetTRDSignalV2(const AliESDtrack *track, Float_t truncation) const {
75d81601 481 //
482 // Calculation of the TRD Signal via truncated mean
483 // Method 2: Take only first 5 slices per chamber
484 // Order them in increasing order
485 // Cut out upper half
486 // Now do mean with the reamining 3 slices per chamber
487 //
bf892a6a 488 const Double_t kWeightSlice[8] = {1., 2.122, 1.8, 1.635, 1.595, 1.614, 1.16, 7.0};
489 const Int_t kLayers = 6;
490 const Int_t kSlicesLow = 6;
491 const Int_t kSlicesHigh = 1;
3ccf8f4c 492 const Double_t kVerySmall = 1e-12;
bf892a6a 493 Double_t trdSlicesLowTime[kLayers*kSlicesLow], trdSlicesRemaining[kLayers*(kSlicesHigh + kSlicesLow)];
494 Int_t indices[kLayers*kSlicesLow];
75d81601 495 Int_t cntLowTime=0, cntRemaining = 0;
496 for(Int_t idet = 0; idet < 6; idet++)
e156c3bb 497 for(Int_t islice = fTotalChargeInSlice0 ? 1 : 0; islice < kSlicesLow+kSlicesHigh; islice++){
3ccf8f4c 498 if(TMath::Abs(track->GetTRDslice(idet, islice)) < kVerySmall) continue;;
bf892a6a 499 if(islice < kSlicesLow){
e3fc062d 500 AliDebug(3, Form("Part 1, Det[%d], Slice[%d], TRDSlice: %f", idet, islice, track->GetTRDslice(idet, islice)));
bf892a6a 501 trdSlicesLowTime[cntLowTime++] = track->GetTRDslice(idet, islice) * kWeightSlice[islice];
75d81601 502 } else{
e3fc062d 503 AliDebug(3, Form("Part 1, Det[%d], Slice[%d], TRDSlice: %f", idet, islice, track->GetTRDslice(idet, islice)));
bf892a6a 504 trdSlicesRemaining[cntRemaining++] = track->GetTRDslice(idet, islice) * kWeightSlice[islice];
75d81601 505 }
506 }
507 if(cntLowTime < 4 || cntRemaining < 2) return 0.; // Min. Number of Slices at high time is 2 (matches with 1 layer), for the truncated mean we need at least 4 Slices
508 TMath::Sort(cntLowTime, trdSlicesLowTime, indices, kFALSE);
509 // Fill the second array with the lower half of the first time bins
bf892a6a 510 for(Int_t ien = 0; ien < static_cast<Int_t>(static_cast<Float_t>(cntLowTime) * truncation); ien++)
75d81601 511 trdSlicesRemaining[cntRemaining++] = trdSlicesLowTime[indices[ien]];
512 Double_t trdSignal = TMath::Mean(cntRemaining, trdSlicesRemaining);
513 Double_t mom = track->GetOuterParam() ? track->GetOuterParam()->P() : -1;
e3fc062d 514 AliDebug(3, Form("PID Meth. 2: p[%f], TRDSignal[%f]", mom, trdSignal));
75d81601 515 return trdSignal;
516}