//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class TpcSectorProcessor // see TpcSectorProcessor.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 "TpcSectorProcessor.h" // C/C++ Headers ---------------------- #include #include "assert.h" // Collaborating Class Headers -------- #include "TpcPadPlane.h" #include "TpcDigiMapper.h" #include "TORPadProcessor.h" #include "TpcCluster.h" // Class Member definitions ----------- TpcSectorProcessor::~TpcSectorProcessor() { // clean up PadProcessors std::map::iterator ipad=_pproc.begin(); while(ipad!=_pproc.end()){ delete ipad->second; ++ipad; } _pproc.clear(); } void TpcSectorProcessor::Init(TpcPadPlane* p, unsigned int id, std::vector* ob) { _padplane=p; _SectorId=id; _output_buffer=ob; // Build PadProcessors std::map* pads=_padplane->GetSectorList(_SectorId); std::map::iterator ipad=pads->begin(); while(ipad!=pads->end()){ _pproc[ipad->second->id()]=new padprocessor(ipad->second->id()); _pproc[ipad->second->id()]->setClusterBuffer(&_cluster_buffer); ++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(_pproc[neighID]!=0){ _pproc[ipad->second->id()]->addNeighbour(_pproc[neighID]); //cout << "Pad " << ipad->second->id() << " connects to Pad " << neighID <0)std::cout<padId()<GetPad((_digi_buffer[i])->padId())->sectorId(); //std::cout<<"in sector digisid="<padId()]; assert(pp!=NULL); pp->setData(_digi_buffer[i]); // activate pad processor by putting it into active list // this way only thos pads that have been hit are processing _activepads[_digi_buffer[i]->padId()]=pp; } // run padProcessors // TODO: stop criterion, how many heartbeats???? bool GoOn=true; int counter=0; while(GoOn && counter<40){ //cout<<"beat! ***************"<::iterator ip=_activepads.begin(); for(;ip!=_activepads.end(); ++ip){ std::string nextstate=ip->second->heartbeat(); if(nextstate!="initial"){ GoOn=true; //std::cout<<"padproc_"<first<<" in state: "<::iterator ppit=_pproc.begin(); while(ppit!=_pproc.end()){ ppit->second->reset(); ++ppit; } } void TpcSectorProcessor::cog(){ assert(_padplane!=NULL); assert(_output_buffer!=NULL); // Calculate COG for(unsigned int ic=0;ic<_cluster_buffer.size();++ic){ std::vector* digis=_cluster_buffer[ic]; TVector3 pos(0,0,0); double amp=0; TVector3 sig(0,0,0); unsigned int id=0; McIdCollection mcid; unsigned int ndigis=digis->size(); for(;idmcId()); double a=(double)adigi->amp(); TVector3 thispos; double dx; double dy; TpcDigiMapper::getInstance()->padsize(adigi->padId(),dx,dy); TVector3 thissig(dx*dx/12.,dy*dy/12.,0.2); sig+=a*a*thissig; TpcDigiMapper::getInstance()->map(adigi,thispos); pos+=a*thispos; amp+=a; } pos*=1./amp; sig.SetX(sqrt(sig.X())/amp); sig.SetY(sqrt(sig.Y())/amp); sig.SetZ(sqrt(sig.Z())/amp); TpcCluster* cl=new TpcCluster(pos,sig,(unsigned int)amp,id,ndigis); cl->SetMcId(mcid.DominantID()); _output_buffer->push_back(cl); } }