| 1 | 
mocchiut | 
1.1 | 
/** | 
| 2 | 
  | 
  | 
 * \file TrkLevel2.h | 
| 3 | 
  | 
  | 
 * \author Elena Vannuccini | 
| 4 | 
  | 
  | 
 */ | 
| 5 | 
  | 
  | 
#ifndef trklevel2_h | 
| 6 | 
  | 
  | 
#define trklevel2_h | 
| 7 | 
  | 
  | 
 | 
| 8 | 
  | 
  | 
#include <TObject.h> | 
| 9 | 
  | 
  | 
#include <TObjArray.h> | 
| 10 | 
  | 
  | 
#include <TClonesArray.h> | 
| 11 | 
pam-fi | 
1.7 | 
#include <TRefArray.h> | 
| 12 | 
pam-fi | 
1.8 | 
#include <TRef.h> | 
| 13 | 
pam-fi | 
1.3 | 
 | 
| 14 | 
mocchiut | 
1.1 | 
#include <TrkStruct.h> | 
| 15 | 
pam-fi | 
1.8 | 
#include <TrkLevel1.h> | 
| 16 | 
mocchiut | 
1.1 | 
 | 
| 17 | 
pam-fi | 
1.2 | 
// z-coordinate of track state-vector reference-plane | 
| 18 | 
  | 
  | 
#define ZINI 23.5    | 
| 19 | 
  | 
  | 
// upper and lower (mechanical) z-coordinate of the tracker | 
| 20 | 
pam-fi | 
1.5 | 
//#define ZTRKUP 22.29 | 
| 21 | 
  | 
  | 
//#define ZTRKDW -22.22 | 
| 22 | 
  | 
  | 
// (mechanical) z-coordinate of the tracker planes | 
| 23 | 
  | 
  | 
#define ZTRK6 -22.23 | 
| 24 | 
  | 
  | 
#define ZTRK5 -13.32 | 
| 25 | 
  | 
  | 
#define ZTRK4 -4.42 | 
| 26 | 
  | 
  | 
#define ZTRK3 4.48 | 
| 27 | 
  | 
  | 
#define ZTRK2 13.38 | 
| 28 | 
  | 
  | 
#define ZTRK1 22.28 | 
| 29 | 
  | 
  | 
// (mechanical) x/y-coordinates of magnet cavity | 
| 30 | 
  | 
  | 
#define XTRKL -8.1 | 
| 31 | 
  | 
  | 
#define XTRKR  8.1 | 
| 32 | 
  | 
  | 
#define YTRKL -6.6 | 
| 33 | 
  | 
  | 
#define YTRKR  6.6 | 
| 34 | 
pam-fi | 
1.2 | 
 | 
| 35 | 
mocchiut | 
1.1 | 
/** | 
| 36 | 
  | 
  | 
 * \brief Class to describe, by points, a particle trajectory in the apparatus.  | 
| 37 | 
  | 
  | 
 * | 
| 38 | 
  | 
  | 
 * The idea is to create it by integrating the equations of motion, given the  | 
| 39 | 
  | 
  | 
 * track state vector and the z coordinates where to evaluate track position. | 
| 40 | 
  | 
  | 
 */ | 
| 41 | 
  | 
  | 
// ================================================================== | 
| 42 | 
  | 
  | 
class Trajectory : public TObject{ | 
| 43 | 
  | 
  | 
 private: | 
| 44 | 
  | 
  | 
 | 
| 45 | 
  | 
  | 
 public: | 
| 46 | 
  | 
  | 
 | 
| 47 | 
  | 
  | 
    int npoint; ///< number of evaluated points along the trajectory | 
| 48 | 
  | 
  | 
    float* x;   ///< x coordinates  | 
| 49 | 
  | 
  | 
    float* y;   ///< y coordinates  | 
| 50 | 
  | 
  | 
    float* z;   ///< z coordinates  | 
| 51 | 
pam-fi | 
1.2 | 
    float* thx; ///< x projected angle  | 
| 52 | 
  | 
  | 
    float* thy; ///< y projected angle | 
| 53 | 
  | 
  | 
    float* tl;  ///< track length | 
| 54 | 
mocchiut | 
1.1 | 
 | 
| 55 | 
pam-fi | 
1.2 | 
    Trajectory(); | 
| 56 | 
mocchiut | 
1.1 | 
    Trajectory(int n); | 
| 57 | 
  | 
  | 
    Trajectory(int n, float* pz); | 
| 58 | 
  | 
  | 
    void Dump(); | 
| 59 | 
  | 
  | 
 | 
| 60 | 
pam-fi | 
1.13 | 
    int DoTrack2(float* al); | 
| 61 | 
pam-fi | 
1.2 | 
    float GetLength(){float l=0; for(int i=0; i<npoint;i++)l=l+tl[i]; return l;}; | 
| 62 | 
  | 
  | 
    float GetLength(int,int); | 
| 63 | 
  | 
  | 
 | 
| 64 | 
pam-fi | 
1.9 | 
    ClassDef(Trajectory,2); | 
| 65 | 
mocchiut | 
1.1 | 
 | 
| 66 | 
  | 
  | 
}; | 
| 67 | 
  | 
  | 
