]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSMultReconstructor.h
add getter to cut on n cells
[u/mrichter/AliRoot.git] / ITS / AliITSMultReconstructor.h
index c8e5b092a3b2961a8fd471ca715878ec00be5ece..f0cf25ccd7dbae1dcb075daca5dae599730ae68e 100644 (file)
@@ -17,6 +17,8 @@
 // distance is selected. 
 //_________________________________________________________________________
 #include "AliTrackleter.h"
+#include "AliITSsegmentationSPD.h"
+#include "TMath.h"
 
 class TBits;
 class TTree;
@@ -29,6 +31,8 @@ class AliESDtrack;
 class AliVertex;
 class AliESDVertex;
 class AliMultiplicity;
+class AliRefArray;
+class AliITSRecPoint;
 
 class AliITSMultReconstructor : public AliTrackleter
 {
@@ -42,41 +46,60 @@ public:
   virtual ~AliITSMultReconstructor();
 
   void Reconstruct(AliESDEvent* esd, TTree* treeRP);
-  void Reconstruct(TTree* tree, Float_t* vtx, Float_t* vtxRes);   // old reconstructor invocation
+  void Reconstruct(TTree* tree, Float_t* vtx, Float_t* vtxRes=0);   // old reconstructor invocation
+  void ReconstructMix(TTree* clusterTree, TTree* clusterTreeMix, const Float_t* vtx, Float_t* vtrRes=0);
   void FindTracklets(const Float_t* vtx); 
   void LoadClusterFiredChips(TTree* tree);
   void FlagClustersInOverlapRegions(Int_t ic1,Int_t ic2);
-  void FlagTrackClusters(const AliESDtrack* track);
+  void FlagTrackClusters(Int_t id);
   void FlagIfSecondary(AliESDtrack* track, const AliVertex* vtx);
   void FlagV0s(const AliESDVertex *vtx);
   void ProcessESDTracks();
   Bool_t  CanBeElectron(const AliESDtrack* trc) const;
   
-  void CreateMultiplicityObject();
+  virtual void CreateMultiplicityObject();
   //
   // Following members are set via AliITSRecoParam
-  void SetPhiWindow(Float_t w=0.08) {fPhiWindow=w;}
-  void SetThetaWindow(Float_t w=0.025) {fThetaWindow=w;}
+  void SetPhiWindow(Float_t w=0.08)    {fDPhiWindow=w;   fDPhiWindow2 = w*w;}
+  void SetThetaWindow(Float_t w=0.025) {fDThetaWindow=w; fDThetaWindow2=w*w;}
   void SetPhiShift(Float_t w=0.0045) {fPhiShift=w;}
   void SetRemoveClustersFromOverlaps(Bool_t b = kFALSE) {fRemoveClustersFromOverlaps = b;}
   void SetPhiOverlapCut(Float_t w=0.005) {fPhiOverlapCut=w;}
   void SetZetaOverlapCut(Float_t w=0.05) {fZetaOverlapCut=w;}
+  void SetPhiRotationAngle(Float_t w=0.0) {fPhiRotationAngle=w;}
 
-  Int_t GetNClustersLayer1() const {return fNClustersLay1;}
-  Int_t GetNClustersLayer2() const {return fNClustersLay2;}
+  Int_t GetNClustersLayer1() const {return fNClustersLay[0];}
+  Int_t GetNClustersLayer2() const {return fNClustersLay[1];}
+  Int_t GetNClustersLayer(Int_t i) const {return fNClustersLay[i];}
   Int_t GetNTracklets() const {return fNTracklets;}
   Int_t GetNSingleClusters() const {return fNSingleCluster;}
+  Int_t GetNSingleClustersLr(int lr) const {return lr==0 ? fNSingleCluster-fNSingleClusterSPD2:(GetStoreSPD2SingleCl() ? fNSingleClusterSPD2 : -1) ;}
   Short_t GetNFiredChips(Int_t layer) const {return fNFiredChips[layer];}
 
-  Float_t* GetClusterLayer1(Int_t n) {return &fClustersLay1[n*kClNPar];}
-  Float_t* GetClusterLayer2(Int_t n) {return &fClustersLay2[n*kClNPar];}
-
-  Float_t* GetTracklet(Int_t n) {return fTracklets[n];}
-  Float_t* GetCluster(Int_t n) {return fSClusters[n];}
+  Float_t* GetClusterLayer1(Int_t n) const {return &fClustersLay[0][n*kClNPar];}
+  Float_t* GetClusterLayer2(Int_t n) const {return &fClustersLay[1][n*kClNPar];}
+  Float_t* GetClusterOfLayer(Int_t lr,Int_t n) const {return &fClustersLay[lr][n*kClNPar];}
+  Int_t    GetClusterCopyIndex(Int_t lr,Int_t n) const {return fClusterCopyIndex[lr] ? fClusterCopyIndex[lr][n] : -1;}
+  AliITSRecPoint* GetRecPoint(Int_t lr, Int_t n) const;
+  
+  Float_t* GetTracklet(Int_t n) const {return fTracklets[n];}
+  Float_t* GetCluster(Int_t n) const {return fSClusters[n];}
 
+  void     SetScaleDThetaBySin2T(Bool_t v=kTRUE)         {fScaleDTBySin2T = v;}
+  Bool_t   GetScaleDThetaBySin2T()               const   {return fScaleDTBySin2T;}
+  //
+  void     SetNStdDev(Float_t f=1.)                      {fNStdDev = f<0.01 ? 0.01 : f; fNStdDevSq=TMath::Sqrt(fNStdDev);}
+  Float_t  GetNStdDev()                          const   {return fNStdDev;}
+  //
   void SetHistOn(Bool_t b=kFALSE) {fHistOn=b;}
   void SaveHists();
-
+  //
+  void   SetBuildRefs(Bool_t v=kTRUE)                    {fBuildRefs = v;}
+  Bool_t GetBuildRefs()                          const   {return fBuildRefs;}
+  //
+  void   SetStoreSPD2SingleCl(Bool_t v)                  {fStoreSPD2SingleCl = v;}
+  Bool_t GetStoreSPD2SingleCl()                  const   {return fStoreSPD2SingleCl;}
+  //
   AliITSDetTypeRec *GetDetTypeRec() const {return fDetTypeRec;}
   void SetDetTypeRec(AliITSDetTypeRec *ptr){fDetTypeRec = ptr;}
   //
@@ -122,41 +145,70 @@ public:
   Float_t GetCutK0SFromDecay()                 const {return fCutK0SFromDecay;}
   Float_t GetCutMaxDCA()                       const {return fCutMaxDCA;}
   //
-protected:
+  void  InitAux();
+  void  ClusterPos2Angles(const Float_t *vtx);
+  void  ClusterPos2Angles(Float_t *clPar, const Float_t *vtx) const;
+  Int_t AssociateClusterOfL1(Int_t iC1);
+  Int_t StoreTrackletForL2Cluster(Int_t iC2);
+  void  StoreL1Singles();
+  TClonesArray* GetClustersOfLayer(Int_t il)   const {return fClArr[il];}
+  void  LoadClusters()                               {LoadClusterArrays(fTreeRP);}
+  void  SetTreeRP(TTree* rp)                         {fTreeRP    = rp;}
+  void  SetTreeRPMix(TTree* rp=0)                    {fTreeRPMix = rp;}
+  Bool_t AreClustersLoaded()                   const {return fClustersLoaded;}
+  Bool_t GetCreateClustersCopy()               const {return fCreateClustersCopy;}
+  Bool_t IsRecoDone()                          const {return fRecoDone;}
+  void  SetCreateClustersCopy(Bool_t v=kTRUE)        {fCreateClustersCopy=v;}
+  //
+  //  Float_t* GetClustersArray(Int_t lr)          const {return (Float_t*) (lr==0) ? fClustersLay[0]:fClustersLay[1];}
+  Float_t* GetClustersArray(Int_t lr)          const {if(lr==0){return fClustersLay[0];} 
+                                                      else {return fClustersLay[1];}}
+  Int_t*   GetPartnersOfL2()                   const {return (Int_t*)fPartners;}
+  Float_t* GetMinDistsOfL2()                   const {return (Float_t*)fMinDists;}
+  Double_t GetDPhiShift()                      const {return fDPhiShift;}
+  Double_t GetDPhiWindow2()                    const {return fDPhiWindow2;}
+  Double_t GetDThetaWindow2()                  const {return fDThetaWindow2;}
+  Double_t CalcDist(Double_t dphi, Double_t dtheta, Double_t theta) const; 
+  //
+ protected:
+  void   SetClustersLoaded(Bool_t v=kTRUE)           {fClustersLoaded = v;}
   AliITSMultReconstructor(const AliITSMultReconstructor& mr);
   AliITSMultReconstructor& operator=(const AliITSMultReconstructor& mr);
+  void              CalcThetaPhi(float dx,float dy,float dz,float &theta,float &phi) const;
   AliITSDetTypeRec* fDetTypeRec;            //! pointer to DetTypeRec
   AliESDEvent*      fESDEvent;              //! pointer to ESD event
   TTree*            fTreeRP;                //! ITS recpoints
+  TTree*            fTreeRPMix;             //! ITS recpoints for mixing
+  AliRefArray*      fUsedClusLay[2][2];     //! RS: clusters usage in ESD tracks
+  //
+  Float_t*      fClustersLay[2];            //! clusters in the SPD layers of ITS 
+  Int_t*        fDetectorIndexClustersLay[2];  //! module index for clusters in ITS layers
+  Int_t*        fClusterCopyIndex[2];         //! when clusters copy is requested, store here the reference on the index
+  Bool_t*       fOverlapFlagClustersLay[2];  //! flag for clusters in the overlap regions in ITS layers
 
-  Char_t*       fUsedClusLay1;               // RS: flag of clusters usage in ESD tracks: 0=unused, bit0=TPC/ITS+ITSSA, bit1=ITSSA_Pure
-  Char_t*       fUsedClusLay2;               // RS: flag of clusters usage in ESD tracks: 0=unused, bit0=TPC/ITS+ITSSA, bit1=ITSSA_Pure
-
-  Float_t*      fClustersLay1;               // clusters in the 1st layer of ITS 
-  Float_t*      fClustersLay2;               // clusters in the 2nd layer of ITS 
-  Int_t*        fDetectorIndexClustersLay1;  // module index for clusters 1st ITS layer
-  Int_t*        fDetectorIndexClustersLay2;  // module index for clusters 2nd ITS layer
-  Bool_t*       fOverlapFlagClustersLay1;    // flag for clusters in the overlap regions 1st ITS layer
-  Bool_t*       fOverlapFlagClustersLay2;    // flag for clusters in the overlap regions 2nd ITS layer 
-
-  Float_t**     fTracklets;            // tracklets 
-  Float_t**     fSClusters;            // single clusters (unassociated)
+  Float_t**     fTracklets;            //! tracklets 
+  Float_t**     fSClusters;            //! single clusters (unassociated)
   
-  Int_t         fNClustersLay1;        // Number of clusters (Layer1)
-  Int_t         fNClustersLay2;        // Number of clusters (Layer2)
+  Int_t         fNClustersLay[2];      // Number of clusters on each layer
   Int_t         fNTracklets;           // Number of tracklets
   Int_t         fNSingleCluster;       // Number of unassociated clusters
+  Int_t         fNSingleClusterSPD2;   // Number of unassociated clusters on 2nd lr
   Short_t       fNFiredChips[2];       // Number of fired chips in the two SPD layers
   //
   // Following members are set via AliITSRecoParam
   //
-  Float_t       fPhiWindow;                    // Search window in phi
-  Float_t       fThetaWindow;                  // Search window in theta
+  Float_t       fDPhiWindow;                   // Search window in phi
+  Float_t       fDThetaWindow;                 // Search window in theta
   Float_t       fPhiShift;                     // Phi shift reference value (at 0.5 T) 
   Bool_t        fRemoveClustersFromOverlaps;   // Option to skip clusters in the overlaps
   Float_t       fPhiOverlapCut;                // Fiducial window in phi for overlap cut
   Float_t       fZetaOverlapCut;               // Fiducial window in eta for overlap cut
-
+  Float_t       fPhiRotationAngle;             // Angle to rotate the inner layer cluster for combinatorial reco only 
+  //
+  Bool_t        fScaleDTBySin2T;               // use in distance definition
+  Float_t       fNStdDev;                      // number of standard deviations to keep
+  Float_t       fNStdDevSq;                    // sqrt of number of standard deviations to keep
+  //
   // cuts for secondaries identification
   Float_t       fCutPxDrSPDin;                 // max P*DR for primaries involving at least 1 SPD
   Float_t       fCutPxDrSPDout;                // max P*DR for primaries not involving any SPD
@@ -197,10 +249,65 @@ protected:
   TH1F*         fhetaClustersLay1;     // Pseudorapidity distr. for Clusters L. 1
   TH1F*         fhphiClustersLay1;     // Azimuthal (Phi) distr. for Clusters L. 1 
 
+  // temporary stuff for single event trackleting
+  Double_t      fDPhiShift;            // shift in dphi due to the curvature
+  Double_t      fDPhiWindow2;          // phi window^2
+  Double_t      fDThetaWindow2;        // theta window^2
+  Int_t*        fPartners;             //! L2 partners of L1
+  Int_t*        fAssociatedLay1;       //! association flag
+  Float_t*      fMinDists;             //! smallest distances for L2->L1
+  AliRefArray*  fBlackList;            //! blacklisted cluster references
+  Bool_t        fStoreRefs[2][2];      //! which cluster to track refs to store
+  //
+  // this is for the analysis mode only
+  TClonesArray  *fClArr[2];            //! original clusters
+  Bool_t        fCreateClustersCopy;   //  read and clone clusters directly from the tree
+  Bool_t        fClustersLoaded;       // flag of clusters loaded
+  Bool_t        fRecoDone;             // flag that reconstruction is done
+  Bool_t        fBuildRefs;            // build cluster to tracks references
+  Bool_t        fStoreSPD2SingleCl;    // do we store SPD2 singles
+  //
+  AliITSsegmentationSPD fSPDSeg;       // SPD segmentation model
+  //
+  void LoadClusterArrays(TTree* tree, TTree* treeMix=0);
+  void LoadClusterArrays(TTree* tree,int il);
 
-  void LoadClusterArrays(TTree* tree);
-
-  ClassDef(AliITSMultReconstructor,7)
+  ClassDef(AliITSMultReconstructor,11)
 };
 
