- Timestamp:
- 02/27/04 14:40:57 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHStarMap.cc
r2297 r3340 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2002 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de> 20 ! 21 ! Copyright: MAGIC Software Development, 2000-2004 21 22 ! 22 23 ! … … 31 32 // from the Hillas parameters (Fill) can be enhanced. 32 33 // 34 // For a given a shower, a series of points along its main axis are filled 35 // into the 2-dim histogram (x, y) of the camera plane. 36 // 37 // Before filling a point (x, y) into the histogram it is 38 // - shifted by (xSrc, ySrc) (the expected source position) 39 // - and rotated in order to compensate the rotation of the 40 // sky image in the camera 41 // 42 // 33 43 ///////////////////////////////////////////////////////////////////////////// 34 44 #include "MHStarMap.h" … … 47 57 #include "MHillas.h" 48 58 #include "MBinning.h" 59 #include "MMcEvt.hxx" 60 #include "MSrcPosCam.h" 61 #include "MObservatory.h" 49 62 50 63 ClassImp(MHStarMap); … … 117 130 } 118 131 132 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt"); 133 if (!fMcEvt) 134 { 135 *fLog << err << "MMcEvt not found... aborting." << endl; 136 return kFALSE; 137 } 138 139 fSrcPos = (MSrcPosCam*)plist->FindObject(AddSerialNumber("MSrcPosCam")); 140 if (!fSrcPos) 141 { 142 *fLog << err << "MSrcPosCam not found... aborting" << endl; 143 return kFALSE; 144 } 145 146 119 147 const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap"); 120 148 if (!bins) … … 134 162 if (!geom) 135 163 { 136 *fLog << warn << dbginf <<"No Camera Geometry available. Using mm-scale for histograms." << endl;164 *fLog << warn << "No Camera Geometry available. Using mm-scale for histograms." << endl; 137 165 return kTRUE; 138 166 } … … 141 169 142 170 return kTRUE; 171 } 172 173 // -------------------------------------------------------------------------- 174 // 175 // Get the observatory location "MObservatory" from parameter list 176 // 177 Bool_t MHStarMap::ReInit(MParList *pList) 178 { 179 MObservatory *obs = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory")); 180 if (!obs) 181 { 182 *fLog << err << "MObservatory not found... aborting" << endl; 183 return kFALSE; 184 } 185 186 fSinLat = TMath::Sin(obs->GetPhi()); 187 fCosLat = TMath::Cos(obs->GetPhi()); 188 189 return kTRUE; 190 } 191 192 // -------------------------------------------------------------------------- 193 // 194 // RotationAngle 195 // 196 // calculates the angle for the rotation of the sky image in the camera; 197 // this angle is a function of the local coordinates (theta, phi) in rad. 198 // 199 // calculate rotation angle alpha of sky image in camera 200 // (see TDAS 00-11, eqs. (18) and (20)) 201 // 202 void MHStarMap::GetRotationAngle(Double_t &cosal, Double_t &sinal) 203 { 204 const Double_t theta = fMcEvt->GetTelescopeTheta(); 205 const Double_t phi = fMcEvt->GetTelescopePhi(); 206 207 const Double_t sint = TMath::Sin(theta); 208 const Double_t cost = TMath::Cos(theta); 209 210 const Double_t sinp = TMath::Sin(phi); 211 const Double_t cosp = TMath::Cos(phi); 212 213 const Double_t v1 = sint*sinp; 214 const Double_t v2 = fCosLat*cost - fSinLat*sint*cosp; 215 216 const Double_t denom = 1./ TMath::Sqrt(v1*v1 + v2*v2); 217 218 cosal = (fSinLat * sint) + fCosLat * cost * cosp * denom; 219 sinal = (fCosLat * sinp) * denom; 143 220 } 144 221 … … 152 229 const MHillas &h = *(MHillas*)par; 153 230 154 const float delta = h.GetDelta(); 155 156 const float m = tan(delta); 157 const float cosd = 1.0/sqrt(1.0+m*m); 158 const float sind = sqrt(1.0-cosd*cosd); 159 160 float t = h.GetMeanY() - m*h.GetMeanX(); 231 const Float_t delta = h.GetDelta(); 232 233 const Float_t m = TMath::Tan(delta); 234 235 const Float_t cosd = 1.0/TMath::Sqrt(m*m+1); 236 const Float_t sind = TMath::Sqrt(1-cosd*cosd); 237 238 Float_t t = h.GetMeanY() - m*h.GetMeanX(); 239 240 Float_t xSource = fSrcPos->GetX(); 241 Float_t ySource = fSrcPos->GetY(); 161 242 162 243 if (!fUseMmScale) 244 { 163 245 t *= fMm2Deg; 246 xSource *= fMm2Deg; 247 ySource *= fMm2Deg; 248 } 164 249 165 250 // get step size ds along the main axis of the ellipse 166 251 const TAxis &axex = *fStarMap->GetXaxis(); 167 const float xmin = axex.GetXmin();168 const float xmax = axex.GetXmax();252 const Float_t xmin = axex.GetXmin(); 253 const Float_t xmax = axex.GetXmax(); 169 254 170 255 // FIXME: Fixed number? 171 const float ds = (xmax-xmin) / 200.0; 256 const Float_t ds = (xmax-xmin) / 200.0; 257 258 // Fill points along the main axis of the shower into the histogram; 259 // before filling 260 // - perform a translation by (xSource, ySource) 261 // - and perform a rotation to compensate the rotation of the 262 // sky image in the camera 263 Double_t cosal; 264 Double_t sinal; 265 GetRotationAngle(cosal, sinal); 172 266 173 267 if (m>-1 && m<1) 174 268 { 175 const float dx = ds * cosd;269 const Float_t dx = ds * cosd; 176 270 177 271 for (float x=xmin+dx/2; x<(xmax-xmin)+dx; x+=dx) 178 fStarMap->Fill(x, m*x+t, w); 272 { 273 const Float_t xorig = x - xSource; 274 const Float_t yorig = m*x+t - ySource; 275 276 const Float_t xfill = cosal*xorig + sinal*yorig; 277 const Float_t yfill = -sinal*xorig + cosal*yorig; 278 fStarMap->Fill(xfill, yfill, w); 279 } 179 280 } 180 281 else 181 282 { 182 283 const TAxis &axey = *fStarMap->GetYaxis(); 183 const float ymin = axey.GetXmin();184 const float ymax = axey.GetXmax();284 const Float_t ymin = axey.GetXmin(); 285 const Float_t ymax = axey.GetXmax(); 185 286 186 287 const float dy = ds * sind; 187 288 188 289 for (float y=ymin+dy/2; y<(ymax-ymin)+dy; y+=dy) 189 fStarMap->Fill((y-t)/m, y, w); 290 { 291 const Float_t xorig = (y-t)/m - xSource; 292 const Float_t yorig = y - ySource; 293 294 const Float_t xfill = cosal*xorig + sinal*yorig; 295 const Float_t yfill = -sinal*xorig + cosal*yorig; 296 fStarMap->Fill(xfill, yfill, w); 297 } 190 298 } 191 299 -
trunk/MagicSoft/Mars/mhist/MHStarMap.h
r2297 r3340 8 8 class TH2F; 9 9 class MHillas; 10 class MSrcPosCam; 11 class MMcEvt; 10 12 11 13 class MHStarMap : public MH 12 14 { 13 15 private: 14 TH2F *fStarMap; //-> 16 MSrcPosCam *fSrcPos; //! 17 MMcEvt *fMcEvt; //! 18 19 TH2F *fStarMap; //-> 15 20 16 21 Float_t fMm2Deg; … … 18 23 Bool_t fUseMmScale; 19 24 25 Float_t fCosLat; //! 26 Float_t fSinLat; //! 27 20 28 void PrepareDrawing() const; 21 29 22 30 void Paint(Option_t *opt=""); 31 32 void GetRotationAngle(Double_t &cosangle, Double_t &sinangle); 33 34 Bool_t SetupFill(const MParList *pList); 35 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 36 Bool_t ReInit(MParList *pList); 23 37 24 38 public: … … 29 43 void SetMm2Deg(Float_t mmdeg); 30 44 31 Bool_t SetupFill(const MParList *pList); 32 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 33 34 TH1 *GetHistByName(const TString name) { return (TH1*)fStarMap; } 45 TH1 *GetHistByName(const TString name) { return (TH1*)fStarMap; } 35 46 36 47 TH2F *GetHist() { return fStarMap; } … … 39 50 TObject *DrawClone(Option_t *opt=NULL) const; 40 51 41 ClassDef(MHStarMap, 1) // Container to hold 2-dim histogram (starmap)52 ClassDef(MHStarMap, 1) // Container to hold the Starmap 42 53 }; 43 54
Note:
See TracChangeset
for help on using the changeset viewer.