Changeset 6346 for trunk/MagicSoft
- Timestamp:
- 02/10/05 13:43:50 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r6342 r6346 22 22 -*-*- END OF LINE -*-*- 23 23 24 2005/02/10 Abelardo Moralejo25 26 * macros/starmc.C27 - Cleaned up a little bit, made the option to choose between28 calibration in photons or phe- easier to set.29 30 * manalysis/MMcCalibrationUpdate.[h,cc]31 - Added getter and setter for fSignalType. Set fSignalType=kPhot as32 default for consistency with MCalibrateData.33 34 24 2005/02/10 Markus Gaug 35 25 … … 48 38 49 39 40 50 41 2005/02/10 Thomas Bretz 51 42 … … 56 47 * mars.rc: 57 48 - use same values for image cleaning as default in star 49 50 * mpointing/MSrcPosCalc.[h,cc]: 51 - added the possibility to set the Source position from 52 a resource file 58 53 59 54 … … 65 60 problems... I forgot to commit the header yesterday, but M. Gaug 66 61 did it. 62 63 * macros/starmc.C 64 - Cleaned up a little bit, made the option to choose between 65 calibration in photons or phe- easier to set. 66 67 * manalysis/MMcCalibrationUpdate.[h,cc] 68 - Added getter and setter for fSignalType. Set fSignalType=kPhot as 69 default for consistency with MCalibrateData. 67 70 68 71 -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
r6141 r6346 71 71 #include "MLogManip.h" 72 72 73 #include "M RawRunHeader.h"73 #include "MGeomCam.h" 74 74 #include "MObservatory.h" 75 #include "MPointingPos.h" 75 76 #include "MSrcPosCam.h" 77 78 #include "MAstro.h" 79 #include "MVector3.h" 76 80 #include "MAstroSky2Local.h" 77 #include "MPointingPos.h"78 #include "MGeomCam.h"79 #include "MVector3.h"80 81 81 82 ClassImp(MSrcPosCalc); … … 88 89 // 89 90 MSrcPosCalc::MSrcPosCalc(const char *name, const char *title) 90 : fObservatory( 0), fPointPos(0), fSourcePos(0), fSrcPosCam(0),91 fGeom( 0), fTime(0)91 : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fSrcPosCam(NULL), 92 fGeom(NULL), fTime(NULL) 92 93 { 93 94 fName = name ? name : "MSrcPosCalc"; 94 fTitle = title ? title : "Derotates the source position in the camera"; 95 fTitle = title ? title : "Calculates the source position in the camera"; 96 } 97 98 // -------------------------------------------------------------------------- 99 // 100 // delete fSourcePos if kIsOwner 101 // set fSourcePos to NULL 102 // 103 void MSrcPosCalc::FreeSourcePos() 104 { 105 if (fSourcePos && TestBit(kIsOwner)) 106 delete fSourcePos; 107 108 fSourcePos = NULL; 109 } 110 111 // -------------------------------------------------------------------------- 112 // 113 // ra [h] 114 // dec [deg] 115 // 116 void MSrcPosCalc::SetSourcePos(Double_t ra, Double_t dec) 117 { 118 FreeSourcePos(); 119 120 fSourcePos = new MPointingPos("MSourcePos"); 121 fSourcePos->SetSkyPosition(ra, dec); 122 123 SetOwner(); 124 } 125 126 // -------------------------------------------------------------------------- 127 // 128 // Return ra/dec as string 129 // 130 TString MSrcPosCalc::GetRaDec(const MPointingPos &pos) const 131 { 132 const TString rstr = MAstro::Angle2Coordinate(pos.GetRa()); 133 const TString dstr = MAstro::Angle2Coordinate(pos.GetDec()); 134 135 return Form("Ra=%sh Dec=%sdeg", rstr.Data(), dstr.Data()); 95 136 } 96 137 … … 110 151 return kFALSE; 111 152 112 113 fSourcePos = (MPointingPos*)pList->FindObject("MSourcePos", "MPointingPos");114 153 if (!fSourcePos) 115 154 { 116 *fLog << warn << "MSourcePos [MPointPos] not found... The source position" << endl; 117 *fLog << warn << "set in MSrcPosCam (camera center if not set explicitely) will" << endl; 118 *fLog << warn << "be left unchanged, same for all events." << endl; 119 return kSKIP; 120 } 155 fSourcePos = (MPointingPos*)pList->FindObject("MSourcePos", "MPointingPos"); 156 if (!fSourcePos) 157 { 158 *fLog << warn << "MSourcePos [MPointPos] not found... The source position" << endl; 159 *fLog << warn << "set in MSrcPosCam (camera center if not set explicitely) will" << endl; 160 *fLog << warn << "be left unchanged, same for all events." << endl; 161 return kSKIP; 162 } 163 } 164 // FIXME: Maybe we have to call FreeSourcePos in PostProcess()? 121 165 122 166 fGeom = (MGeomCam*)pList->FindObject("MGeomCam"); … … 147 191 return kFALSE; 148 192 } 193 194 *fLog << inf; 195 *fLog << "Pointing Position: " << GetRaDec(*fPointPos) << endl; 196 *fLog << "Source Position: " << GetRaDec(*fSourcePos) << endl; 149 197 150 198 return kTRUE; … … 246 294 return kTRUE; 247 295 } 296 297 // -------------------------------------------------------------------------- 298 // 299 // Convert a coordinate stored in str into a double, stored in ret. 300 // Returns kTRUE on success, otherwise kFALSE 301 // 302 // Allowed formats are: 303 // 12.5 304 // -12.5 305 // +12.5 306 // -12:30:00.0 307 // 12:30:00.0 308 // +12:30:00.0 309 // 310 Bool_t MSrcPosCalc::GetCoordinate(TString str, Double_t &ret) const 311 { 312 str = str.Strip(TString::kBoth); 313 314 if (str.First(':')<0) 315 return atof(str); 316 317 if (MAstro::Coordinate2Angle(str, ret)) 318 return kTRUE; 319 320 *fLog << err << GetDescriptor() << endl; 321 *fLog << "Interpretation of Coordinate '" << str << "' not successfull... abort." << endl; 322 *fLog << "Corrdinate must have the format: '-12:30:00.0', '12:30:00.0' or '+12:30:00.0'" << endl; 323 return kFALSE; 324 } 325 326 // -------------------------------------------------------------------------- 327 // 328 // Read the setup from a TEnv, eg: 329 // MSrcPosCalc.SourceRa: ra 330 // MSrcPosCalc.SourceDec: dec 331 // MSrcPosCalc.SourcePos: ra dec 332 // 333 // For format of 'ra' and 'dec' see GetCoordinate() 334 // 335 // Coordinates are J2000.0 336 // 337 Int_t MSrcPosCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 338 { 339 Double_t ra=0; 340 Double_t dec=0; 341 342 if (IsEnvDefined(env, prefix, "SourceRaDec", print)) 343 { 344 TString str = GetEnvValue(env, prefix, "SourceRaDec", ""); 345 str = str.Strip(TString::kBoth); 346 347 const Ssiz_t pos = str.First(' '); 348 if (pos<0) 349 { 350 *fLog << err << GetDescriptor() << "SourceRaDec empty... abort." << endl; 351 return kERROR; 352 } 353 354 if (!GetCoordinate(str(0, pos), ra)) 355 return kERROR; 356 if (!GetCoordinate(str(pos+1, str.Length()), dec)) 357 return kERROR; 358 359 SetSourcePos(ra, dec); 360 return kTRUE; 361 } 362 363 Bool_t rc = kFALSE; 364 if (IsEnvDefined(env, prefix, "SourceRa", print)) 365 { 366 TString str = GetEnvValue(env, prefix, "SourceRa", ""); 367 368 if (!GetCoordinate(str, ra)) 369 return kERROR; 370 371 rc = kTRUE; 372 } 373 374 if (IsEnvDefined(env, prefix, "SourceDec", print)) 375 { 376 TString str = GetEnvValue(env, prefix, "SourceDec", ""); 377 378 if (!GetCoordinate(str, dec)) 379 return kERROR; 380 381 rc = kTRUE; 382 } 383 384 if (!rc) 385 return kFALSE; 386 387 SetSourcePos(ra, dec); 388 return kTRUE; 389 } -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h
r6082 r6346 20 20 { 21 21 private: 22 enum { 23 kIsOwner = BIT(14) 24 }; 25 22 26 MObservatory *fObservatory; 23 27 MPointingPos *fPointPos; … … 27 31 MTime *fTime; 28 32 33 // MSrcPosCalc 29 34 TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const; 35 TString GetRaDec(const MPointingPos &pos) const; 36 Bool_t GetCoordinate(TString str, Double_t &ret) const; 37 void FreeSourcePos(); 30 38 39 // MParContainer 40 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 41 42 // MTask 31 43 Int_t PreProcess(MParList *pList); 32 44 Int_t Process(); … … 34 46 public: 35 47 MSrcPosCalc(const char *name=NULL, const char *title=NULL); 48 ~MSrcPosCalc() { FreeSourcePos(); } 36 49 37 ClassDef(MSrcPosCalc, 0) // Derotates the source position in the camera 50 // MSrcPosCalc 51 void SetSourcePos(MPointingPos *pos) { FreeSourcePos(); fSourcePos = pos; } 52 void SetSourcePos(Double_t ra, Double_t dec); 53 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); } // Make MSrcPosCalc owner of fSourcePos 54 55 ClassDef(MSrcPosCalc, 0) // Calculates the source position in the camera 38 56 }; 39 57
Note:
See TracChangeset
for help on using the changeset viewer.