+//____________________________________________________________________
+inline void AliITSMultReconstructor::ClusterPos2Angles(Float_t *clPar, const Float_t *vtx) const
+{
+  // convert cluster coordinates to angles wrt vertex
+  Float_t x = clPar[kClTh] - vtx[0];
+  Float_t y = clPar[kClPh] - vtx[1];
+  Float_t z = clPar[kClZ]  - vtx[2];
+  Float_t r    = TMath::Sqrt(x*x + y*y + z*z);
+  clPar[kClTh] = TMath::ACos(z/r);                   // Store Theta
+  clPar[kClPh] = TMath::Pi() + TMath::ATan2(-y,-x);  // Store Phi 
+  //
+}
+
+//____________________________________________________________________
+inline Double_t AliITSMultReconstructor::CalcDist(Double_t dphi, Double_t dtheta, Double_t theta) const
+{
+  // calculate eliptical distance. theta is the angle of cl1, dtheta = tht(cl1)-tht(cl2)
+  dphi = TMath::Abs(dphi) - fDPhiShift;
+  if (fScaleDTBySin2T) {
+    double sinTI = TMath::Sin(theta-dtheta/2);
+    sinTI *= sinTI;
+    dtheta /= sinTI>1.e-6 ? sinTI : 1.e-6;
+  }
+  return dphi*dphi/fDPhiWindow2 + dtheta*dtheta/fDThetaWindow2;
+}
+
+//____________________________________________________________________
+inline void AliITSMultReconstructor::CalcThetaPhi(float x, float y,float z,float &theta,float &phi) const
+{
+  // get theta and phi in tracklet convention
+  theta = TMath::ACos(z/TMath::Sqrt(x*x + y*y + z*z));
+  phi   = TMath::Pi() + TMath::ATan2(-y,-x);
+}
+
+
 #endif