Changeset 8636 for trunk/MagicSoft/Mars/mpointing
- Timestamp:
- 07/15/07 19:25:45 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mpointing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
r8618 r8636 42 42 // is taken from MGeomCam. The time is taken from MTime, and the 43 43 // coordinates of the observatory from MObservatory. 44 // 44 // 45 // FIXME: Add here some information about the more-cycle calculation 46 // 45 47 // Input Container: 46 48 // MPointingPos … … 65 67 #include "MSrcPosCalc.h" 66 68 69 #include <TRandom.h> 67 70 #include <TVector2.h> 68 71 … … 96 99 : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fDeviation(NULL), 97 100 fSrcPosCam(NULL), fSrcPosAnti(NULL), fGeom(NULL), fTime(NULL), fCallback(NULL), 98 fMode(kDefault) 101 fMode(kDefault), fNumRandomOffPositions(0) 99 102 { 100 103 fName = name ? name : "MSrcPosCalc"; … … 157 160 Int_t MSrcPosCalc::PreProcess(MParList *pList) 158 161 { 162 // Reset fixed position 163 fFixedPos = TVector2(); 164 159 165 fSrcPosCam = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam"); 160 166 if (!fSrcPosCam) … … 172 178 *fLog << inf; 173 179 *fLog << "MSourcePos [MPointPos] not found... The source position" << endl; 174 *fLog << "set in MSrcPosCam will be set to 180 *fLog << "set in MSrcPosCam will be set to (0/0) or in the case" << endl; 175 181 *fLog << "of Monte Carlo set to the appropriate wobble position." << endl; 176 182 return kTRUE; … … 199 205 *fLog << "Source Position: " << GetRaDec(*fSourcePos) << endl; 200 206 if (fCallback) 201 *fLog << "Using " << fCallback->GetNumPasses() << " off-regions." << endl; 207 *fLog << "Calculating " << fCallback->GetNumPasses() << " off-regions." << endl; 208 if (fNumRandomOffPositions) 209 *fLog << "Calculating " << fNumRandomOffPositions << " random off-regions." << endl; 202 210 203 211 // For the case ReInit is never called we try: … … 211 219 // -------------------------------------------------------------------------- 212 220 // 221 // Divide the 360deg into num+1 positions. Rotate the given vector 222 // by pass+1 steps and return the result. 223 // 224 TVector2 MSrcPosCalc::Rotate(TVector2 v, Int_t pass, Int_t num) const 225 { 226 const Double_t step = TMath::TwoPi()/(num+1); 227 return v.Rotate(step*(pass+1)); 228 } 229 230 // -------------------------------------------------------------------------- 231 // 213 232 // If fIsWobbleMode==kFALSE set source position to v and anto-source 214 233 // position to -v, if fIsWobbleMode==kTRUE vice versa. … … 218 237 if (fMode==kWobble) 219 238 { 239 // The trick here is that the anti-source position in case 240 // of the off-source regions is always the on-source positon 241 // thus a proper anti-source cut is possible. 220 242 fSrcPosAnti->SetXY(v); 221 222 243 if (fCallback) 223 { 224 const Double_t step = TMath::TwoPi()/(fCallback->GetNumPasses()+1); 225 v = v.Rotate(step*(fCallback->GetNumPass()+1)); 226 } 244 v = Rotate(v, fCallback->GetNumPass(), fCallback->GetNumPasses()); 227 245 else 228 246 v *= -1; 229 230 247 fSrcPosCam->SetXY(v); 231 248 } 232 249 else 233 250 { 251 // Because we don't process this three times like in the 252 // wobble case we have to find another way to determine which 253 // off-source region is the right anti-source position 254 // We do it randomly. 234 255 fSrcPosCam->SetXY(v); 235 v *= -1; 256 if (fNumRandomOffPositions>1) 257 v = Rotate(v, gRandom->Integer(fNumRandomOffPositions), fNumRandomOffPositions); 258 else 259 v *= -1; 236 260 fSrcPosAnti->SetXY(v); 237 261 } … … 247 271 if (fMode==kOffData) 248 272 { 249 SetSrcPos(TVector2()); 273 // Set fixed position to camera center 274 fFixedPos = TVector2(); 275 276 // It is set here for the cases in which Process is not called at all 277 fSrcPosCam->SetXY(fFixedPos); 250 278 return kTRUE; 251 279 } … … 284 312 } 285 313 314 // Determine Monte Carlo position from Monte Carlo header 286 315 TVector2 v(0, 0); 287 316 if (h->GetWobbleMode()>0.5) … … 290 319 v.Set(-120., 0.); 291 320 292 SetSrcPos(v); 293 321 // Set fixed position 322 fFixedPos = v; 323 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 294 328 *fLog << inf; 295 *fLog << "Source Position set to x=" << f SrcPosCam->GetX() << "mm ";296 *fLog << "y=" << f SrcPosCam->GetY() << "mm" << endl;329 *fLog << "Source Position set to x=" << fFixedPos.X() << "mm "; 330 *fLog << "y=" << fFixedPos.Y() << "mm" << endl; 297 331 298 332 return kTRUE; … … 350 384 if (fRunType==MRawRunHeader::kRTMonteCarlo || !fSourcePos || !fTime || !fObservatory || fMode==kOffData) 351 385 { 352 // If this is MC data do not change source position 353 if (fRunType==MRawRunHeader::kRTMonteCarlo) 354 return kTRUE; 355 356 // For real data reset source position to 0/0 357 SetSrcPos(); 386 SetSrcPos(fFixedPos); 358 387 return kTRUE; 359 388 } -
trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h
r8618 r8636 23 23 public: 24 24 enum Mode_t { 25 kDefault = 0, 26 kOffData = 1, 27 kWobble = 2 25 kDefault = 0, // Set source position to on-position 26 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 28 28 }; 29 29 private: … … 32 32 }; 33 33 34 MObservatory *fObservatory; 35 MPointingPos *fPointPos; 36 MPointingPos *fSourcePos; 37 MPointingDev *fDeviation; 38 MSrcPosCam *fSrcPosCam; 39 MSrcPosCam *fSrcPosAnti; 40 MGeomCam *fGeom; 41 MTime *fTime; 42 MTaskList *fCallback; 34 MObservatory *fObservatory; //! Observatory location 35 MPointingPos *fPointPos; //! Present pointing position of the telescope in Zd/Az 36 MPointingPos *fSourcePos; //! Source Postion in sky coordinates 37 MPointingDev *fDeviation; //! Deviation calculated from starguider data 38 MSrcPosCam *fSrcPosCam; //! Output: Source position in the camera 39 MSrcPosCam *fSrcPosAnti; //! Output: Anti Source position in the camera 40 MGeomCam *fGeom; //! Camera geomety 41 MTime *fTime; //! Time of the current event 42 MTaskList *fCallback; //! Callback function to get the number of the cycle 43 43 44 44 UShort_t fRunType; //! Run Type to decide where to get pointing position from 45 45 46 Int_t fMode; 46 TVector2 fFixedPos; //! Fixed source position 47 48 Int_t fMode; // Mode how the source position is calculated 49 50 Int_t fNumRandomOffPositions; // Number of possible random off-sourcr position 47 51 48 52 // MSrcPosCalc 49 53 void SetSrcPos(TVector2 v=TVector2()) const; 54 TVector2 Rotate(TVector2 v, Int_t pass, Int_t num) const; 50 55 TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const; 51 56 TString GetRaDec(const MPointingPos &pos) const; … … 71 76 void SetMode(Mode_t m=kDefault) { fMode = m; } 72 77 void SetCallback(MTaskList *list) { fCallback=list; } 78 void SetNumRandomOffPositions(Int_t num=0) { fNumRandomOffPositions=num; } 73 79 74 80 ClassDef(MSrcPosCalc, 0) // Calculates the source position in the camera
Note:
See TracChangeset
for help on using the changeset viewer.