///////////////////////////////////////////////////////////// // //-------------------------------------------------------------------------- // File and Version Information: // $Id:$ // // Description: // EMC Digi. // // Software developed for the BaBar Detector at the SLAC B-Factory. // Adapted for the PANDA experiment at GSI // // Author List: // Xiaorong Shi Lawrence Livermore National Lab // Stephen J. Gowdy University of Edinburgh // Dima Melnichuk - adaption for PANDA // // Copyright Information: // Copyright (C) 1996 Lawrence Livermore National Lab // /////////////////////////////////////////////////////////////// #include "EmcDigi.h" #include "EmcMapper.h" #include "EmcStructure.h" #include "EmcXtal.h" #include #include "TClass.h" #include "TVector3.h" #include "TBuffer.h" #include "Riostream.h" using namespace std; // ----- Default constructor ----------------------------------- EmcDigi::EmcDigi() { } // ----------------------------------------------------------------- // ----- Destructor -------------------------------------------- EmcDigi::~EmcDigi() {} // ----------------------------------------------------------------- EmcDigi::EmcDigi(Int_t trackid, Int_t id, Float_t energy, Float_t time):fEnergy(energy),fTrackId(trackid),fDetectorId(id),fTime(time),fWhere(0,0,0) { EmcMapper *emcMap=EmcMapper::Instance(1); fTCI=emcMap->GetTCI(id); fThetaInd=fTCI->itsXCoord(); fPhiInd=fTCI->itsYCoord(); std::map tciXtalMap=EmcStructure::Instance("")->GetTciXtalMap(); EmcXtal* xtal = tciXtalMap[fTCI]; fWhere = algPointer()(xtal); fTheta = fWhere.Theta(); fPhi = fWhere.Phi(); } EmcDigi::EmcDigi(Int_t trackid, Int_t id, Float_t energy, Float_t time,std::vector hitList):fEnergy(energy),fTrackId(trackid),fDetectorId(id),fTime(time),fHitList(hitList),fWhere(0,0,0) { EmcMapper *emcMap=EmcMapper::Instance(1); fTCI=emcMap->GetTCI(id); fThetaInd=fTCI->itsXCoord(); fPhiInd=fTCI->itsYCoord(); std::map tciXtalMap=EmcStructure::Instance("")->GetTciXtalMap(); EmcXtal* xtal = tciXtalMap[fTCI]; fWhere = algPointer()(xtal); fTheta = fWhere.Theta(); fPhi = fWhere.Phi(); } void EmcDigi::SetDetectorId(Int_t id) { // EmcMapper assumed to instantiate first time with correct parameter before EmcMapper *emcMap=EmcMapper::Instance(0); fTCI=emcMap->GetTCI(id); fThetaInd=fTCI->itsXCoord(); fPhiInd=fTCI->itsYCoord(); fDetectorId=id; fThetaInd=fTCI->itsXCoord(); fPhiInd=fTCI->itsYCoord(); std::map tciXtalMap=EmcStructure::Instance("")->GetTciXtalMap(); EmcXtal* xtal = tciXtalMap[fTCI]; fWhere = algPointer()(xtal); fTheta = fWhere.Theta(); fPhi = fWhere.Phi(); } void EmcDigi::addHitToList( CbmEmcHit* hit ) { fHitList.push_back(hit); } void EmcDigi::SetHitList(std::vector hitList) { fHitList=hitList; } TVector3 EmcDigi::surfacePosition( const EmcXtal* xtal ) { return xtal->frontCentre(); } TVector3 EmcDigi::depthPosition( const EmcXtal* xtal ) { //cout << "depth" << endl; TVector3 pos = xtal->frontCentre(); TVector3 norm=xtal->normalToFrontFace(); norm*=_positionDepth; pos += norm; return pos; } void EmcDigi::selectDigiPositionMethod( PositionMethod alg, double rescaleFactor, double positionDepth ) { TVector3 (*algorithm)( const EmcXtal* ) = 0; switch ( alg ) { case surface: algorithm = EmcDigi::surfacePosition; _rescaleFactor = rescaleFactor; _positionDepth = positionDepth; break; case depth: algorithm = EmcDigi::depthPosition; _rescaleFactor = rescaleFactor; _positionDepth = positionDepth; break; default: cout << "EmcDigi::selectDigiPositionMethod. " << "Attempted to select unknown digi position method." << endl; } // Now actually set the pointer algPointer() = algorithm; } //Set the default digi position method TVector3 ( *&EmcDigi::algPointer() ) ( const EmcXtal* ) { static TVector3 (*pointer) ( const EmcXtal* ) = EmcDigi::depthPosition; return pointer; } double EmcDigi::_rescaleFactor = 1.0; double EmcDigi::_positionDepth = 6.2; bool EmcDigi::isNeighbour( EmcDigi* theDigi ) { if (fTCI->isNeighbour(theDigi->GetTCI())) return true; return false; } // When EmcDigi is read from root file fTCI is not valid it should be validated later // I didn't manage to do it with custom Streamer (Dima) void EmcDigi::ValidateTCI() { EmcMapper *emcMap=EmcMapper::Instance(1); fTCI=emcMap->GetTCI(fDetectorId); } Short_t EmcDigi::GetXPad() const { // Return the X pad value for clusterization // Barrel EMC if (GetModule()==1 || GetModule()==2) return (GetCrystal()+(GetCopy()-1)*10); // Endcups and forward EMC if ((GetModule()==3) || (GetModule()==4) || (GetModule()==5)) { if (GetCopy()==1) { return -GetRow()+1;} if (GetCopy()==2) { return -GetRow()+1; } if (GetCopy()==3) { return GetRow();} if (GetCopy()==4) { return GetRow();} } return -1000; // failure } Short_t EmcDigi::GetYPad() const { // Return the Y pad value for clusterization // Barrel EMC if (GetModule()==1) return (GetRow()+29); if (GetModule()==2) return GetRow(); // Endcups and forward EMC if ((GetModule()==3) || (GetModule()==4) || (GetModule()==5)) { if (GetCopy()==1) { return GetCrystal(); } if (GetCopy()==2) { return -GetCrystal()+1; } if (GetCopy()==3) { return -GetCrystal()+1; } if (GetCopy()==4) { return GetCrystal(); } } return -1000; // failure } // ----- Public method Print ----------------------------------- void EmcDigi::Print(const Option_t* opt) const { cout << "EMC digi: cellid=" << GetDetectorId() << ", Energy=" << fEnergy; if (fTrackId>0) cout << ", TrackID= " << fTrackId; // cout << ", x=" << GetX() << ", y=" << GetY() << endl << flush; } ClassImp(EmcDigi)