Skip to content

Commit

Permalink
Merge pull request #186 from VERITAS-Observatory/v487d-dev-v0.1
Browse files Browse the repository at this point in the history
v487d patch release
  • Loading branch information
GernotMaier authored Jul 11, 2022
2 parents a3d7ab0 + 51ca3ed commit ec14ffa
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 13 deletions.
4 changes: 3 additions & 1 deletion inc/VAnaSumRunParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class VAnaSumRunParameter : public TNamed, public VGlobalRunParameter

// add all events to DL3 tree, no gh cuts but add BDT score and IsGamma
bool fWriteAllEvents;
// write data_on and data_off trees (subset of DL3 tree)
bool fWriteDataOnOffTrees;

// vector with all run parameters
vector< VAnaSumRunParameterDataClass > fRunList;
Expand Down Expand Up @@ -274,6 +276,6 @@ class VAnaSumRunParameter : public TNamed, public VGlobalRunParameter
bool writeListOfExcludedSkyRegions();
bool getListOfExcludedSkyRegions( TFile* f );

ClassDef( VAnaSumRunParameter, 17 ) ;
ClassDef( VAnaSumRunParameter, 18 ) ;
};
#endif
4 changes: 4 additions & 0 deletions inc/VLikelihoodFitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class VLikelihoodFitter : public VEnergySpectrum
fFitMax_logTeV = i_max;
}

// Recreate the model
setModel(fModelID);
}

// Setting the min and max energy rannge in linear scale
Expand All @@ -152,6 +154,8 @@ class VLikelihoodFitter : public VEnergySpectrum
fFitMin_logTeV = TMath::Log10(i_min);
fFitMax_logTeV = TMath::Log10(i_max);
}
// Recreate the model
setModel(fModelID);
}

void setBinWidth( double i_BinWidth);
Expand Down
32 changes: 26 additions & 6 deletions macros/VTS/test_reducedIRFFiles.C
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void printEntry( string iname, int iEntry, double ze, int az, double Woff, doubl
cout << " az: " << az;
cout << " Woff: " << Woff;
cout << " pedvar: " << pedvar;
cout << " index: " << index;
if( index > 0. ) cout << " index: " << index;
cout << endl;
}

