/[PAMELA software]/DarthVader/TrackerLevel2/inc/ExtTrkingAlg.h
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/inc/ExtTrkingAlg.h

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

revision 1.1 by pam-fi, Thu Feb 27 11:24:42 2014 UTC revision 1.4 by pam-ts, Wed Oct 15 08:45:51 2014 UTC
# Line 14  Line 14 
14  #include <CaloLevel1.h>  #include <CaloLevel1.h>
15  #include <CaloLevel2.h>  #include <CaloLevel2.h>
16    
17  //#include <ExtTrack.h>  #include <ExtTrack.h>
18    
19  // ROOT classes  // ROOT classes
20  #include <TClonesArray.h>  #include <TClonesArray.h>
# Line 26  Line 26 
26  #include <iostream>  #include <iostream>
27  #include <iomanip>  #include <iomanip>
28    
29    
30    #define nCP 22;
31    #define nCV 2;
32    #define nCS 9;
33    
34     //         relative to pamela reference system (convenzione emiliano):
35     //
36     //        y ^
37     //          |
38     //          | 6 7 8 sisensor
39     //          | 3 4 5  
40     //          | 0 1 2
41     //          ------------> x
42     //
43     //        relative to silicon sensor          
44     //
45     //        S ^
46     //          |   |
47     //        2 |   |  <- strip direction
48     // sensor 1 |   |
49     //        0 |...|...
50     //          ------------> L
51     //            0 1 2
52     //            ladder
53     //
54     //
55    
56    int GetCaloSensor(int view, int sis){
57        if(sis<0||sis>8)return -1;
58        if(view<0||view>1)return -1;
59        if(!view)return (int)(sis/3);
60        else return sis%3;
61    };
62    int GetCaloLadder(int view, int sis){
63        if(sis<0||sis>8)return -1;
64        if(view<0||view>1)return -1;
65        if(!view)return sis%3;  
66        else return (int)(sis/3);
67    };
68    int GetCaloLadder(int strip){
69        return (int)(strip/32);
70    };
71    int GetCaloSiSensor(int view, int l, int s){
72        if(view<0||view>1)return -1;
73        if(s<0||s>2)return -1;
74        if(!view) return 3*s+l;
75        else      return 3*l+s;
76    };
77    
78    /**
79     *
80     * Extended CaloStrip class, to account for rototraslation parameters
81     *
82     */
83    class CaloStripRoto  {
84    
85     private:
86    
87      float fPitch; // = 1.;
88      float shift[3]; //= {0.,0.,0.};//(L,S,Z)
89      float alpha;//  = 0.;
90    
91      int   siSensor; // 0-8
92      int sView;//0-1
93      int sPlane;//0-21
94      CaloStrip st;
95      
96      void Set(int view, int plane, float strip, int sisensor); ///< Set strip giving view [0-1], plane [0-22] and number [0-95]
97      void SetSiSensor( int si=-1  ){ siSensor = si;};
98      void SetView(int view){sView = view;};
99      void SetPlane(int plane){sPlane = plane;};
100    
101     public:
102    
103    /*   CaloStrip st; */
104    
105    
106      float fXA; //< X position in cm of the strip
107      float fYA; //< Y position in cm of the strip
108      float fZA; //< Z position in cm of the strip
109    
110      float fXB; //< X position in cm of the strip
111      float fYB; //< Y position in cm of the strip
112      float fZB; //< Z position in cm of the strip
113      
114      //
115      CaloStripRoto(int view, int plane, int sisensor, bool usemechanicalalignement = true); ///< Default Constructor.
116    
117    
118    
119      void ResetAligParams();
120      void SetAligParams__fPitch( float f ){ fPitch = f; };
121      void SetAligParams__shift( float *s ){ for(int i=0; i<3; i++)shift[i]=s[i]; };
122      void SetAligParams__alpha( float a ){ alpha = a; };
123    
124      void SetStrip(float strip){Set(GetView(),GetPlane(),strip,GetSiSensor());}; ///< Set strip giving view [0-1], plane [0-22] and number [0-95]
125    
126    
127    
128    /*   int GetSensor(int view, int sisensor); */
129    /*   int GetLadder(int view, int sisensor); */
130    /*   int GetSiSensor(int view, int ladder, int sensor); */
131      //  CaloStrip GetCaloStrip(){return st;};
132      bool SensorContains(float x, float y);
133      
134      int GetView(){return sView;};
135      int GetPlane(){return sPlane;};
136      int GetStrip(){return st.GetStrip();};
137      int GetSensor();
138      int GetLadder();
139      int GetSiSensor(){ return siSensor; };
140      
141      float GetSpatialResolution(float def, float degx=0., float degy=0.,  float beta=1.);
142    
143      float GetDistanceTo(float xP, float yP, float& xM, float &yM);
144      float GetDistanceTo(float xP, float yP){ float xM,yM; return GetDistanceTo(xP,yP,xM,yM); };
145    
146    };
147    
148    
149    /**
150     *
151     * Extended hit class
152     *
153     */
154    
155    
156    class ExtHit{
157    
158     private:
159    
160    
161     public:
162    
163    
164      Float_t coordCm; //centimeters
165      Float_t coordPU; //pitch units
166      Float_t resCm;
167      Float_t signal;
168      Int_t start;
169      Int_t mult;
170      Int_t view;
171    
172      
173      void Reset(){    
174        coordCm = 1000.;
175        coordPU = 1000.;
176        resCm   = 1000.;
177        signal  = 0.;
178        start   = -1;
179        mult    = 0;
180        view    = -1;
181      };
182      void Set(int s, int v){start=s; view=v;}  
183      /* void Set(int s, int v){coordPU=s; view=v;}   */
184    
185      ExtHit(){Reset();};
186      ExtHit(int s, int v){Reset(); Set(s,v); };
187      ~ExtHit(){Reset();};
188    
189      ExtHit( const ExtHit& h ){
190        coordCm = h.coordCm;
191        coordPU = h.coordPU;
192        resCm   = h.resCm;
193        signal  = h.signal;
194         start   = h.start;
195        mult    = h.mult;
196        view    = h.view;
197      }
198    
199      void Add(float cc, float pp, float ss){
200        if(ss<0)cout << "void ExtHit(cc="<<cc<<",ss="<<ss<<") -- not valid argument";
201        if(ss<0)return;
202        mult++;
203        float sumcc =  coordCm * signal;
204        float sumpp =  coordPU * signal;
205        signal+=ss;
206        sumcc += ss * cc;
207        sumpp += ss * pp;
208        coordCm = sumcc/signal;
209        coordPU = sumpp/signal;
210      };
211    
212      void Dump(){
213        cout << " View  "<<view<<endl;
214        cout << " Coordinate (cm)   "<<coordCm<<endl;
215        cout << " Coordinate (p.u.) "<<coordPU<<endl;
216        cout << " Resolution (cm) "<<resCm<<endl;
217        cout << " Multiplicity  "<<mult<<endl;
218        cout << " Signal (MIP)  "<<signal<<endl;    
219      };
220    
221      //  ClassDef(ExtHit,1);
222    
223    };
224    
225    /**
226     *
227     * Algorythm class
228     *
229     */
230    
231    
232    
233  class ExtTrkingAlg : public TObject {  class ExtTrkingAlg : public TObject {
234    
235  private:  private:
236    
237    Int_t  _whichAlg;         ///< algorythm id    Int_t  _whichAlg;         ///< algorythm id
238    
   
239    TClonesArray *_trkArray; ///< array of tracks    TClonesArray *_trkArray; ///< array of tracks
240        
241    TrkLevel1*  _trk_l1;    TrkLevel1*  _trk_l1;
# Line 40  private: Line 243  private:
243        
244    CaloLevel1* _cal_l1;    CaloLevel1* _cal_l1;
245    CaloLevel2* _cal_l2;    CaloLevel2* _cal_l2;
246      vector<ExtHit> _cal_cl;///< calorimeter hits
247    
248    ToFLevel2*  _tof_l2;    ToFLevel2*  _tof_l2;
249      vector<ExtHit> _trk_cl;///< tracker hits
250    
251      ExtTrack* _extTrack;
252      float*    _zMech;
253    
     
254    Int_t _sel_nClstrMAX;  ///< selection parameter: maximum number of cluster    Int_t _sel_nClstrMAX;  ///< selection parameter: maximum number of cluster
255    Int_t _sel_nPlaneXMIN; ///< selection parameter: minimum number of hit x-views    Int_t _sel_nPlaneXMIN; ///< selection parameter: minimum number of hit x-views
256    Int_t _sel_nPlaneYMIN; ///< selection parameter: minimum number of hit y-views    Int_t _sel_nPlaneYMIN; ///< selection parameter: minimum number of hit y-views
257    
258    Int_t _alg_nClFixX;     ///< algorythm parameter: n.hits required on X view    Int_t _alg_nClFixX;     ///< algorythm parameter: n.hits required on X view
259    Int_t _alg_nClFixY;     ///< algorythm parameter:n.hits required on X view    Int_t _alg_nClFixY;     ///< algorythm parameter:n.hits required on Y view
260    Int_t _alg_nTrackMAX; ///< algorythm parameter: maximum num. of track candidates    Int_t _alg_nTrackMAX;   ///< algorythm parameter: maximum num. of track candidates
261      Int_t _alg_nViewCal;    ///< algorythm parameter: n. calorimeter planes included
262    
263      Int_t NEXTVIEWS;
264      Int_t NEXTPLANES;
265    
266      float _caloCoord[2][22][96];
267      float _caloZ[44];
268      Trajectory* _caloTj;
269      Trajectory* _tgf;
270    
271    
272      vector<CaloStripRoto> _caloStripRoto; // rotatore di calorimetri! sapevatelo!
273    
274    Bool_t _debug;    Bool_t _debug;
275    
276  public:  public:
277    
   void Reset();                         ///< Reset the algorythm  
278    void Clear(Option_t* option = "");    ///< Clear the event    void Clear(Option_t* option = "");    ///< Clear the event
279    void Delete(){ delete _trkArray; };    void Delete();                        ///< Delete all (deallocate arrays)
280    
281    ExtTrkingAlg(Int_t id=0);    ExtTrkingAlg(Int_t id=0);
282    //  ExtTrkingAlg(){ ExtTrkingAlg(0); };      //  ExtTrkingAlg(){ ExtTrkingAlg(0); };  
# Line 72  public: Line 290  public:
290    void SetCaloLevel1( CaloLevel1* call1 = NULL ) { _cal_l1  = call1; };    void SetCaloLevel1( CaloLevel1* call1 = NULL ) { _cal_l1  = call1; };
291    void SetCaloLevel2( CaloLevel2* call2 = NULL ) { _cal_l2  = call2; };    void SetCaloLevel2( CaloLevel2* call2 = NULL ) { _cal_l2  = call2; };
292    
293      
294      void FillClusterMap(multimap<int,int> &map,TrkLevel1* l1,Int_t vOffset = 0);
295      void FillClusterMap(multimap<int,int> &map,CaloLevel1* l1,Int_t vOffset = 12);
296    
297    Bool_t CheckEvent();                        ///< pre-selection    Bool_t CheckEvent();                        ///< pre-selection
298    void ProcessEvent(Bool_t force = false);    ///< apply tracking algorythm    void ProcessEvent0(Bool_t force = false);    ///< apply tracking algorythm 0
299      void ProcessEvent1(Bool_t force = false);    ///< apply tracking algorythm 1
300      void ProcessEvent2(Bool_t force = false);    ///< apply tracking algorythm 1
301      void ProcessEvent(Bool_t force = false);
302      bool EvaluateClusterPosition_Tracker( int, int, int, int, float*, float*, float*);  
303      bool EvaluateClusterPosition_Calorimeter( int icl, int& sensor, float *xmABar, float *ymABar, float *zmAB, float def=0.);
304    
305    
306    TClonesArray *GetTrackArray(Bool_t reset = false);    TClonesArray *GetTrackArray(Bool_t reset = false);
307    
308    void SetSelectionParams(double* par);    void SetSelectionParams(double* par);
309    void SetAlgorythmParams(double* par);    void SetAlgorythmParams(double* par);
310    
311    
312    void SetDebug(Bool_t dbg = false){ _debug = dbg; };    void SetDebug(Bool_t dbg = false){ _debug = dbg; };
313    
314    void Dump();    void Dump();
315    
316    TClonesArray** GetPointerToTrackArray(){ return &_trkArray; };    TClonesArray** GetPointerToTrackArray(){ return &_trkArray; };
317    
318  };    vector<ExtHit> GetCaloClusters(){ return _cal_cl; };
319      vector<ExtHit> GetTrkClusters(){ return _trk_cl; };
320    
321      CaloStripRoto GetCaloStripRoto(int index){ return _caloStripRoto[index]; };
322    
323    
324    };
325    
326    
327  #endif  #endif

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23