Skip to content

Commit

Permalink
PWGPP-571 Adding TOF debug streamers+IonTail time scaling (#1083)
Browse files Browse the repository at this point in the history
* PWGPP-570 - add ion tail time rescaling from RecoParam to correct for
possible ion drift velocity modification

* PWGPP-571, PWGPP-566 - adding tracking streamer

* PWGPP-571, PWGPP-566 - add MakeGammaSeed - dummy function

* PWGPP-571, PWGPP-566 - bug fix in slection of best match cluster
* temporary disabling usage of Usecluster - as the algorithm influenced
   by bug
* adding streamer to monitor algorithm

* PWGPP-571, PWGPP-566 - Temporary return back IsUsed to be able to merge

* PWGPP-571, PWGPP-566 - Increasing class version

* PWGPP-571 - Adding cluster error matrix for dEdx and Multiplicity
dependent errors

* PWGPP-571 - Replacing hardwired cluster error param (dEdx, mult) with the RecoParam
  • Loading branch information
miranov25 authored and ktf committed Dec 18, 2019
1 parent 4dd3ddd commit b85b9a2
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 18 deletions.
2 changes: 2 additions & 0 deletions TOF/TOFrec/AliTOFReconstructor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
class TTree;

ClassImp(AliTOFReconstructor)
Int_t AliTOFReconstructor::fgStreamLevel = 0; // stream (debug) level
TTreeSRedirector * AliTOFReconstructor::fgDebugStreamer=0; // NOTE - AliTOFReconstructor is not an owner of the streamer - AliTOFtracker is an owner

Double_t AliTOFReconstructor::fgExtraTolerance = 0;
Int_t AliTOFReconstructor::fgCTPtriggerLatency = -1;
Expand Down
14 changes: 12 additions & 2 deletions TOF/TOFrec/AliTOFReconstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AliESDEvent;
class AliRawReader;
class AliTOFcalib;
class AliESDpid;

class TTreeSRedirector;
//class AliTOFT0maker;

class AliTOFReconstructor: public AliReconstructor {
Expand All @@ -49,8 +49,18 @@ class AliTOFReconstructor: public AliReconstructor {

virtual void FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID);
virtual void GetPidSettings(AliESDpid *esdPID);

static Int_t StreamLevel() { return fgStreamLevel;}
static void SetStreamLevel(Int_t level) { fgStreamLevel = level;}
static TTreeSRedirector *GetDebugStreamer(){return fgDebugStreamer;}
static void SetDebugStreamer(TTreeSRedirector *debugStreamer){fgDebugStreamer=debugStreamer;}

static Int_t fgStreamLevel; // flag for streaming - for TPC reconstruction
enum EStreamFlags { // flags to store addition data/code debugging information which is not stored in ESD but in specaial TPCdebug.root file
kStreamSingle = 0x00001, // flag:stream - single hit stream
kStreamV0 = 0x00002, // flag:stream - gamma candidate hit pair stream
};
private:
static TTreeSRedirector *fgDebugStreamer; // pointer to the streamer
AliTOFReconstructor(const AliTOFReconstructor &); //Not implemented
AliTOFReconstructor& operator=(const AliTOFReconstructor &); //Not implemented

Expand Down
102 changes: 100 additions & 2 deletions TOF/TOFrec/AliTOFtracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "AliTOFGeometry.h"
#include "AliTOFtracker.h"
#include "AliTOFtrack.h"
#include "TTreeStream.h"

extern TGeoManager *gGeoManager;
//extern TROOT *gROOT;
Expand All @@ -61,6 +62,7 @@ ClassImp(AliTOFtracker)

//_____________________________________________________________________________
AliTOFtracker::AliTOFtracker():
fDebugStreamer(0x0),
fkRecoParam(0x0),
fGeom(0x0),
fN(0),
Expand Down Expand Up @@ -106,6 +108,10 @@ AliTOFtracker::AliTOFtracker():
}
*/
InitCheckHists();
if (AliTOFReconstructor::StreamLevel()>0) {
fDebugStreamer = new TTreeSRedirector("TOFdebug.root","recreate");
AliTOFReconstructor::SetDebugStreamer(fDebugStreamer);
}

}
//_____________________________________________________________________________
Expand Down Expand Up @@ -162,6 +168,7 @@ AliTOFtracker::~AliTOFtracker() {
}
}
*/
if (fDebugStreamer) delete fDebugStreamer;

}
//_____________________________________________________________________________
Expand Down Expand Up @@ -384,7 +391,7 @@ Int_t AliTOFtracker::PropagateBack(AliESDEvent * const event) {
//Make TOF PID
// Now done in AliESDpid
// fPid->MakePID(event,timeZero);

MakeGammaSeed();
fSeeds->Clear();
//fTracks->Delete();
fTracks->Clear();
Expand Down Expand Up @@ -870,10 +877,35 @@ void AliTOFtracker::MatchTracks( Int_t mLastStep){
Float_t mindistX=stepSize;
for (Int_t iclus= 0; iclus<nfound;iclus++) {
AliTOFtrackPoint *matchableTOFcluster = (AliTOFtrackPoint*)fTOFtrackPoints->At(iclus);
if (fDebugStreamer && (AliTOFReconstructor::StreamLevel())>0){
Float_t mindistNew = matchableTOFcluster->Distance();
Float_t mindistYNew = matchableTOFcluster->DistanceY();
Float_t mindistZNew = matchableTOFcluster->DistanceZ();
Float_t mindistXNew = matchableTOFcluster->DistanceX();
AliTOFcluster *c=fClusters[matchableTOFcluster->Index()];
Int_t clindex=matchableTOFcluster->Index();
(*fDebugStreamer)<<"matchNearest"<<
"mLastStep="<<mLastStep<<
"c.="<<c<<
"clindex="<<clindex<<
"nfound="<<nfound<<
"mindist="<<mindist<<
"iclus="<<iclus<<
"mindistNew="<<mindistNew<<
"mindist="<<mindist<<
"mindistX="<<mindistX<<
"mindistXNew="<<mindistXNew<<
"mindistY="<<mindistY<<
"mindistYNew="<<mindistYNew<<
"mindistZ="<<mindistZ<<
"mindistZNew="<<mindistZNew<<
"\n";
}
//if ( matchableTOFcluster->Distance()<mindist ) {

//if ( TMath::Abs(matchableTOFcluster->DistanceX())<TMath::Abs(mindistX) &&
//TMath::Abs(matchableTOFcluster->DistanceX())<=stepSize ) {
if ( TMath::Abs(matchableTOFcluster->Distance())<TMath::Abs(mindist) &&
if ( TMath::Abs(matchableTOFcluster->Distance())<TMath::Abs(mindist) &&
TMath::Abs(matchableTOFcluster->DistanceX())<=stepSize ) { /// MI - Temporary BUG FIX - use 3D distance instead of the localX (radial) distance

mindist = matchableTOFcluster->Distance();
Expand Down Expand Up @@ -1467,3 +1499,69 @@ AliESDTOFCluster* AliTOFtracker::GetESDTOFCluster(int clID)
return clESD;
//
}


void AliTOFtracker::MakeGammaSeed() {
// find the gamma candidate clusters
const Float_t kTimeOffset = 0.; // time offset for tracking algorithm [ps]
const AliESDVertex * vertex = fESDEv->GetPrimaryVertex();
Double_t xyzVertex[3];
vertex->GetXYZ(xyzVertex);
Int_t nc=0;
const Float_t dPhiCut = 0.34;
const Float_t dZCut = 5.;
Float_t xyz0[3], xyz1[3];
for (Int_t i0=0; i0<fN; i0++) {
AliTOFcluster *c0 = fClusters[i0];
if (!c0->GetStatus()) continue;
c0->GetGlobalXYZ(xyz0);
Float_t phi0= TMath::ATan2(xyz0[1],xyz0[0]);
Float_t length0=(xyz0[0]-xyzVertex[0])*(xyz0[0]-xyzVertex[0])+(xyz0[1]-xyzVertex[1])*(xyz0[1]-xyzVertex[1])+(xyz0[2]-xyzVertex[2])*(xyz0[2]-xyzVertex[2]);
length0=TMath::Sqrt(length0);
Double_t tof0=AliTOFGeometry::TdcBinWidth()*c0->GetTDC()+kTimeOffset; // in ps
if (fDebugStreamer && (AliTOFReconstructor::StreamLevel() & AliTOFReconstructor::kStreamSingle)>0){
(*fDebugStreamer)<<"hit0"<<
"nhits="<<fN<<
"c0.="<<c0<<
"lentgh0="<<length0<<
"tof0="<<tof0<<
"\n";
}
for (Int_t i1=FindClusterIndex(c0->GetZ()-dZCut); i1<fN; i1++) {
if (i0==i1) continue;
AliTOFcluster *c1 = fClusters[i1];
if (!c1->GetStatus()) continue;
if (c1->GetZ()-c0->GetZ()>dZCut) break;
c1->GetGlobalXYZ(xyz1);
Float_t phi1= TMath::ATan2(xyz1[1],xyz1[0]);
Double_t dphi=phi0-phi1;
if (TMath::Abs(dphi) > dPhiCut) continue;
Float_t length1=(xyz1[0]-xyzVertex[0])*(xyz1[0]-xyzVertex[0])+(xyz1[1]-xyzVertex[1])*(xyz1[1]-xyzVertex[1])+(xyz1[2]-xyzVertex[2])*(xyz1[2]-xyzVertex[2]);
length1=TMath::Sqrt(length1);
Double_t tof1=AliTOFGeometry::TdcBinWidth()*c1->GetTDC()+kTimeOffset; // in ps
Double_t dist3D=(xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])+(xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])+(xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]);
dist3D=TMath::Sqrt(dist3D);
Float_t dTime=tof1-tof0;
if (fDebugStreamer && (AliTOFReconstructor::StreamLevel() & AliTOFReconstructor::kStreamV0)>0){
(*fDebugStreamer)<<"gammaSeed"<<
"nhits="<<fN<<
"dphi="<<dphi<<
"c0.="<<c0<<
"length0="<<length0<<
"tof0="<<tof0<<
"c1.="<<c1<<
"length1="<<length1<<
"tof1="<<tof1<<
"\n";
}
}

}

/*
gammaSeed->SetAlias("v1","lentgh1/tof1/0.03")
gammaSeed->SetAlias("v0","lentgh0/tof0/0.03");
gammaSeed->SetAlias("dz","c0.fZ-c1.fZ")
*/
}
6 changes: 5 additions & 1 deletion TOF/TOFrec/AliTOFtracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class AliESDpid;
class AliTOFcluster;
class AliTOFRecoParam;
class AliTOFGeometry;
class TTreeSRedirector;


class AliTOFtrackPoint : public TObject {

Expand Down Expand Up @@ -97,6 +99,7 @@ class AliTOFtracker : public AliTracker {
virtual void GetPidSettings(AliESDpid *esdPID);
virtual Int_t Clusters2Tracks(AliESDEvent* /*event*/) {return -1;};
virtual Int_t PropagateBack(AliESDEvent * const event);
virtual void MakeGammaSeed();
virtual Int_t RefitInward(AliESDEvent* /*event*/) {return -1;};
virtual Int_t LoadClusters(TTree * cTree); // Load Clusters
virtual void UnloadClusters();// UnLoad Clusters
Expand All @@ -108,7 +111,8 @@ class AliTOFtracker : public AliTracker {
void InitCheckHists();
void SaveCheckHists();
void FillClusterArray(TObjArray* arr) const;

TTreeSRedirector *fDebugStreamer; //!debug streamer

protected:
AliESDTOFCluster* GetESDTOFCluster(int clID);

Expand Down
48 changes: 47 additions & 1 deletion TPC/TPCbase/AliTPCRecoParam.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ AliTPCRecoParam::AliTPCRecoParam():
fUseAlignmentTime(kTRUE), // use time dependent alignment correction
fUseIonTailCorrection(0), // no ion tail correction for now
fIonTailCorrection(1), ///< ion tail tail correction factor - NEW SINCE 2018- additonal scaling correcting for imperfect knowledge of the integral of ion tail - shoudl be ~ 1
fIonTailCorrectionTimeScale(1.0), ///< ion tail tail correction factor time stretching - new Since 2019 - default value=1
fCrosstalkCorrection(0), // crosstalk correction factor (from each signal substracted by (mean signal in wite patch)xfCrosstalkCorrection) - Effect important only after removing oc capacitors in 2012
fCrosstalkCorrectionMissingCharge(1), // crosstalk correction factor - missing charge (from each signal substracted by (mean signal in wite patch)xfCrosstalkCorrection) - Effect important only after removing oc capacitors in 2012
fCrosstalkIonTail(kFALSE), /// < flag calculate crosstalk for ion tail
Expand All @@ -129,6 +130,7 @@ AliTPCRecoParam::AliTPCRecoParam():
fSystErrClInnerRegZSigInv(0),
fUseClusterErrordEdxCorrection(false), ///< switch to use the dEdx correction - default is false - for back compatibility
fUseClusterErrordEdxMultCorrection(false), ///< switch to use the dEdx, multiplicity correction - for back compatibility
fClusterErrorMatrix(8,10), /// < cluster error matrix
fClusterNSigma2Cut(3,3), /// < n sigma cluster/track cut
fUseSystematicCorrelation(kTRUE)
{
Expand Down Expand Up @@ -165,7 +167,7 @@ AliTPCRecoParam::AliTPCRecoParam():
fClusterNSigma2Cut(0,0)=1; fClusterNSigma2Cut(0,1)=6.25; fClusterNSigma2Cut(0,2)=2*6.25; // edge n sigma cut
fClusterNSigma2Cut(1,0)=9; fClusterNSigma2Cut(1,1)=9; fClusterNSigma2Cut(1,2)=32; // normal clusters cut
fClusterNSigma2Cut(2,0)=6.25; fClusterNSigma2Cut(2,1)=6.25; fClusterNSigma2Cut(2,2)=2*6.25; // unfolded clusters cut

SetClusterErrorParam();
}

//_____________________________________________________________________________
Expand Down Expand Up @@ -299,6 +301,50 @@ AliTPCRecoParam *AliTPCRecoParam::GetCosmicTestParam(Bool_t bPedestal){
return param;
}

/// Set default cluster error estimator - correcting for the dEdx and multiplicity
void AliTPCRecoParam::SetClusterErrorParam(){
/*
errParam matrix
Low mutplicity:
erry2LM=(sy2+0.04*tanPhi2)*(0.5+mdEdx+0.3*mQ)*0.25;
errz2LM=(sz2)*(0.5+mdEdx+0.3*mQ)*0.5;
-->
errParam(0,i) = (p0+p1*mdEdx+p2*mQ)*p3*(sy2+p4*tanPhi2) // erry2LM
errParam(1,i) = (p0+p1*mdEdx+p2*mQ)*p3*(sz2+p4*tanTheta2) // errz2LM
High multiplicity:
erry2OccudEdx = 0.12*0.12*occu6N*(mdEdx+0.3*mQ);
erry2Ratio = 0.07*negRatio+0.15*posRatio;
erry2HM = (erry2OccudEdx+erry2Ratio)*(0.3+tanPhi2);
errz2OccudEdx = 0.09*0.09*occu6N*(mdEdx+0.3*mQ);
errz2Ratio = 0.01*negRatio+0.05*posRatio;
errz2HM = (errz2OccudEdx+errz2Ratio)*(1+tgl2)*0.5;
errParam(2,i) = occu6N*(p0+p1*mdEdx+p2*mQ)*p3 // erry2OccudEdx
errParam(3,i) = occu6N*(p0+p1*mdEdx+p2*mQ)*p3 // errz2OccudEdx
//
errParam(4,i) = p0*negRatio+p1*posRatio // erry2Ratio
errParam(5,i) = p0*negRatio+p1*posRatio // errz2Ratio
//
errParam(6,i) = (erry2OccudEdx+erry2Ratio)*(p0+p1*tanPhi2); //erry2HM
errParam(7,i) = (errz2OccudEdx+errz2Ratio)*(p0+p1*tgl2); //errz2HM
*/
TMatrixF &e=fClusterErrorMatrix;
e(0,0)=0.5; e(0,1)=1; e(0,2)=0.15; e(0,3)=0.25; e(0,4)=0.04; /// (p0+p1*mdEdx+p2*mQ)*p3*(sy2+p4*tanPhi2) // erry2LM
e(1,0)=0.5; e(1,1)=1; e(1,2)=0.15; e(1,3)=0.5; e(1,4)=0; /// (p0+p1*mdEdx+p2*mQ)*p3*(sy2+p4*tgl2) // errz2LM
//
e(2,0)=0; e(2,1)=1; e(2,2)=0.3; e(2,3)=0.12*0.12; /// occu6N*(p0+p1*mdEdx+p2*mQ)*p3 // erry2OccudEdx 0.12*0.12*occu6N*(mdEdx+0.3*mQ);
e(3,0)=0; e(3,1)=1; e(3,2)=0.3; e(3,3)=0.09*0.09; /// occu6N*(p0+p1*mdEdx+p2*mQ)*p3 // errz2OccudEdx = 0.09*0.09*occu6N*(mdEdx+0.3*mQ);
//
e(4,0)= 0.07; e(4,1)=0.15; /// p0*negRatio+p1*posRatio // erry2Ratio =0.07*negRatio+0.15*posRatio;
e(5,0)= 0.01; e(5,1)=0.05; /// p0*negRatio+p1*posRatio // 0.01*negRatio+0.05*posRatio;
//
e(6,0)= 0.3; e(6,1)=1; e(6,2)=1; /// errParam(6,i) = (erry2OccudEdx+erry2Ratio)*(p0+p1*tanPhi2); //erry2HM = (erry2OccudEdx+erry2Ratio)*(0.3+tanPhi2);
e(7,0)= 1; e(7,1)=1; e(7,2)=0.5; ///errParam(7,i) = (errz2OccudEdx+errz2Ratio)*(p0+p1*tgl2); //errz2HM (errz2OccudEdx+errz2Ratio)*(1+tgl2)*0.5;

}


Bool_t AliTPCRecoParam::GetUseTimeCalibration(){
/// get
Expand Down
10 changes: 9 additions & 1 deletion TPC/TPCbase/AliTPCRecoParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
void SetUseTOFCorrection(Bool_t flag) {fUseTOFCorrection = flag;}
void SetUseIonTailCorrection(Int_t flag) {fUseIonTailCorrection = flag;}
void SetIonTailCorrection(Float_t factor) {fIonTailCorrection = factor;}
void SetIonTailCorrectionTimeScale(Float_t timeScale) {fIonTailCorrectionTimeScale = timeScale;}
void SetCrosstalkCorrection(Float_t crosstalkCorrection) {fCrosstalkCorrection= crosstalkCorrection; }
void SetCrosstalkCorrectionMissingCharge(Float_t crosstalkCorrection) {fCrosstalkCorrectionMissingCharge= crosstalkCorrection; }
void SetCrosstalkIonTail(Bool_t crosstalkIonTail) {fCrosstalkIonTail= crosstalkIonTail; }
Expand All @@ -166,6 +167,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
Bool_t GetUseTOFCorrection() {return fUseTOFCorrection;}
Int_t GetUseIonTailCorrection() const {return fUseIonTailCorrection;}
Float_t GetIonTailCorrection() const {return fIonTailCorrection;}
Float_t GetIonTailCorrectionTimeScale() const {return fIonTailCorrectionTimeScale;}
Double_t GetCrosstalkCorrection() const {return fCrosstalkCorrection;}
Double_t GetCrosstalkCorrectionMissingCharge() const {return fCrosstalkCorrectionMissingCharge;}
Bool_t GetCrosstalkIonTail() const {return fCrosstalkIonTail;}
Expand Down Expand Up @@ -217,6 +219,10 @@ class AliTPCRecoParam : public AliDetectorRecoParam
void SettUseClusterErrordEdxCorrection(Bool_t useClusterErrordEdxCorrection){ fUseClusterErrordEdxCorrection=useClusterErrordEdxCorrection;}
Bool_t GetUseClusterErrordEdxMultCorrection() const {return fUseClusterErrordEdxMultCorrection;}
void SettUseClusterErrordEdxMultCorrection(Bool_t useClusterErrordEdxMultCorrection){ fUseClusterErrordEdxMultCorrection=useClusterErrordEdxMultCorrection;}
const TMatrixF& GetClusterErrorMatrix() const {return fClusterErrorMatrix;}
void SetClusterErrorMatrix(TMatrixF* matrix) {fClusterErrorMatrix=*matrix;}
void SetClusterErrorMatrixElement(Int_t row, Int_t column, Float_t value) {fClusterErrorMatrix(row,column)=value;}
void SetClusterErrorParam(); // set default cluster error Param
const TMatrixF& GetClusterNSigma2Cut() const {return fClusterNSigma2Cut;}
void SetClusterNSigma2Cut(TMatrixF cuts){fClusterNSigma2Cut=cuts;}
void SetClusterNSigma2Cut(Int_t row, Int_t column,Float_t cut){fClusterNSigma2Cut(row,column)=cut;}
Expand Down Expand Up @@ -296,6 +302,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
Bool_t fUseAlignmentTime; ///< use time dependent alignment correction
Int_t fUseIonTailCorrection; ///< use ion tail correction
Float_t fIonTailCorrection; ///< ion tail tail correction factor - NEW SINCE 2018- additonal scaling correcting for imperfect knowledge of the integral of ion tail - shoudl be ~ 1
Float_t fIonTailCorrectionTimeScale; ///< ion tail tail correction factor time stretching - new Since 2019 - default value=1
Double_t fCrosstalkCorrection; ///< crosstalk correction factor (fro each signal substracted by (mean signal in wite patch)xfCrosstalkCorrection) - Effect important only after removing oc capacitors in 2012
Double_t fCrosstalkCorrectionMissingCharge; ///< crosstalk correction factor - missing charge factor (from each signal substracted by (mean signal in wite patch)xfCrosstalkCorrection) - Effect important only after removing capacitors in 2012
Bool_t fCrosstalkIonTail; /// < flag calculate crosstalk for ion tail
Expand Down Expand Up @@ -338,6 +345,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
//
Bool_t fUseClusterErrordEdxCorrection; ///< switch to use the dEdx correction
Bool_t fUseClusterErrordEdxMultCorrection; ///< switch to use the dEdx, multiplicity correction
TMatrixF fClusterErrorMatrix; ///< cluster error matrix
TMatrixF fClusterNSigma2Cut; /// < n sigma cluster/trac cut
static TVectorD* fgSystErrClustCustom; //< custom systematic errors for the TPC clusters overriding persistent data member
static TVectorD* fgPrimaryDCACut; //< only primaries passing DCAYZ cut are reconstructed
Expand All @@ -348,7 +356,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
// Use static function, other option will be to use
// additional specific storage ?
/// \cond CLASSIMP
ClassDef(AliTPCRecoParam, 36)
ClassDef(AliTPCRecoParam, 38)
/// \endcond
};

Expand Down
Loading

0 comments on commit b85b9a2

Please sign in to comment.