Expand All @@ -112,6 +112,8 @@ TGraph* get_effAreaGraph( TFile *f,
TTree *t = (TTree*)f->Get( tree_name.c_str() );
if( !t ) return 0;

int fH2F_treecounter_offset = 20;
int count_max_az_bins = 17;

TGraph *g = new TGraph( 1 );
if( tree_name == "fEffArea" )
Expand All @@ -131,7 +133,9 @@ TGraph* get_effAreaGraph( TFile *f,
}
else
{
int iEntryH2F = iEntry / 340 * 17 + iEntry % 17;
int iEntryH2F = count_max_az_bins * (iEntry / (fH2F_treecounter_offset*count_max_az_bins))
+ iEntry % count_max_az_bins;
cout << "Reading entryH2F " << iEntryH2F << endl;
UShort_t nbins;
Float_t e0[1000];
Float_t eff[1000];
Expand All @@ -157,14 +161,17 @@ void test_reducedIRFFiles( string iIRFFile,
{
return 0;
}
int fH2F_treecounter_offset = 20;
int count_max_az_bins = 17;

TH2F* h1 = plot_h2f( f, iHistogramName, iEntry );

TH2F* h2 = plot_array( f, iHistogramName, iEntry / 20 + iEntry % 17 );
TH2F* h2 = plot_array( f, iHistogramName,
count_max_az_bins * (iEntry / (fH2F_treecounter_offset*count_max_az_bins)) + iEntry % count_max_az_bins );

if( h1 && h2 )
{
TCanvas *c = new TCanvas( ("comp"+iHistogramName).c_str(), "", 1380, 10, 600, 600 );
TCanvas *c = new TCanvas( ("comp"+iHistogramName).c_str(), "", 80, 10, 600, 600 );
c->Draw();
TH2F *h3 = (TH2F*)h1->Clone( ("hc"+iHistogramName).c_str() );
h3->Divide( h2 );
Expand All @@ -190,7 +197,7 @@ void test_effectiveAreas( string iIRFFile,
TGraph *h2_eff = get_effAreaGraph( f, "fEffAreaH2F", iVariable, iEntry );
if( h1_eff && h2_eff )
{
TCanvas *d = new TCanvas( "c_effNoTh2", "", 1380, 600, 600, 600 );
TCanvas *d = new TCanvas( "c_effNoTh2", "", 80, 600, 600, 600 );
d->Draw();
d->cd();
h1_eff->Draw( "ap" );
Expand Down Expand Up @@ -231,6 +238,18 @@ void sync_effectiveAreaTrees( string iIRFFile, int zmax = 100 )
fEffAreaH2F->SetBranchAddress( "Woff", &Woff2 );
fEffAreaH2F->SetBranchAddress( "pedvar", &pedvar2 );

int fH2F_treecounter_offset = fEffArea->GetEntries() / fEffAreaH2F->GetEntries();
cout << "Tree counter offset: " << fH2F_treecounter_offset << endl;
int count_max_az_bins = 0;
for( unsigned int i = 0; i < fEffArea->GetEntries(); i++ )
{
fEffArea->GetEntry( i );
if( az > count_max_az_bins ) count_max_az_bins = az;
if( az < count_max_az_bins ) break;
}
count_max_az_bins++;
cout << "Maximum number of az bin: " << count_max_az_bins << endl;

int z = 0;
for( unsigned int i = 0; i < fEffArea->GetEntries(); i++ )
{
Expand All @@ -246,7 +265,8 @@ void sync_effectiveAreaTrees( string iIRFFile, int zmax = 100 )
if( TMath::Abs( pedvar - pedvar2 ) > 1.e-2 ) continue;
if( az != az2 ) continue;
printEntry( "EffAreaH2", j, ze2, az2, Woff2, pedvar2, 0.);
cout << "H2 entry should be: " << i / 20 + i % 17 << endl;
cout << "H2 entry should be: ";
cout << count_max_az_bins * (i / (fH2F_treecounter_offset*count_max_az_bins)) + i % count_max_az_bins << endl;
cout << "===========================================" << endl;
}
z++;
Expand Down
15 changes: 12 additions & 3 deletions src/VAnaSumRunParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ VAnaSumRunParameter::VAnaSumRunParameter()
fModel3D = false; // MODEL3DANALYSIS
fDirectionModel3D = false; //USEDIRECTIONMODEL3D

// likelihood analysis
fLikelihoodAnalysis = false;
// likelihood analysis
fLikelihoodAnalysis = false;

// Write all events to DL3 Tree
fWriteAllEvents = false;
// Write Dataon/dataoff trees
fWriteDataOnOffTrees = false;

// if 0, use default 1D radial acceptance
// if >0, use alternate 2D-dependent acceptance
Expand Down Expand Up @@ -686,7 +688,14 @@ int VAnaSumRunParameter::readRunParameter( string i_filename )
unsigned int tmpWriteAll = ( unsigned int )atoi( temp2.c_str() ) ;
if( tmpWriteAll == 1 )
{
fWriteAllEvents = true ;
fWriteAllEvents = true;
}
}
else if( temp == "WRITEDATAONOFFEVENTS" )
{
if( (unsigned int)atoi( temp2.c_str() ) == 1 )
{
fWriteDataOnOffTrees = true;
}
}
else
Expand Down
5 changes: 4 additions & 1 deletion src/VEffectiveAreaCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,10 @@ bool VEffectiveAreaCalculator::initializeEffectiveAreasFromHistograms(
// read 2D histograms
if( iEffAreaH2F && count_max_az_bins > 0 )
{
iEffAreaH2F->GetEntry( iIndexAz / fH2F_treecounter_offset + iIndexAz % count_max_az_bins );
iEffAreaH2F->GetEntry(
count_max_az_bins
* (iIndexAz/(fH2F_treecounter_offset*count_max_az_bins))
+ iIndexAz % count_max_az_bins );
}

fEff_EsysMCRelative[i_ID].resize( fH2F_nbins_esys, 0. );
Expand Down
2 changes: 1 addition & 1 deletion src/VEnergySpectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ bool VEnergySpectrum::writeSpectralPointsToCSVFile( string iOFileName,
TGraphAsymmErrors* iDiffFlux )
{
ofstream os;
os.open( iOFileName.c_str() );
os.open( gSystem->ExpandPathName(iOFileName.c_str()) );
if( !os )
{
cout << "VEnergySpectrum::writeSpectralPointsToCSVFile error opening " << iOFileName << endl;
Expand Down
4 changes: 4 additions & 0 deletions src/VStereoAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ void VStereoAnalysis::writeHistograms( bool bOn )
{
write_DL3Tree() ;
}
if( fTreeSelectedEvents && fRunPara->fWriteDataOnOffTrees )
{
fTreeSelectedEvents->Write();
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/logFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ void printHelp()
cout << endl;
cout << "\t examples are: " << endl;
cout << "\t\t convLog, evndispLog" << endl;
cout << "\t\t evndisptzeroLog, evndisppedLog" << endl;
cout << "\t\t makeTableLog, makeTableFileList" << endl;
cout << "\t\t smoothTableLog, mscwTableLog, mscwTableList" << endl;
cout << "\t\t tmvaLog, tmvaRunparameter" << endl;
cout << "\t\t effAreaLog, effAreaCuts, effAreaParameters" << endl;
cout << "\t\t IRFLog" << endl;
cout << "\t to print all log files in the root file: use `printAll`" << endl;
cout << endl;
}

Expand All @@ -55,6 +57,8 @@ int main( int argc, char* argv[] )
// list of prefered logs to print
vector< string > logObjectNames;
logObjectNames.push_back( "evndispLog" );
logObjectNames.push_back( "evndisptzeroLog" );
logObjectNames.push_back( "evndisppedLog" );
logObjectNames.push_back( "makeTableLog" );
logObjectNames.push_back( "mscwTableLog" );
logObjectNames.push_back( "tmvaLog" );
Expand Down Expand Up @@ -84,7 +88,7 @@ int main( int argc, char* argv[] )
cout << "NOXML" << endl;
exit( EXIT_SUCCESS );
}
if( !iM )
if( !iM && fLogFileName == "printAll" )
{
for( unsigned int i = 0; i < logObjectNames.size(); i++ )
{
Expand Down

0 comments on commit ec14ffa

Please sign in to comment.