Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical bug fix in DL3 event tree writing (for gammapy analysis) #170

Merged
merged 4 commits into from
Feb 21, 2022
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
17 changes: 12 additions & 5 deletions inc/VAnaSumRunParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class VAnaSumRunParameterDataClass : public TNamed
double fTargetRA; // [deg], precessed
double fTargetDec; // [deg], precessed
double fPairOffset;

// centre of camera fov
double fArrayPointingRA;
double fArrayPointingDec;
double fArrayPointingRAJ2000;
double fArrayPointingDecJ2000;

double fWobbleNorth; // [deg]
double fWobbleWest; // [deg]
Expand Down Expand Up @@ -258,15 +264,16 @@ class VAnaSumRunParameter : public TNamed, public VGlobalRunParameter
void printStereoParameter( unsigned int icounter );
void printStereoParameter( int irun );
int readRunParameter( string i_filename );
void setArrayPointing(unsigned int, std::pair<double, double>, std::pair<double, double>);
bool setRunTimes( unsigned int irun, double iMJDStart, double iMJDStopp );
bool setSkyMapCentreJ2000( unsigned int i, double ra, double dec );
bool setTargetRADecJ2000( unsigned int i, double ra, double dec, string iTargetName );
bool setTargetRADec_currentEpoch( unsigned int i, double ra, double dec );
bool setTargetShifts( unsigned int i, double west, double north, double ra, double dec );
bool setSkyMapCentreJ2000( unsigned int i );
bool setTargetRADecJ2000( unsigned int i );
void setTargetRADec_currentEpoch( unsigned int i, double ra, double dec );
bool setTargetShifts( unsigned int i );
void sortRunList();
bool writeListOfExcludedSkyRegions();
bool getListOfExcludedSkyRegions( TFile* f );

ClassDef( VAnaSumRunParameter, 15 ) ;
ClassDef( VAnaSumRunParameter, 17 ) ;
};
#endif
6 changes: 6 additions & 0 deletions inc/VSkyCoordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <iomanip>
#include <iostream>
#include <utility>

#include "VASlalib.h"
#include "VSkyCoordinatesUtilities.h"
Expand Down Expand Up @@ -170,6 +171,11 @@ class VSkyCoordinates
{
fTelRA = iTelRA_deg * TMath::DegToRad();
}
void setTelRADec_deg( pair< double, double > iTelRADec_deg )
{
fTelRA = iTelRADec_deg.first * TMath::DegToRad();
fTelDec = iTelRADec_deg.second * TMath::DegToRad();
}
void setTelAzimuth( double iTelAz )
{
fTelAzimuth = iTelAz; //!< set telescope azimuth (e.g.for MC)
Expand Down
6 changes: 4 additions & 2 deletions inc/VStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class VStar : public TObject
~VStar() {};

double getDistance( VStar* iStar1, VStar* iStar2 = 0 );
void printStar();
double getBrightness( string iBand );
void printStar();
void printStar_for_anasum( string iBand );

ClassDef( VStar, 2 );
ClassDef( VStar, 3 );
};


Expand Down
14 changes: 14 additions & 0 deletions inc/VStereoAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;
Expand Down Expand Up @@ -240,6 +241,19 @@ class VStereoAnalysis
// directories
TDirectory* fDirTot;
vector< TDirectory* > fDirTotRun;

void astro_check_for_valid_coordinates( unsigned int runlist_iter );
void astro_set_skymap_center_from_runparameters( unsigned int runlist_iter );
void astro_set_skymap_centershift_from_runparameters( unsigned int runlist_iter );
pair< double, double > astro_calculate_ra_dec_currentEpoch( unsigned int runlist_iter );
pair< double, double > astro_get_wobbleoffset_radec( unsigned int runlist_iter, bool bPrint = true );
pair< double, double > astro_get_arraypointing( unsigned int runlist_iter, bool bPrint = true );
pair< double, double > astro_get_arraypointingJ2000( unsigned int runlist_iter );
double astro_get_mjd( unsigned int runlist_iter );
void astro_print_pointing( unsigned int runlist_iter );
void astro_calculate_modified_wobbleoffset( unsigned int runlist_iter );
void astro_set_exclusionsregions( unsigned int runlist_iter );
void astro_setup_star_cataloge( unsigned int runlist_iter );

