// class EusoDetector
// $Id: EusoDetector.cc,v 1.29 2005/04/01 12:47:12 thea Exp $
// M. Pallavicini - created 08-02-2002
//
#include "EusoDetector.hh"
#include "ElectronicsFactory.hh"
#include "EusoElectronics.hh"
#include "EusoMapping.hh"
#include "DetectorTransportManager.hh"
#include "PhotonsOnPupil.hh"
#include "EEvent.hh"
#include "Photomultiplier.hh"
#include "Photon.hh"
#include "ParentPhoton.hh"
#include "OpticsFactory.hh"
#include "ERunParameters.hh"
#include "ERunParsPixelMapFiller.hh"
#include "ERunParsPmtsFiller.hh"
#include <TStopwatch.h>
#include <TMath.h>
#include <zlib.h>
ClassImp(EusoDetector)
// global variable
EusoDetector *gEusoDetector = NULL;
//______________________________________________________________________________
EusoDetector::EusoDetector() : fElectronics(0), fDetectorTransporter(0) {
//
// Constructor
//
// FIXME: call the factories to get the right associate child and parent
// classes in config
ElectronicsFactory::Get();
OpticsFactory::Get();
EusoMapping::Get();
Build();
gEusoDetector = this;
}
//______________________________________________________________________________
EusoDetector::~EusoDetector() {
//
// Destructor
//
}
//______________________________________________________________________________
void EusoDetector::Build() {
//
// Build or re-build the detector
//
fElectronics = ElectronicsFactory::Get()->Build();
fDetectorTransporter = OpticsFactory::Get()->GetTransportManager();
Double_t alt = Config::Get()->GetCF("General","Euso")->GetNum("Euso.fAltitude")*km;
Double_t radius = fDetectorTransporter->GetOuterRadius();
if ( Conf()->GetBool("EusoDetector.fFixMaxRadius") )
radius = Conf()->GetNum("EusoDetector.fMaxRadius");
fGeometry.SetRadius(radius);
fGeometry.SetPos(TVector3(0,0,alt));
// save runparameters
ERunParameters *runpars = ERunParameters::GetCurrent();
if ( runpars ) {
// get from EusoMapping the config
ERunParsPixelMapFiller pxfiller;
runpars->Fill(pxfiller);
ERunParsPmtsFiller pmtfiller( fElectronics );
runpars->Fill(pmtfiller);
}
fDetectorTransporter->GetFocalPlane()->SetElectronics(fElectronics);
}
//______________________________________________________________________________
void EusoDetector::Reset() {
//
// Reset electronics
//
if ( fElectronics )
fElectronics->Reset();
}
//______________________________________________________________________________
Telemetry* EusoDetector::Get( PhotonsOnPupil* photons ) {
//
// Simulate one event and return a pointer to a Telemetry object
//
// reset previous event
Reset();
// transport photons from pupil to pmts
fDetectorTransporter->Go( photons );
Double_t tBegin = fDetectorTransporter->GetTimeFirstPhoton();
Double_t tEnd = fDetectorTransporter->GetTimeLastPhoton();
MsgForm(EsafMsg::Info,"Photon Time interval (ns):tSTART=%ld END=%ld",
(long int)(tBegin), (long int)tEnd);
// simulate electronics and trigger
if ( !fElectronics->Simulate( tBegin, tEnd ) )
return (Telemetry*)0;
// return telemetry object
return fElectronics->Data();
}