// ESAF : Euso Simulation and Analysis Framework
// $Id: EAtmosphereBunchAdder.cc,v 1.15 2005/02/11 15:30:46 moreggia Exp $
// Author: Anne Stutz Jul, 27 2004
#include "EAtmosphereBunchAdder.hh"
#include "EEvent.hh"
#include "BunchOfPhotons.hh"
#include <stdexcept>
#include "EBunchPhotons.hh"
ClassImp(EAtmosphereBunchAdder)
//_____________________________________________________________________________
EAtmosphereBunchAdder::EAtmosphereBunchAdder(const BunchOfPhotons* bph, Bool_t newb) : EFiller("EAtmosphere") {
//
// Constructor
//
fBunch = bph;
fNewBunch = newb;
}
//_____________________________________________________________________________
EAtmosphereBunchAdder::~EAtmosphereBunchAdder() {
//
// Destructor
//
}
//_____________________________________________________________________________
void EAtmosphereBunchAdder::Fill( EFillable* f) {
//
// fill the root file, EBunchPhotons part, before and after the bunch propagation
//
EAtmosphere *atm = (EAtmosphere*)f;
if ( !fBunch ) return;
if ( fNewBunch ) {
// bunch parameters at the creation point
atm->fNumBunches++;
new ( (*(atm->fBunches))[atm->fNumBunches-1] ) EBunchPhotons() ;
}
EBunchPhotons& bp = *(EBunchPhotons*)(*(atm->fBunches))[atm->fNumBunches-1];
if ( fNewBunch ) {
const ParentBunch* parentb = fBunch->GetParent();
bp.SetYield( parentb->GetYield() );
bp.SetDatei( parentb->GetDatei() );
bp.SetDatef( parentb->GetDatef() );
bp.SetShowerPosi( parentb->GetShowerPosi() );
bp.SetShowerPosf( parentb->GetShowerPosf() );
bp.SetType( fBunch->GetType() );
bp.SetId( fBunch->GetId() );
bp.SetWeight ( fBunch->GetWeight() );
bp.SetFinalPos( fBunch->GetShowerPos() );
bp.SetFate(0);
Int_t n = fBunch->GetNbins();
Float_t wls[n];
for (Int_t i(0); i<n; i++)
wls[i] = fBunch->GetWlSpectrum().GetLambdaEntry(i);
bp.SetSpectrum(n,wls,fBunch->GetWlSpectrum().GetIntegral()); // weight array is interanlly generated from integral array
if (fBunch->GetDir().Mag() == 0) {
bp.SetFlagDir(false);
bp.SetMeanDirTheta(-100);
bp.SetMeanDirPhi(-100);
}
else {
if(bp.GetId() != fBunch->GetId())
Warning("EAtmosphereBunchAdder::Fill()","Wrong bunch identification"); //TOFIX: could happen if bunch splitting..
bp.SetFlagDir(true);
bp.SetMeanDirTheta( fBunch->GetDir().Theta() );
bp.SetMeanDirPhi(fBunch->GetDir().Phi() );
}
}
else {
bp.SetFinalPos(fBunch->GetPos());
bp.SetFate(fBunch->GetFate());
}
}