6#include "EmcRec/EmcRecShowerPosLinShMax.h"
10#include "EmcRecGeoSvc/EmcRecGeoSvc.h"
11#include "GaudiKernel/Bootstrap.h"
12#include "GaudiKernel/ISvcLocator.h"
13#include "EmcRec/EmcRecParameter.h"
14#include "CLHEP/Vector/LorentzVector.h"
20 RecEmcFractionMap::const_iterator cit;
30 ISvcLocator* svcLocator = Gaudi::svcLocator();
31 StatusCode sc = svcLocator->service(
"EmcRecGeoSvc",iGeoSvc);
32 if(sc!=StatusCode::SUCCESS) {
38 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
39 etot+=(cit->second.getEnergy()*cit->second.getFraction());
45 double ltot=(log(etota/0.0145)+0.5)*1.86;
46 double e55=aShower.
e5x5();
47 double len55=(log(etota/0.0145)+0.5)*1.86;
52 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
53 w=(cit->second.getEnergy()*cit->second.getFraction());
59 if(cit->second.getCellId()==seedID) {
61 theDistance=(seedPoint.mag()+ltot);
63 theDistance=(seedPoint.mag()+ltot)/
cos(seedPoint.angle(hitPoint));
71 posMax = (theDistance/pos.mag())*pos;
77 cout<<
"[[[[[[[[[[[[[[["<<wsum;
93 unsigned int theModule;
95 theModule = 43 - thetaModule;
97 posCorr.setZ(-posCorr.z());
99 theModule = thetaModule;
102 double IRShift, parTheta[5],parPhi[5];
105 }
else if(theModule==20) {
113 for(
int i=0;i<5;i++){
131 double theta01,theta23,length,d;
132 theta01 = (center01-IR).theta();
133 theta23 = (center23-IR).theta();
134 length = (center01-IR).mag();
135 d = length*
tan(theta01-theta23);
137 double xIn,xOut,deltaTheta;
138 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
139 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])
140 + parTheta[2]*xIn + parTheta[3] );
141 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
146 double yIn,yOut,deltaPhi;
148 if(phiModule==0&&posCorr.phi()<0){
150 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
152 }
else if (phiModule==119&&posCorr.phi()>0){
154 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
158 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
159 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
162 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
166 deltaPhi = yOut*CLHEP::pi/180.;
169 rotateVector.rotateZ(center01.phi());
170 posCorr.setZ(posCorr.z()-IRShift);
171 posCorr.rotate(-deltaTheta,rotateVector);
172 posCorr.setZ(posCorr.z()+IRShift);
175 posCorr.rotateZ(-deltaPhi);
178 posCorr.setZ(-posCorr.z());
181 posCorr=((posCorr.mag()-len55)/posCorr.mag())*posCorr;
186 if(aShower.
energy()<1e-5)
return;
189 double dtheta,dphi,dx,dy,dz;
192 theta = posCorr.theta();
219 HepSymMatrix matrix(3);
221 matrix[1][1]=dtheta*dtheta;
222 matrix[2][2]=dphi*dphi;
228 HepMatrix matrix1(3,3),matrix2(3,3);
229 matrix1[0][0]=
sin(theta)*
cos(phi);
230 matrix1[0][1]=r*
cos(theta)*
cos(phi);
231 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
232 matrix1[1][0]=
sin(theta)*
sin(phi);
233 matrix1[1][1]=r*
cos(theta)*
sin(phi);
234 matrix1[1][2]=r*
sin(theta)*
cos(phi);
235 matrix1[2][0]=
cos(theta);
236 matrix1[2][1]=-r*
sin(theta);
240 for(
int i=0;i<3;i++) {
241 for(
int j=0;j<3;j++) {
242 matrix2[i][j]=matrix1[j][i];
247 HepMatrix matrix4(3,3);
248 matrix4=matrix1*matrix*matrix2;
251 HepSymMatrix matrix5(3);
252 for(
int i=0;i<3;i++) {
253 for(
int j=0;j<=i;j++) {
254 matrix5[i][j]=matrix4[i][j];
261 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
262 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
263 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)
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()
double BarrShLinPhiPara(int n, int m) const
double SigTheta(int n) const
double BarrShLinThetaPara(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
RecEmcID getShowerId() const
RecEmcFractionMap::const_iterator Begin() const
RecEmcEnergy getEAll() const