Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

XmaxModule - source file

// ESAF : Euso Simulation and Analysis Framework
// $Id: XmaxModule.cc,v 1.8 2005/10/02 14:18:08 thea Exp $
// Naumov Dmitry created Jul,  4 2004

#include "XmaxModule.hh"
#include "RecoRootEvent.hh"
#include "RecoEvent.hh"
#include "EarthVector.hh"
#include "Atmosphere.hh"

using namespace sou;

ClassImp(XmaxModule)

//_____________________________________________________________________________
 XmaxModule::XmaxModule()  : RecoModule("Xmax"){
    // ctor
    
}

//_____________________________________________________________________________
 XmaxModule::~XmaxModule() {
    // dtor
}

//_____________________________________________________________________________
 Bool_t XmaxModule::Init() {
    Msg(EsafMsg::Info) << "Initializing " << MsgDispatch;
    return kTRUE;
}

//_____________________________________________________________________________
 Bool_t XmaxModule::PreProcess() {
    fAltitude = 100;
    fAltitudeProton = 100;
    return kTRUE;
}

//_____________________________________________________________________________
 Bool_t XmaxModule::Process(RecoEvent *ev) {
    const RecoModuleData *td = ev->GetModuleData("TrackDirection");
    if ( td == NULL ) td = ev->GetModuleData("TrackDirection2"); // try to get TrackDirection2
    if ( td==NULL ) {
        Msg(EsafMsg::Panic) << "None of TrackDirectionModule and TrackDirectionModule2 is found." << MsgDispatch;	    
    }
    fTheta    = td->GetDouble("Theta");
    fPhi      = td->GetDouble("Phi");
    const RecoModuleData *hsm = ev->GetModuleData("HmaxByShapeMethod");
    const RecoModuleData *hpr = ev->GetModuleData("HmaxForProton");
    if ( hsm == NULL &&  hpr == NULL) {
        Msg(EsafMsg::Panic) << "Not found neither HmaxForProtonModule nor HmaxByShapeMethodModule." << MsgDispatch;
    }
    if ( hsm != NULL) 
        fAltitude   = hsm->GetDouble("Altitude");
    if ( hpr != NULL) 
        fAltitudeProton = hpr->GetDouble("Altitude");
    fXmax = Atmosphere::Get()->Depth(fAltitude*km,fTheta)*cm2/g;
    fXmaxP = Atmosphere::Get()->Depth(fAltitudeProton*km,fTheta)*cm2/g;
    MyData()->Add("Xmax",fXmax);
    MyData()->Add("XmaxProton",fXmaxP);
    Msg(EsafMsg::Debug) << "Xmax: " << fXmax << "fAltitude: " << fAltitude << "XmaxProton: " << fXmaxP << "fAltitudeProton:" << fAltitudeProton << MsgDispatch;
    return kTRUE;
}

//_____________________________________________________________________________
 Bool_t XmaxModule::PostProcess() {
    return kTRUE;
}

//_____________________________________________________________________________
 Bool_t XmaxModule::SaveRootData(RecoRootEvent *fRecoRootEvent) {
    fRecoRootEvent->GetRecoXmax().SetXmax(fXmax);
    fRecoRootEvent->GetRecoXmax().SetXmaxProton(fXmaxP);
    Double_t XmaxError  = fRecoRootEvent->GetTruth().GetXmax() - fXmax;
    Double_t XmaxErrorP = fRecoRootEvent->GetTruth().GetXmax() - fXmaxP;
    fRecoRootEvent->GetRecoXmax().SetErrorXmax(XmaxError);
    fRecoRootEvent->GetRecoXmax().SetErrorXmaxProton(XmaxErrorP);
    fRecoRootEvent->GetRecoXmax().SetQuality(1);
     
    return kTRUE;
}
//_____________________________________________________________________________
 Bool_t XmaxModule::Done() {
    Msg(EsafMsg::Info) << "Completed" << MsgDispatch;
    return kTRUE;
}

 void XmaxModule::UserMemoryClean()  {
    
}
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