Skip to content

Commit

Permalink
Merge pull request #204 from VERITAS-Observatory/v490-dev-v0.6
Browse files Browse the repository at this point in the history
v490 - alpha.6
  • Loading branch information
GernotMaier authored Oct 7, 2022
2 parents fa00fa2 + d089499 commit cdf3ad0
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 68 deletions.
15 changes: 11 additions & 4 deletions inc/VEffectiveAreaCalculatorMCHistograms.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class VEffectiveAreaCalculatorMCHistograms : public TNamed
// spectral weight calculator
VSpectralWeight* fSpectralWeight; //! backwards compatibility
vector< VSpectralWeight* > fVSpectralWeight; //!

double fMCEnergyRange_TeV_min;
double fMCEnergyRange_TeV_max;
double fMCSpectralIndex;
Expand All @@ -42,8 +41,6 @@ class VEffectiveAreaCalculatorMCHistograms : public TNamed
double fEnergyAxisMin_log10;
double fEnergyAxisMax_log10;



int checkParameters( const VEffectiveAreaCalculatorMCHistograms* );

public:
Expand All @@ -56,14 +53,24 @@ class VEffectiveAreaCalculatorMCHistograms : public TNamed
// MC histograms
vector< vector< TH1D* > > hVEmc; // [spectral index][az]
vector< vector< TProfile* > > hVEmcSWeight; // [spectral index][az]
vector< TH1D* > hVEmcUnWeighted; // [spectral index]

VEffectiveAreaCalculatorMCHistograms();
~VEffectiveAreaCalculatorMCHistograms() {}

bool add( const VEffectiveAreaCalculatorMCHistograms* );
bool fill( double i_ze, TTree* i_MCData, bool iBAzimuthBins );
double getEnergyAxisMin_log10()
{
return fEnergyAxisMin_log10;
}
double getEnergyAxisMax_log10()
{
return fEnergyAxisMax_log10;
}
TH1D* getHistogram_Emc( unsigned int iAz, unsigned int iIndex );
TProfile* getHistogram_EmcWeight( unsigned int iAz, unsigned int iIndex );
TH1D* getHistogram_EmcUnweighted( unsigned int iAz );
void initializeHistograms();
void initializeHistograms( vector< double > iAzMin, vector< double > iAzMax,
vector< double > iSpectralIndex,
Expand All @@ -88,7 +95,7 @@ class VEffectiveAreaCalculatorMCHistograms : public TNamed
void setDefaultValues();
bool setMonteCarloEnergyRange( double iMin, double iMax, double iMCIndex = 2. );

ClassDef( VEffectiveAreaCalculatorMCHistograms, 10 );
ClassDef( VEffectiveAreaCalculatorMCHistograms, 13 );
};

#endif
4 changes: 4 additions & 0 deletions inc/VReadRunParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class VReadRunParameter
map< unsigned int, double > f_pointingErrorY;
double fWobbleNorth_overwriteDB;
double fWobbleEast_overwriteDB;
double fTargetDec_overwriteDB;
double fTargetRA_overwriteDB;
string fTargetName_overwriteDB;

bool checkSecondArgument( std::string, std::string, bool );
void isCompiledWithDB();
Expand All @@ -49,6 +52,7 @@ class VReadRunParameter
void read_db_runinfo();
bool readTraceAmplitudeCorrections( string ifile );
void setDirectories();
double setParameterOverwrite( string ipar_name, double ipar_db, double ipar_db_overwrite );

public:
VReadRunParameter();
Expand Down
71 changes: 66 additions & 5 deletions src/VEffectiveAreaCalculatorMCHistograms.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*! \CLASS veFFECTIVEaREAcALCULATORmchISTOGRAMS
/*! \class VEffectiveAreaCalculatorMCHistograms
\brief filling, reading, writing of MC histograms for effective area calculation
*/

#include "VEffectiveAreaCalculatorMCHistograms.h"
Expand All @@ -20,7 +21,6 @@ VEffectiveAreaCalculatorMCHistograms::VEffectiveAreaCalculatorMCHistograms()
fArrayxyoff_MC_min = -1.e5;
fArrayxyoff_MC_max = 1.e5;

// This should be aligned with all the IRF histograms.
fEnergyAxisBins_log10 = 60;
fEnergyAxisMin_log10 = -2.;
fEnergyAxisMax_log10 = 4.;
Expand Down Expand Up @@ -89,12 +89,27 @@ void VEffectiveAreaCalculatorMCHistograms::print()
cout << "\tEntries (MCweights): ";
cout << getHistogram_EmcWeight( j, i )->GetEntries();
}
if( getHistogram_EmcUnweighted( j ) && getHistogram_EmcUnweighted( j )->GetEntries() > 0 )
{
cout << "\t Entries (Unweighted): ";
cout << getHistogram_EmcUnweighted( j )->GetEntries();
}
cout << endl;
}
}
}
}

