/[PAMELA software]/DarthVader/ToFLevel2/inc/ToFLevel2.h
ViewVC logotype

Diff of /DarthVader/ToFLevel2/inc/ToFLevel2.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by pam-fi, Thu Jan 11 09:34:27 2007 UTC revision 1.27 by mocchiut, Mon Oct 25 13:22:10 2010 UTC
# Line 1  Line 1 
1    /**
2     * \file ToFLevel2.h
3     * \author Gianfranca DeRosa / Wolfgang Menn / Rita Carbone with E. M. supervision
4     */
5    
6  #ifndef ToFLevel2_h  #ifndef ToFLevel2_h
7  #define ToFLevel2_h  #define ToFLevel2_h
8  //  //
# Line 6  Line 11 
11  #include <TArrayF.h>  #include <TArrayF.h>
12  #include <TClonesArray.h>  #include <TClonesArray.h>
13    
14    #include <math.h> // EMILIANO
15    #include <iostream> // from ToFLevel2.cpp
16    #include <fstream> // Emiliano
17    #include <sstream> // Emiliano
18    #include <string> // Emiliano
19    
20    
21  #include <ToFStruct.h>  #include <ToFStruct.h>
22    
23    #include <TrkLevel2.h> // Emiliano
24    #include <TrigLevel2.h> // Emiliano
25    #include <GLTables.h> // Emiliano
26    #include <OrbitalInfo.h> // Emiliano
27    #include <ToFCore.h> // Emiliano
28    #include <physics/tof/TofEvent.h>
29    
30    //
31    // Declaration of the core fortran routines
32    //
33    #define tofl2com tofl2com_
34    extern "C" int tofl2com();
35    #define toftrk toftrk_
36    extern "C" int toftrk();
37    #define rdtofcal rdtofcal_
38    extern "C" int rdtofcal(char [], int *);
39    
40  //  //
41  // class which contains track related variables  // class which contains track related variables
42  //  //
# Line 18  Line 48 
48  #define ZTOF32 -24.34  #define ZTOF32 -24.34
49    
50    
51    class ToFGeom : public TObject {
52    
53    private:
54      TArrayI  ePlane, eXY;
55    
56    public:
57      ToFGeom() {
58        int plane[24] = {
59          0, 0, 0, 0, 0, 0, 0, 0,
60          1, 1, 1, 1, 1, 1,
61          2, 2,            
62          3, 3,            
63          4, 4, 4,
64          5, 5, 5
65        };
66        int plXY[6]= {  2,  1,  1,  2,  2,  1 }; // X==1, Y==2 */
67        ePlane.Set(24,plane);
68        eXY.Set(6,plXY);
69      }
70    
71      int GetPad(   int idpmt)  { return (int)((idpmt+0.5)/2.); }
72      int GetPlane( int idpmt)  { return ePlane[ GetPad(idpmt) ];  }
73      int GetXY(    int idpmt)  { return eXY[ GetPlane(idpmt) ]; }
74    
75       ClassDef(ToFGeom,1);
76    
77    };
78    
79    
80    /**
81     * \brief  Class which contains the PMT data
82     *
83     * If there is a valid ADC or a TDC value (value<4095) for a PMT, both ADC and TDC data
84     * are stored in the PMT class.
85     * Look in the ToFLevel2Ex.cxx example in the repository how to read the PMT class.
86     */
87  class ToFPMT : public TObject {  class ToFPMT : public TObject {
88      
89   private:   private:
90    
91   public:   public:
92      Int_t pmt_id;      Int_t pmt_id;     ///<the identification number of the PMT from 0 to 47
93      Float_t adc;      Float_t adc;      ///<raw ADC value for this PMT
94      Float_t tdc_tw;      Float_t tdc;      ///<raw TDC value for this PMT
95        Float_t tdc_tw;   ///<time-walk corrected TDC value for this PMT
96      //      //
97      ToFPMT();      ToFPMT();
98      ToFPMT(const ToFPMT&);      ToFPMT(const ToFPMT&);
99      //      //
100      ToFPMT* GetToFPMT(){return this;};      ToFPMT* GetToFPMT(){return this;};
101      void Clear();      void Clear(Option_t *t="");
102    
103        ClassDef(ToFPMT,2);
104    };
105    
106    /**
107     * \brief  Class used to calibrate adc to dEdx for each PMT
108     *
109     * Class used to calibrate adc to dEdx for each PMT
110     */
111    class ToFdEdx : public TObject {
112    
113     private:
114        //
115        ToFGeom  eGeom;  // ToF geometry
116        //
117        Float_t  adc_he;
118        TArrayF eDEDXpmt;  // 0-47  pmt dEdx
119        // parameters:
120        TArrayF PMTsat;  // 0-47  saturation parameters
121        Float_t adc[48];
122        //
123    
124        TArrayF parAtt[48];      // 48 x 6
125        TArrayF parPos[48];      // 48 x 4
126        TArrayF parDesatBB[48];  // 48 x 3
127        TArrayF parBBneg[48];    // 48 x 3
128        TArrayF  parBBpos;    // 48 x 1
129    
130        double f_adcPC( float x );
131        double f_BB( TArrayF &p, float x );
132        double f_BB5B( float x );
133        double f_att( TArrayF &p, float x ) ;
134        double f_att5B( float x );
135        double f_desatBB( TArrayF &p, float x );  
136        double f_desatBB5B( float x );
137        double f_pos( TArrayF &p, float x );
138        double f_pos5B( float x );
139        float Get_adc_he( int id, float pl_x[6], float pl_y[6]);
140    
141        Bool_t conn[12];
142    
143        UInt_t ts[12];
144        UInt_t te[12];    
145      
146            
147     public:
148        ToFdEdx();   // class constructor
149        ~ToFdEdx(){ Delete(); };  // class distructor
150        //
151        void Clear(Option_t *option="");
152        void Delete(Option_t *option="") { Clear(); }
153    
154        void Init(pamela::tof::TofEvent *tofl0 );  // init parameters
155        void Init(Int_t i, Int_t j, Float_t adce);
156        void Define_PMTsat();
157    
158        void ReadParAtt(            const char *fname  );
159        void ReadParPos(            const char *fname  );
160        void ReadParBBneg(          const char *fname  );
161        void ReadParBBpos(          const char *fname  );
162        void ReadParDesatBB(        const char *fname  );
163    
164        void CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc);
165    
166        void Process( UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, Int_t exitat=-1); //
167        void Print(Option_t *option="");
168    
169      ClassDef(ToFPMT,1);      Float_t GetdEdx_pmt(Int_t ipmt) { return eDEDXpmt[ipmt]; }  // 0-47 dEdx for each PMT for tracked events
170        //    Float_t GetdEdx_pmt(Int_t ipmt) { return eDEDXpmt.At(ipmt); }  // 0-47 dEdx for each PMT for tracked events
171        //
172        ToFdEdx* GetToFdEdx(){return this;};
173        ClassDef(ToFdEdx,3);
174  };  };
175    
176    
177    /**
178     * \brief Class which contains the tracker related variables
179     *
180     * We can use the ToF standalone to find hitted paddles, calculate beta, etc..
181     * These results are then stored with the "trkseqno" = -1.
182     * If we use the track from the tracker, then the penetration points in the
183     * scintillators are calculated, which defines the hitted paddles. For these paddles
184     * we calculate then all the output.
185     * Note: The artificial ADC values are stored as dEdx in the output, the dEdx will be
186     * by definition = 1. However, the artificial TDC values are just used internally
187     * and not stored in the output. But one can see in both cases which PMT has artificial
188     * values using "adcflag" and "tdcflag".
189     * Look in the ToFLevel2Ex.cxx example in the repository how to read the tracker related
190     * variables.
191     */
192  class ToFTrkVar : public TObject {  class ToFTrkVar : public TObject {
193      
194   private:   private:
195    
196   public:   public:
     //  
   Int_t trkseqno; // tracker entry coming from tracker, 100 if image track is used, -100 if the track is not consistent with MyDetector2 one  
197    //    //
198    Int_t npmttdc;    Int_t trkseqno; ///< tracker sequ. number: -1=ToF standalone, 0=first Tracker track, ...
   TArrayI pmttdc;  
   TArrayI tdcflag; // gf: 30 Nov 2006  
   Float_t beta[13];  
   //  
   Int_t npmtadc;  
   TArrayI pmtadc;  
   TArrayI adcflag; // gf: 30 Nov 2006      
   TArrayF dedx;    
199    //    //
200    Float_t xtofpos[3];    Int_t npmttdc;  ///<number of the TDC measurements used to evaluate beta
201    Float_t ytofpos[3];    TArrayI pmttdc;  ///<contains the ID (0..47) for the PMT used to evaluate beta
202      TArrayI tdcflag; ///<flag for artificial TDC, "0" if normal TDC value
203    
204    /**
205     * \brief beta, 12 measurements for the 12  combinations, beta[13] is modified weighted mean
206     *
207     * The 12 measurements are S11-S31, S11-S32, S12-S31, S12-S32, and then analogue for
208     * S2-S3 and S1-S2.
209     * The calculation of beta[13] is now modified:
210     * We check the individual weights for artificial TDC values, then calculate
211     * am mean beta for the first time. In a second step we loop again through
212     * the single measurements, checking for the residual from the mean
213     * The cut on the residual reject measurements > "x"-sigma. A chi2 value is
214     * calculated, furthermore a "quality" value by adding the weights which
215     * are finally used. If all measurements are taken, "quality" will be = 505.
216     * A chi2 cut around 3-4 and a quality-cut > 400 is needed for clean beta
217     * The Level2 beta[12] which is derived in the fortran routines uses: 10.,200.,20.
218     * This is not a very high quality measurement. One can re-calculate a new beta[13]
219     * using the L2-method "CalcBeta"
220     */
221      Float_t beta[13];
222      //
223      Int_t npmtadc;  ///<number of the ADC measurements used for dEdx evaluation
224      TArrayI pmtadc; ///<contains the ID (0..47) for the PMT used to evaluate dEdx
225      TArrayI adcflag; ///<flag for artificial ADCs, "0" if normal ADC value
226      TArrayF dedx;    ///<energy loss for this PMT in mip
227      //
228      Float_t xtofpos[3];  ///<x-measurement using the TDC values and the calibration from S12, S21, S32
229      Float_t ytofpos[3];  ///<x-measurement using the TDC values and the calibration from S11, S22, S31
230      //
231      Float_t xtr_tof[6];  ///<x-measurement in the ToF layers from tracker
232      Float_t ytr_tof[6];  ///<x-measurement in the ToF layers from tracker
233    //    //
234    ToFTrkVar();    ToFTrkVar();
235    ToFTrkVar(const ToFTrkVar&);    ToFTrkVar(const ToFTrkVar&);
236      
237    ToFTrkVar* GetToFTrkVar(){return this;};    ToFTrkVar* GetToFTrkVar(){return this;};
238    void Clear();    void Clear(Option_t *t="");
239    
240    ClassDef(ToFTrkVar,1);    ClassDef(ToFTrkVar,1);
241    //    //
242  };  };
243    
244    /**
245     * \brief  Class to describe ToF LEVEL2 data
246     *
247     */
248    
249  class ToFLevel2 : public TObject {  class ToFLevel2 : public TObject {
250   private:   private:
251      
252   public:   public:
253    //    //
254    TClonesArray *PMT; // class needed to store PMT hit informations    TClonesArray *PMT; ///<class needed to store PMT hit informations
255    TClonesArray *ToFTrk; // track related variable class    TClonesArray *ToFTrk; ///<track related variable class
256    Int_t tof_j_flag[6];    Int_t tof_j_flag[6];  ///<number of hitted paddle(s) for each ToF layer: flag = flag + 2**(paddlenumber-1)
257    Int_t unpackError;    //
258      Int_t unpackError;///< zero if no error presente
259      Int_t default_calib; ///< one if the default calibration has been used to process the data, zero otherwise
260      //
261      Float_t GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl); // gf Apr 07
262    
263      Float_t CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut);  //  wm feb 08
264    
265    //    //
266    Float_t GetdEdx(Int_t notrack, Int_t plane);  //  Float_t CalcBeta(Int_t notrack, Float_t resmax, Float_t chi2cut, Float_t qualitycut);   // wm feb 08
267    //    //
268    // methods to make life simplier during the analysis, returns a pointer to the ToFTrkVar class containing track related variables    // methods to make life simplier during the analysis, returns a pointer to the ToFTrkVar class containing track related variables
269    //    //
270    Int_t ntrk(){return ToFTrk->GetEntries();};    Int_t ntrk(){return ToFTrk->GetEntries();};
271    Int_t npmt(){return PMT->GetEntries();};    Int_t npmt(){return PMT->GetEntries();};
272        
273    //    //
274    void GetLevel2Struct(cToFLevel2 *) const;    void GetLevel2Struct(cToFLevel2 *) const;
275    //    //
276    ToFTrkVar *GetToFTrkVar(Int_t notrack);      ToFTrkVar *GetToFTrkVar(Int_t notrack);
277    ToFPMT *GetToFPMT(Int_t nohit);      ToFPMT *GetToFPMT(Int_t nohit);
278    Int_t GetPMTid(Int_t gg, Int_t hh);    Int_t GetPMTid(Int_t gg, Int_t hh);
279    TString GetPMTName(Int_t ind);    TString GetPMTName(Int_t ind);
280      
281    Int_t GetPlaneIndex(Int_t pmt_id);    Int_t GetPlaneIndex(Int_t pmt_id);
282    void GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]);    void GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]);
283    void GetPMTIndex(Int_t pmt_id, Int_t &gg, Int_t &hh);    void GetPMTIndex(Int_t pmt_id, Int_t &gg, Int_t &hh);
284    
285      // gf Apr 07
286      void GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning); // gf Apr 07
287      TString GetPMTName(Int_t ind, Int_t &iplane, Int_t &ipaddle,Int_t &ipmt);
288      Int_t GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane); // gf Apr 07
289      Int_t GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin); // wm jun 2008
290      void GetPMTPaddle(Int_t pmt_id, Int_t &plane, Int_t &paddle); // gf Apr 07
291      void GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright); // gf Apr 07
292      void GetPaddleGeometry(Int_t plane, Int_t paddle, Float_t &xleft, Float_t &xright, Float_t &yleft, Float_t &yright); // gf Apr 07
293      Int_t GetPaddleid(Int_t plane, Int_t paddle);
294      void GetPaddlePlane(Int_t padid, Int_t &plane, Int_t &paddle);
295      Int_t GetNPaddle(Int_t plane);
296      //
297      //
298      //
299      Int_t Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force); // Emiliano
300      
301    //    //
302    // constructor    // constructor
303    //    //
304    ToFLevel2();    ToFLevel2();
305    ~ToFLevel2(){Delete();}; //ELENA    ~ToFLevel2(){Delete();}; //ELENA
306    void Delete(); //ELENA    void Delete(Option_t *t=""); //ELENA
307      void Set();//ELENA
308    //    //
309    //    //
310    ToFLevel2*   GetToFLevel2(){return this;};    ToFLevel2*   GetToFLevel2(){return this;};
311    
312    /**
313     * Method to get the z-position of the 6 TOF layers from the plane ID
314     * @param plane_id Plane ID (11 12 21 22 31 32)
315     */
316    Float_t      GetZTOF(Int_t plane_id){    Float_t      GetZTOF(Int_t plane_id){
317        switch(plane_id){        switch(plane_id){
318        case 11: return ZTOF11;        case 11: return ZTOF11;
# Line 117  class ToFLevel2 : public TObject { Line 324  class ToFLevel2 : public TObject {
324        default: return 0.;        default: return 0.;
325        };        };
326    };    };
327      
328      //      //
329      // Paddles position      // Paddles position
330      //      //
# Line 129  class ToFLevel2 : public TObject { Line 336  class ToFLevel2 : public TObject {
336        S31 3 paddles  15.0 x 6.0 cm        S31 3 paddles  15.0 x 6.0 cm
337        S32 3 paddles  18.0 x 5.0 cm        S32 3 paddles  18.0 x 5.0 cm
338      */      */
339        
340      Int_t  GetToFPlaneID(Int_t ip);      Int_t  GetToFPlaneID(Int_t ip);
341      Int_t  GetToFPlaneIndex(Int_t plane_id);      Int_t  GetToFPlaneIndex(Int_t plane_id);
342      Bool_t HitPaddle(Int_t ,Int_t);      Bool_t HitPaddle(Int_t ,Int_t);
343      Int_t  GetNHitPaddles(Int_t plane);      Int_t  GetNHitPaddles(Int_t plane);
344      void Clear();      void Clear(Option_t *t="");
345      //      //
346      ClassDef(ToFLevel2,2);      ClassDef(ToFLevel2,4);
347  };  };
348    
349  #endif  #endif
350    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.23