Changeset 9070
- Timestamp:
- 08/02/08 15:49:41 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9068 r9070 38 38 * msignal/MExtractor.cc: 39 39 - make sure Print() prints the class description 40 41 * mpointing/MSrcPosCalc.[h,cc]: 42 - if the MC camera files are new enough the source position on the 43 camera is now calculated from the stored telescope and shower 44 orientation 40 45 41 46 -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
r8725 r9070 17 17 ! 18 18 ! Author(s): Thomas Bretz 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Author(s): Abelardo Moralejo 1/2005 <mailto:moralejo@pd.infn.it>20 19 ! 21 ! Copyright: MAGIC Software Development, 2000-200 520 ! Copyright: MAGIC Software Development, 2000-2008 22 21 ! 23 22 ! … … 43 42 // coordinates of the observatory from MObservatory. 44 43 // 44 // If a reflector version >= 700 is detected the source position for 45 // Gammas (and _only_ gammas) is dynamically calculated from the 46 // telescope (e.g. MMcEvt::fTelescopePhi) and the shower (e.g. MMcEvt::fPhi) 47 // orientation. In off-mode it is fixed at the camera center. 48 // 45 49 // FIXME: Add here some information about the more-cycle calculation 46 50 // … … 50 54 // MGeomCam 51 55 // MTime 56 // [MMcRunHeader] 57 // [MMcCorsikaRunHeader] 52 58 // [MSourcePos] (of type MPointingPos) 53 59 // … … 57 63 // To be done: 58 64 // - a switch between using sky-coordinates and time or local-coordinates 59 // from MPointingPos for determine the rotation angle 60 ///// NOTE, A. Moralejo: the above is not possible if MAstroSky2Local does not 61 ///// account for precession and nutation. 65 // from MPointingPos for determine the rotation angle. (Therefor a conversion 66 // needs to be implemented inlcuding asrometric corrections) 62 67 // 63 68 // - the center of rotation need not to be the camera center … … 82 87 #include "MSrcPosCam.h" 83 88 #include "MRawRunHeader.h" 89 90 #include "MMcEvt.hxx" 91 #include "MMcRunHeader.hxx" 84 92 #include "MMcCorsikaRunHeader.h" 85 93 … … 97 105 // 98 106 MSrcPosCalc::MSrcPosCalc(const char *name, const char *title) 99 : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fDeviation(NULL), 100 fSrcPosCam(NULL), fSrcPosAnti(NULL), fGeom(NULL), fTime(NULL), fCallback(NULL), 101 fMode(kDefault), fNumRandomOffPositions(0) 107 : fObservatory(NULL), fPointPos(NULL), fDeviation(NULL), fMcEvt(NULL), 108 fMcHeader(NULL), fGeom(NULL), fTime(NULL), fCallback(NULL), 109 fSourcePos(NULL), fSrcPosCam(NULL), fSrcPosAnti(NULL), fMode(kDefault), 110 fNumRandomOffPositions(0) 102 111 { 103 112 fName = name ? name : "MSrcPosCalc"; … … 105 114 106 115 AddToBranchList("MTime.*"); 116 AddToBranchList("MMcEvt.*"); 107 117 AddToBranchList("MPointingPos.*"); 108 118 } … … 170 180 if (!fSrcPosAnti) 171 181 return kFALSE; 182 183 fGeom = (MGeomCam*)pList->FindObject("MGeomCam"); 184 if (!fGeom) 185 { 186 *fLog << err << "MGeomCam not found... aborting." << endl; 187 return kFALSE; 188 } 189 190 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos"); 191 if (!fPointPos) 192 { 193 *fLog << err << "MPointingPos not found... aborting." << endl; 194 return kFALSE; 195 } 172 196 173 197 if (!fSourcePos) … … 184 208 } 185 209 // FIXME: Maybe we have to call FreeSourcePos in PostProcess()? 186 187 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");188 if (!fGeom)189 {190 *fLog << err << "MGeomCam not found... aborting." << endl;191 return kFALSE;192 }193 194 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos");195 if (!fPointPos)196 {197 *fLog << err << "MPointingPos not found... aborting." << endl;198 return kFALSE;199 }200 210 201 211 fDeviation = (MPointingDev*)pList->FindObject("MPointingDev"); … … 262 272 } 263 273 274 void MSrcPosCalc::InitFixedPos() const 275 { 276 // It is set here for the cases in which Process is not called at all 277 fSrcPosCam->SetXY(fFixedPos/fGeom->GetConvMm2Deg()); 278 279 // Informal message output 280 *fLog << inf; 281 *fLog << "Source position set to x=" << fFixedPos.X() << "deg "; 282 *fLog << "y=" << fFixedPos.Y() << "deg" << endl; 283 } 284 264 285 // -------------------------------------------------------------------------- 265 286 // … … 269 290 Bool_t MSrcPosCalc::ReInit(MParList *plist) 270 291 { 292 // In OffMode set fixed position to camera center 271 293 if (fMode==kOffData) 272 {273 // Set fixed position to camera center274 294 fFixedPos = TVector2(); 275 295 296 if (fMode==kOffData || fMode==kFixed) 297 { 276 298 // It is set here for the cases in which Process is not called at all 277 fSrcPosCam->SetXY(fFixedPos);299 InitFixedPos(); 278 300 return kTRUE; 279 301 } … … 302 324 return kFALSE; 303 325 } 326 304 327 return kTRUE; 305 328 } 306 329 307 MMcCorsikaRunHeader *h = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader"); 330 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt"); 331 if (!fMcEvt) 332 { 333 *fLog << err << "MMcEvt not found... aborting." << endl; 334 return kFALSE; 335 } 336 337 fMcHeader = (const MMcRunHeader*)plist->FindObject("MMcRunHeader"); 338 if (!fMcHeader) 339 { 340 *fLog << err << "MMcRunHeader not found... aborting." << endl; 341 return kFALSE; 342 } 343 344 const MMcCorsikaRunHeader *h = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader"); 308 345 if (!h) 309 346 { … … 311 348 return kFALSE; 312 349 } 350 351 // We don't know here if these are gammas 352 //if (fMcHeader->GetReflVersion()>600) 353 // *fLog << inf << "Source position will be calculated from shower and telescope orientation." << endl; 313 354 314 355 // Determine Monte Carlo position from Monte Carlo header 315 356 TVector2 v(0, 0); 316 357 if (h->GetWobbleMode()>0.5) 317 v.Set(120. , 0.);358 v.Set(120.*fGeom->GetConvMm2Deg(), 0.); 318 359 if (h->GetWobbleMode()<-0.5) 319 v.Set(-120. , 0.);360 v.Set(-120.*fGeom->GetConvMm2Deg(), 0.); 320 361 321 362 // Set fixed position 322 363 fFixedPos = v; 323 364 324 // It is set here for the cases in which Process is not called at all 325 fSrcPosCam->SetXY(fFixedPos); 326 327 // Informal message output 328 *fLog << inf; 329 *fLog << "Source Position set to x=" << fFixedPos.X() << "mm "; 330 *fLog << "y=" << fFixedPos.Y() << "mm" << endl; 365 InitFixedPos(); 331 366 332 367 return kTRUE; 333 368 } 334 369 370 void MSrcPosCalc::CalcResult(const MVector3 &pos0, const MVector3 &pos) 371 { 372 // Calculate source position in camera, and convert to mm: 373 TVector2 v = MAstro::GetDistOnPlain(pos0, pos, -fGeom->GetCameraDist()*1000); 374 375 if (fDeviation) 376 v -= fDeviation->GetDevXY()/fGeom->GetConvMm2Deg(); 377 378 SetSrcPos(v); 379 } 380 335 381 // -------------------------------------------------------------------------- 336 382 // … … 339 385 Int_t MSrcPosCalc::Process() 340 386 { 341 if (fRunType==MRawRunHeader::kRTMonteCarlo || !fSourcePos || !fTime || !fObservatory || fMode==kOffData) 342 { 343 SetSrcPos(fFixedPos); 387 // In off-data mode the position is set to a fixed value 388 // independent of the run type. In fixed-data mode the position 389 // is set to the predefined position converted to mm. 390 if (fMode==kOffData || fMode==kFixed) 391 { 392 SetSrcPos(fFixedPos/fGeom->GetConvMm2Deg()); 393 return kTRUE; 394 } 395 396 // If it is a monte carlo run calculate source position from 397 // Monte Carlo headers 398 if (fRunType==MRawRunHeader::kRTMonteCarlo) 399 { 400 // If the reflector version is too old take source position 401 // from the WobbleMode in the header 402 if (fMcHeader->GetReflVersion()<=600) 403 { 404 SetSrcPos(fFixedPos/fGeom->GetConvMm2Deg()); 405 return kTRUE; 406 } 407 408 // If the reflector version was new enough calculate the 409 // source position from shower and telescope orientation 410 // FIXME: Copy fMcEvt to fSourcePos! 411 MVector3 pos0, pos; 412 pos0.SetZdAz(fPointPos->GetZdRad(), fPointPos->GetAzRad()); 413 pos.SetZdAz(fMcEvt->GetTheta(), fMcEvt->GetPhi()); 414 415 CalcResult(pos0, pos); 416 return kTRUE; 417 } 418 419 // If the user requested a fixed source position use this position 420 if (!fSourcePos || !fTime || !fObservatory) 421 { 422 SetSrcPos(fFixedPos/fGeom->GetConvMm2Deg()); 344 423 return kTRUE; 345 424 } … … 352 431 pos.SetRaDec(fSourcePos->GetRaRad(), fSourcePos->GetDecRad()); 353 432 433 // Set sky coordinates of camera center in pos0 (for details see below) 434 MVector3 pos0; // pos0: camera center 435 pos0.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad()); 436 437 // Here we check that the source position which was given 438 // by the drive system is not off by more than 1deg from the 439 // source position given by the user. (Checking every individual 440 // event is not the fastest, but the safest) 441 if (pos.DeltaPhi(pos0)*TMath::RadToDeg()>1) 442 { 443 *fLog << err << "ERROR - Defined source position deviates from pointing-ra/dec by more than 1deg!" << endl; 444 *fLog << "User defined source pos: "; 445 fSourcePos->Print(); 446 *fLog << "Pointing position of tel: "; 447 fPointPos->Print(); 448 449 return kFALSE; 450 } 451 354 452 // Convert sky coordinates of source to local coordinates. Warning! These are not the "true" local 355 453 // coordinates, since this transformation ignores precession and nutation effects. … … 357 455 pos *= conv; 358 456 359 // Set sky coordinates of camera center in pos0, and then convert to360 // local.Same comment as above. These coordinates differ from the true457 // Convert sky coordinates of camera center convert to local. 458 // Same comment as above. These coordinates differ from the true 361 459 // local coordinates of the camera center that one could get from 362 460 // "MPointingPos", calculated by the Drive: the reason is that the Drive … … 369 467 // would be wrong is to set in pos0 directly the local coordinates 370 468 // found in MPointingPos! 371 MVector3 pos0; // pos0: camera center372 pos0.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());373 469 pos0 *= conv; 374 470 … … 384 480 } 385 481 386 // Calculate source position in camera, and convert to mm: 387 TVector2 v = MAstro::GetDistOnPlain(pos0, pos, -fGeom->GetCameraDist()*1000); 388 389 if (fDeviation) 390 v -= fDeviation->GetDevXY()/fGeom->GetConvMm2Deg(); 391 392 SetSrcPos(v); 393 482 CalcResult(pos0, pos); 394 483 return kTRUE; 395 484 } … … 440 529 Int_t MSrcPosCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 441 530 { 531 Bool_t rc = kFALSE; 532 533 if (IsEnvDefined(env, prefix, "FixedPos", print)) 534 { 535 TString str = GetEnvValue(env, prefix, "FixedPos", ""); 536 str = str.Strip(TString::kBoth); 537 538 Double_t x, y; 539 const Int_t n=sscanf(str.Data(), "%lf %lf", &x, &y); 540 if (n!=2) 541 { 542 *fLog << warn << "WARNING - FixedPos requires two numbers." << endl; 543 return kERROR; 544 } 545 546 fFixedPos = TVector2(x, y); 547 fMode = kFixed; 548 549 rc = kTRUE; 550 } 551 442 552 Double_t ra=0; 443 553 Double_t dec=0; … … 461 571 462 572 SetSourcePos(ra, dec); 463 return kTRUE;464 } 465 466 Bool_t rc = kFALSE;573 return rc; 574 } 575 576 Bool_t rcsrc = kFALSE; 467 577 if (IsEnvDefined(env, prefix, "SourceRa", print)) 468 578 { … … 472 582 return kERROR; 473 583 474 rc = kTRUE;584 rcsrc = kTRUE; 475 585 } 476 586 … … 482 592 return kERROR; 483 593 484 rc = kTRUE; 485 } 486 487 if (!rc) 488 return kFALSE; 489 490 SetSourcePos(ra, dec); 491 return kTRUE; 492 } 594 rcsrc = kTRUE; 595 } 596 597 if (rcsrc) 598 SetSourcePos(ra, dec); 599 600 return rcsrc || rc; 601 } -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h
r8719 r9070 18 18 class MVector3; 19 19 class MTaskList; 20 class MMcEvt; 21 class MMcRunHeader; 20 22 21 23 class MSrcPosCalc : public MTask … … 25 27 kDefault = 0, // Set source position to on-position 26 28 kOffData = 1, // The source position is fixed to (0/0) 27 kWobble = 2 // The source position is set to the wobble aka. anti-source position depending on the cycle number 29 kWobble = 2, // The source position is set to the wobble aka. anti-source position depending on the cycle number 30 kFixed = 3 // Set source position to predefined fFixedPos 28 31 }; 29 32 private: … … 32 35 }; 33 36 34 MObservatory *fObservatory; //! Observatory location 35 MPointingPos *fPointPos; //! Present pointing position of the telescope in Zd/Az 37 const MObservatory *fObservatory; //! Observatory location 38 const MPointingPos *fPointPos; //! Present pointing position of the telescope in Zd/Az 39 const MPointingDev *fDeviation; //! Deviation calculated from starguider data 40 const MMcEvt *fMcEvt; //! Possible input of shower position from MC 41 const MMcRunHeader *fMcHeader; //! Monte Carlo run header needed for correct wobble position 42 const MGeomCam *fGeom; //! Camera geomety 43 const MTime *fTime; //! Time of the current event 44 const MTaskList *fCallback; //! Callback function to get the number of the cycle 36 45 MPointingPos *fSourcePos; //! Source Postion in sky coordinates 37 MPointingDev *fDeviation; //! Deviation calculated from starguider data38 46 MSrcPosCam *fSrcPosCam; //! Output: Source position in the camera 39 47 MSrcPosCam *fSrcPosAnti; //! Output: Anti Source position in the camera 40 MGeomCam *fGeom; //! Camera geomety41 MTime *fTime; //! Time of the current event42 MTaskList *fCallback; //! Callback function to get the number of the cycle43 48 44 49 UShort_t fRunType; //! Run Type to decide where to get pointing position from 45 50 46 TVector2 fFixedPos; //! Fixed source position51 TVector2 fFixedPos; //! [deg] Fixed source position 47 52 48 53 Int_t fMode; // Mode how the source position is calculated … … 56 61 Bool_t GetCoordinate(TString str, Double_t &ret) const; 57 62 void FreeSourcePos(); 63 void CalcResult(const MVector3 &pos0, const MVector3 &pos); 64 void InitFixedPos() const; 58 65 59 66 // MParContainer
Note:
See TracChangeset
for help on using the changeset viewer.