/[PAMELA software]/DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp
ViewVC logotype

Annotation of /DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Fri May 19 13:15:49 2006 UTC (18 years, 6 months ago) by mocchiut
Branch: MAIN
Branch point for: DarthVader
Initial revision

1 mocchiut 1.1 /**
2     * \file src/CaloLevel2.cpp
3     * \author Emiliano Mocchiutti
4     *
5     **/
6     #include <TObject.h>
7     #include <CaloLevel2.h>
8     ClassImp(CaloTrkVar);
9     ClassImp(CaloLevel2);
10    
11     /**
12     * CaloTrkVar constructor
13     **/
14     CaloTrkVar::CaloTrkVar() {
15     trkseqno = 0;
16     noint = 0;
17     ncore = 0;
18     qcore = 0.;
19     ncyl = 0;
20     qcyl = 0.;
21     qtrack = 0.;
22     qtrackx = 0.;
23     qtracky = 0.;
24     dxtrack = 0.;
25     dytrack = 0.;
26     qlast = 0.;
27     nlast = 0;
28     qpre = 0.;
29     npre = 0;
30     qpresh = 0.;
31     npresh = 0;
32     qtr = 0.;
33     ntr = 0;
34     planetot = 0;
35     qmean = 0.;
36     qlow = 0.;
37     nlow = 0;
38     dX0l = 0.;
39     for (Int_t i = 0; i<2 ; i++){
40     for ( Int_t j = 0; j<22; j++){
41     tibar[j][i] = 0;
42     tbar[j][i] = 0.;
43     };
44     };
45     }
46    
47     /**
48     * Copies from t to this
49     **/
50     CaloTrkVar::CaloTrkVar(const CaloTrkVar &t){
51     trkseqno = t.trkseqno;
52     noint = t.noint;
53     ncore = t.ncore;
54     qcore = t.qcore;
55     ncyl = t.ncyl;
56     qcyl = t.qcyl;
57     qtrack = t.qtrack;
58     qtrackx = t.qtrackx;
59     qtracky = t.qtracky;
60     dxtrack = t.dxtrack;
61     dytrack = t.dytrack;
62     qlast = t.qlast;
63     nlast = t.nlast;
64     qpre = t.qpre;
65     npre = t.npre;
66     qpresh = t.qpresh;
67     npresh = t.npresh;
68     qtr = t.qtr;
69     ntr = t.ntr;
70     planetot = t.planetot;
71     qmean = t.qmean;
72     dX0l = t.dX0l;
73     qlow = t.qlow;
74     nlow = t.nlow;
75     memcpy(tibar,t.tibar,sizeof(tibar));
76     memcpy(tbar,t.tbar,sizeof(tbar));
77     }
78    
79     /**
80     * CaloLevel2 constructor
81     **/
82     CaloLevel2::CaloLevel2() {
83     //
84     CaloTrk = new TClonesArray("CaloTrkVar",1);
85     //
86     nstrip = 0;
87     qtot = 0.;
88     impx = 0.;
89     impy = 0.;
90     tanx = 0.;
91     tany = 0.;
92     qmax = 0.;
93     nx22 = 0;
94     qx22 = 0.;
95     elen = 0.;
96     selen = 0.;
97     for (Int_t i = 0; i<4 ; i++){
98     qq[i] = 0.;
99     perr[i] = 0;
100     swerr[i] = 0;
101     crc[i] = 0;
102     if ( i < 2 ){
103     planemax[i] = 0;
104     varcfit[i] = 0.;
105     npcfit[i] = 0;
106     for ( Int_t j = 0; j<22; j++){
107     cibar[j][i] = 0;
108     cbar[j][i] = 0.;
109     };
110     };
111     };
112     good = 0;
113     selftrigger = 0;
114     estrip = TArrayF(0,NULL);
115     };
116    
117     /**
118     * Gives the detected energy for the given strip once loaded the event
119     **/
120     Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){
121     Int_t splane = 0;
122     Int_t sstrip = 0;
123     //
124     if ( nstrip == 0 ) return(0.);
125     //
126     for (Int_t i = 0; i<nstrip; i++ ){
127     if ( view == 0 ){
128     if ( estrip.At(i) > 0. ){
129     splane = (Int_t)trunc(estrip.At(i)/1000000.);
130     sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.);
131     if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.);
132     };
133     } else {
134     if ( estrip.At(i) < 0. ){
135     splane = (Int_t)trunc(-estrip.At(i)/1000000.);
136     sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.);
137     if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.);
138     };
139     };
140     };
141     return(0.);
142     };
143    
144     /**
145     * Given estrip entry returns energy and strip
146     **/
147     Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){
148     if ( entry>nstrip ) return(0.);
149     //
150     if ( estrip.At(entry) > 0. ){
151     view = 0;
152     plane = (Int_t)trunc(estrip.At(entry)/1000000.);
153     strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.);
154     return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.);
155     };
156     if ( estrip.At(entry) < 0. ){
157     view = 1;
158     plane = (Int_t)trunc(-estrip.At(entry)/1000000.);
159     strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.);
160     return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.);
161     };
162     //
163     printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry);
164     //
165     view = -1;
166     plane = -1;
167     strip = -1;
168     return(0.);
169     }
170    
171     void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){
172     if ( nstrip == 0 ) return;
173     energy = qtot * 40.82 * 0.000106;
174     sigma = 0.;
175     if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy));
176     return;
177     };
178    
179     /**
180     * Returns pointer to the set of track-related variables "itrk"
181     **/
182     CaloTrkVar *CaloLevel2::GetCaloTrkVar(Int_t itrk){
183     //
184     if(itrk >= ntrk()){
185     printf(" CaloLevel2 ERROR: track related variables set %i does not exists! \n",itrk);
186     printf(" stored track related variables = %i \n",ntrk());
187     return(NULL);
188     }
189     TClonesArray &t = *(CaloTrk);
190     CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk];
191     return calotrack;
192     }

  ViewVC Help
Powered by ViewVC 1.1.23