6#include "EmcRec/EmcRecShowerPosLogShMax.h"
10#include "EmcRecGeoSvc/EmcRecGeoSvc.h"
11#include "GaudiKernel/Bootstrap.h"
12#include "GaudiKernel/ISvcLocator.h"
14#include "EmcRec/EmcRecParameter.h"
19 RecEmcFractionMap::const_iterator cit;
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service(
"EmcRecGeoSvc",iGeoSvc);
30 if(sc!=StatusCode::SUCCESS) {
36 double e55 = aShower.
e5x5();
37 double len55=(log(e55/0.0145)+0.5)*1.86;
41 double ltot=(log(
etot/0.0145)+0.5)*1.86;
47 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
48 w=offset+log((cit->second.getEnergy()/
etot)*cit->second.getFraction());
54 if(cit->second.getCellId()==seedID) {
56 theDistance=(seedPoint.mag()+ltot);
60 theDistance=(seedPoint.mag()+ltot)/
cos(seedPoint.angle(hitPoint));
65 posMax = (theDistance/pos.mag())*pos;
70 double e3x3=aShower.
e3x3();
71 double l3x3=(log(e3x3/0.0145)+0.5)*1.86;
78 for(cit=fracMap3x3.begin();
79 cit!=fracMap3x3.end();
81 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
86 if(cit->second.getCellId()==seedID) {
87 theDistance=(seedPoint.mag()+l3x3);
89 theDistance=(seedPoint.mag()+l3x3)/
cos(seedPoint.angle(hitPoint));
94 posMax = (theDistance/pos.mag())*pos;
99 double e5x5=aShower.
e5x5();
100 double l5x5=(log(e5x5/0.0145)+0.5)*1.86;
107 for(cit=fracMap5x5.begin();
108 cit!=fracMap5x5.end();
110 w=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
116 if(cit->second.getCellId()==seedID) {
117 theDistance=(seedPoint.mag()+l5x5);
119 theDistance=(seedPoint.mag()+l5x5)/
cos(seedPoint.angle(hitPoint));
125 posMax = (theDistance/pos.mag())*pos;
133 cout<<
"[[[[[[[[[[[[[[["<<wsum;
151 unsigned int theModule;
153 theModule = 43 - thetaModule;
155 posCorr.setZ(-posCorr.z());
157 theModule = thetaModule;
160 double IRShift, parTheta[5],parPhi[5];
163 }
else if(theModule==20) {
171 for(
int i=0;i<5;i++){
187 double theta01,theta23,length,d;
188 theta01 = (center01-IR).theta();
189 theta23 = (center23-IR).theta();
190 length = (center01-IR).mag();
191 d = length*
tan(theta01-theta23);
193 double xIn,xOut,deltaTheta;
194 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
195 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])
196 + parTheta[2]*xIn + parTheta[3] );
197 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
202 double yIn,yOut,deltaPhi;
204 if(phiModule==0&&posCorr.phi()<0){
206 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
208 }
else if (phiModule==119&&posCorr.phi()>0){
210 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
214 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
215 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
218 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
221 deltaPhi = yOut*CLHEP::pi/180.;
224 rotateVector.rotateZ(center01.phi());
225 posCorr.setZ(posCorr.z()-IRShift);
226 posCorr.rotate(-deltaTheta,rotateVector);
227 posCorr.setZ(posCorr.z()+IRShift);
229 posCorr.rotateZ(-deltaPhi);
232 posCorr.setZ(-posCorr.z());
235 posCorr=((posCorr.mag()-len55)/posCorr.mag())*posCorr;
240 if(aShower.
energy()<1e-5)
return;
243 double dtheta,dphi,dx,dy,dz;
246 theta = posCorr.theta();
273 HepSymMatrix matrix(3);
275 matrix[1][1]=dtheta*dtheta;
276 matrix[2][2]=dphi*dphi;
282 HepMatrix matrix1(3,3),matrix2(3,3);
283 matrix1[0][0]=
sin(theta)*
cos(phi);
284 matrix1[0][1]=r*
cos(theta)*
cos(phi);
285 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
286 matrix1[1][0]=
sin(theta)*
sin(phi);
287 matrix1[1][1]=r*
cos(theta)*
sin(phi);
288 matrix1[1][2]=r*
sin(theta)*
cos(phi);
289 matrix1[2][0]=
cos(theta);
290 matrix1[2][1]=-r*
sin(theta);
294 for(
int i=0;i<3;i++) {
295 for(
int j=0;j<3;j++) {
296 matrix2[i][j]=matrix1[j][i];
301 HepMatrix matrix4(3,3);
302 matrix4=matrix1*matrix*matrix2;
305 HepSymMatrix matrix5(3);
306 for(
int i=0;i<3;i++) {
307 for(
int j=0;j<=i;j++) {
308 matrix5[i][j]=matrix4[i][j];
315 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
316 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
317 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
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
static EmcRecParameter & GetInstance()
std::string PositionMode2() const
double SigTheta(int n) const
double BarrShLogThetaPara(int n, int m) const
double BarrShLogPhiPara(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