#include "PndTorinoDetectorHitProducerSmearing.h" #include "PndTorinoDetectorPoint.h" #include "PndTorinoDetectorHit.h" #include "TClonesArray.h" #include "TRandom.h" // ---- Default constructor ------------------------------------------- PndTorinoDetectorHitProducerSmearing::PndTorinoDetectorHitProducerSmearing() : FairTask("PndTorinoDetectorHitProducerSmearing"), fPointsArray(NULL), fHitsArray(new TClonesArray("PndTorinoDetectorHit",100)) { fLogger->Debug(MESSAGE_ORIGIN,"Defaul Constructor of PndTorinoDetectorHitProducerSmearing"); } // ---- Destructor ---------------------------------------------------- PndTorinoDetectorHitProducerSmearing::~PndTorinoDetectorHitProducerSmearing() { fLogger->Debug(MESSAGE_ORIGIN,"Destructor of PndTorinoDetectorHitProducerSmearing"); fHitsArray->Delete(); delete fHitsArray; } // ---- Initialisation ---------------------------------------------- void PndTorinoDetectorHitProducerSmearing::SetParContainers() { fLogger->Debug(MESSAGE_ORIGIN,"SetParContainers of PndTorinoDetectorHitProducerSmearing"); // Load all necessary parameter containers from the runtime data base /* FairRunAna* ana = FairRunAna::Instance(); FairRuntimeDb* rtdb=ana->GetRuntimeDb(); = (*) (rtdb->getContainer("")); */ } // ---- Init ---------------------------------------------------------- InitStatus PndTorinoDetectorHitProducerSmearing::Init() { fLogger->Debug(MESSAGE_ORIGIN,"Initilization of PndTorinoDetectorHitProducerSmearing"); // Get a handle from the IO manager FairRootManager* ioman = FairRootManager::Instance(); // Get a pointer to the previous already existing data level fPointsArray = (TClonesArray*) ioman->GetObject("PndTorinoDetectorPoint"); if ( ! fPointsArray ) { fLogger->Error(MESSAGE_ORIGIN,"No InputDataLevelName array!\n PndTorinoDetectorHitProducerSmearing will be inactive"); return kERROR; } // Create the TClonesArray for the output data and register // it in the IO manager ioman->Register("PndTorinoDetectorHit","PndTorinoDetector",fHitsArray,kTRUE); // Do whatever else is needed at the initilization stage // Create histograms to be filled // initialize variables return kSUCCESS; } // ---- ReInit ------------------------------------------------------- InitStatus PndTorinoDetectorHitProducerSmearing::ReInit() { fLogger->Debug(MESSAGE_ORIGIN,"Initilization of PndTorinoDetectorHitProducerSmearing"); return kSUCCESS; } // ---- Exec ---------------------------------------------------------- void PndTorinoDetectorHitProducerSmearing::Exec(Option_t* option) { fLogger->Debug(MESSAGE_ORIGIN,"Exec of PndTorinoDetectorHitProducerSmearing"); fHitsArray->Delete(); // fill the map PndTorinoDetectorPoint *point = NULL; PndTorinoDetectorHit *hit = NULL; for(int iPoint = 0; iPoint < fPointsArray->GetEntriesFast(); iPoint++) { point = (PndTorinoDetectorPoint*) fPointsArray->At(iPoint); if(!point) continue; TVector3 position; point->Position(position); TVector3 dposition; // simulate the detector response: smear position with gaussians dposition.SetXYZ(0.05, 0.05, 0.); position.SetXYZ(gRandom->Gaus(position.X(), 0.05), gRandom->Gaus(position.Y(), 0.05), position.Z()); hit = new ((*fHitsArray)[iPoint]) PndTorinoDetectorHit(point->GetDetectorID(), iPoint, position, dposition, point->GetPlane()); } } // ---- Finish -------------------------------------------------------- void PndTorinoDetectorHitProducerSmearing::Finish() { fLogger->Debug(MESSAGE_ORIGIN,"Finish of PndTorinoDetectorHitProducerSmearing"); } ClassImp(PndTorinoDetectorHitProducerSmearing)