From 2826595e90263d28495547b33087776623df70f1 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Sun, 20 Feb 2022 19:24:16 +0100 Subject: [PATCH 1/3] refactoring of VStereoAnalysis::defineAstroSource() --- inc/VAnaSumRunParameter.h | 10 +- inc/VSkyCoordinates.h | 6 + inc/VStar.h | 6 +- inc/VStereoAnalysis.h | 14 + src/VAnaSumRunParameter.cpp | 63 ++-- src/VStar.cpp | 24 +- src/VStereoAnalysis.cpp | 648 ++++++++++++++++++++---------------- 7 files changed, 438 insertions(+), 333 deletions(-) diff --git a/inc/VAnaSumRunParameter.h b/inc/VAnaSumRunParameter.h index f3c6ee6b..987ffeb2 100644 --- a/inc/VAnaSumRunParameter.h +++ b/inc/VAnaSumRunParameter.h @@ -259,14 +259,14 @@ class VAnaSumRunParameter : public TNamed, public VGlobalRunParameter void printStereoParameter( int irun ); int readRunParameter( string i_filename ); 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 diff --git a/inc/VSkyCoordinates.h b/inc/VSkyCoordinates.h index 9b8f5734..1274a0e9 100644 --- a/inc/VSkyCoordinates.h +++ b/inc/VSkyCoordinates.h @@ -7,6 +7,7 @@ #include #include +#include #include "VASlalib.h" #include "VSkyCoordinatesUtilities.h" @@ -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) diff --git a/inc/VStar.h b/inc/VStar.h index 4e3ed829..c6d77988 100644 --- a/inc/VStar.h +++ b/inc/VStar.h @@ -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 ); }; diff --git a/inc/VStereoAnalysis.h b/inc/VStereoAnalysis.h index 29969588..e952d6aa 100644 --- a/inc/VStereoAnalysis.h +++ b/inc/VStereoAnalysis.h @@ -34,6 +34,7 @@ #include #include #include +#include #include using namespace std; @@ -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(); diff --git a/src/VAnaSumRunParameter.cpp b/src/VAnaSumRunParameter.cpp index 26f628fc..22ed7a23 100644 --- a/src/VAnaSumRunParameter.cpp +++ b/src/VAnaSumRunParameter.cpp @@ -10,15 +10,15 @@ 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.; @@ -44,7 +44,7 @@ VAnaSumRunParameterDataClass::VAnaSumRunParameterDataClass() fTargetShiftDecJ2000 = 0.; fNTel = 4; - fTelToAna = ""; + fTelToAna = ""; fMaxTelID = fNTel; fBackgroundModel = 0; @@ -324,14 +324,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" ) { @@ -1528,32 +1528,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; } @@ -1577,18 +1575,15 @@ 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 @@ -1596,15 +1591,15 @@ bool VAnaSumRunParameter::setTargetRADecJ2000( unsigned int i, double ra, double { 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; @@ -1613,7 +1608,7 @@ bool VAnaSumRunParameter::setTargetRADecJ2000( unsigned int i, double ra, double } -bool VAnaSumRunParameter::setTargetRADec_currentEpoch( unsigned int i, double ra, double dec ) +void VAnaSumRunParameter::setTargetRADec_currentEpoch( unsigned int i, double ra, double dec ) { if( i < fRunList.size() ) { @@ -1624,9 +1619,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; } @@ -1660,6 +1653,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; } diff --git a/src/VStar.cpp b/src/VStar.cpp index 2c371079..ff38f1ab 100644 --- a/src/VStar.cpp +++ b/src/VStar.cpp @@ -7,7 +7,7 @@ VStar::VStar() { - fStarID = 0; + fStarID = 0; fStarName = ""; fDec2000 = 0.; fRA2000 = 0.; @@ -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.; +} diff --git a/src/VStereoAnalysis.cpp b/src/VStereoAnalysis.cpp index 0cb196f1..8469e7ec 100644 --- a/src/VStereoAnalysis.cpp +++ b/src/VStereoAnalysis.cpp @@ -1371,9 +1371,350 @@ double VStereoAnalysis::getDeadTimeFraction() return 0.; } +void VStereoAnalysis::astro_check_for_valid_coordinates( unsigned int runlist_iter ) +{ + // (this is the target of observation) + ///////////////////////////////////////////////////////// + if( fRunPara->fRunList[runlist_iter].fTargetDecJ2000 < -89.99 ) + { + cout << "ERROR in VStereoAnalysis::astro_check_for_valid_coordinates: invalid target "; + cout << fRunPara->fRunList[runlist_iter].fTarget << endl; + cout << "\t run " << fRunPara->fRunList[runlist_iter].fRunOn << "\t" << fRunPara->fRunList[runlist_iter].fTarget; + cout << fRunPara->fRunList[runlist_iter].fTargetDecJ2000 << "\t" << fRunPara->fRunList[runlist_iter].fTargetShiftDecJ2000 << endl; + exit( EXIT_FAILURE ); + } +} + +void VStereoAnalysis::astro_set_skymap_center_from_runparameters( unsigned int runlist_iter ) +{ + ///////////////////////////////////////////////////////// + // Case 1: sky map centre is given as xy offset [deg] in runparameter file + if( TMath::Abs( fRunPara->fSkyMapCentreNorth ) > 1.e-8 || TMath::Abs( fRunPara->fSkyMapCentreWest ) > 1.e-8 ) + { + fRunPara->fRunList[runlist_iter].fSkyMapCentreWest = fRunPara->fSkyMapCentreWest; + fRunPara->fRunList[runlist_iter].fSkyMapCentreNorth = fRunPara->fSkyMapCentreNorth; + double i_decDiff = 0.; // offset in dec + double i_raDiff = 0.; // offset in ra + VSkyCoordinatesUtilities::getWobbleOffset_in_RADec( + fRunPara->fRunList[runlist_iter].fSkyMapCentreNorth, + fRunPara->fRunList[runlist_iter].fSkyMapCentreWest, + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + i_decDiff, i_raDiff ); + fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000 = fRunPara->fRunList[runlist_iter].fTargetRAJ2000 + i_raDiff; + fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000 = fRunPara->fRunList[runlist_iter].fTargetDecJ2000 + i_decDiff; + } + // Case 2: sky map centre is given in J200 in runparameter file + // (this is in almost all analysis the usual/default case) + else if( TMath::Abs( fRunPara->fSkyMapCentreRAJ2000 ) > 1.e-8 ) + { + fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000 = fRunPara->fSkyMapCentreRAJ2000; + fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000 = fRunPara->fSkyMapCentreDecJ2000; + fRunPara->fRunList[runlist_iter].fSkyMapCentreWest = + VSkyCoordinatesUtilities::getTargetShiftWest( + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + fRunPara->fSkyMapCentreRAJ2000, fRunPara->fSkyMapCentreDecJ2000 ) * -1.; + fRunPara->fRunList[runlist_iter].fSkyMapCentreNorth = + VSkyCoordinatesUtilities::getTargetShiftNorth( + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + fRunPara->fSkyMapCentreRAJ2000, fRunPara->fSkyMapCentreDecJ2000 ); + } + // if not set in runparameter file: set to target direction + else + { + fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000 = fRunPara->fRunList[runlist_iter].fTargetRAJ2000; + fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000 = fRunPara->fRunList[runlist_iter].fTargetDecJ2000; + fRunPara->fSkyMapCentreRAJ2000 = fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000; + fRunPara->fSkyMapCentreDecJ2000 = fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000; + } +} + +void VStereoAnalysis::astro_set_skymap_centershift_from_runparameters( unsigned int runlist_iter ) +{ + ///////////////////////////////////////////////////////// + // from runparameter file: set and get target shifts + // (calculated relative to sky map centre) + // (this is the position where all 1D histograms (theta2, energy spectra, etc) are calculated) + if( fIsOn ) + { + if( TMath::Abs( fRunPara->fTargetShiftDecJ2000 ) > 1.e-8 || TMath::Abs( fRunPara->fTargetShiftRAJ2000 ) > 1.e-8 ) + { + fRunPara->fRunList[runlist_iter].fTargetShiftWest = VSkyCoordinatesUtilities::getTargetShiftWest( + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + fRunPara->fTargetShiftRAJ2000, fRunPara->fTargetShiftDecJ2000 ); + fRunPara->fRunList[runlist_iter].fTargetShiftNorth = -1.*VSkyCoordinatesUtilities::getTargetShiftNorth( + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + fRunPara->fTargetShiftRAJ2000, fRunPara->fTargetShiftDecJ2000 ); + + fRunPara->fRunList[runlist_iter].fTargetShiftWest += fRunPara->fRunList[runlist_iter].fSkyMapCentreWest; + fRunPara->fRunList[runlist_iter].fTargetShiftNorth += fRunPara->fRunList[runlist_iter].fSkyMapCentreNorth; + } + else + { + fRunPara->fRunList[runlist_iter].fTargetShiftWest = fRunPara->fTargetShiftWest; + fRunPara->fRunList[runlist_iter].fTargetShiftNorth = fRunPara->fTargetShiftNorth; + } + fRunPara->fRunList[runlist_iter].fTargetShiftWest *= -1.; + fRunPara->fTargetShiftWest = fRunPara->fRunList[runlist_iter].fTargetShiftWest; + fRunPara->fTargetShiftNorth = fRunPara->fRunList[runlist_iter].fTargetShiftNorth; + fRunPara->setTargetShifts( runlist_iter ); + } +} + +double VStereoAnalysis::astro_get_mjd( unsigned int runlist_iter ) +{ + double iMJD = ( double )fRunPara->fRunList[runlist_iter].fMJDOn; + if( !fIsOn ) + { + iMJD = ( double )fRunPara->fRunList[runlist_iter].fMJDOff; + } + return iMJD; +} + +/* + * convert wobble offsets from angle in the sky + * to offsets in RA/Dec + */ +pair< double, double > VStereoAnalysis::astro_get_wobbleoffset_radec( unsigned int runlist_iter, bool bPrint ) +{ + // calculate wobble offset in ra/dec for current epoch + pair< double, double > i_radec_diff; + + VSkyCoordinatesUtilities::getWobbleOffset_in_RADec( + fRunPara->fRunList[runlist_iter].fWobbleNorth, + -1.*fRunPara->fRunList[runlist_iter].fWobbleWest, + fRunPara->fRunList[runlist_iter].fTargetDec, + fRunPara->fRunList[runlist_iter].fTargetRA, + i_radec_diff.second, + i_radec_diff.first ); + if( i_radec_diff.first < -180. ) + { + i_radec_diff.first += 360.; + } + if( fIsOn && bPrint ) + { + cout << "\tWobble offsets (currE): N: "; + cout << fRunPara->fRunList[runlist_iter].fWobbleNorth; + cout << " W: " << fRunPara->fRunList[runlist_iter].fWobbleWest; + cout << ", RA " << i_radec_diff.first << ", Dec " << i_radec_diff.second << endl; + } + return i_radec_diff; +} + +/* + * array pointing (center of pointing FOV) + * in current epoch + */ +pair< double, double > VStereoAnalysis::astro_get_arraypointing( unsigned int runlist_iter, bool bPrint ) +{ + pair< double, double > ra_dec_wobbleoffset = astro_get_wobbleoffset_radec( runlist_iter, bPrint ); + + pair< double, double > i_radec_arraypointing; + i_radec_arraypointing.first = fRunPara->fRunList[runlist_iter].fTargetRA + ra_dec_wobbleoffset.first; + i_radec_arraypointing.second = fRunPara->fRunList[runlist_iter].fTargetDec + ra_dec_wobbleoffset.second; + + return i_radec_arraypointing; +} + +/* + * array pointing (center of pointing FOV) + * in J2000 + */ +pair< double, double > VStereoAnalysis::astro_get_arraypointingJ2000( unsigned int runlist_iter ) +{ + pair< double, double > i_radec_arraypointing = astro_get_arraypointing(runlist_iter); + // correct for precession (from current epoch to J2000=MJD51544) + VSkyCoordinatesUtilities::precessTarget( + 51544., + i_radec_arraypointing.first, i_radec_arraypointing.second, + astro_get_mjd(runlist_iter), true ); + return i_radec_arraypointing; +} + +void VStereoAnalysis::astro_calculate_modified_wobbleoffset( unsigned int runlist_iter ) +{ + pair< double, double > ra_dec_arraypointing = astro_get_arraypointingJ2000(runlist_iter); + + double i_WobbleJ2000_West = VSkyCoordinatesUtilities::getTargetShiftWest( + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, + fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + ra_dec_arraypointing.first, + ra_dec_arraypointing.second) * -1.; + double i_WobbleJ2000_North = VSkyCoordinatesUtilities::getTargetShiftNorth( + fRunPara->fRunList[runlist_iter].fTargetRAJ2000, + fRunPara->fRunList[runlist_iter].fTargetDecJ2000, + ra_dec_arraypointing.first, + ra_dec_arraypointing.second); + + // modify wobble offsets for centering of sky maps + fRunPara->fRunList[runlist_iter].fWobbleNorthMod = i_WobbleJ2000_North - fRunPara->fRunList[runlist_iter].fSkyMapCentreNorth; + fRunPara->fRunList[runlist_iter].fWobbleWestMod = i_WobbleJ2000_West - fRunPara->fRunList[runlist_iter].fSkyMapCentreWest; + + if( fIsOn ) + { + cout << "\tWobble offsets (J2000): N: " << i_WobbleJ2000_North << " W: " << i_WobbleJ2000_West << endl; + cout << "\tSky maps centred at (ra,dec (J2000)) ("; + cout << fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000 << ", "; + cout << fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000 << ")"; + cout << "\tTelescopes pointing to: (ra,dec (J2000)) ("; + cout << ra_dec_arraypointing.first << ", "; + cout << ra_dec_arraypointing.second << ")"; + cout << ", N: " << fRunPara->fRunList[runlist_iter].fWobbleNorthMod; + cout << " W: " << fRunPara->fRunList[runlist_iter].fWobbleWestMod << endl; + cout << "\t1D-histograms calculated at (x,y): "; + cout << fRunPara->fRunList[runlist_iter].fTargetShiftNorth << ", " << fRunPara->fRunList[runlist_iter].fTargetShiftWest; + if( TMath::Abs( fRunPara->fTargetShiftDecJ2000 ) > 1.e-8 && TMath::Abs( fRunPara->fTargetShiftRAJ2000 ) > 1.e-8 ) + { + cout << " (ra,dec (J2000)) " << fRunPara->fTargetShiftRAJ2000 << ", " << fRunPara->fTargetShiftDecJ2000; + } + cout << endl; + } +} + +/* + * precess telescope pointing from J2000 to current epoch + * and return current epoch coordinates + */ +pair< double, double > VStereoAnalysis::astro_calculate_ra_dec_currentEpoch( unsigned int runlist_iter ) +{ + pair< double, double > i_radec; + i_radec.first = fRunPara->fRunList[runlist_iter].fTargetRAJ2000 * TMath::DegToRad(); + i_radec.second = fRunPara->fRunList[runlist_iter].fTargetDecJ2000 * TMath::DegToRad(); + + VSkyCoordinatesUtilities::precessTarget( astro_get_mjd( runlist_iter ), i_radec.first, i_radec.second ); + // set target coordinates into run parameter list + fRunPara->setTargetRADec_currentEpoch( + runlist_iter, + i_radec.first * TMath::RadToDeg(), + i_radec.second * TMath::RadToDeg() ); + + return i_radec; +} + +void VStereoAnalysis::astro_print_pointing( unsigned int runlist_iter ) +{ + if( !fIsOn ) return; + // print some information on targeting/pointing to screen + cout << "Run " << fRunPara->fRunList[runlist_iter].fRunOn << " ---------------------------" << endl; + // print target info to screen + cout << "\tTarget: " << fRunPara->fRunList[runlist_iter].fTarget << " (ra,dec)=("; + cout << fRunPara->fRunList[runlist_iter].fTargetRA << ", " << fRunPara->fRunList[runlist_iter].fTargetDec << ")"; + cout << " (precessed, MJD=" << astro_get_mjd( runlist_iter ) << "), "; + cout << "(ra,dec (J2000)) = ("; + cout << fRunPara->fRunList[runlist_iter].fTargetRAJ2000 << ", "; + cout << fRunPara->fRunList[runlist_iter].fTargetDecJ2000 << ")"; + if( TMath::Abs( fRunPara->fRunList[runlist_iter].fPairOffset ) > 1.e-2 ) + { + cout << ", pair offset [min]: " << fRunPara->fRunList[runlist_iter].fPairOffset; + } + cout << endl; +} + +/* + * set and get the regions to exclude + * (these are calculated relative to the sky map centre) +*/ +void VStereoAnalysis::astro_set_exclusionsregions( unsigned int runlist_iter ) +{ + astro_setup_star_cataloge(runlist_iter); + + for( unsigned int k = 0 ; k < fRunPara->fExclusionRegions.size(); k++ ) + { + if( fRunPara->fExclusionRegions[k]->fExcludeFromBackground_DecJ2000 < -90. ) + { + continue; + } + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_West = + VSkyCoordinatesUtilities::getTargetShiftWest( + fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000, + fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000, + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_RAJ2000, + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_DecJ2000 ); + + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_North = + VSkyCoordinatesUtilities::getTargetShiftNorth( + fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000, + fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000, + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_RAJ2000, + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_DecJ2000 ); + + if( TMath::Abs( fRunPara->fExclusionRegions[k]->fExcludeFromBackground_North ) < 1.e-8 ) + { + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_North = 0.; + } + if( TMath::Abs( fRunPara->fExclusionRegions[k]->fExcludeFromBackground_West ) < 1.e-8 ) + { + fRunPara->fExclusionRegions[k]->fExcludeFromBackground_West = 0.; + } + } +} + +/* + * set up star catalogue and exclusion regions + * (all in J2000) + */ +void VStereoAnalysis::astro_setup_star_cataloge( unsigned int runlist_iter ) +{ + if( !fIsOn ) return; + + fAstro.back()->initStarCatalogue( + fRunPara->fStarCatalogue, + astro_get_mjd(runlist_iter), + fRunPara->fSkyMapSizeXmin, fRunPara->fSkyMapSizeXmax, + fRunPara->fSkyMapSizeYmin, fRunPara->fSkyMapSizeYmax, + fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000, fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000 ); + VStarCatalogue* iStarCatalogue = fAstro.back()->getStarCatalogue(); + if( !iStarCatalogue ) + { + cout << "VStereoAnalysis::astro_setup_star_cataloge() error: star catalogue not found: " << fRunPara->fStarCatalogue << endl; + cout << "exiting..." << endl; + exit( EXIT_FAILURE ); + } + // remove double entries + iStarCatalogue->purge(); + if( iStarCatalogue->getListOfStarsinFOV().size() == 0 ) return; + + cout << "\tbright stars (magnitude brighter than " << fRunPara->fStarMinBrightness << ", exclusion radius "; + cout << fRunPara->fStarExlusionRadius << " deg, " << fRunPara->fStarBand << "-band) in field of view (J2000): " << endl; + cout << "\t\t ID \t RA \t Dec \t magnitude " << endl; + for( unsigned int i = 0; i < iStarCatalogue->getListOfStarsinFOV().size(); i++ ) + { + if( !iStarCatalogue->getListOfStarsinFOV()[i] + || iStarCatalogue->getListOfStarsinFOV()[i]->getBrightness( fRunPara->fStarBand ) + >= fRunPara->fStarMinBrightness + || fRunPara->fStarExlusionRadius <= 0. ) + { + continue; + } + iStarCatalogue->getListOfStarsinFOV()[i]->printStar_for_anasum( fRunPara->fStarBand ); + + // check if this region is already excluded (avoid dublications) + bool b_isExcluded = false; + for( unsigned int e = 0; e < fRunPara->fExclusionRegions.size(); e++ ) + { + if( fRunPara->fExclusionRegions[e]->fExcludeFromBackground_StarID >= 0 + && fRunPara->fExclusionRegions[e]->fExcludeFromBackground_StarID == (int)iStarCatalogue->getListOfStarsinFOV()[i]->fStarID ) + { + b_isExcluded = true; + } + } + if( b_isExcluded ) continue; + fRunPara->fExclusionRegions.push_back( new VAnaSumRunParameterListOfExclusionRegions() ); + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_RAJ2000 = iStarCatalogue->getListOfStarsinFOV()[i]->fRA2000; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_DecJ2000 = iStarCatalogue->getListOfStarsinFOV()[i]->fDec2000; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_Radius1 = fRunPara->fStarExlusionRadius; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_Radius2 = fRunPara->fStarExlusionRadius; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_North = 0.; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_West = 0.; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarID = ( int )iStarCatalogue->getListOfStarsinFOV()[i]->fStarID; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarName = iStarCatalogue->getListOfStarsinFOV()[i]->fStarName; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarBrightness_V = iStarCatalogue->getListOfStarsinFOV()[i]->fBrightness_V; + fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarBrightness_B = iStarCatalogue->getListOfStarsinFOV()[i]->fBrightness_B; + } + iStarCatalogue->purge(); +} /* - (this is called for each run) + setup all coordinate systems - set targets - set sky map centres @@ -1396,309 +1737,32 @@ void VStereoAnalysis::defineAstroSource() cout << "Defining targets and exclusion regions" << endl; } - ///////////////////////////////////////////////////////// - // loop over all runs in runlist for( unsigned int i = 0; i < fRunPara->fRunList.size(); i++ ) { - ///////////////////////////////////////////////////////// - // check source coordinates - // (this is the target of observation) - ///////////////////////////////////////////////////////// - if( fRunPara->fRunList[i].fTargetDecJ2000 < -89.99 ) - { - cout << "ERROR in VStereoAnalysis::defineAstroSource: invalid target " << fRunPara->fRunList[i].fTarget << endl; - cout << "\t run " << fRunPara->fRunList[i].fRunOn << "\t" << fRunPara->fRunList[i].fTarget; - cout << fRunPara->fRunList[i].fTargetDecJ2000 << "\t" << fRunPara->fRunList[i].fTargetShiftDecJ2000 << endl; - exit( EXIT_FAILURE ); - } - - ///////////////////////////////////////////////////////// - // Case 1: sky map centre is given as xy offset [deg] in runparameter file - if( TMath::Abs( fRunPara->fSkyMapCentreNorth ) > 1.e-8 || TMath::Abs( fRunPara->fSkyMapCentreWest ) > 1.e-8 ) - { - fRunPara->fRunList[i].fSkyMapCentreWest = fRunPara->fSkyMapCentreWest; - fRunPara->fRunList[i].fSkyMapCentreNorth = fRunPara->fSkyMapCentreNorth; - double i_decDiff = 0.; // offset in dec - double i_raDiff = 0.; // offset in ra - VSkyCoordinatesUtilities::getWobbleOffset_in_RADec( - fRunPara->fRunList[i].fSkyMapCentreNorth, - fRunPara->fRunList[i].fSkyMapCentreWest, - fRunPara->fRunList[i].fTargetRAJ2000, fRunPara->fRunList[i].fTargetDecJ2000, - i_decDiff, i_raDiff ); - fRunPara->fRunList[i].fSkyMapCentreRAJ2000 = fRunPara->fRunList[i].fTargetRAJ2000 + i_raDiff; - fRunPara->fRunList[i].fSkyMapCentreDecJ2000 = fRunPara->fRunList[i].fTargetDecJ2000 + i_decDiff; - } - // Case 2: sky map centre is given in J200 in runparameter file - // (this is in almost all analysis the usual/default case) - else if( TMath::Abs( fRunPara->fSkyMapCentreRAJ2000 ) > 1.e-8 ) - { - fRunPara->fRunList[i].fSkyMapCentreRAJ2000 = fRunPara->fSkyMapCentreRAJ2000; - fRunPara->fRunList[i].fSkyMapCentreDecJ2000 = fRunPara->fSkyMapCentreDecJ2000; - fRunPara->fRunList[i].fSkyMapCentreWest = - VSkyCoordinatesUtilities::getTargetShiftWest( - fRunPara->fRunList[i].fTargetRAJ2000, fRunPara->fRunList[i].fTargetDecJ2000, - fRunPara->fSkyMapCentreRAJ2000, fRunPara->fSkyMapCentreDecJ2000 ) * -1.; - fRunPara->fRunList[i].fSkyMapCentreNorth = - VSkyCoordinatesUtilities::getTargetShiftNorth( - fRunPara->fRunList[i].fTargetRAJ2000, fRunPara->fRunList[i].fTargetDecJ2000, - fRunPara->fSkyMapCentreRAJ2000, fRunPara->fSkyMapCentreDecJ2000 ); - } - // if not set in runparameter file: set to target direction - else - { - fRunPara->fRunList[i].fSkyMapCentreRAJ2000 = fRunPara->fRunList[i].fTargetRAJ2000; - fRunPara->fRunList[i].fSkyMapCentreDecJ2000 = fRunPara->fRunList[i].fTargetDecJ2000; - fRunPara->fSkyMapCentreRAJ2000 = fRunPara->fRunList[i].fSkyMapCentreRAJ2000; - fRunPara->fSkyMapCentreDecJ2000 = fRunPara->fRunList[i].fSkyMapCentreDecJ2000; - } + astro_check_for_valid_coordinates( i ); + astro_set_skymap_center_from_runparameters( i ); + astro_set_skymap_centershift_from_runparameters( i ); - ///////////////////////////////////////////////////////// - // from runparameter file: set and get target shifts - // (calculated relative to sky map centre) - // (this is the position where all 1D histograms (theta2, energy spectra, etc) are calculated) - if( fIsOn ) - { - if( TMath::Abs( fRunPara->fTargetShiftDecJ2000 ) > 1.e-8 || TMath::Abs( fRunPara->fTargetShiftRAJ2000 ) > 1.e-8 ) - { - fRunPara->fRunList[i].fTargetShiftWest = VSkyCoordinatesUtilities::getTargetShiftWest( - fRunPara->fRunList[i].fTargetRAJ2000, fRunPara->fRunList[i].fTargetDecJ2000, - fRunPara->fTargetShiftRAJ2000, fRunPara->fTargetShiftDecJ2000 ); - fRunPara->fRunList[i].fTargetShiftNorth = -1.*VSkyCoordinatesUtilities::getTargetShiftNorth( - fRunPara->fRunList[i].fTargetRAJ2000, fRunPara->fRunList[i].fTargetDecJ2000, - fRunPara->fTargetShiftRAJ2000, fRunPara->fTargetShiftDecJ2000 ); - - fRunPara->fRunList[i].fTargetShiftWest += fRunPara->fRunList[i].fSkyMapCentreWest; - fRunPara->fRunList[i].fTargetShiftNorth += fRunPara->fRunList[i].fSkyMapCentreNorth; - } - else - { - fRunPara->fRunList[i].fTargetShiftWest = fRunPara->fTargetShiftWest; - fRunPara->fRunList[i].fTargetShiftNorth = fRunPara->fTargetShiftNorth; - } - fRunPara->fRunList[i].fTargetShiftWest *= -1.; - fRunPara->fTargetShiftWest = fRunPara->fRunList[i].fTargetShiftWest; - fRunPara->fTargetShiftNorth = fRunPara->fRunList[i].fTargetShiftNorth; - fRunPara->setTargetShifts( i, fRunPara->fRunList[i].fTargetShiftWest, fRunPara->fRunList[i].fTargetShiftNorth, - fRunPara->fTargetShiftRAJ2000, fRunPara->fTargetShiftDecJ2000 ); - } - ///////////////////////////////////////////////////////// - // precess target coordinates from J2000 to current epoch - // (direction of telescope pointing) - double i_dec = fRunPara->fRunList[i].fTargetDecJ2000 * TMath::DegToRad(); - double i_ra = fRunPara->fRunList[i].fTargetRAJ2000 * TMath::DegToRad(); - double iMJD = ( double )fRunPara->fRunList[i].fMJDOn; - if( !fIsOn ) - { - iMJD = ( double )fRunPara->fRunList[i].fMJDOff; - } - // (i_dec and i_ra are in current epoch coordinates in the following, not J2000) - VSkyCoordinatesUtilities::precessTarget( iMJD, i_ra, i_dec ); - - // print some information on targeting/pointing to screen - if( fIsOn ) - { - cout << "Run " << fRunPara->fRunList[i].fRunOn << " ---------------------------" << endl; - // set target coordinates into run parameter list - fRunPara->setTargetRADec_currentEpoch( i, i_ra * TMath::RadToDeg(), i_dec * TMath::RadToDeg() ); - // print target info to screen - cout << "\tTarget: " << fRunPara->fRunList[i].fTarget << " (ra,dec)=("; - cout << fRunPara->fRunList[i].fTargetRA << ", " << fRunPara->fRunList[i].fTargetDec << ")"; - cout << " (precessed, MJD=" << iMJD << "), "; - cout << "(ra,dec (J2000)) = (" << fRunPara->fRunList[i].fTargetRAJ2000 << ", " << fRunPara->fRunList[i].fTargetDecJ2000 << ")"; - if( TMath::Abs( fRunPara->fRunList[i].fPairOffset ) > 1.e-2 ) - { - cout << ", pair offset [min]: " << fRunPara->fRunList[i].fPairOffset; - } - cout << endl; - } - ///////////////////////////////////// - // calculate wobble offsets in J2000 - // (this might be overcomplicated) - ///////////////////////////////////// - // calculate wobble offset in ra/dec for current epoch - double i_decDiff = 0.; - double i_raDiff = 0.; - VSkyCoordinatesUtilities::getWobbleOffset_in_RADec( - fRunPara->fRunList[i].fWobbleNorth, -1.*fRunPara->fRunList[i].fWobbleWest, - i_dec * TMath::RadToDeg(), i_ra * TMath::RadToDeg(), i_decDiff, i_raDiff ); - if( i_raDiff < -180. ) - { - i_raDiff += 360.; - } - double i_decWobble = i_dec * TMath::RadToDeg() + i_decDiff; - double i_raWobble = i_ra * TMath::RadToDeg() + i_raDiff; - // correct for precession (from current epoch to J2000=MJD51544) - VSkyCoordinatesUtilities::precessTarget( 51544., i_raWobble, i_decWobble, iMJD, true ); - double i_WobbleJ2000_West = VSkyCoordinatesUtilities::getTargetShiftWest( - fRunPara->fRunList[i].fTargetRAJ2000, - fRunPara->fRunList[i].fTargetDecJ2000, - i_raWobble, i_decWobble ) * -1.; - double i_WobbleJ2000_North = VSkyCoordinatesUtilities::getTargetShiftNorth( - fRunPara->fRunList[i].fTargetRAJ2000, - fRunPara->fRunList[i].fTargetDecJ2000, - i_raWobble, i_decWobble ); - // modify wobble offsets for centering of sky maps - fRunPara->fRunList[i].fWobbleNorthMod = i_WobbleJ2000_North - fRunPara->fRunList[i].fSkyMapCentreNorth; - fRunPara->fRunList[i].fWobbleWestMod = i_WobbleJ2000_West - fRunPara->fRunList[i].fSkyMapCentreWest; + astro_calculate_ra_dec_currentEpoch( i ); + astro_print_pointing( i ); + astro_calculate_modified_wobbleoffset( i ); // fill run parameter values - fRunPara->setTargetRADecJ2000( i, fRunPara->fRunList[i].fTargetRAJ2000, - fRunPara->fRunList[i].fTargetDecJ2000, - fRunPara->fRunList[i].fTarget ); - fRunPara->setTargetShifts( i, fRunPara->fRunList[i].fTargetShiftWest, fRunPara->fRunList[i].fTargetShiftNorth, - fRunPara->fTargetShiftRAJ2000, fRunPara->fTargetShiftDecJ2000 ); - fRunPara->setSkyMapCentreJ2000( i, fRunPara->fRunList[i].fSkyMapCentreRAJ2000, fRunPara->fRunList[i].fSkyMapCentreDecJ2000 ); - - /////////////////////////////////////////////////////////////////// - // some printout - if( fIsOn ) - { - cout << "\tWobble offsets (currE): N: " << fRunPara->fRunList[i].fWobbleNorth << " W: " << fRunPara->fRunList[i].fWobbleWest; - cout << ", RA " << i_raDiff << ", Dec " << i_decDiff << endl; - cout << "\tWobble offsets (J2000): N: " << i_WobbleJ2000_North << " W: " << i_WobbleJ2000_West << endl; - cout << "\tSky maps centred at (ra,dec (J2000)) ("; - cout << fRunPara->fRunList[i].fSkyMapCentreRAJ2000 << ", " << fRunPara->fRunList[i].fSkyMapCentreDecJ2000 << ")"; - cout << "\tTelescopes pointing to: (ra,dec (J2000)) (" << i_raWobble << ", " << i_decWobble << ")"; - cout << ", N: " << fRunPara->fRunList[i].fWobbleNorthMod << " W: " << fRunPara->fRunList[i].fWobbleWestMod << endl; - cout << "\t1D-histograms calculated at (x,y): "; - cout << fRunPara->fRunList[i].fTargetShiftNorth << ", " << fRunPara->fRunList[i].fTargetShiftWest; - if( TMath::Abs( fRunPara->fTargetShiftDecJ2000 ) > 1.e-8 && TMath::Abs( fRunPara->fTargetShiftRAJ2000 ) > 1.e-8 ) - { - cout << " (ra,dec (J2000)) " << fRunPara->fTargetShiftRAJ2000 << ", " << fRunPara->fTargetShiftDecJ2000; - } - cout << endl; - } - - ////////////////////////////////// + fRunPara->setTargetRADecJ2000( i ); + fRunPara->setTargetShifts( i ); + fRunPara->setSkyMapCentreJ2000( i ); - // ============================================================= // define source and tracking class fAstro.push_back( new VSkyCoordinates() ); - // get wobble offsets in ra,dec - i_dec = fRunPara->fRunList[i].fTargetDecJ2000 * TMath::DegToRad(); - i_ra = fRunPara->fRunList[i].fTargetRAJ2000 * TMath::DegToRad(); - // precess target to current epoch - VSkyCoordinatesUtilities::precessTarget( iMJD, i_ra, i_dec ); - double idec_T = 0.; - double ira_T = 0.; - VSkyCoordinatesUtilities::getWobbledDirection( fRunPara->fRunList[i].fWobbleNorth, fRunPara->fRunList[i].fWobbleWest, - i_dec * TMath::RadToDeg(), i_ra * TMath::RadToDeg(), idec_T, ira_T ); - // setting telescope coordinates (in current epoch) - // (ignore pointing errors here (very small impact)) - fAstro.back()->setTelDec_deg( idec_T ); - fAstro.back()->setTelRA_deg( ira_T ); - // set observatory position - fAstro.back()->setObservatory( fRunPara->getObservatory_Longitude_deg(), fRunPara->getObservatory_Latitude_deg() ); - // ============================================================= - // set up star catalogue and exclusion regions - // (all in J2000) - if( fIsOn ) - { - fAstro.back()->initStarCatalogue( fRunPara->fStarCatalogue, iMJD, fRunPara->fSkyMapSizeXmin, fRunPara->fSkyMapSizeXmax, - fRunPara->fSkyMapSizeYmin, fRunPara->fSkyMapSizeYmax, - fRunPara->fRunList[i].fSkyMapCentreRAJ2000, fRunPara->fRunList[i].fSkyMapCentreDecJ2000 ); - VStarCatalogue* iStarCatalogue = fAstro.back()->getStarCatalogue(); - if( !iStarCatalogue ) - { - cout << "VStereoAnalysis::defineAstroSource() error: star catalogue not found: " << fRunPara->fStarCatalogue << endl; - cout << "exiting..." << endl; - exit( EXIT_FAILURE ); - } - // remove double entries - iStarCatalogue->purge(); - if( iStarCatalogue->getListOfStarsinFOV().size() > 0 ) - { - cout << "\tbright stars (magnitude brighter than " << fRunPara->fStarMinBrightness << ", exclusion radius "; - cout << fRunPara->fStarExlusionRadius << " deg, " << fRunPara->fStarBand << "-band) in field of view (J2000): " << endl; - cout << "\t\t ID \t RA \t Dec \t magnitude " << endl; - double i_brightness = 100.; - for( unsigned int i = 0; i < iStarCatalogue->getListOfStarsinFOV().size(); i++ ) - { - if( !iStarCatalogue->getListOfStarsinFOV()[i] ) - { - continue; - } + fAstro.back()->setTelRADec_deg( astro_get_arraypointing( i, false ) ); - if( fRunPara->fStarBand == "V" ) - { - i_brightness = iStarCatalogue->getListOfStarsinFOV()[i]->fBrightness_V; - } - else if( fRunPara->fStarBand == "B" ) - { - i_brightness = iStarCatalogue->getListOfStarsinFOV()[i]->fBrightness_B; - } + fAstro.back()->setObservatory( + fRunPara->getObservatory_Longitude_deg(), + fRunPara->getObservatory_Latitude_deg() ); - if( i_brightness < fRunPara->fStarMinBrightness ) - { - cout << "\t\t" << iStarCatalogue->getListOfStarsinFOV()[i]->fStarID << "\t"; - cout << iStarCatalogue->getListOfStarsinFOV()[i]->fRA2000 << "\t"; - cout << iStarCatalogue->getListOfStarsinFOV()[i]->fDec2000 << "\t"; - cout << i_brightness << " (" << fRunPara->fStarBand << " band)"; - cout << " " << iStarCatalogue->getListOfStarsinFOV()[i]->fStarName; - cout << endl; - // add this to set of exclusion regions - if( fRunPara->fStarExlusionRadius > 0. ) - { - // check if this region is already excluded (avoid dublications) - bool b_isExcluded = false; - for( unsigned int e = 0; e < fRunPara->fExclusionRegions.size(); e++ ) - { - if( fRunPara->fExclusionRegions[e]->fExcludeFromBackground_StarID >= 0 - && fRunPara->fExclusionRegions[e]->fExcludeFromBackground_StarID == ( int )iStarCatalogue->getListOfStarsinFOV()[i]->fStarID ) - { - b_isExcluded = true; - } - } - if( !b_isExcluded ) - { - fRunPara->fExclusionRegions.push_back( new VAnaSumRunParameterListOfExclusionRegions() ); - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_RAJ2000 = iStarCatalogue->getListOfStarsinFOV()[i]->fRA2000; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_DecJ2000 = iStarCatalogue->getListOfStarsinFOV()[i]->fDec2000; - //fRunPara->fExclusionRegions.back()->fExcludeFromBackground_Radius = fRunPara->fStarExlusionRadius; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_Radius1 = fRunPara->fStarExlusionRadius; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_Radius2 = fRunPara->fStarExlusionRadius; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_North = 0.; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_West = 0.; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarID = ( int )iStarCatalogue->getListOfStarsinFOV()[i]->fStarID; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarName = iStarCatalogue->getListOfStarsinFOV()[i]->fStarName; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarBrightness_V = iStarCatalogue->getListOfStarsinFOV()[i]->fBrightness_V; - fRunPara->fExclusionRegions.back()->fExcludeFromBackground_StarBrightness_B = iStarCatalogue->getListOfStarsinFOV()[i]->fBrightness_B; - } - } - } - } - } - iStarCatalogue->purge(); - } - // doesn't work if different sources are analyzed with RA <> 360 deg - ///////////////////////////////////////////////////////// - // set and get the regions to exclude - // (these are calculated relative to the sky map centre) - for( unsigned int k = 0 ; k < fRunPara->fExclusionRegions.size(); k++ ) - { - if( fRunPara->fExclusionRegions[k]->fExcludeFromBackground_DecJ2000 > -90. ) - { - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_West = VSkyCoordinatesUtilities::getTargetShiftWest( fRunPara->fRunList[i].fSkyMapCentreRAJ2000, - fRunPara->fRunList[i].fSkyMapCentreDecJ2000, - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_RAJ2000, - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_DecJ2000 ); - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_North = VSkyCoordinatesUtilities::getTargetShiftNorth( fRunPara->fRunList[i].fSkyMapCentreRAJ2000, - fRunPara->fRunList[i].fSkyMapCentreDecJ2000, - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_RAJ2000, - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_DecJ2000 ); - if( TMath::Abs( fRunPara->fExclusionRegions[k]->fExcludeFromBackground_North ) < 1.e-4 ) - { - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_North = 0.; - } - if( TMath::Abs( fRunPara->fExclusionRegions[k]->fExcludeFromBackground_West ) < 1.e-4 ) - { - fRunPara->fExclusionRegions[k]->fExcludeFromBackground_West = 0.; - } - } - } + astro_set_exclusionsregions( i ); } } -///////////////////////////////////////////////////////// void VStereoAnalysis::setCuts( VAnaSumRunParameterDataClass iL, int irun ) From 8c1c2a7055dbe2a40fe11521c6fc7eb624da36b1 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Sun, 20 Feb 2022 21:58:03 +0100 Subject: [PATCH 2/3] add array pointing as explicity variable --- inc/VAnaSumRunParameter.h | 7 +++++++ src/VAnaSumRunParameter.cpp | 32 ++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/inc/VAnaSumRunParameter.h b/inc/VAnaSumRunParameter.h index 987ffeb2..53ac2451 100644 --- a/inc/VAnaSumRunParameter.h +++ b/inc/VAnaSumRunParameter.h @@ -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] @@ -258,6 +264,7 @@ 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, std::pair); bool setRunTimes( unsigned int irun, double iMJDStart, double iMJDStopp ); bool setSkyMapCentreJ2000( unsigned int i ); bool setTargetRADecJ2000( unsigned int i ); diff --git a/src/VAnaSumRunParameter.cpp b/src/VAnaSumRunParameter.cpp index 22ed7a23..2fa37987 100644 --- a/src/VAnaSumRunParameter.cpp +++ b/src/VAnaSumRunParameter.cpp @@ -25,6 +25,11 @@ VAnaSumRunParameterDataClass::VAnaSumRunParameterDataClass() fTargetDecJ2000 = -90.; fTargetRA = 0.; fTargetDec = 0.; + + fArrayPointingRA = 0.; + fArrayPointingDec = 0.; + fArrayPointingRAJ2000 = 0.; + fArrayPointingDecJ2000 = 0.; fPairOffset = 0.; @@ -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" ) @@ -1607,6 +1612,25 @@ bool VAnaSumRunParameter::setTargetRADecJ2000( unsigned int i ) return false; } +void VAnaSumRunParameter::setArrayPointing( + unsigned int i, + pair< double, double > i_radec, + pair< double, double > i_radecJ2000 ) +{ + if( i >= fRunList.size() ) return; + + 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 ) { From c5574c68bf7d31d691ba04f45ae3c4d0675bee46 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Sun, 20 Feb 2022 22:00:14 +0100 Subject: [PATCH 3/3] bug fix in filling of ra/dec for DL3 Tree --- src/VStereoAnalysis.cpp | 53 +++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/VStereoAnalysis.cpp b/src/VStereoAnalysis.cpp index 8469e7ec..680aaaa9 100644 --- a/src/VStereoAnalysis.cpp +++ b/src/VStereoAnalysis.cpp @@ -275,7 +275,6 @@ double VStereoAnalysis::fillHistograms( int icounter, int irun, double iAzMin, d fHisCounter = -1; return combineHistograms(); } - //////////////////////////////////////////////// //////////////////////////////////////////////// // analyze individual run @@ -503,12 +502,8 @@ double VStereoAnalysis::fillHistograms( int icounter, int irun, double iAzMin, d fHisto[fHisCounter]->hTriggerPatternBeforeCuts->Fill( fDataRun->LTrig ); fHisto[fHisCounter]->hImagePatternBeforeCuts->Fill( fDataRun->ImgSel ); - // direction offset iDirectionOffset = sqrt( iXoff * iXoff + iYoff * iYoff ); - - // derotate coordinates - // (sign change in Y important - GrISU inspired coordinate system) - getDerotatedCoordinates( icounter, i_UTC, iXoff, -1.* iYoff, i_xderot, i_yderot ); + getDerotatedCoordinates( icounter, i_UTC, iXoff, iYoff, i_xderot, i_yderot ); // gamma/hadron cuts bIsGamma = fCuts->isGamma( i, false, fIsOn ); @@ -1555,6 +1550,7 @@ void VStereoAnalysis::astro_calculate_modified_wobbleoffset( unsigned int runlis cout << "\tSky maps centred at (ra,dec (J2000)) ("; cout << fRunPara->fRunList[runlist_iter].fSkyMapCentreRAJ2000 << ", "; cout << fRunPara->fRunList[runlist_iter].fSkyMapCentreDecJ2000 << ")"; + cout << endl; cout << "\tTelescopes pointing to: (ra,dec (J2000)) ("; cout << ra_dec_arraypointing.first << ", "; cout << ra_dec_arraypointing.second << ")"; @@ -1746,6 +1742,10 @@ void VStereoAnalysis::defineAstroSource() astro_calculate_ra_dec_currentEpoch( i ); astro_print_pointing( i ); astro_calculate_modified_wobbleoffset( i ); + fRunPara->setArrayPointing( + i, + astro_get_arraypointing(i, false), + astro_get_arraypointingJ2000(i) ); // fill run parameter values fRunPara->setTargetRADecJ2000( i ); @@ -2131,7 +2131,7 @@ void VStereoAnalysis::getDerotatedCoordinates( unsigned int icounter, double i_ // (!!!! Y coordinate reflected in eventdisplay for version < v.3.43 !!!!) // ( don't change signs if you don't know why! ) - fAstro[icounter]->derotateCoords( i_UTC, x, y, x_derot, y_derot ); + fAstro[icounter]->derotateCoords( i_UTC, x, -1.*y, x_derot, y_derot ); y_derot *= -1.; VSkyCoordinatesUtilities::convert_derotatedCoordinates_to_J2000( i_UTC, @@ -2231,18 +2231,18 @@ void VStereoAnalysis::fill_DL3Tree( CData* c , double i_xderot, double i_yderot, return; } - fDL3EventTree_runNumber = c->runNumber; // Run Number - fDL3EventTree_eventNumber = c->eventNumber; // Event Number + fDL3EventTree_runNumber = c->runNumber; + fDL3EventTree_eventNumber = c->eventNumber; fDL3EventTree_Time = c->Time; // Time of day (seconds) of gamma ray event - fDL3EventTree_MJD = c->MJD; // Day of epoch (days) + fDL3EventTree_MJD = c->MJD; fDL3EventTree_Xoff = c->Xoff; // Gamma Point-Of-Origin, in camera coodinates (deg) fDL3EventTree_Yoff = c->Yoff; // Gamma Point-Of-Origin, in camera coodinates (deg) fDL3EventTree_Xderot = i_xderot; // Derotated Gamma Point-Of-Origin (deg, RA) fDL3EventTree_Yderot = i_yderot; // Derotated Gamma Point-Of-Origin (deg, DEC) if( fCuts ) { - fDL3EventTree_Erec = fCuts->getReconstructedEnergy( fRunPara->fEnergyReconstructionMethod ); // Reconstructed Gamma Energy (TeV) - fDL3EventTree_Erec_Err = fCuts->getReconstructedEnergydE( fRunPara->fEnergyReconstructionMethod ); // Reconstructed Gamma Energy (TeV) Error + fDL3EventTree_Erec = fCuts->getReconstructedEnergy( fRunPara->fEnergyReconstructionMethod ); + fDL3EventTree_Erec_Err = fCuts->getReconstructedEnergydE( fRunPara->fEnergyReconstructionMethod ); // Reconstructed Gamma Energy (TeV) Error } else { @@ -2251,7 +2251,7 @@ void VStereoAnalysis::fill_DL3Tree( CData* c , double i_xderot, double i_yderot, } fDL3EventTree_XGroundCore = c->Xcore; // Gamma Ray Core-Ground intersection location (north) fDL3EventTree_YGroundCore = c->Ycore; // Gamma Ray Core-Ground intersection location (east) - fDL3EventTree_NImages = c->NImages; // Number of images used in reconstruction? + fDL3EventTree_NImages = c->NImages; // Number of images used in reconstruction fDL3EventTree_ImgSel = c->ImgSel; // binary code describing which telescopes had images fDL3EventTree_MeanPedvar = c->meanPedvar_Image; // average pedvar fDL3EventTree_MSCW = c->MSCW; // mean scaled width @@ -2265,27 +2265,22 @@ void VStereoAnalysis::fill_DL3Tree( CData* c , double i_xderot, double i_yderot, { fDL3EventTree_Acceptance = 0.; } - // get event ra and dec if( icounter < fRunPara->fRunList.size() ) { - double i_centerpoint_RA = ( fRunPara->fRunList[icounter].fTargetRAJ2000 + -1.0 * getWobbleWest() ); - double i_centerpoint_dec = ( fRunPara->fRunList[icounter].fTargetDecJ2000 + getWobbleNorth() ); - double i_Spherical_RA = 0.; - double i_Spherical_DEC = 0.; + double i_RA = 0.; + double i_DEC = 0.; slaDtp2s( fDL3EventTree_Xderot * TMath::DegToRad(), fDL3EventTree_Yderot * TMath::DegToRad(), - i_centerpoint_RA * TMath::DegToRad(), - i_centerpoint_dec * TMath::DegToRad(), - &i_Spherical_RA, &i_Spherical_DEC); - fDL3EventTree_RA = i_Spherical_RA * TMath::RadToDeg(); - fDL3EventTree_DEC = i_Spherical_DEC * TMath::RadToDeg(); - - // Convert from spherical RA and DEC to Azimuth and Zenith - // convert to degrees and do calculation - fVsky->setTargetJ2000( i_Spherical_DEC * TMath::RadToDeg(), i_Spherical_RA * TMath::RadToDeg() ); + fRunPara->fRunList[icounter].fArrayPointingRAJ2000 * TMath::DegToRad(), + fRunPara->fRunList[icounter].fArrayPointingDecJ2000 * TMath::DegToRad(), + &i_RA, &i_DEC); + fDL3EventTree_RA = i_RA * TMath::RadToDeg(); + fDL3EventTree_DEC = i_DEC * TMath::RadToDeg(); + + // Convert from RA and DEC to Azimuth and Zenith + fVsky->setTargetJ2000( i_DEC * TMath::RadToDeg(), i_RA * TMath::RadToDeg() ); fVsky->precessTarget( fDL3EventTree_MJD, 0 ) ; - // calculate new param fVsky->updatePointing( fDL3EventTree_MJD, fDL3EventTree_Time ) ; fDL3EventTree_Az = fVsky->getTargetAzimuth(); fDL3EventTree_El = fVsky->getTargetElevation(); @@ -2294,6 +2289,8 @@ void VStereoAnalysis::fill_DL3Tree( CData* c , double i_xderot, double i_yderot, { fDL3EventTree_RA = 0.; fDL3EventTree_DEC = 0.; + fDL3EventTree_Az = 0.; + fDL3EventTree_El = 0.; } if ( fCuts && fRunPara->fWriteAllEvents ) {