double combineHistograms();
void defineAstroSource();
Expand Down
95 changes: 58 additions & 37 deletions src/VAnaSumRunParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ VAnaSumRunParameterDataClass::VAnaSumRunParameterDataClass()
fEventDisplayVersion = "";

fRunOn = 0;
fRunOnFileName = "";
fRunOnFileName = "";
fRunOff = 0;
fRunOffFileName = "";
fRunOffFileName = "";

fMJDOn = 0.;
fMJDOff = 0.;

fMJDOnStart = 0.;
fMJDOnStop = 0.;
fMJDOnStart = 0.;
fMJDOnStop = 0.;

fTarget = "";
fTargetRAJ2000 = 0.;
fTargetDecJ2000 = -90.;
fTargetRA = 0.;
fTargetDec = 0.;

fArrayPointingRA = 0.;
fArrayPointingDec = 0.;
fArrayPointingRAJ2000 = 0.;
fArrayPointingDecJ2000 = 0.;

fPairOffset = 0.;

Expand All @@ -44,7 +49,7 @@ VAnaSumRunParameterDataClass::VAnaSumRunParameterDataClass()
fTargetShiftDecJ2000 = 0.;

fNTel = 4;
fTelToAna = "";
fTelToAna = "";
fMaxTelID = fNTel;

fBackgroundModel = 0;
Expand Down Expand Up @@ -324,14 +329,14 @@ int VAnaSumRunParameter::readRunParameter( string i_filename )
else if( temp == "SKYMAPSIZEX" )
{
fSkyMapSizeXmin = atof( temp2.c_str() );
fSkyMapSizeXmin = -1. *TMath::Abs( fSkyMapSizeXmin );
fSkyMapSizeXmax = TMath::Abs( fSkyMapSizeXmin );
fSkyMapSizeXmin = -1. *TMath::Abs( fSkyMapSizeXmin );
fSkyMapSizeXmax = TMath::Abs( fSkyMapSizeXmin );
}
else if( temp == "SKYMAPSIZEY" )
{
fSkyMapSizeYmin = atof( temp2.c_str() );
fSkyMapSizeYmin = -1. *TMath::Abs( fSkyMapSizeYmin );
fSkyMapSizeYmax = TMath::Abs( fSkyMapSizeYmin );
fSkyMapSizeYmin = -1. *TMath::Abs( fSkyMapSizeYmin );
fSkyMapSizeYmax = TMath::Abs( fSkyMapSizeYmin );
}
else if( temp == "BRIGHTSTARCATALOGUE" )
{
Expand Down Expand Up @@ -452,13 +457,13 @@ int VAnaSumRunParameter::readRunParameter( string i_filename )
d_tt += atof( temp2.c_str() ) / 3600.;
fTargetShiftRAJ2000 = d_tt / 24. * 360.;
// dec
string iDec1;
string iDec2;
string iDec3;
string iDec1;
string iDec2;
string iDec3;
is_stream >> iDec1;
is_stream >> iDec2;
is_stream >> iDec3;
fTargetShiftDecJ2000 = getDeclinationFromStrings( iDec1, iDec2, iDec3 );
fTargetShiftDecJ2000 = getDeclinationFromStrings( iDec1, iDec2, iDec3 );
}

else if( temp == "REGIONTOEXCLUDE" || temp == "REGIONTOEXCLUDE_RADECJ2000_DEG" )
Expand Down Expand Up @@ -1528,32 +1533,30 @@ unsigned int VAnaSumRunParameter::getMaxNumberofTelescopes()
}


