///______________________________________________________________________________ ///______________________________________________________________________________ /// /// /// RESTSoft : Software for Rare Event Searches with TPCs /// /// TRestTrackPETAnalysisProcess.cxx /// /// /// First implementation of Geant4 analysis process into REST_v2 /// Date : dec/2017 /// Author : G. Luzón /// ///_______________________________________________________________________________ #include "TRestTrackPETAnalysisProcess.h" using namespace std; ClassImp(TRestTrackPETAnalysisProcess) //______________________________________________________________________________ TRestTrackPETAnalysisProcess::TRestTrackPETAnalysisProcess() { Initialize(); } //______________________________________________________________________________ TRestTrackPETAnalysisProcess::TRestTrackPETAnalysisProcess( char *cfgFileName ) { Initialize(); if( LoadConfigFromFile( cfgFileName ) ) LoadDefaultConfig( ); } //______________________________________________________________________________ TRestTrackPETAnalysisProcess::~TRestTrackPETAnalysisProcess() { delete fTrackEvent; } void TRestTrackPETAnalysisProcess::LoadDefaultConfig() { SetTitle( "Default config" ); } //______________________________________________________________________________ void TRestTrackPETAnalysisProcess::Initialize() { SetSectionName( this->ClassName() ); fTrackEvent = new TRestTrackEvent(); fOutputEvent = fTrackEvent; fInputEvent = fTrackEvent; } void TRestTrackPETAnalysisProcess::LoadConfig( std::string cfgFilename, std::string name ) { if( LoadConfigFromFile( cfgFilename, name ) ) LoadDefaultConfig( ); } //______________________________________________________________________________ void TRestTrackPETAnalysisProcess::InitProcess() { std::vector fObservables; fObservables = TRestEventProcess::ReadObservables(); } //______________________________________________________________________________ void TRestTrackPETAnalysisProcess::BeginOfEventProcess() { } //______________________________________________________________________________ TRestEvent* TRestTrackPETAnalysisProcess::ProcessEvent( TRestEvent *evInput ) { *fTrackEvent = *(( TRestTrackEvent *) evInput); TString obsName; TVector3 pos1, pos2; Double_t en1=0,en2=0; Int_t nTracks = 0; Int_t petTracks=0; Int_t petEvent=0; Double_t enTrack; for( int tck = 0; tck < fTrackEvent->GetNumberOfTracks(); tck++ ) { if( !fTrackEvent->isTopLevel( tck ) ) continue; TRestTrack *t = fTrackEvent->GetTrack( tck ); Double_t en = t->GetEnergy( ); if ((en>fPetThresEnergy)&&(en<515)) { petTracks++; if (petTracks==1) { pos1=t->GetMeanPosition(); en1=en; } if (petTracks==2) { pos2=t->GetMeanPosition(); en2=en; petEvent=1; } } //Analysis for 2 and 4 boxes it has to be adapted in case of different configurations if(petEvent==1) { if(((pos1.Z()*pos1.Z())>(fPetInnerSizeZ*fPetInnerSizeZ))&&((pos2.Z()*pos2.Z())>(fPetInnerSizeZ*fPetInnerSizeZ))) { if((pos1.Z()*pos2.Z())<0) petEvent=1; else petEvent=0; } else if(((pos1.Z()*pos1.Z())<(fPetInnerSizeZ*fPetInnerSizeZ))&&((pos2.Z()*pos2.Z())<(fPetInnerSizeZ*fPetInnerSizeZ))) { if((pos1.X()*pos2.X())<0) petEvent=1; else petEvent=0; } else petEvent=0; } enTrack+=en; nTracks++; } obsName = this->GetName() + (TString) ".nTracks"; fAnalysisTree->SetObservableValue( obsName, nTracks ); obsName = this->GetName() + (TString) ".nPetTracks"; fAnalysisTree->SetObservableValue( obsName, petTracks ); obsName = this->GetName() + (TString) ".TracksEnergy"; fAnalysisTree->SetObservableValue( obsName, enTrack ); obsName = this->GetName() + (TString) ".Track1Energy"; fAnalysisTree->SetObservableValue( obsName, en1 ); obsName = this->GetName() + (TString) ".Track2Energy"; fAnalysisTree->SetObservableValue( obsName, en2 ); obsName = this->GetName() + (TString) ".Pos1X"; fAnalysisTree->SetObservableValue( obsName, pos1.X() ); obsName = this->GetName() + (TString) ".Pos1Y"; fAnalysisTree->SetObservableValue( obsName, pos1.Y() ); obsName = this->GetName() + (TString) ".Pos1Z"; fAnalysisTree->SetObservableValue( obsName, pos1.Z() ); obsName = this->GetName() + (TString) ".Pos2X"; fAnalysisTree->SetObservableValue( obsName, pos2.X() ); obsName = this->GetName() + (TString) ".Pos2Y"; fAnalysisTree->SetObservableValue( obsName, pos2.Y() ); obsName = this->GetName() + (TString) ".Pos2Z"; fAnalysisTree->SetObservableValue( obsName, pos2.Z() ); if(petEvent==1) return fTrackEvent; else return NULL; } //______________________________________________________________________________ void TRestTrackPETAnalysisProcess::EndOfEventProcess() { } //______________________________________________________________________________ void TRestTrackPETAnalysisProcess::EndProcess() { // Function to be executed once at the end of the process // (after all events have been processed) //Start by calling the EndProcess function of the abstract class. //Comment this if you don't want it. //TRestEventProcess::EndProcess(); } //______________________________________________________________________________ void TRestTrackPETAnalysisProcess::InitFromConfigFile( ) { fPetThresEnergy = GetDblParameterWithUnits( "petThresholdEnergy", 1 ); fPetInnerSizeZ = GetDblParameterWithUnits( "petInnerSizeZ", 1 ); fPetInnerSizeX = GetDblParameterWithUnits( "petInnerSizeX", 1 ); }