Changeset 3957 for trunk/MagicSoft/Mars/mastro
- Timestamp:
- 05/04/04 15:27:25 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mastro
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mastro/MAstroCamera.cc
r3918 r3957 70 70 #include "MAstroCamera.h" 71 71 72 #include <KeySymbols.h> // kKey_* 73 74 #include <TH2.h> // TH2D 75 #include <TMarker.h> // TMarker 76 #include <TVirtualPad.h> // gPad 72 #include <errno.h> // strerror 73 #include <fstream> // ifstream 74 75 #include <KeySymbols.h> // kKey_* 76 77 #include <TH2.h> // TH2D 78 #include <TMarker.h> // TMarker 79 #include <TVirtualPad.h> // gPad 77 80 78 81 #include "MLog.h" … … 144 147 memcpy((*fMirrors)[i], arr[i], sizeof(MGeomMirror)); 145 148 149 } 150 151 // -------------------------------------------------------------------------- 152 // 153 // Read the mirror geometry from a MC .def file. The following 154 // structure is expected: 155 // 156 // #* TYPE=1 (MAGIC) 157 // #* i f sx sy x y z thetan phin 158 // #* 159 // #* i : number of the mirror 160 // #* f : focal distance of that mirror 161 // #* sx : curvilinear coordinate of mirror's center in X[cm] 162 // #* sy : curvilinear coordinate of mirror's center in X[cm] 163 // #* x : x coordinate of the center of the mirror [cm] 164 // #* y : y coordinate of the center of the mirror [cm] 165 // #* z : z coordinate of the center of the mirror [cm] 166 // #* thetan : polar theta angle of the direction where the mirror points to 167 // #* phin : polar phi angle of the direction where the mirror points to 168 // #* xn : xn coordinate of the normal vector in the center (normalized) 169 // #* yn : yn coordinate of the normal vector in the center (normalized) 170 // #* zn : zn coordinate of the normal vector in the center (normalized) 171 // # 172 // define_mirrors 173 // 1 1700.9200 25.0002 75.0061 25.0000 75.0000 0.9207 0.02328894 1.24904577 -0.00736394 -0.02209183 0.99972882 174 // 2 ... 175 // 176 void MAstroCamera::SetMirrors(const char *fname) 177 { 178 ifstream fin(fname); 179 if (!fin) 180 { 181 gLog << err << "Cannot open file " << fname << ": "; 182 gLog << strerror(errno) << endl; 183 return; 184 } 185 186 TString line; 187 while (1) 188 { 189 line.ReadLine(fin); 190 if (!fin) 191 return; 192 193 line = line.Strip(TString::kBoth); 194 195 if (line.BeginsWith("n_mirrors")) 196 { 197 Int_t n; 198 sscanf(line.Data(), "%*s %d", &n); 199 200 if (!fMirrors) 201 fMirrors = new TClonesArray(MGeomMirror::Class(), n); 202 203 fMirrors->ExpandCreate(n); 204 continue; 205 } 206 207 208 Int_t id; 209 Float_t f, sx, sy, x, y, z, thetan, phin, xn, yn, zn; 210 211 const Int_t n = sscanf(line.Data(), "%d %f %f %f %f %f %f %f %f %f %f %f", 212 &id, &f, &sx, &sy, &x, &y, &z, &thetan, 213 &phin, &xn, &yn, &zn); 214 if (n!=12) 215 continue; 216 217 new ((*fMirrors)[id-1]) MGeomMirror; 218 ((MGeomMirror*)(*fMirrors)[id-1])->SetMirrorContent(id, f, sx, sy, x, y, z, thetan, phin, xn, yn, zn); 219 } 146 220 } 147 221 … … 287 361 { 288 362 const Double_t mag = radec->Magnitude(); 363 if (mag>GetLimMag()) 364 continue; 289 365 290 366 TVector3 star(*radec); … … 334 410 const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000; 335 411 DrawStar(spot(0), spot(1), *radec, !hasmean, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1))); 412 //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl; 336 413 } 337 414 } … … 362 439 } 363 440 364 // Get camera 365 MHCamera *camera=(MHCamera*)FindObjectInPad("MHCamera", gPad); 366 if (camera) 367 { 368 if (!camera->GetGeometry() || camera->GetGeometry()->IsA()!=fGeom->IsA()) 369 camera->SetGeometry(*fGeom); 370 } 371 else 372 { 373 camera = new MHCamera(*fGeom); 374 camera->SetName("MHCamera"); 375 camera->SetStats(0); 376 camera->SetInvDeepBlueSeaPalette(); 377 camera->SetBit(kCanDelete); 378 camera->Draw(); 379 } 380 381 const TRotation rot(GetGrid(kTRUE)); 441 const MAstroSky2Local s2l(*fTime, *fObservatory); 442 const TRotation trans(AlignCoordinates(rot*fRaDec)); 443 444 // Return the correct rotation matrix 445 const TRotation rot = trans*s2l; 382 446 383 447 MVector3 *radec; … … 397 461 list->Add(starpos); 398 462 } 463 // For MAGIC the distance of the mean of the light distribution 464 // to the Mirror0 reflection of the star (Abberation) can be 465 // expressed as: dr = (0.0713 +/- 0.0002) * r = r/14.03 466 // with r = hypot(mean(0), mean(1)) 399 467 } 400 468 */ … … 402 470 // ------------------------------------------------------------------------ 403 471 // 472 // Uses fRaDec as a reference point. 473 // 474 // Return dZd and dAz corresponding to the distance from x,y to fRaDec 475 // 476 // Before calling this function you should correct for abberation. In 477 // case of MAGIC you can do this by: 478 // x /= 1.0713; 479 // y /= 1.0713; 480 // 481 // x [mm]: x coordinate in the camera plane (assuming a perfect mirror) 482 // y [mm]: y coordinate in the camera plane (assuming a perfect mirror) 483 // 484 // dzd [deg]: Delta Zd 485 // daz [deg]: Delta Az 486 // 487 void MAstroCamera::GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz) 488 { 489 // Reflect the corrected pixel on a perfect mirror 490 TVector3 v(x, y, fGeom->GetCameraDist()*1000); 491 TVector3 spot = fMirror0->GetReflection(v); 492 493 // Derotate into the local coordinate system 494 const MAstroSky2Local rot(*fTime, *fObservatory); 495 const TRotation align(AlignCoordinates(rot*fRaDec).Inverse()); 496 spot *= align; 497 498 cout << "Zd="<<spot.Theta()*TMath::RadToDeg() << " "; 499 cout << "Az="<<spot.Phi() *TMath::RadToDeg()+360 << endl; 500 501 // Derotatet the center of the camera 502 TVector3 c(0, 0, 1); 503 c *= align; 504 505 dzd = (spot.Theta()-c.Theta())*TMath::RadToDeg(); 506 daz = (spot.Phi() -c.Phi()) *TMath::RadToDeg(); 507 508 if (daz> 180) daz -= 360; 509 if (daz<-180) daz += 360; 510 } 511 512 // ------------------------------------------------------------------------ 513 // 404 514 // Execute a gui event on the camera 405 515 // 406 516 void MAstroCamera::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2) 407 517 { 518 // if (mp1>0 && mp2>0) 519 // { 520 // // Calculate World coordinates from pixel 521 // Double_t x = gPad->AbsPixeltoX(mp1); 522 // Double_t y = gPad->AbsPixeltoY(mp2); 523 // 524 // // Correct for abberation 525 // x /= 1.0713; 526 // y /= 1.0713; 527 // 528 // Double_t dzd, daz; 529 // GetDiffZdAz(x, y, dzd, daz); 530 // 531 // cout << "dZd="<< dzd << " " << "dAz="<< daz << endl; 532 // } 533 // 534 // For MAGIC the distance of the mean of the light distribution 535 // to the Mirror0 reflection of the star (Abberation) can be 536 // expressed as: dr = 0.0713*r = r/14.03 537 // +-0.0002 538 408 539 if (event==kKeyPress && fTime) 409 540 switch (mp2) -
trunk/MagicSoft/Mars/mastro/MAstroCamera.h
r3918 r3957 32 32 33 33 void SetMirrors(TClonesArray &arr); 34 void SetMirrors(const char *fname); 34 35 void SetGeom(const MGeomCam &cam); 36 37 void GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz); 35 38 36 39 ClassDef(MAstroCamera, 1) // Display class to display stars on the camera -
trunk/MagicSoft/Mars/mastro/MObservatory.h
r3568 r3957 36 36 MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL); 37 37 38 void Copy(TObject &obj) const 39 { 40 MObservatory &obs = (MObservatory&)obj; 41 obs.fObservatoryName = fObservatoryName; 42 obs.fLongitude = fLongitude; 43 obs.fLatitude = fLatitude; 44 obs.fSinLatitude = fSinLatitude; 45 obs.fCosLatitude = fCosLatitude; 46 obs.fHeight = fHeight; 47 } 48 38 49 void SetLocation(LocationName_t name); 39 50
Note:
See TracChangeset
for help on using the changeset viewer.