Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changes/352.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Bug fix: non-XGB jobs no longer probe XGB sidecar files (E4)

XGB sidecar files (stereo and gamma-hadron) are now opened only when the active
reconstruction method and gamma-hadron cut type actually require them, eliminating
spurious ROOT file-open errors in non-XGB jobs.
2 changes: 2 additions & 0 deletions inc/CData.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CData
vector< double > fTelX;
vector< double > fTelY;
vector< double > fTelZ;
string fDataFileName;

void reconstruct_3tel_images( long unsigned int );
void reconstruct_3tel_images_direction();
Expand Down Expand Up @@ -280,6 +281,7 @@ class CData
float get_Yoff( unsigned int method );
void initialize_xgb_tree();
TTree* getXGBTree( string file_name, string suffix, string tree_name );
bool loadGHXGBTree( string gh_suffix );
pair<float, float> get_XYoff_derot( unsigned int method );
virtual Long64_t LoadTree( Long64_t entry );
float get_GH_Gamma_Prediction();
Expand Down
23 changes: 23 additions & 0 deletions src/CData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CData::CData( TTree* tree, bool bMC, bool bShort, string file_name, string stere
fShort = bShort;
fVersion = 6;
fTelescopeCombination = 0;
fDataFileName = file_name;
Init( tree );

fStereoFriendTree = getXGBTree( file_name, stereo_suffix, "StereoAnalysis" );
Expand Down Expand Up @@ -1126,3 +1127,25 @@ void CData::initialize_xgb_tree()
GH_Is_Gamma = false;
}
}

/*
* Deferred loading of the XGB gamma-hadron friend tree.
* Call this after the analysis type is known (e.g. after readCuts()),
* when the caller has confirmed that XGB gamma-hadron cuts are active.
* Idempotent: a second call is a no-op if the tree is already loaded.
*/
bool CData::loadGHXGBTree( string gh_suffix )
{
if( fGHFriendTree )
{
return true;
}
if( fDataFileName.empty() )
{
cout << "CData::loadGHXGBTree error: no data file name stored" << endl;
return false;
}
fGHFriendTree = getXGBTree( fDataFileName, gh_suffix, "Classification" );
initialize_xgb_tree();
return ( fGHFriendTree != 0 );
}
13 changes: 11 additions & 2 deletions src/VStereoAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,14 @@ double VStereoAnalysis::fillHistograms( int icounter, int irun, double iAzMin, d
// initialize cuts
setCuts( fRunPara->fRunList[fHisCounter], irun );

// load XGB gamma-hadron friend tree now that the analysis type is known
if( fCuts && fCuts->useXGBoostCuts()
&& fDataRun
&& !fRunPara->fXGB_gh_file_suffix.empty() )
{
fDataRun->loadGHXGBTree( fRunPara->fXGB_gh_file_suffix );
}

// define histograms
fDirTotRun[fHisCounter]->cd();
fHisto[fHisCounter]->setRunNumber( irun );
Expand Down Expand Up @@ -1967,8 +1975,9 @@ CData* VStereoAnalysis::getDataFromFile( int i_runNumber )
false,
false,
iFileName,
fRunPara->fXGB_stereo_file_suffix,
fRunPara->fXGB_gh_file_suffix
( fRunPara->fEnergyReconstructionMethod == 2 || fRunPara->fDirectionReconstructionMethod == 2 )
? fRunPara->fXGB_stereo_file_suffix : "",
"" // GH XGB tree loaded later, after analysis type is known from cut file
);
// read current (major) epoch from data file
VEvndispRunParameter* i_runPara = ( VEvndispRunParameter* )fDataFile->Get( "runparameterV2" );
Expand Down
6 changes: 5 additions & 1 deletion src/makeEffectiveArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ int main( int argc, char* argv[] )
exit( EXIT_FAILURE );
}

CData d( c, true, false, fRunPara->fdatafile, fRunPara->fXGB_stereo_file_suffix, fRunPara->fXGB_gh_file_suffix );
const bool i_need_stereo_xgb = ( fRunPara->fEnergyReconstructionMethod == 2
|| fRunPara->fDirectionReconstructionMethod == 2 );
CData d( c, true, false, fRunPara->fdatafile,
i_need_stereo_xgb ? fRunPara->fXGB_stereo_file_suffix : "",
fCuts->useXGBoostCuts() ? fRunPara->fXGB_gh_file_suffix : "" );
d.initialize_3tel_reconstruction(
fRunPara->fRerunStereoReconstruction_3telescopes,
fRunPara->fRerunStereoReconstruction_minAngle,
Expand Down
Loading