//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of TpcLaser. // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Felix Boehmer TUM (original author) // // //----------------------------------------------------------- // This class' header #include "TpcLaser.h" // Collaborating class headers #include "TError.h" #include #include #include "TpcPoint.h" #include "TpcPrimaryCluster.h" #include "LinearInterpolPolicy.h" #include "TRandom.h" TpcLaser::TpcLaser() { fEval = false; fId = false; } TpcLaser::TpcLaser(unsigned int id, const TVector3& start, const TVector3& direction, double iondens, double width, double time, bool dirisend) { fstart=start; fId=id; if(direction.Mag()!=0) { if(dirisend==false){ fdir = direction; fdir.SetMag(1.); //normalize fend = TVector3(0,0,0);} else { fend = direction; fdir = TVector3(0,0,0); } } fionDens = iondens; fwidth = width; ftime = time; frMin=15.5; frMax=41.5; fzMin=-39.5; fzMax=109.5; fEval = false; evalGeometry(); } TpcLaser::TpcLaser(unsigned int id, double rMin, double rMax, double zMin, double zMax, const TVector3& start, const TVector3& direction, double iondens, double width, double time, bool dirisend) { fstart=start; fId = id; if(direction.Mag()!=0) { if(dirisend==false){ fdir = direction; fdir.SetMag(1.); //normalize fend = TVector3(0,0,0); } else { fend = direction; fdir = TVector3(0,0,0); } } fionDens = iondens; fwidth = width; ftime = time; frMin=rMin; frMax=rMax; fzMin=zMin; fzMax=zMax; fEval = false; evalGeometry(); } TpcLaser::~TpcLaser() { ; } void TpcLaser::evalGeometry() { if(fEval) return; if(fdir.Mag() < 1.E-5 && fend.Mag() < 1.E-5) Error("TpcLaser::evalGeometry()", "geometry not set! supply direction or end"); if(fend.Mag() < 1.E-5) //direction is given, standard case { fdir.SetMag(1.); double stepsize = 0.1; //1 mm, should be small enough fend = fstart; //determine the end-point //the correction +0.05 guarantees that we don't lie outside due to //rounding errors int count = 0; while(fend.Perp() >= (frMin-0.05) && fend.Perp() <= (frMax+0.05) && fend.Z() >= (fzMin-0.05) && fend.Z() <= (fzMax+0.05)) { fend += (fdir*stepsize); count++; } } if(fdir.Mag() < 1.E-5) //end-point is given { fdir = fend - fstart; fdir.SetMag(1.); } fEval = true; } TClonesArray* TpcLaser::activate() { if(!fEval) evalGeometry(); double trackLength = (fend - fstart).Mag(); //total number of electrons ftotalNE = (unsigned int)std::floor(fionDens*trackLength); TClonesArray* laserArray = new TClonesArray("TpcPrimaryCluster"); for (int i=0; isetIndex(i); } TpcPoint* startPoint = new TpcPoint(1, 1, fstart, TVector3(0,0,0), ftime, 0, 0); TpcPoint* endPoint = new TpcPoint(1, 1, fend, TVector3(0,0,0), ftime, 0, 0); //arrange the created "clusters" along a straight line, the beam LinearInterpolPolicy().Interpolate(startPoint,endPoint,laserArray,0,ftotalNE); // Gauss-profile ... smear them double dx, dy, dz; TpcPrimaryCluster* cluster; TVector3 pos; int size = laserArray->GetEntriesFast(); for(int j=0; jAt(j); pos = cluster->pos(); dx = gRandom->Gaus(0,fwidth); dy = gRandom->Gaus(0,fwidth); dz = gRandom->Gaus(0,fwidth); TVector3 tempPos(pos.X()+dx, pos.Y()+dy, pos.Z()+dz); if(tempPos.Perp() < frMin) tempPos.SetPerp(frMin+0.001); if(tempPos.Perp() > frMax) tempPos.SetPerp(frMax-0.001); cluster->setpos(tempPos.X(),tempPos.Y(),tempPos.Z()); } return laserArray; } void TpcLaser::print() { if(!fEval) evalGeometry(); std::cout<<"\nId: "<