Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

EAtmosphereBunchAdder - source file

// ESAF : Euso Simulation and Analysis Framework
// $Id: EAtmosphereBunchAdder.cc,v 1.18 2005/08/01 09:29:57 moreggia Exp $
// Author: Anne Stutz   Jul, 27 2004

#include "EAtmosphereBunchAdder.hh"
#include "EEvent.hh"
#include "EAtmosphere.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.SetMeanDir( fBunch->GetDir() );
        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(bp.GetId() != fBunch->GetId()) Warning("EAtmosphereBunchAdder::Fill()","Wrong bunch identification"); //TOFIX: could happen if bunch splitting..
    }
    
    else {
        bp.SetFinalPos(fBunch->GetPos());
        bp.SetFate(fBunch->GetFate());	
    }
}
About Us | EUSO Official Website | Web pages created by Roberto Pesce and Alessandro Thea - Last Update Wed Nov 16 16:57:39 2005 Wed Nov 16 16:29:22 2005