//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class TpcClusterizerTask // see TpcClusterizerTask.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 "TpcClusterizerTask.h" // C/C++ Headers ---------------------- // Collaborating Class Headers -------- #include "CbmRootManager.h" #include "TClonesArray.h" #include "TpcPoint.h" #include "TpcGas.h" #include "TRandom.h" #include "TpcPrimaryCluster.h" #include "LinearInterpolPolicy.h" // Class Member definitions ----------- TpcClusterizerTask::TpcClusterizerTask() : CbmTask("TPC Clusterizer"), _persistence(kFALSE) { _pointBranchName = "TpcPoint"; _gas= new TpcGas("NEON-90_CO2-10_B2_PRES1013.asc",400); std::cout<<*_gas<GetObject(_pointBranchName); if(_pointArray==0) { Error("TpcClusterizerTask::Init","Point-array not found!"); return kERROR; } // create and register output array _primArray = new TClonesArray("TpcPrimaryCluster"); ioman->Register("TpcPrimaryCluster","Tpc",_primArray,_persistence); return kSUCCESS; } void TpcClusterizerTask::Exec(Option_t* opt) { // Reset output Array if(_primArray==0) Fatal("TpcPrimCluster::Exec)","No PrimClusterArray"); _primArray->Delete(); TpcPoint* point; TpcPoint* theLastPoint; Int_t icluster=0; Int_t np=_pointArray->GetEntriesFast(); if(np<2){ Warning("TpcClusterizerTask::Exec","Not enough Hits in Tpc for Digitization (<2)"); return; } theLastPoint= (TpcPoint*)_pointArray->At(0); for(int ip=1;ipAt(ip); //point->Print(); //check if hits ly on the same track if(point->GetTrackID()==theLastPoint->GetTrackID()){ double dE=point->GetEnergyLoss()*1E9; //convert from GeV to eV //Step 0: calculate the overall ammount of charge, produced if(dE<0){ Error("TpcClusterizerTask::Exec","Note: particle:: negative Energy loss!"); continue; } unsigned int q_total =(unsigned int)floor(fabs(dE / _gas->W())); unsigned int q_cluster=0; unsigned int ncluster=0; //Step 1: Create Clusters //while still charge not used-up distribute charge into next cluster while(q_total>0){ //roll dice for next clustersize q_cluster=_gas->GetRandomCS(gRandom->Uniform()); if(q_cluster>q_total)q_cluster=q_total; q_total-=q_cluster; // create cluster Int_t size = _primArray->GetEntriesFast(); new((*_primArray)[size]) TpcPrimaryCluster(point->GetTime(), q_cluster, TVector3(0,0,0), point->GetTrackID(), ip); ++ncluster; }// finish loop for cluster creation //Step 2: Distribute Clusters along track segment LinearInterpolPolicy().Interpolate(theLastPoint,point,_primArray,icluster,ncluster); icluster+=ncluster; }//end check for same track theLastPoint=point; } // finish loop over GHits std::cout<<"TpcClusterizer:: "<<_primArray->GetEntriesFast()<<" clusters created"<