| 1 |
|
|---|
| 2 |
|
|---|
| 3 | /* ======================================================================== *\
|
|---|
| 4 | !
|
|---|
| 5 | ! *
|
|---|
| 6 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 7 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 8 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 9 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 10 | ! *
|
|---|
| 11 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 12 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 13 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 14 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 15 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 16 | ! * or implied warranty.
|
|---|
| 17 | ! *
|
|---|
| 18 | !
|
|---|
| 19 | !
|
|---|
| 20 | ! Author(s): Sebastian Commichau 05/2004 <mailto:commichau@particle.phys.ethz.ch>
|
|---|
| 21 | ! Author(s): Sabrina Stark 05/2004 <mailto:lstark@particle.phys.ethz.ch>
|
|---|
| 22 | !
|
|---|
| 23 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 24 | !
|
|---|
| 25 | !
|
|---|
| 26 | \* ======================================================================== */
|
|---|
| 27 |
|
|---|
| 28 | // Container to store the DCA stuff - it offers a nice draw option...
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | #include "MDCA.h"
|
|---|
| 32 |
|
|---|
| 33 | using namespace std;
|
|---|
| 34 |
|
|---|
| 35 | ClassImp(MDCA);
|
|---|
| 36 |
|
|---|
| 37 | // Default constructor
|
|---|
| 38 | MDCA::MDCA(const char *name, const char *title) : fXRef(0.0), fYRef(0.0)
|
|---|
| 39 | {
|
|---|
| 40 | fName = name ? name : "MDCA";
|
|---|
| 41 | fTitle = title ? title : "Storage container for Hillas parameters and DCA of one event";
|
|---|
| 42 |
|
|---|
| 43 | Reset();
|
|---|
| 44 |
|
|---|
| 45 | fEllipse = new TEllipse;
|
|---|
| 46 | fRefCircle = new TEllipse;
|
|---|
| 47 |
|
|---|
| 48 | fLineL = new TLine;
|
|---|
| 49 | fLineW = new TLine;
|
|---|
| 50 | fLineX = new TLine;
|
|---|
| 51 | fLineY = new TLine;
|
|---|
| 52 | fLineDCA = new TLine;
|
|---|
| 53 | fLineMean = new TLine;
|
|---|
| 54 |
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | // Destructor: Deletes ellipse and lines if they do exist
|
|---|
| 58 |
|
|---|
| 59 | MDCA::~MDCA()
|
|---|
| 60 | {
|
|---|
| 61 | Clear();
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | // Initialize parameters with default values
|
|---|
| 65 |
|
|---|
| 66 | void MDCA::Reset()
|
|---|
| 67 | {
|
|---|
| 68 |
|
|---|
| 69 | fLength = -1;
|
|---|
| 70 | fWidth = -1;
|
|---|
| 71 | fDelta0 = 0;
|
|---|
| 72 | fMeanX = 0;
|
|---|
| 73 | fMeanY = 0;
|
|---|
| 74 | fDelta1 = 0;
|
|---|
| 75 | fDCA = -1;
|
|---|
| 76 | fX1W = 0;
|
|---|
| 77 | fY1W = 0;
|
|---|
| 78 | fX2W = 0;
|
|---|
| 79 | fY2W = 0;
|
|---|
| 80 | fX1L = 0;
|
|---|
| 81 | fY1L = 0;
|
|---|
| 82 | fX2L = 0;
|
|---|
| 83 | fY2L = 0;
|
|---|
| 84 | fXDCA = 0;
|
|---|
| 85 | fYDCA = 0;
|
|---|
| 86 |
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | // Print parameters to *fLog
|
|---|
| 91 |
|
|---|
| 92 | void MDCA::Print(Option_t *) const
|
|---|
| 93 | {
|
|---|
| 94 | Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
|
|---|
| 95 |
|
|---|
| 96 | if (atg<0)
|
|---|
| 97 | atg += 180;
|
|---|
| 98 |
|
|---|
| 99 | *fLog << all;
|
|---|
| 100 | *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
|
|---|
| 101 | *fLog << " - Length [mm] = " << fLength << endl;
|
|---|
| 102 | *fLog << " - Width [mm] = " << fWidth << endl;
|
|---|
| 103 | *fLog << " - Delta0 [deg] = " << fDelta0*kRad2Deg << endl;
|
|---|
| 104 | *fLog << " - Meanx [mm] = " << fMeanX << endl;
|
|---|
| 105 | *fLog << " - Meany [mm] = " << fMeanY << endl;
|
|---|
| 106 | *fLog << " - atg(y/x) [deg] = " << atg << endl;
|
|---|
| 107 | *fLog << " - DCA [mm] = " << fDCA << endl;
|
|---|
| 108 | *fLog << " - Delta1 [deg] = " << fDelta1*kRad2Deg << endl;
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | void MDCA::Paint(Option_t *opt)
|
|---|
| 114 | {
|
|---|
| 115 | Clear();
|
|---|
| 116 |
|
|---|
| 117 | if (fLength<=0 || fWidth<=0) //fLength<0 || fWidth<0 doesn't look nice...
|
|---|
| 118 | return; //We get a circle!
|
|---|
| 119 |
|
|---|
| 120 | // Length line
|
|---|
| 121 | fLineL = new TLine(fX1L, fY1L, fX2L, fY2L);
|
|---|
| 122 | fLineL->SetLineWidth(2);
|
|---|
| 123 | fLineL->SetLineColor(2);
|
|---|
| 124 | fLineL->Draw();
|
|---|
| 125 |
|
|---|
| 126 | // Width line
|
|---|
| 127 | fLineW = new TLine(fX1W, fY1W, fX2W, fY2W);
|
|---|
| 128 | fLineW->SetLineWidth(2);
|
|---|
| 129 | fLineW->SetLineColor(2);
|
|---|
| 130 | fLineW->Draw();
|
|---|
| 131 |
|
|---|
| 132 | // Coordinate system
|
|---|
| 133 | fLineX = new TLine(-600,fYRef,600,fYRef);
|
|---|
| 134 | fLineY = new TLine(fXRef,-600,fXRef,600);
|
|---|
| 135 | fLineX->SetLineWidth(2);
|
|---|
| 136 | fLineX->SetLineColor(1);
|
|---|
| 137 | fLineY->SetLineWidth(2);
|
|---|
| 138 | fLineY->SetLineColor(1);
|
|---|
| 139 | fLineX->Draw();
|
|---|
| 140 | fLineY->Draw();
|
|---|
| 141 |
|
|---|
| 142 | // DCA line
|
|---|
| 143 | fLineDCA = new TLine(fXRef,fYRef,fXDCA+fXRef,fYDCA+fYRef);
|
|---|
| 144 | fLineDCA->SetLineWidth(2);
|
|---|
| 145 | fLineDCA->SetLineColor(2);
|
|---|
| 146 | fLineDCA->Draw();
|
|---|
| 147 |
|
|---|
| 148 | // COG line
|
|---|
| 149 | fLineMean = new TLine(fXRef,fYRef,fMeanX,fMeanY);
|
|---|
| 150 | fLineMean->SetLineWidth(2);
|
|---|
| 151 | fLineMean->SetLineColor(2);
|
|---|
| 152 | fLineMean->Draw();
|
|---|
| 153 |
|
|---|
| 154 | // Reference point marker
|
|---|
| 155 | fRefCircle = new TEllipse(fXRef, fYRef, 5, 5, 0, 360, 0);
|
|---|
| 156 | fRefCircle->SetLineColor(8);
|
|---|
| 157 | fRefCircle->SetFillColor(8);
|
|---|
| 158 | fRefCircle->Draw();
|
|---|
| 159 |
|
|---|
| 160 | // Hillas ellipse
|
|---|
| 161 | fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth, 0, 360, fDelta0*kRad2Deg+180);
|
|---|
| 162 | fEllipse->SetLineWidth(2);
|
|---|
| 163 | fEllipse->SetLineColor(2);
|
|---|
| 164 | fEllipse->Draw();
|
|---|
| 165 |
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | // If an ellipse and lines exist they will be deleted
|
|---|
| 170 |
|
|---|
| 171 | void MDCA::Clear(Option_t *)
|
|---|
| 172 | {
|
|---|
| 173 | if (!fEllipse && !fRefCircle && !fLineL && !fLineW && !fLineX && !fLineY && !fLineDCA && !fLineMean)
|
|---|
| 174 | return;
|
|---|
| 175 |
|
|---|
| 176 | delete fEllipse;
|
|---|
| 177 | delete fRefCircle;
|
|---|
| 178 | delete fLineL;
|
|---|
| 179 | delete fLineW;
|
|---|
| 180 | delete fLineX;
|
|---|
| 181 | delete fLineY;
|
|---|
| 182 | delete fLineDCA;
|
|---|
| 183 | delete fLineMean;
|
|---|
| 184 |
|
|---|
| 185 | fLineL = NULL;
|
|---|
| 186 | fLineX = NULL;
|
|---|
| 187 | fLineY = NULL;
|
|---|
| 188 | fLineW = NULL;
|
|---|
| 189 | fLineDCA = NULL;
|
|---|
| 190 | fLineMean = NULL;
|
|---|
| 191 | fEllipse = NULL;
|
|---|
| 192 | fRefCircle = NULL;
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 | Int_t MDCA::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hil)
|
|---|
| 197 | {
|
|---|
| 198 | // Get basic Hillas parameters from MHillas
|
|---|
| 199 | fDelta0 = hil.GetDelta();
|
|---|
| 200 | fMeanX = hil.GetMeanX();
|
|---|
| 201 | fMeanY = hil.GetMeanY();
|
|---|
| 202 | fLength = hil.GetLength();
|
|---|
| 203 | fWidth = hil.GetWidth();
|
|---|
| 204 |
|
|---|
| 205 | // The Length Line - rotation and shift
|
|---|
| 206 | fX1L = - (fLength+OffsetL)*cos(fDelta0) + fMeanX; // [mm]
|
|---|
| 207 | fY1L = - (fLength+OffsetL)*sin(fDelta0) + fMeanY; // [mm]
|
|---|
| 208 | fX2L = (fLength+OffsetL)*cos(fDelta0) + fMeanX; // [mm]
|
|---|
| 209 | fY2L = (fLength+OffsetL)*sin(fDelta0) + fMeanY; // [mm]
|
|---|
| 210 |
|
|---|
| 211 | // The Width Line - rotation and shift
|
|---|
| 212 | fX1W = (fWidth+OffsetW)*sin(fDelta0) + fMeanX; // [mm]
|
|---|
| 213 | fY1W = - (fWidth+OffsetW)*cos(fDelta0) + fMeanY; // [mm]
|
|---|
| 214 | fX2W = - (fWidth+OffsetW)*sin(fDelta0) + fMeanX; // [mm]
|
|---|
| 215 | fY2W = (fWidth+OffsetW)*cos(fDelta0) + fMeanY; // [mm]
|
|---|
| 216 |
|
|---|
| 217 | // Vector of orientation of the shower axis
|
|---|
| 218 | fr1 = fX2L-fX1L;
|
|---|
| 219 | fr2 = fY2L-fY1L;
|
|---|
| 220 |
|
|---|
| 221 | // Determine parameters to calculate coordinates of the DCA vector
|
|---|
| 222 | flambda = (fr1*(fXRef-fMeanX) + fr2*(fYRef-fMeanY))/(fr1*fr1 + fr2*fr2);
|
|---|
| 223 | fmu = (fMeanY-fYRef)/fr1 + flambda*fr2/fr1;
|
|---|
| 224 |
|
|---|
| 225 | // Components of the DCA vector
|
|---|
| 226 | fXDCA = -fmu*fr2;
|
|---|
| 227 | fYDCA = fmu*fr1;
|
|---|
| 228 |
|
|---|
| 229 | // Components of vector going from intersection point of the DCA vector
|
|---|
| 230 | // with the shower axis to the COG
|
|---|
| 231 | fd1 = fMeanX + fmu*fr2 - fXRef;
|
|---|
| 232 | fd2 = fMeanY - fmu*fr1 - fYRef;
|
|---|
| 233 |
|
|---|
| 234 | // Calculate DCA value
|
|---|
| 235 | fDCA = sqrt(fXDCA*fXDCA + fYDCA*fYDCA);
|
|---|
| 236 |
|
|---|
| 237 | // Calculate angle of the shower axis with respect to the x-axis
|
|---|
| 238 | fDelta1 = acos(fd1/sqrt(fd1*fd1 + fd2*fd2));
|
|---|
| 239 |
|
|---|
| 240 | // Calculate angle of the shower axis with respect to the y-axis
|
|---|
| 241 | //fDelta1 = acos(fd2/sqrt(fd1*fd1 + fd2*fd2));
|
|---|
| 242 |
|
|---|
| 243 | // Determine the correct sign of the DCA (cross product of DCA vector and
|
|---|
| 244 | // vector going from the intersection point of the DCA vector with the shower axis
|
|---|
| 245 | // to the COG)
|
|---|
| 246 | if((fmu*(-fr2*(fMeanY-fYRef)-fr1*(fMeanX-fXRef)))<0)
|
|---|
| 247 | fDCA = -fDCA;
|
|---|
| 248 |
|
|---|
| 249 | gRandom->Rannor(gx,gy);
|
|---|
| 250 | gx = fabs(gx);
|
|---|
| 251 |
|
|---|
| 252 | // This is nice but does not remove the systematics in the profile plot...
|
|---|
| 253 | //if(((1-0.6*gx)*(180-kRad2Deg*fDelta1)>120) || ((1-0.6*gx)*kRad2Deg*fDelta1>120))
|
|---|
| 254 | // fDCA = -1;
|
|---|
| 255 |
|
|---|
| 256 | // Enlarge the interval of Delta correctly...
|
|---|
| 257 | if((fMeanY-fYRef-fmu*fr1)<0)
|
|---|
| 258 | fDelta1 = TwoPi-fDelta1;
|
|---|
| 259 |
|
|---|
| 260 | // Enlarge the interval of Delta correctly... (Delta with respect to the y-axis)
|
|---|
| 261 | // if(-(fMeanX-fXRef+fmu*fr2)<0)
|
|---|
| 262 | // fDelta1 = TwoPi-fDelta1;
|
|---|
| 263 |
|
|---|
| 264 | // This has to be improved...
|
|---|
| 265 | if(fr1 == 0 || fr2 == 0 || (fr1*fr1+fr2*fr2) == 0 || sqrt(fd1*fd1+fd2*fd2) == 0)
|
|---|
| 266 | fDCA = -fDCA;
|
|---|
| 267 |
|
|---|
| 268 | SetReadyToSave();
|
|---|
| 269 |
|
|---|
| 270 | return 0;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | void MDCA::SetRefPoint(const Float_t fXRef0, const Float_t fYRef0)
|
|---|
| 274 | {
|
|---|
| 275 | fXRef = fXRef0;
|
|---|
| 276 | fYRef = fYRef0;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|