1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file CaloDoubleShower.cpp |
3 |
|
|
* \author Emiliano Mocchiutti (2007/08/10) |
4 |
|
|
*/ |
5 |
|
|
// |
6 |
|
|
// headers |
7 |
|
|
// |
8 |
|
|
#include <CaloDoubleShower.h> |
9 |
|
|
//-------------------------------------- |
10 |
|
|
/** |
11 |
|
|
* Default constructor |
12 |
|
|
*/ |
13 |
|
|
CaloDoubleShower::CaloDoubleShower(){ |
14 |
|
|
Clear(); |
15 |
|
|
}; |
16 |
|
|
|
17 |
|
|
CaloDoubleShower::CaloDoubleShower(PamLevel2 *l2p){ |
18 |
|
|
// |
19 |
|
|
L2 = l2p; |
20 |
|
|
// |
21 |
|
|
if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n"); |
22 |
|
|
// |
23 |
|
|
OBT = 0; |
24 |
|
|
PKT = 0; |
25 |
|
|
atime = 0; |
26 |
|
|
// |
27 |
|
|
// Default variables |
28 |
|
|
// |
29 |
|
|
extern struct Calo2sh sdouble_; |
30 |
|
|
c2s = &sdouble_; |
31 |
|
|
event = new CaloLevel0(); |
32 |
|
|
cstrip = new CaloStrip(false); |
33 |
|
|
debug = false; |
34 |
|
|
simulation = false; |
35 |
mocchiut |
1.3 |
usepl18x = false; |
36 |
mocchiut |
1.1 |
// |
37 |
|
|
Clear(); |
38 |
|
|
// |
39 |
|
|
}; |
40 |
|
|
|
41 |
|
|
void CaloDoubleShower::LoadMagneticField(){ |
42 |
|
|
// |
43 |
|
|
// loading magnetic field... |
44 |
|
|
// |
45 |
|
|
TrkLevel2 *trk = new TrkLevel2(); |
46 |
|
|
GL_PARAM *q4 = new GL_PARAM(); |
47 |
|
|
TSQLServer *dbc = 0; |
48 |
|
|
TString host = "mysql://localhost/pamelaprod"; |
49 |
|
|
TString user = "anonymous"; |
50 |
|
|
TString psw = ""; |
51 |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
52 |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
53 |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
54 |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
55 |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
56 |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
57 |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
58 |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
59 |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
60 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
61 |
|
|
q4->Query_GL_PARAM(1,1,dbc); |
62 |
|
|
printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data()); |
63 |
|
|
trk->LoadField(q4->PATH+q4->NAME); |
64 |
|
|
// |
65 |
|
|
}; |
66 |
|
|
|
67 |
|
|
void CaloDoubleShower::Clear(){ |
68 |
|
|
// |
69 |
|
|
dbls = 0; |
70 |
|
|
qdbls = 0.; |
71 |
|
|
// |
72 |
|
|
}; |
73 |
|
|
|
74 |
|
|
void CaloDoubleShower::Print(){ |
75 |
|
|
Print(0); |
76 |
|
|
}; |
77 |
|
|
|
78 |
|
|
void CaloDoubleShower::Print(UInt_t nt){ |
79 |
|
|
// |
80 |
|
|
Process(nt); |
81 |
|
|
// |
82 |
|
|
printf("========================================================================\n"); |
83 |
|
|
printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime); |
84 |
|
|
printf(" debug [debug flag]:.. %i\n",debug); |
85 |
|
|
printf(" simulation [simulation flag]:.. %i\n",simulation); |
86 |
|
|
printf(" dbls [double shower flag]:.. %i\n",dbls); |
87 |
|
|
printf(" qdbls [double shower energy]:.. %f\n",qdbls); |
88 |
|
|
printf("========================================================================\n"); |
89 |
|
|
// |
90 |
|
|
}; |
91 |
|
|
|
92 |
|
|
void CaloDoubleShower::Delete(){ |
93 |
|
|
Clear(); |
94 |
|
|
}; |
95 |
|
|
|
96 |
|
|
|
97 |
|
|
void CaloDoubleShower::Process(){ |
98 |
|
|
Process(0); |
99 |
|
|
}; |
100 |
|
|
|
101 |
|
|
void CaloDoubleShower::Process(UInt_t ntr){ |
102 |
|
|
// |
103 |
|
|
if ( !L2 ){ |
104 |
|
|
printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); |
105 |
|
|
printf(" ERROR: CaloDoubleShower variables _NOT_ filled \n"); |
106 |
|
|
return; |
107 |
|
|
}; |
108 |
|
|
// |
109 |
|
|
Bool_t newentry = false; |
110 |
|
|
// |
111 |
|
|
if ( L2->IsORB() ){ |
112 |
|
|
if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr){ |
113 |
|
|
newentry = true; |
114 |
|
|
OBT = L2->GetOrbitalInfo()->OBT; |
115 |
|
|
PKT = L2->GetOrbitalInfo()->pkt_num; |
116 |
|
|
atime = L2->GetOrbitalInfo()->absTime; |
117 |
|
|
sntr = ntr; |
118 |
|
|
}; |
119 |
|
|
} else { |
120 |
|
|
newentry = true; |
121 |
|
|
}; |
122 |
|
|
// |
123 |
|
|
if ( !newentry ) return; |
124 |
|
|
// |
125 |
|
|
// check track |
126 |
|
|
// |
127 |
|
|
PamTrack *ptrack = 0; |
128 |
|
|
if ( ntr >= 0 ){ |
129 |
|
|
ptrack = L2->GetTrack(ntr); |
130 |
|
|
}; |
131 |
|
|
// |
132 |
|
|
if ( !ptrack ){ |
133 |
|
|
printf(" ERROR: cannot find requested track!\n"); |
134 |
|
|
printf(" ERROR: CaloDoubleShower variables _NOT_ filled \n"); |
135 |
|
|
return; |
136 |
|
|
}; |
137 |
|
|
// |
138 |
|
|
tr = ntr; |
139 |
|
|
// |
140 |
|
|
if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); |
141 |
|
|
// |
142 |
|
|
this->Clear(); |
143 |
|
|
// |
144 |
|
|
// Some variables |
145 |
|
|
// |
146 |
|
|
|
147 |
|
|
// |
148 |
|
|
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
149 |
|
|
// |
150 |
|
|
// Fill the estrip matrix |
151 |
|
|
// |
152 |
|
|
memset(event->clevel1->estrip, 0, 2*22*96*sizeof(Float_t)); |
153 |
|
|
Int_t view = 0; |
154 |
|
|
Int_t plane = 0; |
155 |
|
|
Int_t strip = 0; |
156 |
|
|
Float_t mip = 0.; |
157 |
|
|
for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){ |
158 |
|
|
// |
159 |
|
|
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
160 |
mocchiut |
1.3 |
// |
161 |
|
|
if ( !usepl18x && view==0 && plane==18 ) mip = 0.; |
162 |
|
|
// |
163 |
mocchiut |
1.1 |
event->clevel1->estrip[strip][plane][view] = mip; |
164 |
|
|
// |
165 |
|
|
}; |
166 |
|
|
// |
167 |
|
|
// if data comes from the simulation we must use mechanical alignment parameters (default is flight parameters) |
168 |
|
|
// |
169 |
|
|
if ( simulation ){ |
170 |
|
|
cstrip->UseMechanicalAlig(); |
171 |
|
|
}; |
172 |
|
|
// |
173 |
|
|
// Set alignment parameter |
174 |
|
|
// |
175 |
|
|
event->clevel1->xalig = cstrip->GetXalig(); |
176 |
|
|
event->clevel1->yalig = cstrip->GetYalig(); |
177 |
|
|
event->clevel1->zalig = cstrip->GetZalig(); |
178 |
|
|
// |
179 |
|
|
event->clevel1->emin = 0.7; |
180 |
|
|
event->clevel1->npla = 22; |
181 |
|
|
event->clevel1->reverse = 0; // if the number of planes is even we have taken away a full module no need to do anything strange... |
182 |
|
|
// |
183 |
|
|
if ( debug ) printf(" xalig = %f \n",event->clevel1->xalig); |
184 |
|
|
if ( debug ) printf(" yalig = %f \n",event->clevel1->yalig); |
185 |
|
|
if ( debug ) printf(" zalig = %f \n",event->clevel1->zalig); |
186 |
|
|
// |
187 |
|
|
// let's go |
188 |
|
|
// |
189 |
|
|
TrkTrack *ptt = ptrack->GetTrkTrack(); |
190 |
|
|
// |
191 |
|
|
// Copy the alpha vector in the input structure |
192 |
|
|
// |
193 |
|
|
for (Int_t e = 0; e < 5 ; e++){ |
194 |
|
|
event->clevel1->al_p[e][0] = ptt->al[e]; |
195 |
|
|
}; |
196 |
|
|
// |
197 |
|
|
Float_t m = (ptrack->GetToFTrack()->xtr_tof[0] - ptrack->GetToFTrack()->xtr_tof[3])/(ZTOF11-ZTOF21); |
198 |
|
|
Float_t q = ptrack->GetToFTrack()->xtr_tof[3] - m * ZTOF21; |
199 |
|
|
// |
200 |
mocchiut |
1.2 |
c2s->pos = (m * (event->clevel1->zalig/10.) + q)*10. + event->clevel1->xalig; |
201 |
mocchiut |
1.1 |
c2s->angol = m; |
202 |
|
|
// |
203 |
|
|
// call fortran routine |
204 |
|
|
// |
205 |
|
|
getdblsh(); |
206 |
|
|
// |
207 |
|
|
// retrieve calculated variables; |
208 |
|
|
// |
209 |
|
|
dbls = (Int_t)c2s->dbls; |
210 |
|
|
qdbls = c2s->dblsq; |
211 |
|
|
// |
212 |
|
|
if ( debug ) this->Print(); |
213 |
|
|
if ( debug ) printf(" exit \n"); |
214 |
|
|
// |
215 |
|
|
}; |