Changeset 20046 for trunk/FACT++


Ignore:
Timestamp:
03/23/21 11:25:26 (4 years ago)
Author:
tbretz
Message:
Handle an exception if a MC file does not contain MC information.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/getevent.cc

    r18969 r20046  
    214214    }
    215215
    216     float energy, impact, phi, theta;
     216    float energy=0, impact, phi, theta;
    217217    if (isMC)
    218218    {
    219         file.SetRefAddress("MMcEvtBasic.fEnergy", energy);
    220         file.SetRefAddress("MMcEvtBasic.fImpact", impact);
    221         file.SetRefAddress("MMcEvtBasic.fTelescopeTheta", theta);
    222         file.SetRefAddress("MMcEvtBasic.fTelescopePhi", phi);
     219        try
     220        {
     221            file.SetRefAddress("MMcEvtBasic.fEnergy", energy);
     222            file.SetRefAddress("MMcEvtBasic.fImpact", impact);
     223            file.SetRefAddress("MMcEvtBasic.fTelescopeTheta", theta);
     224            file.SetRefAddress("MMcEvtBasic.fTelescopePhi", phi);
     225        }
     226        catch (const std::runtime_error &)
     227        {
     228        }
    223229    }
    224230
     
    253259    cout.write((char*)data.data(),        sizeof(int16_t)*nRoi*nPix);
    254260
     261    if (energy!=0)
     262    {
     263        cout.write((char*)&energy,        sizeof(float));
     264        cout.write((char*)&impact,        sizeof(float));
     265        cout.write((char*)&phi,           sizeof(float));
     266        cout.write((char*)&theta,         sizeof(float));
     267    }
     268
    255269    return 0;
    256270}
Note: See TracChangeset for help on using the changeset viewer.