source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/lightsources/src/EAtmosphereSingleAdder.cc @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 3.3 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: EAtmosphereSingleAdder.cc 2768 2006-11-15 15:51:28Z moreggia $
3// Author: Anne Stutz   Aug,  9 2004
4
5#include "EAtmosphereSingleAdder.hh"
6#include "EEvent.hh"
7#include "EAtmosphere.hh"
8#include "SinglePhoton.hh"
9
10#include <stdexcept>
11
12#include "ESinglePhoton.hh"
13#include "EBunchPhotons.hh"
14
15ClassImp(EAtmosphereSingleAdder)
16
17//_____________________________________________________________________________
18EAtmosphereSingleAdder::EAtmosphereSingleAdder(const SinglePhoton* ph, Bool_t news, Bool_t fromb, Int_t count) : EFiller("EAtmosphere"){
19    //
20    // Constructor
21    //
22    fSingle = ph;
23    fNewSingle = news;
24    fFromBunch = fromb;
25    fCounter = count;
26}
27
28//_____________________________________________________________________________
29EAtmosphereSingleAdder::~EAtmosphereSingleAdder() {
30    //
31    // Destructor
32    //
33}
34
35//_____________________________________________________________________________
36void EAtmosphereSingleAdder::Fill( EFillable* f) {
37    //
38    // fill the root file
39    //
40    EAtmosphere *atm = (EAtmosphere*)f;
41
42    if ( !fSingle ) return;
43   
44    if ( fNewSingle ) {
45        // new single photon
46        if(fCounter !=0 ) throw runtime_error("EAtmosphereSingleAdder cannot add a new Single Photon");
47        atm->fNumSingles++;
48        new ( (*(atm->fSingles))[atm->fNumSingles-1] ) ESinglePhoton() ;
49
50        // single parameters at the creation point
51        ESinglePhoton& sp = *(ESinglePhoton*)(*(atm->fSingles))[atm->fNumSingles-1];
52
53        sp.SetType( fSingle->Type() );
54        sp.SetWl( fSingle->Wl() );
55        sp.SetShowerPos( fSingle->ShowerPos() );
56        sp.SetShowerAge( fSingle->ShowerAge() );
57        sp.SetPos( fSingle->Pos() );
58        sp.SetMScatDir( fSingle->MScatDir() );
59        sp.SetHistory( fSingle->Status() );
60        sp.SetDate( fSingle->Date() );
61        sp.SetBunchId( fSingle->BunchId() );
62        sp.SetAbsorbed(false);
63        sp.SetCloudAbsorbed(false);
64        sp.SetOutFoV(false);
65        sp.SetTof(fSingle->Tof());
66        sp.SetNbinter(fSingle->NbOfInteractions());
67        sp.SetNbMaxInter(atm->GetMaxScatOrder());
68       
69        // single photon obtained from a bunch
70        if ( fFromBunch ) {
71            EBunchPhotons& bp = *(EBunchPhotons*)(*(atm->fBunches))[fSingle->BunchId()-1];
72            bp.AddSingleRef(&sp);
73            if(sp.GetBunchId() != bp.GetId()) throw runtime_error("<EAtmosphereSingleAdder::Fill> -> wrong identification Single/Bunch");
74        }
75   }
76
77    else {
78        if ( fCounter > (atm->fNumSingles) ) throw runtime_error("EAtmosphereSingleAdder fCounter greater than fNumsingles");
79        fCounter++;
80        ESinglePhoton& sp = *(ESinglePhoton*)(*(atm->fSingles))[fCounter-1];
81        sp.SetTof(fSingle->Tof());
82        if(fSingle->IsAbsorbed()) sp.SetAbsorbed();
83        if(fSingle->IsCloudAbsorbed()) sp.SetCloudAbsorbed();
84        if(fSingle->IsOutFoV()) sp.SetOutFoV();
85        sp.SetNbinter(fSingle->NbOfInteractions());
86        if(atm->GetMaxScatOrder() > 0) for(UInt_t m=0; m<fSingle->GetHistories().size();m++) sp.SetAllHistory(m,fSingle->GetHistories()[m]);
87        sp.SetLastTrans(fSingle->GetLastTrans("tot"),TString("tot"));
88        sp.SetLastTrans(fSingle->GetLastTrans("rayl"),TString("rayl"));
89        sp.SetLastTrans(fSingle->GetLastTrans("ozone"),TString("ozone"));
90        sp.SetLastTrans(fSingle->GetLastTrans("aero"),TString("aero"));
91        sp.SetLastTrans(fSingle->GetLastTrans("cloud"),TString("cloud"));
92    }
93}
Note: See TracBrowser for help on using the repository browser.