Changeset 1203 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 01/21/02 20:52:12 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 8 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
r1151 r1203 21 21 #pragma link C++ class MMcPedestalNSBAdd+; 22 22 23 #pragma link C++ class MSrcPosCam+; 23 24 #pragma link C++ class MHillas+; 25 #pragma link C++ class MHillasSrc+; 26 #pragma link C++ class MHillasSrcCalc+; 27 #pragma link C++ class MHillasExt+; 24 28 #pragma link C++ class MHillasCalc+; 25 29 -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
r1081 r1203 32 32 33 33 #include "MLog.h" 34 35 #include "MGeomCam.h" 36 #include "MGeomPix.h" 37 34 38 #include "MHexagon.h" 35 39 … … 148 152 // -------------------------------------------------------------------------- 149 153 // 150 // get the minimum number of photons of all valid pixels in the list 151 // 152 Float_t MCerPhotEvt::GetNumPhotonsMin() const 154 // get the minimum number of photons of all valid pixels in the list 155 // If you specify a geometry the number of photons is weighted with the 156 // area of the pixel 157 // 158 Float_t MCerPhotEvt::GetNumPhotonsMin(const MGeomCam *geom) const 153 159 { 154 160 if (fNumPixels <= 0) 155 161 return -5.; 156 162 163 const Float_t A0 = geom ? (*geom)[0].GetA() : 0; 164 157 165 Float_t minval = (*this)[0].GetNumPhotons(); 158 166 159 167 for (UInt_t i=1; i<fNumPixels; i++) 160 168 { 161 const Float_t testval = (*this)[i].GetNumPhotons(); 169 const MCerPhotPix &pix = (*this)[i]; 170 171 Float_t testval = pix.GetNumPhotons(); 172 173 if (geom) 174 testval *= A0/(*geom)[pix.GetPixId()].GetA(); 162 175 163 176 if (testval < minval) … … 171 184 // 172 185 // get the maximum number of photons of all valid pixels in the list 173 // 174 Float_t MCerPhotEvt::GetNumPhotonsMax() const 186 // If you specify a geometry the number of photons is weighted with the 187 // area of the pixel 188 // 189 Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const 175 190 { 176 191 if (fNumPixels <= 0) 177 192 return 50.; 178 193 194 const Float_t A0 = geom ? (*geom)[0].GetA() : 0; 179 195 Float_t maxval = (*this)[0].GetNumPhotons(); 180 196 181 197 for (UInt_t i=1; i<fNumPixels; i++) 182 198 { 183 const Float_t testval = (*this)[i].GetNumPhotons(); 199 const MCerPhotPix &pix = (*this)[i]; 200 201 Float_t testval = pix.GetNumPhotons(); 202 203 if (geom) 204 testval *= A0/(*geom)[pix.GetPixId()].GetA(); 184 205 185 206 if (testval > maxval) -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
r1083 r1203 9 9 #endif 10 10 11 class MGeomCam; 11 12 class MCerPhotPix; 12 13 … … 34 35 Bool_t IsPixelCore (Int_t id) const; 35 36 36 Float_t GetNumPhotonsMin( ) const;37 Float_t GetNumPhotonsMax( ) const;37 Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const; 38 Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const; 38 39 39 40 MCerPhotPix &operator[](int i) { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); } -
trunk/MagicSoft/Mars/manalysis/MHillas.cc
r1081 r1203 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de> 19 ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de) 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de> 19 ! Author(s): Harald Kornmayer 1/2001 20 ! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch> 20 21 ! 21 22 ! Copyright: MAGIC Software Development, 2000-2001 … … 25 26 26 27 ///////////////////////////////////////////////////////////////////////////// 27 // // 28 // MHillas // 29 // // 30 // Storage Container for the Hillas parameter // 31 // // 32 // FIXME: - Here everybody should find an explanation of the parameters // 33 // - using boooleans for fIsPixelUsed, fIsPixelCore, ... is rather // 34 // slow because you have to loop over all pixels in any loop. // 35 // There could be a huge speed improvement using Hash Tables // 36 // (linked lists, see THashTable and THashList, too) // 37 // // 28 // 29 // MHillas 30 // 31 // Storage Container for image parameters 32 // 33 // basic image parameters 34 // fLength major axis of ellipse 35 // fWidth minor axis 36 // fDelta angle of major axis wrt x-axis 37 // fSize total sum of pixels 38 // fMeanx x of center of ellipse 39 // fMeany y of center of ellipse 40 // 38 41 ///////////////////////////////////////////////////////////////////////////// 39 42 #include "MHillas.h" 40 43 41 #include <math.h>42 44 #include <fstream.h> 43 45 … … 51 53 52 54 #include "MLog.h" 55 #include "MLogManip.h" 53 56 54 57 ClassImp(MHillas); … … 61 64 { 62 65 fName = name ? name : "MHillas"; 63 fTitle = title ? title : "Storage container for Hillas parameterof one event";66 fTitle = title ? title : "Storage container for image parameters of one event"; 64 67 65 68 Reset(); 66 69 // FIXME: (intelligent) initialization of values missing 70 71 fEllipse = new TEllipse; 67 72 } 68 73 … … 76 81 } 77 82 83 // -------------------------------------------------------------------------- 84 // 78 85 void MHillas::Reset() 79 86 { 80 fAlpha = 0; 81 fTheta = 0; 87 fLength = 0; 82 88 fWidth = 0; 83 f Length= 0;89 fDelta = 0; 84 90 fSize = 0; 85 fDist = 0; 91 fMeanx = 0; 92 fMeany = 0; 86 93 87 94 Clear(); … … 94 101 void MHillas::Print(Option_t *) const 95 102 { 96 *fLog << "Hillas Parameter: " << GetDescriptor() << endl; 97 *fLog << " - Alpha = " << fabs(fAlpha) << " deg" << endl; 98 *fLog << " - Width = " << fWidth << " mm" << endl; 99 *fLog << " - Length = " << fLength << " mm" << endl; 100 *fLog << " - Size = " << fSize << " #CerPhot" << endl; 101 *fLog << " - Dist = " << fDist << " mm" << endl; 103 Double_t atg = atan2(fMeany, fMeanx)*kRad2Deg; 104 105 if (atg<0) 106 atg += 180; 107 108 *fLog << all; 109 *fLog << "Basic Image Parameters (" << GetName() << ")" << endl; 110 *fLog << " - Length [mm] = " << fLength << endl; 111 *fLog << " - Width [mm] = " << fWidth << endl; 112 *fLog << " - Meanx [mm] = " << fMeanx << endl; 113 *fLog << " - Meany [mm] = " << fMeany << endl; 114 *fLog << " - Delta [deg] = " << fDelta*kRad2Deg << endl; 115 *fLog << " - atg(y/x) [deg] = " << atg << endl; 116 *fLog << " - Size [1] = " << fSize << " #CherPhot" << endl; 102 117 } 103 118 104 119 /* 105 // ----------------------------------------------------------- ---------------120 // ----------------------------------------------------------- 106 121 // 107 122 // call the Paint function of the Ellipse if a TEllipse exists 108 123 // 109 124 void MHillas::Paint(Option_t *) 125 { 126 fEllipse->SetLineWidth(2); 127 fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth, 128 0, 360, fDelta*kRad2Deg+180); 129 } 130 */ 131 132 // -------------------------------------------------------------------------- 133 // 134 // Instead of adding MHillas itself to the Pad 135 // (s. AppendPad in TObject) we create an ellipse, 136 // which is added to the Pad by its Draw function 137 // You can remove it by deleting the Ellipse Object 138 // (s. Clear() ) 139 // 140 void MHillas::Draw(Option_t *opt) 141 { 142 143 Clear(); 144 145 fEllipse = new TEllipse(fMeanx, fMeany, fLength, fWidth, 146 0, 360, fDelta*kRad2Deg+180); 147 148 fEllipse->SetLineWidth(2); 149 fEllipse->Draw(); 150 151 /* 152 fEllipse->SetPhimin(); 153 fEllipse->SetPhimax(); 154 fEllipse->SetR1(fLength); 155 fEllipse->SetR2(fWidth); 156 fEllipse->SetTheta(fDelta*kRad2Deg+180); 157 fEllipse->SetX1(fMeanx); 158 fEllipse->SetY1(fMeany); 159 160 fEllipse->SetLineWidth(2); 161 fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth, 162 0, 360, fDelta*kRad2Deg+180); 163 164 AppendPad(opt); 165 166 // This is from TH1 167 TString opt = option; 168 opt.ToLower(); 169 if (gPad && !opt.Contains("same")) { 170 //the following statement is necessary in case one attempts to draw 171 //a temporary histogram already in the current pad 172 if (TestBit(kCanDelete)) gPad->GetListOfPrimitives()->Remove(this); 173 gPad->Clear(); 174 } 175 */ 176 } 177 178 // -------------------------------------------------------------------------- 179 // 180 // If a TEllipse object exists it is deleted 181 // 182 void MHillas::Clear(Option_t *) 110 183 { 111 184 if (!fEllipse) 112 185 return; 113 186 114 fEllipse->Paint();115 }116 */117 118 // --------------------------------------------------------------------------119 //120 // Instead of adding MHillas itself to the Pad121 // (s. AppendPad in TObject) we create an ellipse,122 // which is added to the Pad by it's Draw function123 // You can remove it by deleting the Ellipse Object124 // (s. Clear() )125 //126 void MHillas::Draw(Option_t *opt)127 {128 Clear();129 130 fEllipse = new TEllipse(cos(fTheta)*fDist, sin(fTheta)*fDist,131 fLength, fWidth,132 0, 360, fTheta*kRad2Deg+fAlpha-180);133 134 fEllipse->SetLineWidth(2);135 fEllipse->Draw();136 //AppendPad(opt);137 138 /*139 This is from TH1140 TString opt = option;141 opt.ToLower();142 if (gPad && !opt.Contains("same")) {143 //the following statement is necessary in case one attempts to draw144 //a temporary histogram already in the current pad145 if (TestBit(kCanDelete)) gPad->GetListOfPrimitives()->Remove(this);146 gPad->Clear();147 }148 AppendPad(opt.Data());149 */150 }151 152 // --------------------------------------------------------------------------153 //154 // If a TEllipse object exists it is deleted155 //156 void MHillas::Clear(Option_t *)157 {158 if (!fEllipse)159 return;160 161 187 delete fEllipse; 162 188 … … 164 190 } 165 191 166 // -------------------------------------------------------------------------- 167 // 168 // Calculate the Hillas parameters from a cerenkov photon event 169 // (The calcualtion is some kind of two dimentional statistics) 170 // 171 // FIXME: MHillas::Calc is rather slow at the moment because it loops 172 // unnecessarily over all pixels in all its loops (s.MImgCleanStd) 173 // The speed could be improved very much by using Hash-Tables 174 // (linked lists, see THashTable and THashList, too) 192 193 // -------------------------------------------------------------------------- 194 // 195 // Calculate the image parameters from a Cherenkov photon event 196 // assuming Cher.photons/pixel and pixel coordinates are given 175 197 // 176 198 Bool_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt) 177 199 { 178 const UInt_t nevt = evt.GetNumPixels(); 200 // FIXME: MHillas::Calc is rather slow at the moment because it loops 201 // unnecessarily over all pixels in all its loops (s.MImgCleanStd) 202 // The speed could be improved very much by using Hash-Tables 203 // (linked lists, see THashTable and THashList, too) 204 // 205 206 const UInt_t npixevt = evt.GetNumPixels(); 179 207 180 208 // 181 209 // sanity check 182 210 // 183 if (n evt <= 2)211 if (npixevt <= 2) 184 212 return kFALSE; 185 213 186 214 // 187 // calculate mean valu of pixels188 // 189 float xmean =0;190 f loat ymean =0;191 192 fSize = 0;215 // calculate mean value of pixel coordinates and fSize 216 // ----------------------------------------------------- 217 // 218 fMeanx = 0; 219 fMeany = 0; 220 fSize = 0; 193 221 194 222 // … … 196 224 // 197 225 UShort_t npix=0; 198 for (UInt_t i=0; i<n evt; i++)226 for (UInt_t i=0; i<npixevt; i++) 199 227 { 200 228 const MCerPhotPix &pix = evt[i]; … … 207 235 const float nphot = pix.GetNumPhotons(); 208 236 209 fSize += nphot;210 xmean += nphot * gpix.GetX();// [mm]211 ymean += nphot * gpix.GetY();// [mm]237 fSize += nphot; // [counter] 238 fMeanx += nphot * gpix.GetX(); // [mm] 239 fMeany += nphot * gpix.GetY(); // [mm] 212 240 213 241 npix++; … … 220 248 return kFALSE; 221 249 222 xmean /= fSize; // [mm] 223 ymean /= fSize; // [mm] 224 225 // 226 // calculate sdev 227 // 228 float sigmaxx=0; 229 float sigmaxy=0; 230 float sigmayy=0; 231 232 for (UInt_t i=0; i<nevt; i++) 250 fMeanx /= fSize; // [mm] 251 fMeany /= fSize; // [mm] 252 253 // 254 // calculate 2nd moments 255 // ------------------- 256 // 257 float corrxx=0; // [m^2] 258 float corrxy=0; // [m^2] 259 float corryy=0; // [m^2] 260 261 for (UInt_t i=0; i<npixevt; i++) 233 262 { 234 263 const MCerPhotPix &pix = evt[i]; … … 238 267 239 268 const MGeomPix &gpix = geom[pix.GetPixId()]; 240 241 const float dx = gpix.GetX() - xmean; 242 const float dy = gpix.GetY() - ymean; 243 244 const float nphot = pix.GetNumPhotons(); 245 246 sigmaxx += nphot * dx*dx; // [mm^2] 247 sigmaxy += nphot * dx*dy; // [mm^2] 248 sigmayy += nphot * dy*dy; // [mm^2] 269 const float dx = gpix.GetX() - fMeanx; // [mm] 270 const float dy = gpix.GetY() - fMeany; // [mm] 271 272 const float nphot = pix.GetNumPhotons(); // [#phot] 273 274 corrxx += nphot * dx*dx; // [mm^2] 275 corrxy += nphot * dx*dy; // [mm^2] 276 corryy += nphot * dy*dy; // [mm^2] 249 277 } 250 278 251 279 // 252 // check for orientation 253 // 254 const float theta = atan(sigmaxy/(sigmaxx-sigmayy)*2)/2; 255 256 float c = cos(theta); // [1] 257 float s = sin(theta); // [1] 258 259 // 260 // calculate the length of the two axis 261 // 262 float axis1 = 2.0*c*s*sigmaxy + c*c*sigmaxx + s*s*sigmayy; // [mm^2] 263 float axis2 = -2.0*c*s*sigmaxy + s*s*sigmaxx + c*c*sigmayy; // [mm^2] 264 265 axis1 /= fSize; // [mm^2] 266 axis2 /= fSize; // [mm^2] 267 268 // 269 // check for numerical negatives 270 // (very small number can get negative by chance) 271 // 280 // calculate the basic Hillas parameters: orientation and size of axes 281 // ------------------------------------------------------------------- 282 // 283 const float d = corryy - corrxx; 284 285 fDelta = atan2(d + sqrt(d*d + corrxy*corrxy*4), corrxy*2); 286 287 fCosDelta = cos(fDelta); // need these in derived classes 288 fSinDelta = sin(fDelta); // like MHillasExt 289 290 float axis1 = ( fCosDelta*fSinDelta*corrxy*2 + fCosDelta*fCosDelta*corrxx + fSinDelta*fSinDelta*corryy) / fSize; // [mm^2] 291 float axis2 = (-fCosDelta*fSinDelta*corrxy*2 + fSinDelta*fSinDelta*corrxx + fCosDelta*fCosDelta*corryy) / fSize; // [mm^2] 292 293 // very small numbers can get negative by rounding 272 294 if (axis1 < 0) axis1=0; 273 if (axis2 < 0) axis2=0; 274 275 // 276 // calculate the main Hillas parameters 277 // 278 // fLength, fWidth describes the two axis of the ellipse 279 // fAlpha is the angle between the length-axis and the center 280 // of the camera 281 // fDist is the distance between the center of the camera and the 282 // denter of the ellipse 283 // 284 const int rotation = axis1<axis2; 285 286 fLength = rotation ? sqrt(axis2) : sqrt(axis1); // [mm] 287 fWidth = rotation ? sqrt(axis1) : sqrt(axis2); // [mm] 288 289 const float a = c*xmean + s*ymean; 290 const float b = c*ymean - s*xmean; 291 292 fAlpha = rotation ? atan(a/b) : atan(-b/a); // [rad] 293 fAlpha *= kRad2Deg; // [deg] 294 295 fDist = sqrt(xmean*xmean + ymean*ymean); // [mm] 296 297 fTheta = atan(ymean/xmean); // [rad] 298 if (xmean<0) fTheta += kPI; // [rad] 295 if (axis2 < 0) axis2=0; 296 297 fLength = sqrt(axis1); // [mm] 298 fWidth = sqrt(axis2); // [mm] 299 299 300 300 SetReadyToSave(); … … 303 303 } 304 304 305 // -------------------------------------------------------------------------- 306 // 305 307 void MHillas::AsciiRead(ifstream &fin) 306 308 { 307 fin >> fAlpha; 308 fin >> fTheta; 309 fin >> fLength; 309 310 fin >> fWidth; 310 fin >> f Length;311 fin >> fDelta; 311 312 fin >> fSize; 312 fin >> fDist; 313 } 314 313 fin >> fMeanx; 314 fin >> fMeany; 315 } 316 317 // -------------------------------------------------------------------------- 318 // 315 319 void MHillas::AsciiWrite(ofstream &fout) const 316 320 { 317 fout << fAlpha << " ";318 fout << fTheta << " ";319 fout << fWidth << " ";320 321 fout << fLength << " "; 321 fout << fSize << " "; 322 fout << fDist << endl; 323 } 322 fout << fWidth << " "; 323 fout << fDelta << " "; 324 fout << fSize << " "; 325 fout << fMeanx << " "; 326 fout << fMeany; 327 } -
trunk/MagicSoft/Mars/manalysis/MHillas.h
r1018 r1203 14 14 { 15 15 private: 16 Float_t fAlpha; // [deg] Angle between the length axis of the ellipse and the camera center 17 Float_t fTheta; // [rad] Angle between the x axis and the center of the ellipse 18 Float_t fWidth; // [mm] Width of the ellipse 19 Float_t fLength; // [mm] Length of the ellipse 20 Float_t fSize; // [#CerPhot] Size of the ellipse 21 Float_t fDist; // [mm] Distance of the ellipse COM from the camera center 16 // for description see MHillas.cc 17 Float_t fLength; // [mm] major axis of ellipse 18 Float_t fWidth; // [mm] minor axis of ellipse 19 Float_t fDelta; // [rad] angle of major axis with x-axis 20 Float_t fSize; // [#CerPhot] sum of content of all pixels (number of Cherenkov photons) 21 Float_t fMeanx; // [mm] x-coordinate of center of ellipse 22 Float_t fMeany; // [mm] y-coordinate of center of ellipse 22 23 23 TEllipse *fEllipse; //! Graphical Object to Display Ellipse 24 Float_t fSinDelta; //! [1] sin of Delta (to be used in derived classes) 25 Float_t fCosDelta; //! [1] cos of Delta (to be used in derived classes) 26 27 TEllipse *fEllipse; //! Graphical Object to Display Ellipse 28 29 protected: 30 // 31 // This is only for calculations in derived classes because 32 // we don't want to read/write this data members 33 // 34 Float_t GetCosDelta() const { return fCosDelta; } 35 Float_t GetSinDelta() const { return fSinDelta; } 24 36 25 37 public: … … 29 41 void Reset(); 30 42 31 Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);43 virtual Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix); 32 44 33 v oid Print(Option_t *opt=NULL) const;34 v oid Draw(Option_t *opt=NULL);35 //v oid Paint(Option_t *opt=NULL);45 virtual void Print(Option_t *opt=NULL) const; 46 virtual void Draw(Option_t *opt=NULL); 47 //virtual void Paint(Option_t *); 36 48 37 v oid Clear(Option_t *opt=NULL);49 virtual void Clear(Option_t *opt=NULL); 38 50 39 Float_t Get Alpha() const { return fAlpha; }51 Float_t GetLength() const { return fLength; } 40 52 Float_t GetWidth() const { return fWidth; } 41 Float_t GetLength() const { return fLength; } 42 Float_t GetDist() const { return fDist; } 53 Float_t GetDelta() const { return fDelta; } 43 54 Float_t GetSize() const { return fSize; } 44 Float_t GetTheta() const { return fTheta; } 55 Float_t GetMeanX() const { return fMeanx; } 56 Float_t GetMeanY() const { return fMeany; } 45 57 46 v oid AsciiRead(ifstream &fin);47 v oid AsciiWrite(ofstream &fout) const;58 virtual void AsciiRead(ifstream &fin); 59 virtual void AsciiWrite(ofstream &fout) const; 48 60 49 61 ClassDef(MHillas, 1) // Storage Container for Hillas Parameter … … 51 63 52 64 #endif 53 -
trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc
r1081 r1203 54 54 // Default constructor. 55 55 // 56 MHillasCalc::MHillasCalc(const char * name, const char *title)56 MHillasCalc::MHillasCalc(const char *hil, const char *name, const char *title) 57 57 { 58 58 fName = name ? name : "MHillasCalc"; 59 59 fTitle = title ? title : "Task to calculate Hillas parameters"; 60 61 fHilName = hil; 60 62 } 61 63 … … 82 84 } 83 85 84 fHillas = (MHillas*)pList->FindCreateObj( "MHillas");86 fHillas = (MHillas*)pList->FindCreateObj(fHilName); 85 87 if (!fHillas) 86 88 return kFALSE; -
trunk/MagicSoft/Mars/manalysis/MHillasCalc.h
r1014 r1203 24 24 MHillas *fHillas; // ouput container to store result 25 25 26 TString fHilName; 26 27 public: 27 MHillasCalc(const char * name=NULL, const char *title=NULL);28 MHillasCalc(const char *hil="MHillas", const char *name=NULL, const char *title=NULL); 28 29 29 30 Bool_t PreProcess(MParList *pList); -
trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
r1081 r1203 194 194 // 195 195 // Look for the boundary pixels around the core pixels 196 // if a pixel has more than 2.5 (clean level 2 ) sigma, and196 // if a pixel has more than 2.5 (clean level 2.5) sigma, and 197 197 // a core neigbor it is declared as used. 198 198 // -
trunk/MagicSoft/Mars/manalysis/Makefile
r1151 r1203 34 34 MMcPedestalNSBAdd.cc \ 35 35 MImgCleanStd.cc \ 36 MSrcPosCam.cc \ 36 37 MHillas.cc \ 38 MHillasExt.cc \ 37 39 MHillasCalc.cc \ 40 MHillasSrc.cc \ 41 MHillasSrcCalc.cc \ 38 42 MCerPhotCalc.cc \ 39 43 MCerPhotEvt.cc \
Note:
See TracChangeset
for help on using the changeset viewer.