/** | 
| 68 | 
  | 
  | 
 * \brief Class to describe fitted tracks.  | 
| 69 | 
  | 
  | 
 * | 
| 70 | 
  | 
  | 
 * A track is defined by the measured coordinates associated to it, the  | 
| 71 | 
  | 
  | 
 * track status vector, plus other quantities. | 
| 72 | 
  | 
  | 
 * A track may have an "image", due to the ambiguity in the y view. | 
| 73 | 
  | 
  | 
 */ | 
| 74 | 
  | 
  | 
// ================================================================== | 
| 75 | 
  | 
  | 
class TrkTrack : public TObject { | 
| 76 | 
  | 
  | 
 | 
| 77 | 
  | 
  | 
private: | 
| 78 | 
  | 
  | 
 | 
| 79 | 
pam-fi | 
1.3 | 
    int   seqno;           ///<stored track sequential number | 
| 80 | 
  | 
  | 
    int   image;           ///<sequential number of track-image | 
| 81 | 
  | 
  | 
 | 
| 82 | 
pam-fi | 
1.8 | 
         | 
| 83 | 
mocchiut | 
1.1 | 
public: | 
| 84 | 
  | 
  | 
 | 
| 85 | 
pam-fi | 
1.8 | 
//      TRef clx[6]; | 
| 86 | 
  | 
  | 
//      TRef cly[6]; | 
| 87 | 
pam-fi | 
1.12 | 
    TRefArray *clx; | 
| 88 | 
  | 
  | 
    TRefArray *cly; | 
| 89 | 
pam-fi | 
1.3 | 
 | 
| 90 | 
mocchiut | 
1.1 | 
    float al[5];           ///<TRACK STATE VECTOR  | 
| 91 | 
  | 
  | 
    float coval[5][5];     ///<covariance matrix  | 
| 92 | 
  | 
  | 
    int   xgood[6];        ///<mask of included x planes  | 
| 93 | 
  | 
  | 
    int   ygood[6];        ///<mask of included y planes  | 
| 94 | 
  | 
  | 
    float xm[6];           ///<measured x coordinates | 
| 95 | 
  | 
  | 
    float ym[6];           ///<measured y coordinates  | 
| 96 | 
  | 
  | 
    float zm[6];           ///<measured z coordinates  | 
| 97 | 
  | 
  | 
    float resx[6];         ///<spatial resolution on X view | 
| 98 | 
  | 
  | 
    float resy[6];         ///<spatial resolution on y view | 
| 99 | 
  | 
  | 
    float chi2;            ///<chi2 | 
| 100 | 
pam-fi | 
1.12 | 
    int   nstep;           ///<n. step | 
| 101 | 
  | 
  | 
    float xv[6];           ///<calculated x coordinates | 
| 102 | 
mocchiut | 
1.1 | 
    float yv[6];           ///<calculated y coordinates | 
| 103 | 
  | 
  | 
    float zv[6];           ///<calculated z coordinates | 
| 104 | 
  | 
  | 
    float axv[6];          ///<calculated angles (deg) on x view | 
| 105 | 
  | 
  | 
    float ayv[6];          ///<calculated angles (deg) on y view | 
| 106 | 
  | 
  | 
    float dedx_x[6];       ///<signal in MIP (scaled to 300 micrometer) | 
| 107 | 
  | 
  | 
    float dedx_y[6];       ///<signal in MIP (scaled to 300 micrometer) | 
| 108 | 
pam-fi | 
1.3 | 
 | 
| 109 | 
mocchiut | 
1.1 | 
 | 
| 110 | 
  | 
  | 
    TrkTrack(); | 
| 111 | 
  | 
  | 
    TrkTrack(const TrkTrack&); | 
| 112 | 
  | 
  | 
 | 
| 113 | 
pam-fi | 
1.12 | 
    ~TrkTrack(){Delete();}; | 
| 114 | 
pam-fi | 
1.10 | 
         | 
| 115 | 
mocchiut | 
1.1 | 
    void Dump(); | 
| 116 | 
pam-fi | 
1.12 | 
    void Clear(); | 
| 117 | 
  | 
  | 
    void Delete(); | 
| 118 | 
pam-fi | 
1.9 | 
         | 
| 119 | 
pam-fi | 
1.3 | 
    Int_t  GetSeqNo(){return seqno;}        ///< Returns the track sequential number | 
| 120 | 
  | 
  | 
    Int_t  GetImageSeqNo(){return image;}   ///< Returns the track image sequential number | 
| 121 | 
mocchiut | 
1.1 | 
    Bool_t HasImage(){return !(image==-1);} ///< Returns true if the track has an image | 
| 122 | 
pam-fi | 
1.2 | 
    int DoTrack(Trajectory* t);                         ///< Evaluates the trajectory in the apparatus. | 
| 123 | 
  | 
  | 
    int DoTrack2(Trajectory* t);                        ///< Evaluates the trajectory in the apparatus. | 
| 124 | 
  | 
  | 
    float BdL(){return 0;};                                     ///< Evaluates the integral of B*dL along the track. | 
| 125 | 
mocchiut | 
1.1 | 
    Int_t GetNX(){Int_t n=0; for(Int_t i=0; i<6; i++)n+=xgood[i]; return n;};  | 
| 126 | 
  | 
  | 
    Int_t GetNY(){Int_t n=0; for(Int_t i=0; i<6; i++)n+=ygood[i]; return n;}; | 
| 127 | 
pam-fi | 
1.3 | 
    Int_t GetNtot(){return GetNX()+GetNY();}; | 
| 128 | 
mocchiut | 
1.1 | 
    Float_t GetRigidity(); | 
| 129 | 
  | 
  | 
    Float_t GetDeflection(); | 
| 130 | 
  | 
  | 
    Float_t GetDEDX(); | 
| 131 | 
pam-fi | 
1.12 | 
    Float_t GetDEDX(Int_t ip){if( !(xgood[ip]+ygood[ip]) ) return 0; return (dedx_x[ip]+dedx_y[ip])/(xgood[ip]+ygood[ip]);}; | 
| 132 | 
  | 
  | 
    // sono un'imbecille... assegno xm e ym anche quando si tratta di un singolo | 
| 133 | 
  | 
  | 
    // non posso quindi usare xm e ym per dire se una vista e` inclusa nel fit o no | 
| 134 | 
pam-fi | 
1.9 | 
/*      Bool_t XGood(int ip){ return xm[ip] != -100.;}; | 
| 135 | 
  | 
  | 
        Bool_t YGood(int ip){ return ym[ip] != -100.;};*/ | 
| 136 | 
pam-fi | 
1.12 | 
    Bool_t XGood(int ip){ return xgood[ip]==1;}; | 
| 137 | 
  | 
  | 
    Bool_t YGood(int ip){ return ygood[ip]==1;}; | 
| 138 | 
  | 
  | 
 | 
| 139 | 
  | 
  | 
    void SetMeasure(double *xmeas, double *ymeas, double *zmeas); | 
| 140 | 
  | 
  | 
    void SetResolution(double *rx, double *ry); | 
| 141 | 
  | 
  | 
    void SetGood(int *xg, int *yg); | 
| 142 | 
  | 
  | 
    void LoadField(TString s); | 
| 143 | 
  | 
  | 
    void Fit(double pfixed, int& fail, int iprint); | 
| 144 | 
  | 
  | 
    void FitReset(); | 
| 145 | 
pam-fi | 
1.14 | 
 | 
| 146 | 
  | 
  | 
    void FillMiniStruct(cMini2track&); | 
| 147 | 
  | 
  | 
    void SetFromMiniStruct(cMini2track*); | 
| 148 | 
pam-fi | 
1.12 | 
     | 
| 149 | 
  | 
  | 
    TrkCluster *GetClusterX(int ip){TrkCluster *pt = (TrkCluster*)(clx->At(ip)); return pt;}; | 
| 150 | 
  | 
  | 
    TrkCluster *GetClusterY(int ip){TrkCluster *pt = (TrkCluster*)(cly->At(ip)); return pt;}; | 
| 151 | 
  | 
  | 
     | 
| 152 | 
mocchiut | 
1.1 | 
    TrkTrack* GetTrkTrack(){return this;}; | 
| 153 | 
  | 
  | 
 | 
| 154 | 
pam-fi | 
1.3 | 
    friend class TrkLevel2; | 
| 155 | 
  | 
  | 
 | 
| 156 | 
pam-fi | 
1.9 | 
    ClassDef(TrkTrack,2); | 
| 157 | 
mocchiut | 
1.1 | 
 | 
| 158 | 
  | 
  | 
}; | 
| 159 | 
  | 
  | 