bool VAnaSumRunParameter::setTargetShifts( unsigned int i, double west, double north, double ra, double dec )
bool VAnaSumRunParameter::setTargetShifts( unsigned int i )
{
if( i < fRunList.size() )
{
if( fMapRunList.find( fRunList[i].fRunOn ) != fMapRunList.end() )
{
fMapRunList[fRunList[i].fRunOn].fTargetShiftWest = west;
fMapRunList[fRunList[i].fRunOn].fTargetShiftNorth = north;
fMapRunList[fRunList[i].fRunOn].fTargetShiftRAJ2000 = ra;
fMapRunList[fRunList[i].fRunOn].fTargetShiftDecJ2000 = dec;
fMapRunList[fRunList[i].fRunOn].fTargetShiftWest = fRunList[i].fTargetShiftWest;
fMapRunList[fRunList[i].fRunOn].fTargetShiftNorth = fRunList[i].fTargetShiftNorth;
fMapRunList[fRunList[i].fRunOn].fTargetShiftRAJ2000 = fTargetShiftRAJ2000;
fMapRunList[fRunList[i].fRunOn].fTargetShiftDecJ2000 = fTargetShiftDecJ2000;
}
return true;
}
return false;
}

bool VAnaSumRunParameter::setSkyMapCentreJ2000( unsigned int i, double ra, double dec )
bool VAnaSumRunParameter::setSkyMapCentreJ2000( unsigned int i )
{
if( i < fRunList.size() )
{
fRunList[i].fSkyMapCentreRAJ2000 = ra;
fRunList[i].fSkyMapCentreDecJ2000 = dec;
if( fMapRunList.find( fRunList[i].fRunOn ) != fMapRunList.end() )
{
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreRAJ2000 = ra;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreDecJ2000 = dec;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreRAJ2000 = fRunList[i].fSkyMapCentreRAJ2000;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreDecJ2000 = fRunList[i].fSkyMapCentreDecJ2000;
}
return true;
}
Expand All @@ -1577,43 +1580,59 @@ bool VAnaSumRunParameter::setRunTimes( unsigned int i, double iMJDStart, double
}


bool VAnaSumRunParameter::setTargetRADecJ2000( unsigned int i, double ra, double dec, string iTargetName )
bool VAnaSumRunParameter::setTargetRADecJ2000( unsigned int i )
{
if( i < fRunList.size() )
{
fRunList[i].fTargetRAJ2000 = ra;
fRunList[i].fTargetDecJ2000 = dec;
fRunList[i].fTarget = iTargetName;
if( fMapRunList.find( fRunList[i].fRunOn ) != fMapRunList.end() )
{
fMapRunList[fRunList[i].fRunOn].fTargetRAJ2000 = ra;
fMapRunList[fRunList[i].fRunOn].fTargetDecJ2000 = dec;
fMapRunList[fRunList[i].fRunOn].fTarget = iTargetName;
fMapRunList[fRunList[i].fRunOn].fTargetRAJ2000 = fRunList[i].fTargetRAJ2000;
fMapRunList[fRunList[i].fRunOn].fTargetDecJ2000 = fRunList[i].fTargetDecJ2000;
fMapRunList[fRunList[i].fRunOn].fTarget = fRunList[i].fTarget;
}
// set centre of stereo maps (if this parameter is not set in the file runparameter.dat)
if( TMath::Abs( fSkyMapCentreNorth ) < 1.e-8 && TMath::Abs( fSkyMapCentreWest ) < 1.e-8
&& TMath::Abs( fSkyMapCentreRAJ2000 ) < 1.e-8 && TMath::Abs( fSkyMapCentreDecJ2000 ) < 1.e-8 )
{
fRunList[i].fSkyMapCentreNorth = 0.;
fRunList[i].fSkyMapCentreWest = 0.;
fRunList[i].fSkyMapCentreRAJ2000 = ra;
fRunList[i].fSkyMapCentreDecJ2000 = dec;
fRunList[i].fSkyMapCentreRAJ2000 = fRunList[i].fTargetRAJ2000;
fRunList[i].fSkyMapCentreDecJ2000 = fRunList[i].fTargetDecJ2000;

if( fMapRunList.find( fRunList[i].fRunOn ) != fMapRunList.end() )
{
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreNorth = 0.;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreWest = 0.;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreRAJ2000 = ra;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreDecJ2000 = dec;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreRAJ2000 = fRunList[i].fTargetRAJ2000;;
fMapRunList[fRunList[i].fRunOn].fSkyMapCentreDecJ2000 = fRunList[i].fTargetDecJ2000;
}
}
return true;
}
return false;
}

void VAnaSumRunParameter::setArrayPointing(
unsigned int i,
pair< double, double > i_radec,
pair< double, double > i_radecJ2000 )
{
if( i >= fRunList.size() ) return;

bool VAnaSumRunParameter::setTargetRADec_currentEpoch( unsigned int i, double ra, double dec )
fRunList[i].fArrayPointingRA = i_radec.first;
fRunList[i].fArrayPointingDec = i_radec.second;
fRunList[i].fArrayPointingRAJ2000 = i_radecJ2000.first;
fRunList[i].fArrayPointingDecJ2000 = i_radecJ2000.second;
if( fMapRunList.find( fRunList[i].fRunOn ) != fMapRunList.end() )
{
fMapRunList[fRunList[i].fRunOn].fArrayPointingRA = i_radec.first;
fMapRunList[fRunList[i].fRunOn].fArrayPointingDec = i_radec.second;
fMapRunList[fRunList[i].fRunOn].fArrayPointingRAJ2000 = i_radecJ2000.first;
fMapRunList[fRunList[i].fRunOn].fArrayPointingDecJ2000 = i_radecJ2000.second;
}
}

void VAnaSumRunParameter::setTargetRADec_currentEpoch( unsigned int i, double ra, double dec )
{
if( i < fRunList.size() )
{
Expand All @@ -1624,9 +1643,7 @@ bool VAnaSumRunParameter::setTargetRADec_currentEpoch( unsigned int i, double ra
fMapRunList[fRunList[i].fRunOn].fTargetRA = ra;
fMapRunList[fRunList[i].fRunOn].fTargetDec = dec;
}
return true;
}
return false;
}


Expand Down Expand Up @@ -1660,6 +1677,10 @@ void VAnaSumRunParameter::getEventdisplayRunParameter( string fDatadir )
fRunList[i].fWobbleWest = -1.*iParV2->fWobbleEast;
fRunList[i].fWobbleNorthMod = iParV2->fWobbleNorth;
fRunList[i].fWobbleWestMod = -1.*iParV2->fWobbleEast;
cout << "Run " << fRunList[i].fRunOn << ":";
cout << "\t pointing from mscw file is ";
cout << " (ra,dec (J2000)) = (" << fRunList[i].fTargetRAJ2000 << ", " << fRunList[i].fTargetDecJ2000;
cout << ")" << endl;
fRunList[i].fNTel = ( int )iParV2->fTelToAnalyze.size();
fRunList[i].fTelToAnalyze = iParV2->fTelToAnalyze;
}
Expand Down
24 changes: 23 additions & 1 deletion src/VStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

VStar::VStar()
{
fStarID = 0;
fStarID = 0;
fStarName = "";
fDec2000 = 0.;
fRA2000 = 0.;
Expand Down Expand Up @@ -60,3 +60,25 @@ void VStar::printStar()
{
cout << fStarName << "\t" << fRA2000 << "\t" << fDec2000 << " B: " << fBrightness_B << " V: " << fBrightness_V << endl;
}

void VStar::printStar_for_anasum( string iBand )
{
cout << "\t\t" << fStarID << "\t";
cout << fRA2000 << "\t";
cout << fDec2000 << "\t";
cout << getBrightness( iBand ) << " (" << iBand << " band)";
cout << " " << fStarName << endl;
}

double VStar::getBrightness( string iBand )
{
if( iBand == "B" )
{
return fBrightness_B;
}
else if( iBand == "V" )
{
return fBrightness_V;
}
return 0.;
}
Loading