13#include "GaudiKernel/Bootstrap.h"
14#include "GaudiKernel/ISvcLocator.h"
21 RecEmcFractionMap::const_iterator cit;
24 double w,w1,w2,wsum=0;
30 ISvcLocator* svcLocator = Gaudi::svcLocator();
31 StatusCode sc = svcLocator->service(
"EmcRecGeoSvc",iGeoSvc);
32 if(sc!=StatusCode::SUCCESS) {
46 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
47 w=offset+log((cit->second.getEnergy()/
etot)*cit->second.getFraction());
55 double e3x3=aShower.
e3x3();
57 for(cit=fracMap3x3.begin();cit!=fracMap3x3.end();cit++) {
58 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
67 offset=a0-1.594*
exp(-2.543*e5x5);
72 for(cit=fracMap5x5.begin();cit!=fracMap5x5.end();cit++) {
73 w1=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
74 w2=(cit->second.getEnergy()/e5x5)*cit->second.getFraction();
86 for(cit=fracMap5x5.begin();cit!=fracMap5x5.end();cit++) {
87 w1=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
88 w2=(cit->second.getEnergy()/e5x5)*cit->second.getFraction();
130 unsigned int theModule;
132 theModule = 43 - thetaModule;
134 posCorr.setZ(-posCorr.z());
136 theModule = thetaModule;
139 double IRShift=0, parTheta[5],parPhi[5];
142 }
else if(theModule==20) {
150 for(
int i=0;i<5;i++){
171 double theta01,theta23,length,d;
172 theta01 = (center01-IR).theta();
173 theta23 = (center23-IR).theta();
174 length = (center01-IR).mag();
175 d = length*
tan(theta01-theta23);
177 double xIn,xOut,deltaTheta;
178 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
179 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])+ parTheta[2]*xIn + parTheta[3] );
180 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
187 double yIn,yOut,deltaPhi;
192 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
193 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
195 if(phiModule==0&&posCorr.phi()<0){
196 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
197 }
else if (phiModule==119&&posCorr.phi()>0){
198 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
200 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
202 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
203 deltaPhi = yOut*CLHEP::pi/180.;
206 rotateVector.rotateZ(center01.phi());
207 posCorr.setZ(posCorr.z()-IRShift);
208 posCorr.rotate(-deltaTheta,rotateVector);
209 posCorr.setZ(posCorr.z()+IRShift);
212 posCorr.rotateZ(-deltaPhi);
215 posCorr.setZ(-posCorr.z());
223 if(aShower.
energy()<1e-5)
return;
226 double dtheta,dphi,dx,dy,dz;
229 theta = posCorr.theta();
256 HepSymMatrix matrix(3);
258 matrix[1][1]=dtheta*dtheta;
259 matrix[2][2]=dphi*dphi;
265 HepMatrix matrix1(3,3),matrix2(3,3);
266 matrix1[0][0]=
sin(theta)*
cos(phi);
267 matrix1[0][1]=r*
cos(theta)*
cos(phi);
268 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
269 matrix1[1][0]=
sin(theta)*
sin(phi);
270 matrix1[1][1]=r*
cos(theta)*
sin(phi);
271 matrix1[1][2]=r*
sin(theta)*
cos(phi);
272 matrix1[2][0]=
cos(theta);
273 matrix1[2][1]=-r*
sin(theta);
277 for(
int i=0;i<3;i++) {
278 for(
int j=0;j<3;j++) {
279 matrix2[i][j]=matrix1[j][i];
284 HepMatrix matrix4(3,3);
285 matrix4=matrix1*matrix*matrix2;
288 HepSymMatrix matrix5(3);
289 for(
int i=0;i<3;i++) {
290 for(
int j=0;j<=i;j++) {
291 matrix5[i][j]=matrix4[i][j];
298 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
299 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
300 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)
EvtComplex exp(const EvtComplex &c)
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)
static EmcRecParameter & GetInstance()
std::string PositionMode2() const
double SigTheta(int n) const
double BarrLoglinThetaPara(int n, int m) const
double BarrLoglinPhiPara(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