Skip to content

Commit f55514a

Browse files
authored
Merge pull request #310 from VERITAS-Observatory/v492-dev3
v492 development
2 parents e5756d7 + 4391d3f commit f55514a

File tree

2 files changed

+33
-38
lines changed

2 files changed

+33
-38
lines changed

src/trainTMVAforAngularReconstruction.cpp

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,6 @@ bool writeTrainingFile( const string iInputFile, ULong64_t iTelType,
493493
{
494494
i_tel.GetEntry( i );
495495

496-
// select telescope type
497-
if( iTelType != 0 && i_tel.TelType != iTelType )
498-
{
499-
continue;
500-
}
501-
502496
if( fMapOfTrainingTree.find( i_tel.TelType ) == fMapOfTrainingTree.end() )
503497
{
504498
ostringstream iTreeName;
@@ -574,26 +568,18 @@ bool writeTrainingFile( const string iInputFile, ULong64_t iTelType,
574568
vector< Ctpars* > i_tpars;
575569
for( unsigned int i = 0; i < fTelType.size(); i++ )
576570
{
577-
if( iTelType == 0 || iTelType == fTelType[i] )
578-
{
579-
ostringstream iTreeName;
580-
iTreeName << "Tel_" << i + 1 << "/tpars";
581-
i_tparsTree.push_back( new TChain( iTreeName.str().c_str() ) );
582-
for( unsigned int f = 0; f < iInputFileList.size(); f++ )
583-
{
584-
i_tparsTree.back()->Add( iInputFileList[f].c_str(), 0 );
585-
}
586-
i_tpars.push_back( new Ctpars( i_tparsTree.back(), true, true ) );
587-
cout << "\t found tree " << iTreeName.str();
588-
cout << " (teltype " << fTelType[i] << ")";
589-
cout << ", entries: ";
590-
cout << i_tpars.back()->fChain->GetEntries() << endl;
591-
}
592-
else
571+
ostringstream iTreeName;
572+
iTreeName << "Tel_" << i + 1 << "/tpars";
573+
i_tparsTree.push_back( new TChain( iTreeName.str().c_str() ) );
574+
for( unsigned int f = 0; f < iInputFileList.size(); f++ )
593575
{
594-
i_tpars.push_back( 0 );
595-
cout << "\t ignore tree for telescope type " << fTelType[i] << endl;
576+
i_tparsTree.back()->Add( iInputFileList[f].c_str(), 0 );
596577
}
578+
i_tpars.push_back( new Ctpars( i_tparsTree.back(), true, true ) );
579+
cout << "\t found tree " << iTreeName.str();
580+
cout << " (teltype " << fTelType[i] << ")";
581+
cout << ", entries: ";
582+
cout << i_tpars.back()->fChain->GetEntries() << endl;
597583
}
598584

599585
// temporary variables for emission height calculation
@@ -686,6 +672,11 @@ bool writeTrainingFile( const string iInputFile, ULong64_t iTelType,
686672
fEM_length,
687673
fEM_weight );
688674

675+
if( i_SR.fShower_Xoffset < -90. || i_SR.fShower_Yoffset < -90. )
676+
{
677+
continue;
678+
}
679+
689680
//////////////////////////////////////
690681
// loop over all telescopes
691682
for( unsigned int i = 0; i < i_tpars.size(); i++ )
@@ -703,7 +694,6 @@ bool writeTrainingFile( const string iInputFile, ULong64_t iTelType,
703694
{
704695
continue;
705696
}
706-
707697
i_tpars[i]->GetEntry( n );
708698

709699
// check if telescope was reconstructed
@@ -718,7 +708,6 @@ bool writeTrainingFile( const string iInputFile, ULong64_t iTelType,
718708
{
719709
continue;
720710
}
721-
722711
runNumber = i_showerpars.runNumber;
723712
eventNumber = i_showerpars.eventNumber;
724713
tel = i + 1;
@@ -809,7 +798,10 @@ bool writeTrainingFile( const string iInputFile, ULong64_t iTelType,
809798

810799
if( fMapOfTrainingTree.find( fTelType[i] ) != fMapOfTrainingTree.end() )
811800
{
812-
fMapOfTrainingTree[fTelType[i]]->Fill();
801+
if( iTelType == 0 || iTelType == fTelType[i] )
802+
{
803+
fMapOfTrainingTree[fTelType[i]]->Fill();
804+
}
813805
}
814806
}
815807
}
@@ -884,7 +876,7 @@ int main( int argc, char* argv[] )
884876
iQualityCut = argv[7];
885877
}
886878
// TMVA options (default options derived from hyperparameter optimisation on CTAO prod3 simulations)
887-
string iTMVAOptions = "NTrees=100:BoostType=Grad:Shrinkage=0.1:UseBaggedBoost:GradBaggingFraction=0.5:nCuts=20:MaxDepth=10:";
879+
string iTMVAOptions = "NTrees=300:BoostType=Grad:Shrinkage=0.1:UseBaggedBoost:GradBaggingFraction=0.5:nCuts=20:MaxDepth=10:";
888880
iTMVAOptions += "PruneMethod=ExpectedError:RegressionLossFunctionBDTG=Huber:MinNodeSize=0.02:VarTransform=N";
889881
if( argc >= 9 )
890882
{
@@ -972,7 +964,7 @@ int main( int argc, char* argv[] )
972964
fMapOfTrainingTree_iter != fMapOfTrainingTree.end();
973965
++fMapOfTrainingTree_iter )
974966
{
975-
if( fMapOfTrainingTree_iter->second )
967+
if( fMapOfTrainingTree_iter->second && fMapOfTrainingTree_iter->second->GetEntries() > 0 )
976968
{
977969
cout << "\t writing training tree for telescope type " << fMapOfTrainingTree_iter->first;
978970
cout << " with " << fMapOfTrainingTree_iter->second->GetEntries() << " entries ";
@@ -987,11 +979,14 @@ int main( int argc, char* argv[] )
987979
fMapOfTrainingTree_iter != fMapOfTrainingTree.end();
988980
++fMapOfTrainingTree_iter )
989981
{
990-
trainTMVA( fOutputDir, fTrainTest,
991-
fMapOfTrainingTree_iter->first,
992-
fMapOfTrainingTree_iter->second,
993-
iTargetML, iTMVAOptions, iQualityCut,
994-
iWeightExpression );
982+
if( fMapOfTrainingTree_iter->second && fMapOfTrainingTree_iter->second->GetEntries() > 0 )
983+
{
984+
trainTMVA( fOutputDir, fTrainTest,
985+
fMapOfTrainingTree_iter->first,
986+
fMapOfTrainingTree_iter->second,
987+
iTargetML, iTMVAOptions, iQualityCut,
988+
iWeightExpression );
989+
}
995990
}
996991

997992
//////////////////////

src/trainTMVAforGammaHadronSeparation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ TTree* prepareSelectedEventsTree( VTMVARunData* iRun, TCut iCut,
6969
Double_t Az = 0.;
7070
Double_t WobbleN = 0;
7171
Double_t WobbleE = 0;
72-
Double_t MSCW = 0.;
73-
Double_t MSCL = 0.;
72+
Float_t MSCW = 0.;
73+
Float_t MSCL = 0.;
7474
Float_t ErecS = 0.;
7575
Float_t EChi2S = 0.;
7676
Double_t Xcore = 0.;
@@ -89,8 +89,8 @@ TTree* prepareSelectedEventsTree( VTMVARunData* iRun, TCut iCut,
8989
iDataTree_reduced->Branch( "Az", &Az, "Az/D" );
9090
iDataTree_reduced->Branch( "WobbleN", &WobbleN, "WobbleN/D" );
9191
iDataTree_reduced->Branch( "WobbleE", &WobbleE, "WobbleE/D" );
92-
iDataTree_reduced->Branch( "MSCW", &MSCW, "MSCW/D" );
93-
iDataTree_reduced->Branch( "MSCL", &MSCL, "MSCL/D" );
92+
iDataTree_reduced->Branch( "MSCW", &MSCW, "MSCW/F" );
93+
iDataTree_reduced->Branch( "MSCL", &MSCL, "MSCL/F" );
9494
iDataTree_reduced->Branch( "ErecS", &ErecS, "ErecS/F" );
9595
iDataTree_reduced->Branch( "EChi2S", &EChi2S, "EChi2S/F" );
9696
iDataTree_reduced->Branch( "Xcore", &Xcore, "Xcore/D" );

0 commit comments

Comments
 (0)