//----------------------------------------------------------- // 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 "FairRootManager.h" #include "TClonesArray.h" #include "TRandom.h" #include "TpcDriftedElectron.h" #include "TpcAvalanche.h" #include "TpcGem.h" #include "FairRunAna.h" #include "FairRuntimeDb.h" #include "TpcDigiPar.h" #include "PndDetectorList.h" #include #include using std::log; // Class Member definitions ----------- TpcGemTask::TpcGemTask() : FairTask("TPC Gem", 0), fpersistence(kFALSE), fgainFluctuations(kFALSE), finitialized(kFALSE),fgain(1) { fdriftedBranchName = "TpcDriftedElectron"; } TpcGemTask::~TpcGemTask() {} void TpcGemTask::SetParContainers() { std::cout<<"TpcGemTask::SetParContainers"<GetRuntimeDb(); if ( ! db ) Fatal("SetParContainers", "No runtime database"); // Get Tpc digitisation parameter container fpar= (TpcDigiPar*) db->getContainer("TpcDigiPar"); if (! fpar ) Fatal("SetParContainers", "TpcDigiPar not found"); } InitStatus TpcGemTask::Init() { finitialized=false; //Get ROOT Manager FairRootManager* ioman= FairRootManager::Instance(); if(ioman==0) { Error("TpcGemTask::Init","RootManager not instantiated!"); return kERROR; } // Get input collection fdriftedArray=(TClonesArray*) ioman->GetObject(fdriftedBranchName); if(fdriftedArray==0) { Error("TpcGemTask::Init","DriftedElectron-array not found!"); return kERROR; } // create and register output array favalancheArray = new TClonesArray("TpcAvalanche"); ioman->Register("TpcAvalanche","Tpc",favalancheArray,fpersistence); fgain=fpar->getGem()->gain(); finitialized=true; return kSUCCESS; } void TpcGemTask::Exec(Option_t* opt) { // Reset output Array if(favalancheArray==0) Fatal("TpcPrimCluster::Exec)","No AvalancheArray"); favalancheArray->Delete(); Int_t counter=0; Int_t nd=fdriftedArray->GetEntriesFast(); if (fVerbose) std::cout<<"Aggregating drifted electrons into avalanches "; // loop over drifted electrons for(Int_t id=0;idAt(id); int na=favalancheArray->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(fgain); found=true; ++counter; //std::cout<<"Combined an electron into an existing avalanche"<Uniform()); //TODO: implement full set: exp. distr. for first stage, //representing rest TpcAvalanche* myAvalanche = new ((*favalancheArray)[na]) TpcAvalanche(e->x(), e->y(), e->t(), fgain*gainFactor, e); myAvalanche->setIndex(na); //myAvalanche->SetLink(FairLink(fdriftedBranchName, id)); } } // end loop over drifted electrons if (fVerbose) { std::cout<<" finished."<GetEntriesFast() <<" Avalanches created"<