/** | 
| 160 | 
  | 
  | 
 * \brief Class to describe single clusters ("singlets").  | 
| 161 | 
  | 
  | 
 * | 
| 162 | 
  | 
  | 
 * Single clusters are clusters not associated to any track. | 
| 163 | 
  | 
  | 
 */ | 
| 164 | 
  | 
  | 
class TrkSinglet : public TObject { | 
| 165 | 
  | 
  | 
 | 
| 166 | 
  | 
  | 
private: | 
| 167 | 
pam-fi | 
1.8 | 
         | 
| 168 | 
mocchiut | 
1.1 | 
 | 
| 169 | 
  | 
  | 
public: | 
| 170 | 
pam-fi | 
1.8 | 
         | 
| 171 | 
  | 
  | 
        TRef cls; | 
| 172 | 
mocchiut | 
1.1 | 
 | 
| 173 | 
  | 
  | 
    int plane;       ///<plane  | 
| 174 | 
  | 
  | 
    float coord[2];  ///<coordinate (on sensor 1 and 2) | 
| 175 | 
  | 
  | 
    float sgnl;      ///<cluster signal in MIP  | 
| 176 | 
  | 
  | 
 | 
| 177 | 
  | 
  | 
    TrkSinglet(); | 
| 178 | 
  | 
  | 
    TrkSinglet(const TrkSinglet&); | 
| 179 | 
  | 
  | 
 | 
| 180 | 
  | 
  | 
    void Dump(); | 
| 181 | 
pam-fi | 
1.8 | 
         | 
| 182 | 
pam-fi | 
1.11 | 
    TrkCluster *GetCluster(){TrkCluster *pt = (TrkCluster*)cls.GetObject(); return pt;}; | 
| 183 | 
mocchiut | 
1.1 | 
 | 
| 184 | 
pam-fi | 
1.3 | 
    friend class TrkLevel2; | 
| 185 | 
  | 
  | 
 | 
| 186 | 
pam-fi | 
1.9 | 
    ClassDef(TrkSinglet,2); | 
| 187 | 
mocchiut | 
1.1 | 
 | 
| 188 | 
  | 
  | 
}; | 
| 189 | 
  | 
  | 
 | 
