/* $Id$ */
+#include "TVectorT.h"
#include "AliLog.h"
#include "AliESDtrack.h"
#include "AliTracker.h"
#include "AliTRDReconstructor.h"
#include "AliTRDPIDResponse.h"
#include "AliTRDrecoParam.h"
+#include "AliTRDdEdxBaseUtils.h"
+#include "AliTRDdEdxCalibHistArray.h"
+#include "AliTRDdEdxCalibUtils.h"
+#include "AliTRDdEdxReconUtils.h"
ClassImp(AliTRDtrackV1)
,fStatus(0)
,fESDid(0)
,fDE(0.)
+ ,fTruncatedMean(0)
+ ,fNchamberdEdx(0)
+ ,fNclusterdEdx(0)
+ ,fNdEdxSlices(0)
,fkReconstructor(NULL)
,fBackupTrack(NULL)
,fTrackLow(NULL)
fTrackletIndex[ip] = -1;
fTracklet[ip] = NULL;
}
+ SetLabel(-123456789); // reset label
}
//_______________________________________________________________
,fStatus(ref.fStatus)
,fESDid(ref.fESDid)
,fDE(ref.fDE)
+ ,fTruncatedMean(ref.fTruncatedMean)
+ ,fNchamberdEdx(ref.fNchamberdEdx)
+ ,fNclusterdEdx(ref.fNclusterdEdx)
+ ,fNdEdxSlices(ref.fNdEdxSlices)
,fkReconstructor(ref.fkReconstructor)
,fBackupTrack(NULL)
,fTrackLow(NULL)
,fStatus(0)
,fESDid(0)
,fDE(0.)
+ ,fTruncatedMean(0)
+ ,fNchamberdEdx(0)
+ ,fNclusterdEdx(0)
+ ,fNdEdxSlices(0)
,fkReconstructor(NULL)
,fBackupTrack(NULL)
,fTrackLow(NULL)
SetLabel(t.GetLabel());
SetChi2(0.0);
- SetMass(t.GetMass()/*0.000510*/);
+ SetMass(t.GetMassForTracking());
AliKalmanTrack::SetNumberOfClusters(t.GetTRDncls());
Int_t ti[]={-1, -1, -1, -1, -1, -1}; t.GetTRDtracklets(&ti[0]);
for(int ip=0; ip<kNplane; ip++){
for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
const AliExternalTrackParam *par = &t;
- if (t.GetStatus() & AliESDtrack::kTRDbackup) {
+ /* RS
+ if (t.GetStatus() & AliESDtrack::kTRDbackup) {
par = t.GetOuterParam();
if (!par) {
AliError("No backup info!");
par = &t;
}
}
+ */
Set(par->GetX()
,par->GetAlpha()
,par->GetParameter()
if(t.GetStatus() & AliESDtrack::kTIME) {
StartTimeIntegral();
- Double_t times[10];
- t.GetIntegratedTimes(times);
+ Double_t times[AliPID::kSPECIESC];
+ t.GetIntegratedTimes(times,AliPID::kSPECIESC);
SetIntegratedTimes(times);
SetIntegratedLength(t.GetIntegratedLength());
}
,fStatus(0)
,fESDid(0)
,fDE(0.)
+ ,fTruncatedMean(0)
+ ,fNchamberdEdx(0)
+ ,fNclusterdEdx(0)
+ ,fNdEdxSlices(0)
,fkReconstructor(NULL)
,fBackupTrack(NULL)
,fTrackLow(NULL)
Float_t pid = 1./AliPID::kSPECIES;
for(int is =0; is<AliPID::kSPECIES; is++) fPID[is] = pid;
+ SetLabel(-123456789); // reset label
}
//_______________________________________________________________
//
if (this != &t) {
+ AliKalmanTrack::operator=(t);
((AliTRDtrackV1 &) t).Copy(*this);
}
}
//_______________________________________________________________
-Bool_t AliTRDtrackV1::CookLabel(Float_t wrong)
+Int_t AliTRDtrackV1::CookLabel(Float_t wrong, Int_t *labs, Float_t *freq)
{
- // set MC label for this track
- if(!GetNumberOfClusters()) return kFALSE;
+// Set MC label for this track
+// On demand i.e. if arrays "labs" and "freq" are allocated by user returns :
+// nlabs = the no of distinct labels
+// labs = array of distinct labels in decreasing order of frequency
+// freq = frequency of each label in decreasing order
- Int_t s[kMAXCLUSTERSPERTRACK][2];
+ Int_t ncl(0);
+ if(!(ncl = GetNumberOfClusters())) return 0;
+
+ Int_t s[2][kMAXCLUSTERSPERTRACK];
for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
- s[i][0] = -1;
- s[i][1] = 0;
+ s[0][i] = -1;
+ s[1][i] = 0;
}
-
- Bool_t labelAdded;
- Int_t label;
- AliTRDcluster *c = NULL;
- for (Int_t ip = 0; ip < kNplane; ip++) {
+
+ Int_t label(-123456789), nlabels(0);
+ AliTRDcluster *c(NULL);
+ for (Int_t ip(0); ip < AliTRDgeometry::kNlayer; ip++) {
if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
- for (Int_t ic = 0; ic < AliTRDseedV1::kNclusters; ic++) {
+ for (Int_t ic(0); ic < AliTRDseedV1::kNclusters; ic++) {
if(!(c = fTracklet[ip]->GetClusters(ic))) continue;
- for (Int_t k = 0; k < 3; k++) {
- label = c->GetLabel(k);
- labelAdded = kFALSE;
- Int_t j = 0;
- if (label >= 0) {
- while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) {
- if ((s[j][0] == label) ||
- (s[j][1] == 0)) {
- s[j][0] = label;
- s[j][1]++;
- labelAdded = kTRUE;
- }
- j++;
- }
+ for (Int_t k(0); k < 3; k++) {
+ if ((label = c->GetLabel(k)) < 0) continue;
+ Int_t j(0);
+ while(j < kMAXCLUSTERSPERTRACK){
+ if(s[0][j]!=label && s[1][j]!=0){j++; continue;}
+ if(!s[1][j]) nlabels++;
+ s[0][j] = label; s[1][j]++;
+ break;
}
}
}
}
-
- Int_t max = 0;
- label = -123456789;
- for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
- if (s[i][1] <= max) continue;
- max = s[i][1];
- label = s[i][0];
+ //printf(" Found %4d labels\n", nlabels);
+ Float_t prob(1.);
+ if(!nlabels){
+ AliError(Form("No MC labels found for track %d.", fESDid));
+ return 0;
+ } else if(nlabels==1) {
+ label = s[0][0];
+ if(labs && freq){labs[0]=label; freq[0]=1.;}
+ } else {
+ Int_t idx[kMAXCLUSTERSPERTRACK];
+ TMath::Sort(nlabels, s[1], idx);
+ label = s[0][idx[0]]; prob = s[1][idx[0]]/Float_t(ncl);
+ if(labs && freq){
+ for (Int_t i(0); i<nlabels; i++){
+ labs[i] = s[0][idx[i]];
+ freq[i] = s[1][idx[i]]/Float_t(ncl);
+ }
+ }
}
- if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label;
-
- SetLabel(label);
-
- return kTRUE;
+ SetLabel((1.-prob > wrong)?-label:label);
+ return nlabels;
}
//_______________________________________________________________
AliError("PID Response not available");
return kFALSE;
}
- Int_t nslices = pidResponse->GetNumberOfSlices();
- Double_t dEdx[kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN];
- Float_t trackletP[kNplane];
- memset(dEdx, 0, sizeof(Double_t) * kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN);
- memset(trackletP, 0, sizeof(Float_t)*kNplane);
+ Double_t dEdx[kNplane * (Int_t)AliTRDseedV1::kNdEdxSlices] = {0.};
+ Float_t trackletP[kNplane] = {0.};
+
+ fNdEdxSlices = pidResponse->GetNumberOfSlices();
for(Int_t iseed = 0; iseed < kNplane; iseed++){
if(!fTracklet[iseed]) continue;
trackletP[iseed] = fTracklet[iseed]->GetMomentum();
- fTracklet[iseed]->SetPID();
- if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){
+// if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){
dEdx[iseed] = fTracklet[iseed]->GetdQdl();
- } else {
- fTracklet[iseed]->CookdEdx(nslices);
+/* } else {
+ fTracklet[iseed]->CookdEdx(fNdEdxSlices);
const Float_t *trackletdEdx = fTracklet[iseed]->GetdEdx();
- for(Int_t islice = 0; islice < nslices; islice++){
- dEdx[iseed*nslices + islice] = trackletdEdx[islice];
+ for(Int_t islice = 0; islice < fNdEdxSlices; islice++){
+ dEdx[iseed*fNdEdxSlices + islice] = trackletdEdx[islice];
}
- }
+ }*/
}
- pidResponse->GetResponse(nslices, dEdx, trackletP, fPID);
+ pidResponse->GetResponse(fNdEdxSlices, dEdx, trackletP, fPID);
+
+ static Int_t nprint = 0;
+ if(!nprint){
+ AliTRDdEdxBaseUtils::PrintControl();
+ nprint++;
+ }
+
+ //do truncated mean
+ AliTRDdEdxCalibUtils::SetObjArray(AliTRDcalibDB::Instance()->GetPHQ());
+ const Double_t mag = AliTRDdEdxBaseUtils::IsExBOn() ? GetBz() : -1;
+ const Double_t charge = AliTRDdEdxBaseUtils::IsExBOn() ? Charge() : -1;
+ fTruncatedMean = CookTruncatedMean(0, mag, charge, kTRUE, fNchamberdEdx, fNclusterdEdx);
+
return kTRUE;
}
for(Int_t il(AliTRDgeometry::kNlayer); il--;){
if(!fTracklet[il]) continue;
n++;
- occupancy+=fTracklet[il]->GetOccupancyTB();
+ occupancy+=fTracklet[il]->GetTBoccupancy()/AliTRDseedV1::kNtb;
ncls += fTracklet[il]->GetN();
}
if(!n) return -1;
}
//_____________________________________________________________________________
-Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t /*xx0*/, Double_t xrho)
+Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
{
//
// Propagates this track to a reference plane defined by "xk" [cm]
Double_t xyz1[3] = {GetX(), GetY(), GetZ()};
// printf("x0[%6.2f] -> x1[%6.2f] dx[%6.2f] rho[%f]\n", xyz0[0], xyz1[0], xyz0[0]-xk, xrho/TMath::Abs(xyz0[0]-xk));
if(xyz0[0] < xk) {
- //xrho = -xrho;
+ xrho = -xrho;
if (IsStartedTimeIntegral()) {
Double_t l2 = TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])
+ (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])
AddTimeStep(l2);
}
}
-
-// if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, GetMass())) return kFALSE;
+ if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, fMass)) return kFALSE;
{
// Energy losses
Double_t p2 = (1.0 + GetTgl()*GetTgl()) / (GetSigned1Pt()*GetSigned1Pt());
- Double_t beta2 = p2 / (p2 + GetMass()*GetMass());
+ if (fMass<0) p2 *= 4; // q=2
+ Double_t beta2 = p2 / (p2 + fMass*fMass);
if ((beta2 < 1.0e-10) ||
((5940.0 * beta2/(1.0 - beta2 + 1.0e-10) - beta2) < 0.0)) {
return kFALSE;
Double_t dE = 0.153e-3 / beta2
* (TMath::Log(5940.0 * beta2/(1.0 - beta2 + 1.0e-10)) - beta2)
* xrho;
+ if (fMass<0) dE *= 4; // q=2
fBudget[0] += xrho;
/*
/*
// Suspicious ! I.B.
Double_t sigmade = 0.07 * TMath::Sqrt(TMath::Abs(dE)); // Energy loss fluctuation
- Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+GetMass()*GetMass())/(p2*p2);
+ Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+fMass*fMass)/(p2*p2);
fCcc += sigmac2;
fCee += fX*fX * sigmac2;
*/
// pack the two numbers together and store them in the ESD
track->SetTRDntracklets(nPID | (nTrk<<3));
// allocate space to store raw PID signals dEdx & momentum
- track->SetNumberOfTRDslices((AliTRDPIDResponse::kNslicesNN+3)*AliTRDgeometry::kNlayer);
+ // independent of the method used to calculate PID (see below AliTRDPIDResponse)
+ track->SetNumberOfTRDslices((AliTRDseedV1::kNdEdxSlices+2)*AliTRDgeometry::kNlayer);
// store raw signals
Float_t p, sp; Double_t spd;
for (Int_t ip = 0; ip < kNplane; ip++) {
if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
- if(!fTracklet[ip]->HasPID()) continue;
- //printf("Setting slices for tracklet %d\n", ip);
+ // Fill TRD dEdx info into ESD track
+ // a. Set Summed dEdx into the first slice
+ track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0);
+ // b. Set NN dEdx slices
fTracklet[ip]->CookdEdx(AliTRDPIDResponse::kNslicesNN);
const Float_t *dedx = fTracklet[ip]->GetdEdx();
- for (Int_t js = 0; js < AliTRDPIDResponse::kNslicesNN; js++, dedx++){
- //printf("Slice %d, dEdx %f\n", js, *dedx);
- track->SetTRDslice(*dedx, ip, js+1);
+ for (Int_t js(0), ks(1); js < AliTRDPIDResponse::kNslicesNN; js++, ks++, dedx++){
+ if(ks>=AliTRDseedV1::kNdEdxSlices){
+ AliError(Form("Exceed allocated space for dEdx slices."));
+ break;
+ }
+ track->SetTRDslice(*dedx, ip, ks);
}
- p = fTracklet[ip]->GetMomentum(&sp);
- // 04.01.11 A.Bercuci
- // store global dQdl per tracklet instead of momentum error
- spd = sp;
+ // fill TRD momentum info into ESD track
+ p = fTracklet[ip]->GetMomentum(&sp); spd = sp;
track->SetTRDmomentum(p, ip, &spd);
- //printf("Total Charge %f\n", fTracklet[ip]->GetdQdl());
- track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0); // Set Summed dEdx into the first slice
+ // store global quality per tracklet instead of momentum error
+ // 26.09.11 A.Bercuci
+ // first implementation store no. of time bins filled in tracklet (5bits see "y" bits) and
+ // no. of double clusters in case of pad row cross (4bits see "x" bits)
+ // bit map for tracklet quality xxxxyyyyy
+ // 27.10.11 A.Bercuci
+ // add chamber status bit "z" bit
+ // bit map for tracklet quality zxxxxyyyyy
+ // 12.11.11 A.Bercuci
+ // fit tracklet quality into the field fTRDTimeBin [Char_t]
+ // bit map for tracklet quality zxxyyyyy
+ // The information should be retrieved by the following functions of AliESDtrack for each TRD layer
+ // GetTRDtrkltOccupancy(layer) -> no of TB filled in tracklet
+ // GetTRDtrkltClCross(layer) -> no of TB filled in crossing pad rows
+ // IsTRDtrkltChmbGood(layer) -> status of the chamber from which the tracklet is found
+ Int_t nCross(fTracklet[ip]->IsRowCross()?fTracklet[ip]->GetTBcross():0); if(nCross>3) nCross = 3;
+ Char_t trackletQ = Char_t(fTracklet[ip]->GetTBoccupancy() | (nCross<<5) | (fTracklet[ip]->IsChmbGood()<<7));
+ track->SetTRDTimBin(trackletQ, ip);
}
// store PID probabilities
track->SetTRDpid(fPID);
+
+ //store truncated mean
+ track->SetTRDsignal(fTruncatedMean);
+ track->SetTRDNchamberdEdx(fNchamberdEdx);
+ track->SetTRDNclusterdEdx(fNclusterdEdx);
+}
+
+//_______________________________________________________________
+Double_t AliTRDtrackV1::CookTruncatedMean(const Bool_t kinvq, const Double_t mag, const Int_t charge, const Int_t kcalib, Int_t &nch, Int_t &ncls, TVectorD *Qs, TVectorD *Xs, Int_t timeBin0, Int_t timeBin1, Int_t tstep) const
+{
+ //
+ //Origin: Xianguo Lu <xianguo.lu@cern.ch>, Marian Ivanov <marian.ivanov@cern.ch>
+ //
+
+ TVectorD arrayQ(200), arrayX(200);
+ ncls = AliTRDdEdxReconUtils::GetArrayClusterQ(kinvq, &arrayQ, &arrayX, this, timeBin0, timeBin1, tstep);
+
+ const TObjArray *cobj = kcalib ? AliTRDdEdxCalibUtils::GetObj(kinvq, mag, charge) : NULL;
+
+ const Double_t tmean = AliTRDdEdxReconUtils::ToyCook(kinvq, ncls, &arrayQ, &arrayX, cobj);
+
+ nch = AliTRDdEdxReconUtils::UpdateArrayX(ncls, &arrayX);
+
+ if(Qs && Xs){
+ (*Qs)=arrayQ;
+ (*Xs)=arrayX;
+ }
+
+ //printf("\ntest %.10f %d %d\n", tmean, nch, ncls);
+
+ return tmean;
+}
+
+//_______________________________________________________________
+TObject* AliTRDtrackV1::Clone(const char* newname) const
+{
+ // temporary override TObject::Clone to avoid crashes in reco
+ AliTRDtrackV1* src = (AliTRDtrackV1*)this;
+ Bool_t isown = src->IsOwner();
+ AliInfo(Form("src_owner %d",isown));
+ AliTRDtrackV1* dst = new AliTRDtrackV1(*src);
+ if (isown) {
+ src->SetBit(kOwner);
+ dst->SetOwner();
+ }
+ return dst;
}