Changeset 4741 for trunk/MagicSoft/Mars/mtemp
- Timestamp:
- 08/26/04 14:13:36 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mtemp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/MTelAxisFromStars.cc
r4726 r4741 48 48 49 49 #include "MParList.h" 50 #include "MSrcPosCam.h" 50 51 51 52 52 #include "MLog.h" 53 53 #include "MLogManip.h" 54 55 #include "MReportDrive.h" 56 #include "MPointingPos.h" 57 #include "MSrcPosCam.h" 54 58 55 59 #include "MStarCam.h" 56 60 #include "MStarPos.h" 57 61 #include "MSkyCamTrans.h" 62 #include "MStarCamTrans.h" 58 63 59 64 ClassImp(MTelAxisFromStars); … … 82 87 // type 1 : result from the Gauss fit 83 88 fInputType = 1; 89 90 // default value of fAberr 91 // the value 1.07 is valid if the expected position (with aberration) 92 // in the camera is calculated as the average of the positions obtained 93 // from the reflections at the individual mirrors 94 fAberr = 1.07; 95 84 96 } 85 97 … … 90 102 MTelAxisFromStars::~MTelAxisFromStars() 91 103 { 104 delete fStarCamTrans; 92 105 } 93 106 … … 99 112 Int_t MTelAxisFromStars::PreProcess(MParList *pList) 100 113 { 114 fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive")); 115 if (!fDrive) 116 { 117 *fLog << err << AddSerialNumber("MReportDrive") 118 << " not found... aborting." << endl; 119 return kFALSE; 120 } 121 101 122 102 123 fStarCam = (MStarCam*)pList->FindObject("MStarCam", "MStarCam"); … … 115 136 116 137 138 //----------------------------------------------------------------- 117 139 fSrcPos = (MSrcPosCam*)pList->FindCreateObj(AddSerialNumber("MSrcPosCam")); 118 140 if (!fSrcPos) … … 122 144 } 123 145 146 fPointPos = (MPointingPos*)pList->FindCreateObj(AddSerialNumber("MPointingPos"), "MPointingPos"); 147 if (!fPointPos) 148 { 149 *fLog << err << "MTelAxisFromStars::PreProcess; MPointingPos not found... aborting" << endl; 150 return kFALSE; 151 } 152 153 fSourcePos = (MPointingPos*)pList->FindCreateObj(AddSerialNumber("MPointingPos"), "MSourcePos"); 154 if (!fSourcePos) 155 { 156 *fLog << err << "MTelAxisFromStars::PreProcess; MSourcePos[MPointingPos] not found... aborting" << endl; 157 return kFALSE; 158 } 159 124 160 fSkyCamTrans = (MSkyCamTrans*)pList->FindCreateObj(AddSerialNumber("MSkyCamTrans")); 125 161 if (!fSkyCamTrans) … … 129 165 } 130 166 167 //----------------------------------------------------------------- 168 // book an MStarCamTrans object 169 // this is needed when calling one of the member functions of MStarCamTrans 170 171 MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam")); 172 if (!geom) 173 { 174 *fLog << err << AddSerialNumber("MGeomCam") 175 << " not found... aborting." << endl; 176 return kFALSE; 177 } 178 179 MObservatory *obs = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory")); 180 if (!obs) 181 { 182 *fLog << err << AddSerialNumber("MObservatory") 183 << " not found... aborting." << endl; 184 return kFALSE; 185 } 186 187 fStarCamTrans = new MStarCamTrans(*geom, *obs); 131 188 132 189 return kTRUE; 190 } 191 192 // -------------------------------------------------------------------------- 193 // 194 // Set optical aberration factor 195 // 196 // fAberr is the ratio between 197 // the distance from the camera center with optical aberration and 198 // the distance from the camera center with an ideal imaging 199 // 200 // fAberr = r_real/r_ideal 201 // 202 void MTelAxisFromStars::SetOpticalAberr(Double_t aberr) 203 { 204 *fLog << all << "MTelAxisFromStars::SetOpticalAberr; the optical aberration factor is set equal to : " 205 << aberr ; 206 207 fAberr = aberr; 133 208 } 134 209 … … 374 449 375 450 //-------------------------------------- 376 // Put the estimated position, obtained by transforming the expected 377 // position (0,0), into SrcPosCam 451 // Put the corrected pointing position into MPointingPos 452 // 453 SetPointingPosition(fStarCamTrans, fDrive, fSkyCamTrans, fPointPos); 454 455 456 //-------------------------------------- 457 // Put the estimated position of the source into SrcPosCam 458 // 459 // get the source direction from MReportDrive 378 460 // Note : this has to be changed for the wobble mode, where the source 379 // won't be in the center of the camera 380 381 fSrcPos->SetXY(fD[0], fD[1]); 382 fSrcPos->SetReadyToSave(); 383 461 // isn't in the center of the camera 462 Double_t decsource = fDrive->GetDec(); 463 Double_t rasource = fDrive->GetRa(); 464 // 465 Double_t radrive = fDrive->GetRa(); 466 Double_t hdrive = fDrive->GetHa(); 467 Double_t hsource = hdrive + radrive - rasource; 468 fSourcePos->SetSkyPosition(rasource, decsource, hsource); 469 470 SetSourcePosition(fStarCamTrans, fPointPos, fSourcePos, fSrcPos); 471 //fSrcPos->SetXY(fD[0], fD[1]); 472 //fSrcPos->SetReadyToSave(); 473 *fLog << "after calling SetSourcePosition : , X, Y ,fD = " 474 << fSrcPos->GetX() << ", " << fSrcPos->GetY() << ", " 475 << fD[0] << ", " << fD[1] << endl; 384 476 385 477 //-------------------------------------- … … 448 540 return kTRUE; 449 541 } 542 543 450 544 451 545 //--------------------------------------------------------------------------- … … 1045 1139 // -------------------------------------------------------------------------- 1046 1140 // 1141 // SetPointingPosition 1142 // 1143 // put the corrected pointing direction into MPointingPos[MPointingPos]; 1144 // this direction corresponds to the position (0,0) in the camera 1145 // 1146 1147 Bool_t MTelAxisFromStars::SetPointingPosition(MStarCamTrans *fstarcamtrans, 1148 MReportDrive *fdrive, MSkyCamTrans *ftrans, MPointingPos *fpointpos) 1149 { 1150 Double_t decdrive = fdrive->GetDec(); 1151 Double_t hdrive = fdrive->GetHa(); 1152 Double_t radrive = fdrive->GetRa(); 1153 1154 // this is the estimated position (with optical aberration) in the camera 1155 // corresponding to the direction in MReportDrive 1156 Double_t Xpoint = (ftrans->GetShiftD())[0]; 1157 Double_t Ypoint = (ftrans->GetShiftD())[1]; 1158 1159 // get the sky direction corresponding to the position (0,0) in the camera 1160 Double_t decpoint = 0.0; 1161 Double_t hpoint = 0.0; 1162 fstarcamtrans->CelCamToCel0(decdrive, hdrive, 1163 Xpoint/fAberr, Ypoint/fAberr, decpoint, hpoint); 1164 Double_t rapoint = radrive - hpoint + hdrive; 1165 fpointpos->SetSkyPosition(rapoint, decpoint, hpoint); 1166 1167 // get the local direction corresponding to the position (0,0) in the camera 1168 Double_t thetadrive = fdrive->GetNominalZd(); 1169 Double_t phidrive = fdrive->GetNominalAz(); 1170 Double_t thetapoint = 0.0; 1171 Double_t phipoint = 0.0; 1172 fstarcamtrans->LocCamToLoc0(thetadrive, phidrive, 1173 Xpoint/fAberr, Ypoint/fAberr, thetapoint, phipoint); 1174 fpointpos->SetLocalPosition(thetapoint, phipoint); 1175 fpointpos->SetReadyToSave(); 1176 1177 *fLog << "SetPointingPosition : decdrive, hdrive, radrive Xpoint, Ypoint = " 1178 << decdrive << ", " << hdrive << ", " << radrive << ", " 1179 << Xpoint << ", " << Ypoint << endl; 1180 1181 *fLog << "SetPointingPosition : thetadrive, phidrive, thetapoint, phipoint = " 1182 << thetadrive << ", " << phidrive << ", " << thetapoint << ", " 1183 << phipoint << endl; 1184 1185 return kTRUE; 1186 } 1187 1188 // -------------------------------------------------------------------------- 1189 // 1190 // SetSourcePosition 1191 // 1192 // put the estimated position of the source in the camera into 1193 // MSrcPosCam[MSrcPosCam] 1194 // 1195 // and the estimated local direction of the source into 1196 // MSourcePos[MPointingPos] 1197 // 1198 1199 Bool_t MTelAxisFromStars::SetSourcePosition(MStarCamTrans *fstarcamtrans, 1200 MPointingPos *fpointpos, MPointingPos *fsourcepos, MSrcPosCam *fsrcpos) 1201 { 1202 // get the corrected pointing direction 1203 // corresponding to the position (0,0) in the camera 1204 Double_t decpoint = fpointpos->GetDec(); 1205 Double_t hpoint = fpointpos->GetHa(); 1206 1207 // get the sky direction of the source 1208 Double_t decsource = fsourcepos->GetDec(); 1209 Double_t hsource = fsourcepos->GetHa(); 1210 1211 // get the estimated position (Xsource, Ysource) of the source in the camera; 1212 // this is a position for an ideal imaging, without optical aberration 1213 Double_t Xsource = 0.0; 1214 Double_t Ysource = 0.0; 1215 fstarcamtrans->Cel0CelToCam(decpoint, hpoint, 1216 decsource, hsource, Xsource, Ysource); 1217 fsrcpos->SetXY(Xsource*fAberr, Ysource*fAberr); 1218 fsrcpos->SetReadyToSave(); 1219 1220 // get the estimated local direction of the source 1221 Double_t thetapoint = fpointpos->GetZd(); 1222 Double_t phipoint = fpointpos->GetAz(); 1223 Double_t thetasource = 0.0; 1224 Double_t phisource = 0.0; 1225 fstarcamtrans->Loc0CamToLoc(thetapoint, phipoint, 1226 Xsource, Ysource, thetasource, phisource); 1227 fsourcepos->SetLocalPosition(thetasource, phisource); 1228 fsourcepos->SetReadyToSave(); 1229 1230 *fLog << "SetSourcePosition : decpoint, hpoint, decsource, hsource, Xsource, Ysource = " 1231 << decpoint << ", " << hpoint << ", " << decsource << ", " 1232 << hsource << ", " << Xsource << ", " << Ysource << endl; 1233 *fLog << "SetSourcePosition : thetapoint, phipoint, thetasource, phisource = " 1234 << thetapoint << ", " << phipoint << ", " << thetasource << ", " 1235 << phisource << endl; 1236 1237 return kTRUE; 1238 } 1239 1240 // -------------------------------------------------------------------------- 1241 // 1047 1242 // 1048 1243 Int_t MTelAxisFromStars::PostProcess() -
trunk/MagicSoft/Mars/mtemp/MTelAxisFromStars.h
r4705 r4741 20 20 #endif 21 21 22 class MReportDrive; 23 class MPointingPos; 22 24 class MSrcPosCam; 23 25 class MStarCam; 24 26 class MSkyCamTrans; 27 class MStarCamTrans; 25 28 26 29 class MTelAxisFromStars : public MTask … … 31 34 const MStarCam *fSourceCam; //! 32 35 36 MReportDrive *fDrive; //! 37 MPointingPos *fPointPos; //! 38 MPointingPos *fSourcePos; //! 33 39 MSrcPosCam *fSrcPos; //! 34 40 MSkyCamTrans *fSkyCamTrans; //! 41 MStarCamTrans *fStarCamTrans; //! 35 42 36 43 Double_t fFixedScaleFactor; //! 37 44 Double_t fFixedRotationAngle; //! [degrees] 45 Double_t fAberr; //! optical aberration factor 38 46 39 47 Int_t fInputType; //! type of input … … 50 58 void FixScaleFactorAt(Double_t lambda = 1.0); 51 59 void FixRotationAngleAt(Double_t alfa = 0.0); // alfa in [degrees] 52 53 void SetInputType(Int_t type = 2); 60 61 void SetOpticalAberr(Double_t aberr); 62 void SetInputType(Int_t type = 1); 54 63 55 64 Bool_t FindSkyCamTrans(TArrayD[2], TArrayD[2], TArrayD[2][2], … … 60 69 void TransSkyCam(Double_t &, Double_t[2][2], Double_t[2], Double_t[2][2], 61 70 TArrayD[2], TArrayD[2], TArrayD[2][2]); 71 72 Bool_t SetPointingPosition(MStarCamTrans *fstarcamtrans, 73 MReportDrive *fdrive, MSkyCamTrans *ftrans, MPointingPos *fpointpos); 74 Bool_t SetSourcePosition(MStarCamTrans *fstarcamtrans, 75 MPointingPos *fpointpos, MPointingPos *fsourcepos, MSrcPosCam *fsrcpos); 62 76 63 77 ClassDef(MTelAxisFromStars, 0) // Task to calculate the source position from star positions -
trunk/MagicSoft/Mars/mtemp/findTelAxisFromStars.C
r4707 r4741 15 15 } 16 16 17 //-------------------------------------------------------------------------- 18 // 19 // findTelAxisFromStars 20 // 21 // macro to 22 // - determine the positions of stars in the camera from the DC currents 23 // - and to find the expected position of the source in the camera 24 // 25 17 26 void findTelAxisFromStars(const TString filename="20040422_23213_D_Mrk421_E.root", const TString directory="/.magic/magicserv01/MAGIC/rootdata/2004_04_22/", const UInt_t numEvents = 0) 18 27 { 19 28 gLog.SetNoColors(); 20 29 30 //------------------------------------------------------------------- 31 // book some histograms which are to be filled in the event loop 32 // 33 34 TH2D *aberr = new TH2D("OpticalAberr", "Opt_Aberr", 35 100, 0.0, 650.0, 100, 0.0, 650.0); 36 aberr->SetXTitle("Ideal distance from center [mm]"); 37 aberr->SetYTitle("Expected distance from center [mm]"); 38 39 TProfile *reldiff = new TProfile("RelativeDiff", "Rel_Diff", 40 100, 0.0, 650.0, -0.2, 0.2, "S"); 41 reldiff->SetXTitle("Ideal distance from center [mm]"); 42 reldiff->SetYTitle("(R - R0)/R0"); 43 44 //------------------------------------------------------------------- 45 46 21 47 MParList plist; 22 48 MTaskList tlist; … … 28 54 29 55 //$$$$$$$$$$$$$$$$ ww 56 MObservatory obs; 30 57 MStarCam sourcecam; 31 58 sourcecam.SetName("MSourceCam"); 32 59 33 60 MHTelAxisFromStars htelaxis; 61 62 plist.AddToList(&obs); 34 63 plist.AddToList(&htelaxis); 35 64 //$$$$$$$$$$$$$$$$ ww … … 99 128 const Double_t dec = MAstro::Dms2Rad(38, 14, 29); 100 129 sdirs.AddDirection(ra,dec,1,"My_UMa 51"); 130 131 // dummy source dirtections 132 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 133 const Double_t dec = MAstro::Dms2Rad(38, 20, 0); 134 sdirs.AddDirection(ra,dec,1,"Dummy1"); 135 136 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 137 const Double_t dec = MAstro::Dms2Rad(38, 20, 0); 138 sdirs.AddDirection(ra,dec,1,"Dummy2"); 139 140 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 141 const Double_t dec = MAstro::Dms2Rad(38, 30, 0); 142 sdirs.AddDirection(ra,dec,1,"Dummy3"); 143 144 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 145 const Double_t dec = MAstro::Dms2Rad(38, 40, 0); 146 sdirs.AddDirection(ra,dec,1,"Dummy4"); 147 148 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 149 const Double_t dec = MAstro::Dms2Rad(38, 50, 0); 150 sdirs.AddDirection(ra,dec,1,"Dummy5"); 151 152 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 153 const Double_t dec = MAstro::Dms2Rad(39, 0, 0); 154 sdirs.AddDirection(ra,dec,1,"Dummy6"); 155 156 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 157 const Double_t dec = MAstro::Dms2Rad(39, 10, 0); 158 sdirs.AddDirection(ra,dec,1,"Dummy7"); 159 160 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 161 const Double_t dec = MAstro::Dms2Rad(39, 20, 0); 162 sdirs.AddDirection(ra,dec,1,"Dummy8"); 163 164 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 165 const Double_t dec = MAstro::Dms2Rad(39, 30, 0); 166 sdirs.AddDirection(ra,dec,1,"Dummy9"); 167 168 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 169 const Double_t dec = MAstro::Dms2Rad(39, 40, 0); 170 sdirs.AddDirection(ra,dec,1,"Dummy10"); 171 172 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 173 const Double_t dec = MAstro::Dms2Rad(39, 50, 0); 174 sdirs.AddDirection(ra,dec,1,"Dummy11"); 175 176 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 177 const Double_t dec = MAstro::Dms2Rad(40, 0, 0); 178 sdirs.AddDirection(ra,dec,1,"Dummy12"); 179 180 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 181 const Double_t dec = MAstro::Dms2Rad(40, 10, 0); 182 sdirs.AddDirection(ra,dec,1,"Dummy13"); 183 184 const Double_t ra = MAstro::Hms2Rad(11, 4, 31); 185 const Double_t dec = MAstro::Dms2Rad(40, 20, 0); 186 sdirs.AddDirection(ra,dec,1,"Dummy14"); 101 187 102 188 … … 195 281 // This line prints the results: 196 282 // starcam.Print(); 283 197 284 // This is how to access the TList of stars: 198 // 285 // TList* starlist = starcam.GetList(); 199 286 200 287 // This is how to iterate over stars found: 201 // 288 // TIter Next(starlist); 202 289 // MStarPos* star; 203 290 // UInt_t starnum = 0; 204 // cout << filename << " "; 205 // cout << "Iterating over list" << endl; 206 // while ((star=(MStarPos*)Next())) 207 // { 208 // cout << "star[" << starnum << "] "; 209 // cout << star->GetMeanX() << " " 210 // << star->GetMeanY() << " "; 211 // starnum++; 212 // } 213 // cout << endl; 291 // cout << filename << " "; 292 // cout << "Iterating over list" << endl; 293 // while ( (star=(MStarPos*)Next()) ) 294 // { 295 // cout << "star[" << starnum << "] "; 296 // cout << star->GetMeanX() << " " 297 // << star->GetMeanY() << " "; 298 // starnum++; 299 // } 300 // cout << endl; 301 } 302 303 // fill the histograms 304 // loop over stars in "MSourceCam" 305 TList* sourcelist = sourcecam.GetList(); 306 TIter Nextsource(sourcelist); 307 MStarPos* source; 308 while ( (source=(MStarPos*)Nextsource()) ) 309 { 310 Double_t R = sqrt( source->GetXExp()*source->GetXExp() 311 + source->GetYExp()*source->GetYExp() ); 312 313 Double_t R0= sqrt( source->GetXIdeal()*source->GetXIdeal() 314 + source->GetYIdeal()*source->GetYIdeal() ); 315 316 cout << "R0, R = " << R0 << ", " << R << endl; 317 318 aberr->Fill(R0, R, 1.0); 319 reldiff->Fill(R0, (R-R0)/R0), 1.0); 320 } 214 321 215 }//integratedevents 216 322 //-------------------------------------- 217 323 MTime time; 218 324 time.Set(2004, 4, 22, 21, 51, 15); … … 225 331 226 332 // wait after each event 227 if (!HandleInput())228 break;333 //if (!HandleInput()) 334 // break; 229 335 230 336 } … … 256 362 //$$$$$$$$$$$$$$$$ ww 257 363 258 364 // plot the histograms 365 TCanvas *canv = new TCanvas("Optical_Aberration", "Optical aberration", 366 0, 0, 600, 300); 367 canv->Divide(2,1); 368 canv->SetBorderMode(0); 369 370 canv->cd(1); 371 aberr->Draw(); 372 373 canv->cd(2); 374 reldiff->Draw(); 259 375 260 376 } 261 377 378 //---------------------------------------------------------------------- 379 // 380 // 262 381 263 382 Bool_t HandleInput() … … 283 402 return kFALSE; 284 403 } 404 //========================================================================= 405 406 407 408 409 410 411 412 413
Note:
See TracChangeset
for help on using the changeset viewer.