/[PAMELA software]/DarthVader/ToFLevel2/src/ToFLevel2.cpp
ViewVC logotype

Annotation of /DarthVader/ToFLevel2/src/ToFLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Fri Jun 30 09:22:03 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: MAIN
Changes since 1.2: +30 -0 lines
Memory leak bug fixed

1 mocchiut 1.1 #include <TObject.h>
2     #include <ToFLevel2.h>
3     #include <iostream>
4     using namespace std;
5     ClassImp(ToFTrkVar);
6     ClassImp(ToFLevel2);
7    
8     ToFTrkVar::ToFTrkVar() {
9    
10     trkseqno = 0;
11    
12     for (Int_t kk=0; kk<13;kk++){
13     beta_a[kk] = 0;
14     }
15    
16     for (Int_t kk=0; kk<4;kk++){
17     for (Int_t hh=0; hh<12;hh++){
18     adc_c[hh][kk] = 0;
19     }
20     }
21     }
22    
23     ToFTrkVar::ToFTrkVar(const ToFTrkVar &t){
24    
25     trkseqno = t.trkseqno;
26    
27     memcpy(adc_c,t.adc_c,sizeof(adc_c));
28     memcpy(beta_a,t.beta_a,sizeof(beta_a));
29     }
30    
31     ToFLevel2::ToFLevel2() {
32     //
33     ToFTrk = new TClonesArray("ToFTrkVar",1);
34     //
35     for (Int_t kk=0; kk<3;kk++){
36     xtofpos[kk] = 0.;
37     ytofpos[kk] = 0.;
38     }
39    
40     for (Int_t kk=0; kk<6;kk++){
41     tof_i_flag[kk] = 0;
42     tof_j_flag[kk] = 0;
43     }
44    
45     for (Int_t kk=0; kk<13;kk++){
46     betatof_a[kk] = 0;
47     }
48    
49     for (Int_t kk=0; kk<4;kk++){
50     for (Int_t hh=0; hh<12;hh++){
51     adctof_c[hh][kk] = 0;
52     }
53     }
54    
55     for (Int_t kk=0; kk<4;kk++){
56     for (Int_t hh=0; hh<12;hh++){
57     tdc_c[hh][kk] = 0;
58     }
59     }
60    
61 mocchiut 1.3 };
62    
63     void ToFLevel2::Clear(){
64     //
65     ToFTrk->Clear();
66     //
67     for (Int_t kk=0; kk<3;kk++){
68     xtofpos[kk] = 0.;
69     ytofpos[kk] = 0.;
70     }
71 mocchiut 1.1
72 mocchiut 1.3 for (Int_t kk=0; kk<6;kk++){
73     tof_i_flag[kk] = 0;
74     tof_j_flag[kk] = 0;
75     }
76    
77     for (Int_t kk=0; kk<13;kk++){
78     betatof_a[kk] = 0;
79     }
80    
81     for (Int_t kk=0; kk<4;kk++){
82     for (Int_t hh=0; hh<12;hh++){
83     adctof_c[hh][kk] = 0;
84     }
85     }
86    
87     for (Int_t kk=0; kk<4;kk++){
88     for (Int_t hh=0; hh<12;hh++){
89     tdc_c[hh][kk] = 0;
90     }
91     }
92 mocchiut 1.1 };
93    
94     ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){
95     //
96     if(itrk >= ntrk()){
97     printf(" ToFLevel2 ERROR: track related variables set %i does not exists! \n",itrk);
98     printf(" stored track related variables = %i \n",ntrk());
99     return(NULL);
100     }
101     //
102     TClonesArray &t = *(ToFTrk);
103     ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk];
104     return toftrack;
105     }
106     //--------------------------------------
107     //
108     //
109     //--------------------------------------
110     /**
111     * Method to get the paddle ID (11 12 21 22 31 32) from the paddle index (0 1 2 3 4 5)
112     */
113     Int_t ToFLevel2::GetToFPlaneID(Int_t ip){
114     if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1;
115     else return -1;
116     };
117     /**
118     * Method to get the paddle index (0 1 2 3 4 5) from the paddle ID (11 12 21 22 31 32)
119     */
120     Int_t ToFLevel2::GetToFPlaneIndex(Int_t plane_id){
121     if(
122     plane_id == 11 ||
123     plane_id == 12 ||
124     plane_id == 21 ||
125     plane_id == 22 ||
126     plane_id == 31 ||
127     plane_id == 32 ||
128     false)return (Int_t)(plane_id/10)*2-1- plane_id%2;
129     else return -1;
130     };
131     /**
132     * Method to know if a given ToF paddle was hit, that is there is a TDC signal from both PMTs
133     * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).
134     * @param paddle_id Paddle ID.
135     * @return 1 if the paddle was hit.
136     */
137     Bool_t ToFLevel2::HitPaddle(Int_t plane, Int_t paddle_id){ //<<< NEW
138     Int_t ip = -1;
139     if (plane>=6 ) ip = GetToFPlaneIndex(plane);
140     else if(plane>=0 && plane < 6) ip = plane;
141     Int_t flag=0;
142 mocchiut 1.2 if(ip != -1)flag = tof_j_flag[ip] & (int)pow(2.,(double)paddle_id);
143 mocchiut 1.1 if(
144     (ip == 0 && paddle_id < 8 && flag) ||
145     (ip == 1 && paddle_id < 6 && flag) ||
146     (ip == 2 && paddle_id < 2 && flag) ||
147     (ip == 3 && paddle_id < 2 && flag) ||
148     (ip == 4 && paddle_id < 3 && flag) ||
149     (ip == 5 && paddle_id < 3 && flag) ||
150     false) return true;
151     else return false;
152     };
153     /**
154     * Method to get the number of hit paddles on a ToF plane.
155     * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).
156     */
157     Int_t ToFLevel2::GetNHitPaddles(Int_t plane){
158     Int_t npad=0;
159     for(Int_t i=0; i<8; i++)npad = npad + (int)HitPaddle(plane,i);
160     return npad;
161     };

  ViewVC Help
Powered by ViewVC 1.1.23