//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class PndTpcSectorProcessor // see PndTpcSectorProcessor.hh for details // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Sebastian Neubert TUM (original author) // // //----------------------------------------------------------- // Panda Headers ---------------------- // This Class' Header ------------------ #include "PndTpcSectorProcessor.h" // C/C++ Headers ---------------------- #include #include "assert.h" #include using std::map; // Collaborating Class Headers -------- #include "PndTpcPadPlane.h" #include "PndTpcDigiMapper.h" #include "TORPadProcessor.h" #include "PndTpcCluster.h" #include "TMatrixD.h" #include "FairMultiLinkedData.h" #include "PndDetectorList.h" #include "TORPPState_Compare.h" #include "PndTpcClusterFitter.h" // Class Member definitions ----------- #define DEBUG 0 PndTpcSectorProcessor::~PndTpcSectorProcessor() { // clean up PadProcessors std::map::iterator ipad=fpproc.begin(); while(ipad!=fpproc.end()){ delete ipad->second; ++ipad; } fpproc.clear(); } void PndTpcSectorProcessor::Init(PndTpcPadPlane* p, unsigned int id, std::vector* ob, double diffFactor, double timeCut, double G, double C) { fpadplane=p; fSectorId=id; fG=G; fC=C; foutput_buffer=ob; // Build PadProcessors std::map* pads=fpadplane->GetSectorList(fSectorId); std::map::iterator ipad=pads->begin(); while(ipad!=pads->end()){ fpproc[ipad->second->id()]=new padprocessor(ipad->second->id()); fpproc[ipad->second->id()]->setClusterBuffer(&fcluster_buffer); dynamic_cast(fpproc[ipad->second->id()]->getState("compare"))->setDiffFactor(diffFactor); dynamic_cast(fpproc[ipad->second->id()]->getState("compare"))->setTimeCut(timeCut); ++ipad; } // Connect PadProcessor neighbours ipad=pads->begin(); while(ipad!=pads->end()){ unsigned int nneighb=ipad->second->nNeighbours(); for(unsigned int in=0; insecond->getNeighbour(in); if(fpproc[neighID]!=0){ fpproc[ipad->second->id()]->addNeighbour(fpproc[neighID]); //cout << "Pad " << ipad->second->id() << " connects to Pad " << neighID <& refs){ unsigned int n=refs.size(); for(unsigned int i=0;isetMasked(); } } } void PndTpcSectorProcessor::process(){ //fcluster_buffer.clear(); unsigned int ndigis=fdigi_buffer.size(); if(ndigis==0){ //std::cout<<"PndTpcSectorProcessor::process(): Digi buffer is empty!"<0)std::cout<padId()<GetPad((fdigi_buffer[i])->padId())->sectorId(); //std::cout<<"in sector digisid="<padId()]; assert(pp!=NULL); pp->setData(fdigi_buffer[i]); // activate pad processor by putting it into active list // this way only thos pads that have been hit are processing factivepads[fdigi_buffer[i]->padId()]=pp; } // end loop over digis // run padProcessors // TODO: stop criterion, how many heartbeats???? bool GoOn=true; int counter=0; while(GoOn && counter<40){ //cout<<"beat! ***************"<::iterator ip=factivepads.begin(); for(;ip!=factivepads.end(); ++ip){ std::string nextstate=ip->second->heartbeat(); if(nextstate!="end"){ GoOn=true; //std::cout<<"padproc_"<first<<" in state: "<size(); } int dif=(int)ndigis-(int)numdig; if(numdig!=ndigis)std::cout<<"SectorProc"<clear(); delete fcluster_buffer.back(); fcluster_buffer.pop_back(); } fcluster_buffer.clear(); std::map::iterator ppit=factivepads.begin(); while(ppit!=factivepads.end()){ //std::cout<<"still "<second->ndata()<<" data on padproc"<second->reset(); ++ppit; } factivepads.clear(); } void PndTpcSectorProcessor::cog(){ assert(fpadplane!=NULL); assert(foutput_buffer!=NULL); McId dummyID(1,1,0); McIdCollection dummyColl; dummyColl.AddID(dummyID); //this block is to define the z jitter TVector3 zDiff1,zDiff2; PndTpcDigi zDiffDigi1(1,1,1,dummyColl),zDiffDigi2(1,2,1,dummyColl); PndTpcDigiMapper::getInstance()->map(&zDiffDigi1,zDiff1); PndTpcDigiMapper::getInstance()->map(&zDiffDigi2,zDiff2); double zDiff = zDiff2.z() - zDiff1.z(); //end of z jitter // Calculate COG -------------------------------------------- for(unsigned int ic=0;ic* digis=fcluster_buffer[ic]; TVector3 pos(0,0,0); double amp=0; unsigned int id=0; McIdCollection mcid; unsigned int ndigis=digis->size(); map padmap; // padmap[1]=how often pad 1 has been hit double dx; double dy; for(;idamp(); padmap[adigi->padId()]+=1; mcid.AddIDCollection(adigi->mcId(),a); TVector3 thispos; PndTpcDigiMapper::getInstance()->map(adigi,thispos); if(DEBUG) { std::cout<<"PndTpcSectorProcessor: Digi position: "; thispos.Print(); } PndTpcDigiMapper::getInstance()->padsize(adigi->padId(),dx,dy); if(DEBUG) { std::cout<<"PndTpcSectorProcessor: Got PadSize dx: " <getGas()->Dl(); double Dt = PndTpcDigiMapper::getInstance()->getGas()->Dt(); double driftl=pos.z()-PndTpcDigiMapper::getInstance()->zGem(); if(DEBUG) { std::cout<<"PndTpcSectorProcessor: Gas DiffL: "<
zGem()<amp(); TVector3 thispos; PndTpcDigiMapper::getInstance()->map(adigi,thispos); TVector3 df=thispos-pos; double sigmaX_sq = a*df.X()*df.X(); double sigmaY_sq = a*df.Y()*df.Y(); double sigmaZ_sq = a*df.Z()*df.Z(); TVector3 thissig(sigmaX_sq,sigmaY_sq,sigmaZ_sq); sig+=thissig; } // end second loop over digis //if(ndigis==1 && sig.Mag()>1E-5)sig.Print(); if(sig.X()<1E-5)sig.SetX(sqrt(dx*dx/12+diffSigmaT)); else sig.SetX(sqrt((sig.X()+fG*diffSigmaT)/amp)*fC/amp); if(sig.Y()<1E-5)sig.SetY(sqrt(dy*dy/12+diffSigmaT)); else sig.SetY(sqrt((sig.Y()+fG*diffSigmaT)/amp)*fC/amp); if(sig.Z()<1E-5)sig.SetZ(sqrt(zDiff*zDiff/12+diffSigmaL)); else sig.SetZ(sqrt((sig.Z()+fG*diffSigmaL)/amp)*fC/amp); if(DEBUG && ndigis==1){ sig.Print(); } PndTpcCluster* cl=new PndTpcCluster(pos,sig,amp,ic,ndigis); mcid.Renormalize(); cl->SetMcId(mcid); cl->nPad(padmap.size()); //set link (temporary solution) //if(!fDataMode) //cl->SetLink(FairLink("MCTrack", mcid.DominantID().mctrackID())); // loop again over the digis to calculate 2nd moment TMatrixD cov(3,3); for(id=0;idmap(adigi,thispos); TMatrixD c(3,1); for(int i=0; i<3; ++i)c[i][0]=thispos[i]-pos[i]; TMatrixD c_t(TMatrixD::kTransposed,c); TMatrixD acov(c,TMatrixD::kMult,c_t); cov+=acov; cl->addDigi(adigi); } cov*=1./(double)ndigis; cl->SetCov(cov); cl->SetSector(fSectorId); foutput_buffer->push_back(cl); } }