TH1D* VEffectiveAreaCalculatorMCHistograms::getHistogram_EmcUnweighted( unsigned int iAz )
{
if( iAz < hVEmcUnWeighted.size() )
{
return hVEmcUnWeighted[iAz];
}

return 0;
}


TH1D* VEffectiveAreaCalculatorMCHistograms::getHistogram_Emc( unsigned int iAz, unsigned int iIndex )
{
Expand Down Expand Up @@ -251,6 +266,8 @@ bool VEffectiveAreaCalculatorMCHistograms::fill( double i_ze, TTree* i_MCData, b
hVEmcSWeight[s][i_az]->Fill( eMC, i_weight );
}
}
// fill unweighted histogram
hVEmcUnWeighted[i_az]->Fill( eMC );
}
} // end of loop over all MC entries

Expand Down Expand Up @@ -284,24 +301,35 @@ void VEffectiveAreaCalculatorMCHistograms::initializeHistograms( vector< double
iT_TH1D.clear();
for( unsigned int j = 0; j < fVMinAz.size(); j++ )
{
sprintf( hname, "hVVEmc_%d_%d", i, j );
sprintf( hname, "hVVEmc_%u_%u", i, j );
iT_TH1D.push_back( new TH1D( hname, "", nbins, xmin, xmax ) );
iT_TH1D.back()->SetXTitle( "energy_{MC} [TeV]" );
iT_TH1D.back()->SetYTitle( "entries" );
iT_TH1D.back()->SetYTitle( "entries (weighted)" );
iT_TH1D.back()->Sumw2();
}
hVEmc.push_back( iT_TH1D );

for( unsigned int j = 0; j < fVMinAz.size(); j++ )
{
sprintf( hname, "hVVEmcSWeight_%d_%d", i, j );
sprintf( hname, "hVVEmcSWeight_%u_%u", i, j );
iT_TProfile.push_back( new TProfile( hname, "", nbins, xmin, xmax, 0., 1.e12 ) );
iT_TProfile.back()->SetXTitle( "energy_{MC} [TeV]" );
iT_TProfile.back()->SetYTitle( "spectral weight" );
}
hVEmcSWeight.push_back( iT_TProfile );

}
// unweighted histogram (for debugging purposes)
for( unsigned int j = 0; j < fVMinAz.size(); j++ )
{
sprintf( hname, "hVVEmc_%u", j );
hVEmcUnWeighted.push_back( new TH1D( hname, "", nbins, xmin, xmax ) );
hVEmcUnWeighted.back()->SetXTitle( "energy_{MC} [TeV]" );
hVEmcUnWeighted.back()->SetYTitle( "entries (not weighted)" );
hVEmcUnWeighted.back()->Sumw2();
}


// set spectral weight vector
for( unsigned int s = 0; s < fVSpectralIndex.size(); s++ )
{
Expand Down Expand Up @@ -396,9 +424,22 @@ bool VEffectiveAreaCalculatorMCHistograms::add( const VEffectiveAreaCalculatorMC
}
}

for( unsigned int j = 0; j < hVEmcUnWeighted.size(); j++ )
{
if( hVEmcUnWeighted[j] && iMChis->hVEmcUnWeighted[j] )
{
hVEmcUnWeighted[j]->Add( iMChis->hVEmcUnWeighted[j] );
}
}

return true;
}

