12#include "GaudiKernel/Bootstrap.h"
13#include "GaudiKernel/ISvcLocator.h"
20 RecEmcFractionMap::const_iterator cit;
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service(
"EmcRecGeoSvc",iGeoSvc);
30 if(sc!=StatusCode::SUCCESS) {
42 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
43 w=offset+log((cit->second.getEnergy()/
etot)*cit->second.getFraction());
51 double e3x3=aShower.
e3x3();
53 for(cit=fracMap3x3.begin();cit!=fracMap3x3.end();cit++) {
54 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
64 for(cit=fracMap5x5.begin();cit!=fracMap5x5.end();cit++) {
65 w=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
90 double IRShift=0, parTheta[5],parPhi[5];
92 unsigned int theModule;
94 theModule = 43 - thetaModule;
96 posCorr.setZ(-posCorr.z());
98 theModule = thetaModule;
104 }
else if(theModule==20) {
115 for(
int i=0;i<5;i++){
117 double par[5] = { 51.97, -0.1209, 6.175, -0.1431, -0.005497 };
118 parTheta[i] = par[i];
119 }
else if(theModule==20){
120 double par[5] = { 56.31, -0.1135, 6.312, -1.216, -0.02978 };
121 parTheta[i] = par[i];
123 double par[5] = { 10.65, -0.2257, 2.216, -0.1562, -0.05552 };
124 parTheta[i] = par[i];
130 for(
int i=0;i<5;i++){
133 else if(e5x5<=1.0 && e5x5>0.5) parTheta[i] = Para.
BarrLogThetaPara(theModule+22,i);
137 else if(e5x5<=1.0 && e5x5>0.5) parPhi[i] = Para.
BarrLogPhiPara(theModule+22,i);
138 else if(e5x5<=0.5) parPhi[i] = Para.
BarrLogPhiPara(theModule+44,i);
149 double theta01,theta23,length,d;
150 theta01 = (center01-IR).theta();
151 theta23 = (center23-IR).theta();
152 length = (center01-IR).mag();
153 d = length*
tan(theta01-theta23);
155 double xIn,xOut,deltaTheta;
156 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
157 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])+ parTheta[2]*xIn + parTheta[3] );
158 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
162 double yIn,deltaY,deltaPhi;
166 yIn = posCorr.phi()*180./CLHEP::pi -phiModule*3. - 1.843;
167 }
else if (phiModule==119){
168 yIn = posCorr.phi()*180./CLHEP::pi + 360.-phiModule*3. -1.843;
170 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
171 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
175 deltaY = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
176 deltaPhi = deltaY*CLHEP::pi/180.;
179 rotateVector.rotateZ(center01.phi());
180 posCorr.setZ(posCorr.z()-IRShift);
181 posCorr.rotate(-deltaTheta,rotateVector);
182 posCorr.setZ(posCorr.z()+IRShift);
185 posCorr.rotateZ(-0.002994);
187 posCorr.rotateZ(-deltaPhi);
191 posCorr.setZ(-posCorr.z());
195 lengthemc =
abs(posCorr.z()/
cos(posCorr.theta()));
197 double posDataCorPar;
200 posCorr.setTheta(posCorr.theta()-posDataCorPar/lengthemc);
207 posCorr.setTheta(posCorr.theta()-posMCCorPar/lengthemc);
213 double IRShift=0, parTheta[5],parPhi[5];
219 for(
int i=0;i<5;i++) {
223 else if(e5x5<=1.0 && e5x5>0.5) parTheta[i] = Para.
EastLogThetaPara(thetaModule+6,i);
227 else if(e5x5<=1.0 && e5x5>0.5) parPhi[i] = Para.
EastLogPhiPara(1,i);
231 }
else if (module==2){
233 for(
int i=0;i<5;i++){
236 else if(e5x5<=1.0 && e5x5>0.5) parTheta[i] = Para.
WestLogThetaPara(thetaModule+6,i);
240 else if(e5x5<=1.0 && e5x5>0.5) parPhi[i] = Para.
WestLogPhiPara(1,i);
249 double theta12=-9999,theta03=-9999,theta23=-9999,theta14=-9999,
delta=-9999;
250 double phi01=-9999,phi23=-9999,phi12=-9999,phi34=-9999,deltaphi=-9999;
251 double xIn,deltaX,deltaTheta,yIn,deltaY,deltaPhi;
253 double posphi=posCorr.phi();
256 }
else if( ((thetaModule==0||thetaModule==1)&&phiModule==63)
257 ||((thetaModule==2||thetaModule==3)&&phiModule==79)
258 ||((thetaModule==4||thetaModule==5)&&phiModule==95)
260 posphi = posphi+2*CLHEP::pi;
262 posphi = posphi < 0 ? posphi+2*CLHEP::pi : posphi;
265 HepPoint3D center,center01, center23, center12,center03,center34,center14;
268 if( (thetaModule==1&&((phiModule+3)%4 == 0||(phiModule+2)%4 == 0))
269 ||(thetaModule==3&&((phiModule+4)%5 == 0||(phiModule+3)%5 == 0||(phiModule+2)%5 == 0)))
275 theta23 = (center23 - IR).theta();
276 theta14 = (center14 - IR).theta();
277 delta = theta14 - theta23;
278 xIn = (((posCorr-IR).theta() - theta23) -
delta*0.5)/
delta;
283 phi12 = center12.phi();
284 phi34 = center34.phi();
286 phi12 = phi12 <0 ? phi12+2*CLHEP::pi : phi12;
287 phi34 = phi34 <0 ? phi34+2*CLHEP::pi : phi34;
288 deltaphi = phi34 - phi12;
289 yIn = ((posphi - phi12) - deltaphi*0.5)/deltaphi;
297 theta12 = (center12 - IR).theta();
298 theta03 = (center03 - IR).theta();
299 delta = theta03 - theta12;
300 xIn = (((posCorr-IR).theta() - theta12) -
delta*0.5)/
delta;
305 phi01 = center01.phi();
306 phi23 = center23.phi();
307 phi01 = phi01 <0 ? phi01+2*CLHEP::pi : phi01;
308 phi23 = phi23 <0 ? phi23+2*CLHEP::pi : phi23;
309 deltaphi = phi23 - phi01;
310 yIn = ((posphi - phi01) - deltaphi*0.5)/deltaphi;
314 deltaX = parTheta[0]*atan(xIn*parTheta[1]-parTheta[4]) + parTheta[2]*xIn + parTheta[3] ;
315 deltaTheta = deltaX*
delta;
317 deltaY = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4]) + parPhi[2]*yIn + parPhi[3] ;
318 deltaPhi = deltaY*deltaphi;
321 rotateVector.rotateZ(center.phi());
322 posCorr.setZ(posCorr.z()-IRShift);
323 posCorr.rotate(-deltaTheta,rotateVector);
324 posCorr.setZ(posCorr.z()+IRShift);
325 posCorr.rotateZ(-deltaPhi);
328 lengthemc =
abs(posCorr.z()/
cos(posCorr.theta()));
329 double posDataCorPar;
331 if(module==0) posDataCorPar=Para.
EastPosDataCor(thetaModule,phiModule);
332 if(module==2) posDataCorPar=Para.
WestPosDataCor(thetaModule,phiModule);
333 posCorr.setTheta(posCorr.theta()-posDataCorPar/lengthemc);
348 if(aShower.
energy()<1e-5)
return;
351 double dtheta,dphi,dx,dy,dz;
354 theta = posCorr.theta();
381 HepSymMatrix matrix(3);
383 matrix[1][1]=dtheta*dtheta;
384 matrix[2][2]=dphi*dphi;
390 HepMatrix matrix1(3,3),matrix2(3,3);
391 matrix1[0][0]=
sin(theta)*
cos(phi);
392 matrix1[0][1]=r*
cos(theta)*
cos(phi);
393 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
394 matrix1[1][0]=
sin(theta)*
sin(phi);
395 matrix1[1][1]=r*
cos(theta)*
sin(phi);
396 matrix1[1][2]=r*
sin(theta)*
cos(phi);
397 matrix1[2][0]=
cos(theta);
398 matrix1[2][1]=-r*
sin(theta);
402 for(
int i=0;i<3;i++) {
403 for(
int j=0;j<3;j++) {
404 matrix2[i][j]=matrix1[j][i];
409 HepMatrix matrix4(3,3);
410 matrix4=matrix1*matrix*matrix2;
413 HepSymMatrix matrix5(3);
414 for(
int i=0;i<3;i++) {
415 for(
int j=0;j<=i;j++) {
416 matrix5[i][j]=matrix4[i][j];
423 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
424 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
425 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
void setDtheta(double dt)
void setPosition(const HepPoint3D &pos)
void setErrorMatrix(const HepSymMatrix &error)
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
double LogPosOffset() const
double BarrPosMCCor(int ntheta, int nphi) const
static EmcRecParameter & GetInstance()
double EastPosDataCor(int ntheta, int nphi) const
double WestPosDataCor(int ntheta, int nphi) const
double BarrLogPhiPara(int n, int m) const
double MethodMode() const
std::string PositionMode2() const
double SigTheta(int n) const
double WestLogThetaPara(int n, int m) const
double BarrPosDataCor(int ntheta, int nphi) const
double BarrLogThetaPara(int n, int m) const
double WestLogPhiPara(int n, int m) const
double EastLogPhiPara(int n, int m) const
double EastLogThetaPara(int n, int m) const
double SigPhi(int n) const
virtual void Position(RecEmcShower &aShower)
virtual double GetBarrelR() const =0
virtual HepPoint3D GetCFrontCenter(const Identifier &id) const =0
virtual HepPoint3D GetCrystalPoint(const Identifier &id, const int i) const =0
RecEmcFractionMap::const_iterator End() const
RecEmcFractionMap getFractionMap5x5() const
RecEmcID getShowerId() const
RecEmcFractionMap::const_iterator Begin() const
RecEmcEnergy getEAll() const
RecEmcFractionMap getFractionMap3x3() const