// ESAF : Euso Simulation and Analysis Framework
// $Id: EDetectorPhotonAdder.cc,v 1.3 2005/02/13 23:23:03 thea Exp $
// Alessandro Thea created Oct, 24 2003
#include "EDetectorPhotonAdder.hh"
#include "EEvent.hh"
#include "Etypes.hh"
#include "Photon.hh"
#include "PmtSignal.hh"
#include "ParentPhoton.hh"
#include "EDetPhoton.hh"
ClassImp(EDetectorPhotonAdder)
//______________________________________________________________________________
EDetectorPhotonAdder::EDetectorPhotonAdder(Photon* ph, PmtSignal* s, Bool_t newph)
: EFiller("EDetector") {
// ctor
fPhoton = ph;
fSignal = s;
fNewPh = newph;
}
//______________________________________________________________________________
EDetectorPhotonAdder::~EDetectorPhotonAdder() {
// dtor
}
//______________________________________________________________________________
void EDetectorPhotonAdder::Fill( EFillable* f ) {
// filler
EDetector *det = (EDetector*)f;
if ( !fPhoton ) return;
if ( fNewPh ) {
if ( det->IsPhotonFillable() )
// if photons filling is enabled add a new ph
new ( (*(det->fPhotons))[det->fNumPhotons++] ) EDetPhoton();
// otherwise save only the time of the first and the last one
if ( fPhoton->time < det->fFirstTime )
det->fFirstTime = fPhoton->time;
if ( fPhoton->time > det->fLastTime )
det->fLastTime = fPhoton->time;
}
// if photons are disabled return
if ( !det->IsPhotonFillable() ) return;
EDetPhoton& p = *(EDetPhoton*)(*(det->fPhotons))[det->fNumPhotons-1];
// photon params at the pupil
if ( fNewPh ) {
p.fType = fPhoton->parent->Type(); // type of photon
p.fStatusBits = 0; // flag to know if phtoton has generated signal
p.fShowerPosX = fPhoton->parent->ShowerPos()[X]; // X position of origin in shower
p.fShowerPosY = fPhoton->parent->ShowerPos()[Y]; // Y position of origin in shower
p.fShowerPosZ = fPhoton->parent->ShowerPos()[Z]; // Z position of origin in shower
p.fTheta = fPhoton->dir.Theta(); // photon theta direction in Euso detector
p.fPhi = fPhoton->dir.Phi(); // " phi " " " "
p.fLambda = fPhoton->wl; // photon wavelength
p.fTime = fPhoton->time; // photon time (detection)
p.fPosX = kHuge; // X position of hit in focal surface
p.fPosY = kHuge; // Y position of hit in focal surface
p.fPosZ = kHuge; // Z position of hit in focal surface
p.fIdealFocalPosX = kHuge; // X position of hit in focal surface
p.fIdealFocalPosY = kHuge; // Y position of hit in focal surface
p.fIdealFocalPosZ = kHuge; // Z position of hit in focal surface
p.fSignalId = -1; // id of pmt signal
p.fCharge = -1.e-12; // charge in C
p.fIPeak = -1.e-6; // peak current in Amps
p.fHistory = kNotInside; // code of the last position
p.fFate = 0; // 0 until the photon is alive
p.fMacroCell = 0; // macrocell id (starts from 1)
p.fFe = 0; // front end chip id (starts from 1)
p.fXCell = -1; // macrocell X coordinate
p.fYCell = -1; // macrocell Y coordinate
p.fGtu = -1; // gtu reldetant for this photon
p.fPixelUID = -1; // unique id of hit pixel
}
// impact point on focal plane
if ( fPhoton ) {
p.fPosX = fPhoton->pos[X];
p.fPosY = fPhoton->pos[Y];
p.fPosZ = fPhoton->pos[Z];
p.fIdealFocalPosX = fPhoton->posOnIfs[X];
p.fIdealFocalPosY = fPhoton->posOnIfs[Y];
p.fIdealFocalPosZ = fPhoton->posOnIfs[Z];
if ( fPhoton->hitIfs ) p.SetCrossedIFS();
p.fHistory = fPhoton->history;
p.fPixelUID = fPhoton->pixelUid;
p.fFate = fPhoton->fate;
}
// pmt response
if ( fSignal ) {
p.SetMadeSignal();
p.fSignalId = fSignal->Id();
p.fCharge = fSignal->Charge();
p.fIPeak = fSignal->Current(fSignal->Time());
p.fSignalTime = fSignal->Time();
}
}