| 190 | 
  | 
  | 
/** | 
| 191 | 
  | 
  | 
 * \brief Class to describe tracker LEVEL2 data. | 
| 192 | 
  | 
  | 
 * | 
| 193 | 
  | 
  | 
 * A tracker events is defined by some general variables, plus the collection of all the fitted tracks and all  | 
| 194 | 
  | 
  | 
 * single clusters on X and Y views.  | 
| 195 | 
  | 
  | 
 * Tracks and single clusters ("singlets") are described by the classes TrkTrack and TrkSinglet respectivelly. | 
| 196 | 
  | 
  | 
 *  | 
| 197 | 
  | 
  | 
 * Each track may have an "image", due to the ambiguity on the Y view, which is stored also.  | 
| 198 | 
  | 
  | 
 * Thus, the number of stored tracks ( ntrk() ) differs from the number of "physical" tracks ( GetNTracks() ).  | 
| 199 | 
  | 
  | 
 * Proper methods allow to sort tracks and select the physical ones ( GetTracks() ). | 
| 200 | 
  | 
  | 
 */ | 
| 201 | 
  | 
  | 
class TrkLevel2 : public TObject { | 
| 202 | 
  | 
  | 
 | 
| 203 | 
  | 
  | 
 private: | 
| 204 | 
pam-fi | 
1.5 | 
         | 
| 205 | 
  | 
  | 
//      TRefArray    *PhysicalTrack;  ///< physical tracks (no image) -  | 
| 206 | 
  | 
  | 
          | 
| 207 | 
mocchiut | 
1.1 | 
 public: | 
| 208 | 
  | 
  | 
 | 
| 209 | 
pam-fi | 
1.9 | 
        Int_t         good[12];       ///< event status | 
| 210 | 
  | 
  | 
//      Int_t good2; | 
| 211 | 
  | 
  | 
//    Int_t crc[12]; | 
| 212 | 
mocchiut | 
1.1 | 
 | 
| 213 | 
  | 
  | 
    TClonesArray *Track;        ///< fitted tracks | 
| 214 | 
  | 
  | 
    TClonesArray *SingletX;     ///< x singlets | 
| 215 | 
  | 
  | 
    TClonesArray *SingletY;     ///< y singlets | 
| 216 | 
  | 
  | 
 | 
| 217 | 
  | 
  | 
    TrkLevel2(); | 
| 218 | 
  | 
  | 
//    TrkLevel2(cTrkLevel2 *); | 
| 219 | 
pam-fi | 
1.11 | 
    ~TrkLevel2(){Delete();}; | 
| 220 | 
pam-fi | 
1.10 | 
         | 
| 221 | 
pam-fi | 
1.11 | 
    void Clear(); | 
| 222 | 
  | 
  | 
    void Delete(); | 
| 223 | 
  | 
  | 
     | 
| 224 | 
  | 
  | 
    int ntrk() {return Track->GetEntries();}    ///< number of stored track | 
| 225 | 
mocchiut | 
1.1 | 
    int nclsx(){return SingletX->GetEntries();} ///< number of x singlets  | 
| 226 | 
  | 
  | 
    int nclsy(){return SingletY->GetEntries();} ///< number of y singlets  | 
| 227 | 
  | 
  | 
 | 
| 228 | 
  | 
  | 
    void Dump(); | 
| 229 | 
pam-fi | 
1.6 | 
    void SetFromLevel2Struct(cTrkLevel2 *); | 
| 230 | 
pam-fi | 
1.11 | 
    void SetFromLevel2Struct(cTrkLevel2 *, TrkLevel1 *); | 
| 231 | 
  | 
  | 
    void GetLevel2Struct(cTrkLevel2 *) const; | 
| 232 | 
pam-fi | 
1.3 | 
    void LoadField(TString); | 
| 233 | 
pam-fi | 
1.6 | 
    Float_t GetZTrk(Int_t); | 
| 234 | 
  | 
  | 
    Float_t GetXTrkLeft(){return XTRKL;}; | 
| 235 | 
  | 
  | 
    Float_t GetXTrkRight(){return XTRKR;}; | 
| 236 | 
  | 
  | 
    Float_t GetYTrkLeft(){return YTRKL;}; | 
| 237 | 
  | 
  | 
    Float_t GetYTrkRight(){return YTRKR;}; | 
| 238 | 
  | 
  | 
     | 
| 239 | 
  | 
  | 
    TrkSinglet   *GetSingletX(int); | 
| 240 | 
  | 
  | 
    TrkSinglet   *GetSingletY(int); | 
| 241 | 
  | 
  | 
     | 
| 242 | 
  | 
  | 
    TrkTrack     *GetStoredTrack(int i); | 
| 243 | 
pam-fi | 
1.3 | 
    Int_t         GetSeqNo(Int_t i)  {return (((TrkTrack *)Track->At(i))->seqno);}; ///< Returns track sequential number | 
| 244 | 
pam-fi | 
1.5 | 
//    TClonesArray *GetTracks_Chi2Sorted(); | 
| 245 | 
pam-fi | 
1.7 | 
//    TClonesArray *GetTracks_NFitSorted(); | 
| 246 | 
  | 
  | 
//    TClonesArray *GetTracks(); | 
| 247 | 
pam-fi | 
1.11 | 
    TRefArray *GetTracks_NFitSorted(); | 
| 248 | 
  | 
  | 
    TRefArray *GetTracks(){return this->GetTracks_NFitSorted();}; | 
| 249 | 
  | 
  | 
     | 
| 250 | 
pam-fi | 
1.4 | 
//    int       GetNTracks(){return this->GetTracks()->GetEntries();} | 
| 251 | 
pam-fi | 
1.11 | 
    Int_t     GetNTracks(); | 
| 252 | 
  | 
  | 
    TrkTrack* GetTrack(int i); | 
| 253 | 
mocchiut | 
1.1 | 
    TrkTrack* GetTrackImage(int i); | 
| 254 | 
pam-fi | 
1.11 | 
     | 
| 255 | 
pam-fi | 
1.3 | 
    TrkLevel2*    GetTrkLevel2(){return this;} | 
| 256 | 
  | 
  | 
    TClonesArray* GetTrackArray(){return Track;};///< returns pointer to the track array | 
| 257 | 
  | 
  | 
     | 
| 258 | 
pam-fi | 
1.9 | 
    ClassDef(TrkLevel2,2); | 
| 259 | 
mocchiut | 
1.1 | 
 | 
| 260 | 
  | 
  | 
}; | 
| 261 | 
  | 
  | 
 | 
| 262 | 
  | 
  | 
#endif |