/*
note the interesting error coding...
*/
int VEffectiveAreaCalculatorMCHistograms::checkParameters( const VEffectiveAreaCalculatorMCHistograms* iMChis )
{
if( fDebug )
Expand Down Expand Up @@ -534,6 +575,13 @@ bool VEffectiveAreaCalculatorMCHistograms::matchDataVectors( vector< double > iA
vector< TProfile* > iP;

// match spectral index
if( fDebug )
{
cout << "VEffectiveAreaCalculatorMCHistograms::matchDataVectors: ";
cout << "matching spectral index;";
cout << " found: " << fVSpectralIndex.size();
cout << " requested: " << iSpectralIndex.size() << endl;
}
for( unsigned int i = 0; i < fVSpectralIndex.size(); i++ )
{
for( unsigned int j = 0; j < iSpectralIndex.size(); j++ )
Expand Down Expand Up @@ -568,6 +616,7 @@ bool VEffectiveAreaCalculatorMCHistograms::matchDataVectors( vector< double > iA
// match azimuth vector
vector< double > iVMinAz_new;
vector< double > iVMaxAz_new;
vector< unsigned int > iVAz_match;
for( unsigned int s = 0; s < fVSpectralIndex.size(); s++ )
{
iVMinAz_new.clear();
Expand All @@ -587,6 +636,7 @@ bool VEffectiveAreaCalculatorMCHistograms::matchDataVectors( vector< double > iA
iVMaxAz_new.push_back( iAzMax[i] );
ihVEmc_new.push_back( hVEmc[s][j] );
iVEmcSWeight_new.push_back( hVEmcSWeight[s][j] );
iVAz_match.push_back( j );
}
}
}
Expand All @@ -596,5 +646,16 @@ bool VEffectiveAreaCalculatorMCHistograms::matchDataVectors( vector< double > iA
fVMinAz = iVMinAz_new;
fVMaxAz = iVMaxAz_new;

// unweighted histogram
vector< TH1D* > ihVEmcUnWeighted_new;
for( unsigned int i = 0; i < iVAz_match.size(); i++ )
{
if( iVAz_match[i] < hVEmcUnWeighted.size() )
{
ihVEmcUnWeighted_new.push_back( hVEmcUnWeighted[iVAz_match[i]] );
}
}
hVEmcUnWeighted = ihVEmcUnWeighted_new;

return true;
}
80 changes: 50 additions & 30 deletions src/VReadRunParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ VReadRunParameter::VReadRunParameter()

fPrintOutputFile = false;

fTargetName_overwriteDB = "";
fTargetDec_overwriteDB = -9999.;
fTargetRA_overwriteDB = -9999.;
fWobbleNorth_overwriteDB = -9999.;
fWobbleEast_overwriteDB = -9999.;
}
Expand Down Expand Up @@ -411,6 +414,7 @@ bool VReadRunParameter::readCommandline( int argc, char* argv[] )
{
fRunPara->fFillMCHistos = true;
}
// use db for run infos
else if( iTemp.find( "usedbinfo" ) < iTemp.size() && !( iTemp.find( "donotusedbinfo" ) < iTemp.size() ) )
{
fRunPara->fuseDB = true;
Expand Down Expand Up @@ -505,15 +509,25 @@ bool VReadRunParameter::readCommandline( int argc, char* argv[] )
fRunPara->fazimuth = atof( iTemp.substr( iTemp.rfind( "=" ) + 1, iTemp.size() ).c_str() );
}
// target declination
else if( iTemp.rfind( "declination" ) < iTemp.size() )
else if( iTemp.rfind( "declination" ) < iTemp.size() && !( iTemp.rfind( "overwritedb_declination" ) < iTemp.size() ) )
{
fRunPara->fTargetDec = atof( iTemp.substr( iTemp.rfind( "=" ) + 1, iTemp.size() ).c_str() );
}
// target ra [J2000] overwrite DB
else if( iTemp.rfind( "overwritedb_declination" ) < iTemp.size() )
{
fTargetDec_overwriteDB = atof( iTemp.substr( iTemp.rfind( "=" ) + 1, iTemp.size() ).c_str() );
}
// target ra [J2000]
else if( iTemp.rfind( "rightascension" ) < iTemp.size() )
else if( iTemp.rfind( "rightascension" ) < iTemp.size() && !( iTemp.rfind( "overwritedb_rightascension" ) < iTemp.size() ) )
{
fRunPara->fTargetRA = atof( iTemp.substr( iTemp.rfind( "=" ) + 1, iTemp.size() ).c_str() );
}
// target ra [J2000] overwrite DB
else if( iTemp.rfind( "overwritedb_rightascension" ) < iTemp.size() )
{
fTargetRA_overwriteDB = atof( iTemp.substr( iTemp.rfind( "=" ) + 1, iTemp.size() ).c_str() );
}
// target declination offset [J2000]
else if( iTemp.rfind( "decoffset" ) < iTemp.size() )
{
Expand All @@ -525,17 +539,20 @@ bool VReadRunParameter::readCommandline( int argc, char* argv[] )
fRunPara->fTargetRAOffset = atof( iTemp.substr( iTemp.rfind( "=" ) + 1, iTemp.size() ).c_str() );
}
// target name
else if( iTemp.rfind( "target" ) < iTemp.size() )
else if( iTemp.rfind( "target" ) < iTemp.size() && !( iTemp.rfind( "overwritedb_target" ) < iTemp.size() ) )
{
fRunPara->fTargetName = "";
if( iTemp2.size() > 0 )
{
fRunPara->fTargetName = iTemp2;
i++;
}
else
{
fRunPara->fTargetName = "";
}
}
// target name (overwrite DB)
else if( iTemp.rfind( "overwritedb_target" ) < iTemp.size() && iTemp2.size() > 0 )
{
fTargetName_overwriteDB = iTemp2;
i++;
}
// these two command line settings might be overwritten by values read from the data base
// wobble offset NORTH
Expand Down Expand Up @@ -1473,6 +1490,22 @@ void VReadRunParameter::test_and_adjustParams()
printStartMessage();
}

/*
* Check if overwrite parameter is given - return value dependent on this result
*
*/
double VReadRunParameter::setParameterOverwrite( string ipar_name, double ipar_db, double ipar_db_overwrite )
{
if( ipar_db_overwrite > -9998. )
{
cout << "VReadRunParameter::setParameterOverwrite() info: overwriting DB parameter ";
cout << ipar_name << " (was " << ipar_db << ")";
cout << " with new value: " << ipar_db_overwrite << endl;
return ipar_db_overwrite;
}
return ipar_db;
}

void VReadRunParameter::printShortHelp()
{
cout << endl;
Expand Down Expand Up @@ -1854,31 +1887,18 @@ void VReadRunParameter::read_db_runinfo()
if( i_DBinfo.isGood() )
{
fRunPara->fTargetName = i_DBinfo.getTargetName();
// DB coordinates are in J2000
fRunPara->fTargetDec = i_DBinfo.getTargetDec();
fRunPara->fTargetRA = i_DBinfo.getTargetRA();
if( fWobbleNorth_overwriteDB < -9998. )
{
fRunPara->fWobbleNorth = i_DBinfo.getWobbleNorth();
}
else
if( fTargetName_overwriteDB.size() > 0 )
{
fRunPara->fWobbleNorth = fWobbleNorth_overwriteDB;
cout << "VReadRunParameter::test_and_adjustParams() info: overwriting DB wobble north (";
cout << i_DBinfo.getWobbleNorth() << " deg)";
cout << "with command line value: " << fWobbleNorth_overwriteDB << " deg" << endl;
}
if( fWobbleEast_overwriteDB < -9998. )
{
fRunPara->fWobbleEast = i_DBinfo.getWobbleEast();
}
else
{
fRunPara->fWobbleEast = fWobbleEast_overwriteDB;
cout << "VReadRunParameter::test_and_adjustParams() info: overwriting DB wobble east (";
cout << i_DBinfo.getWobbleEast() << " deg)";
cout << "with command line value: " << fWobbleEast_overwriteDB << " deg" << endl;
fRunPara->fTargetName = fTargetName_overwriteDB;
cout << "VReadRunParameter::setParameterOverwrite() info: overwriting DB target name";
cout << " (" << i_DBinfo.getTargetName() << ") by " << fRunPara->fTargetName << endl;
}
// DB coordinates are in J2000
fRunPara->fTargetDec = setParameterOverwrite( "fTargetDec", i_DBinfo.getTargetDec(), fTargetDec_overwriteDB );
fRunPara->fTargetRA = setParameterOverwrite( "fTargetRA", i_DBinfo.getTargetRA(), fTargetRA_overwriteDB );
fRunPara->fWobbleNorth = setParameterOverwrite( "fWobbleNorth", i_DBinfo.getWobbleNorth(), fWobbleNorth_overwriteDB );
fRunPara->fWobbleEast = setParameterOverwrite( "fWobbleEast", i_DBinfo.getWobbleEast(), fWobbleEast_overwriteDB );

fRunPara->fDBRunType = i_DBinfo.getRunType();
fRunPara->fDBRunStartTimeSQL = i_DBinfo.getDataStartTimeSQL();
fRunPara->fDBRunStoppTimeSQL = i_DBinfo.getDataStoppTimeSQL();
Expand Down
5 changes: 3 additions & 2 deletions src/VSimpleStereoReconstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ void VSimpleStereoReconstructor::reset()
Hofmann et al 1999, Method 1 (HEGRA method)
shower direction by intersection of image axes
shower core by intersection of lines connecting reconstruced shower
direction and image centroids
corresponds to rcs_method4 in VArrayAnalyzer
Expand Down Expand Up @@ -391,7 +393,7 @@ bool VSimpleStereoReconstructor::reconstruct_core( unsigned int i_ntel,
bool VSimpleStereoReconstructor::fillShowerDirection( float xoff, float yoff )
{
if( TMath::IsNaN( yoff ) || TMath::IsNaN( yoff )
|| xoff < -99998. || yoff < -99998. || yoff > 99999.5 )
|| xoff < -998. || yoff < -998. || yoff > 998. )
{
reset();
return false;
Expand Down Expand Up @@ -465,4 +467,3 @@ bool VSimpleStereoReconstructor::fillShowerCore( float ximp, float yimp )
}
return true;
}

Loading

0 comments on commit cdf3ad0

Please sign in to comment.