//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class TpcGemTask // see TpcGemTask.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 "TpcGemTask.h" // C/C++ Headers ---------------------- // Collaborating Class Headers -------- #include "CbmRootManager.h" #include "TClonesArray.h" #include "TRandom.h" #include "TpcDriftedElectron.h" #include "TpcAvalanche.h" // Class Member definitions ----------- TpcGemTask::TpcGemTask() : CbmTask("TPC Gem"), _persistence(kFALSE) { _driftedBranchName = "TpcDriftedElectron"; } TpcGemTask::~TpcGemTask() {} InitStatus TpcGemTask::Init() { //Get ROOT Manager CbmRootManager* ioman= CbmRootManager::Instance(); if(ioman==0) { Error("TpcGemTask::Init","RootManager not instantiated!"); return kERROR; } // Get input collection _driftedArray=(TClonesArray*) ioman->GetObject(_driftedBranchName); if(_driftedArray==0) { Error("TpcGemTask::Init","DriftedElectron-array not found!"); return kERROR; } // create and register output array _avalancheArray = new TClonesArray("TpcAvalanche"); ioman->Register("TpcAvalanche","Tpc",_avalancheArray,_persistence); _gain=5000; // TODO: get from database! return kSUCCESS; } void TpcGemTask::Exec(Option_t* opt) { // Reset output Array if(_avalancheArray==0) Fatal("TpcPrimCluster::Exec)","No AvalancheArray"); _avalancheArray->Delete(); Int_t counter=0; Int_t nd=_driftedArray->GetEntriesFast(); std::cout<<"Aggregating drifted electrons into avalanches "; // loop over drifted electrons for(Int_t id=0;idAt(id); int na=_avalancheArray->GetEntriesFast(); // look if there is already an avalanche where we can put this electron bool found=false; if(na%1000==0)std::cout<<".";std::cout.flush(); for(int ia=0; iaAt(ia); // calculate distance in t and cut double dt=e->t()-a->t(); if(fabs(dt)>20) { //std::cout<<"t cut"<ns } // calculate distance in xy and cut double dx=a->x()-e->x(); double dy=a->y()-e->y(); double dr=sqrt(dx*dx+dy*dy); if(dr>0.1) { //std::cout<<"dr cut"<1mm } // if electron survived enlarge amplitude of avalanche a->addAmp(_gain); found=true; ++counter; //std::cout<<"Combined an electron into an existing avalanche"<x(), e->y(), e->t(), _gain, e); } } // end loop over drifted electrons std::cout<<" finished."<GetEntriesFast() <<" Avalanches created"<