| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | ! Author(s): Javier Rico 05/2004 <mailto:jrico@ifae.es>
|
|---|
| 18 | !
|
|---|
| 19 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 20 | !
|
|---|
| 21 | !
|
|---|
| 22 | \* ======================================================================== */
|
|---|
| 23 |
|
|---|
| 24 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 25 | //
|
|---|
| 26 | // MDisplayHillas
|
|---|
| 27 | //
|
|---|
| 28 | // Display the camera event of type MCerPhotEvt plus the computed hillas
|
|---|
| 29 | // parameters.
|
|---|
| 30 | //
|
|---|
| 31 | // Input containers (in constructor):
|
|---|
| 32 | // MCerPhotEvt
|
|---|
| 33 | // MGeomCam
|
|---|
| 34 | //
|
|---|
| 35 | // Input containers
|
|---|
| 36 | // MHillas
|
|---|
| 37 | // [MSrcPosCam]
|
|---|
| 38 | // [MIslands]
|
|---|
| 39 | //
|
|---|
| 40 | // Output containers
|
|---|
| 41 | // [...]
|
|---|
| 42 | //
|
|---|
| 43 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 44 | #include <fstream>
|
|---|
| 45 | #include <math.h>
|
|---|
| 46 |
|
|---|
| 47 | #include "TVirtualPad.h"
|
|---|
| 48 | #include "TLine.h"
|
|---|
| 49 | #include "TEllipse.h"
|
|---|
| 50 |
|
|---|
| 51 | #include "MLog.h"
|
|---|
| 52 | #include "MLogManip.h"
|
|---|
| 53 |
|
|---|
| 54 | #include "MParList.h"
|
|---|
| 55 | #include "MHillasDisplay.h"
|
|---|
| 56 | #include "MCerPhotEvt.h"
|
|---|
| 57 | #include "MGeomCam.h"
|
|---|
| 58 | #include "MHillas.h"
|
|---|
| 59 | #include "MNewImagePar.h"
|
|---|
| 60 | #include "MSrcPosCam.h"
|
|---|
| 61 | #include "MIslands.h"
|
|---|
| 62 |
|
|---|
| 63 | ClassImp(MHillasDisplay);
|
|---|
| 64 |
|
|---|
| 65 | using namespace std;
|
|---|
| 66 |
|
|---|
| 67 | static const TString gsDefName = "MHillasDisplay";
|
|---|
| 68 | static const TString gsDefTitle = "Hillas Camera display task";
|
|---|
| 69 |
|
|---|
| 70 | // -------------------------------------------------------------------------
|
|---|
| 71 | //
|
|---|
| 72 | // Constructor (see MDisplay documentation for more information)
|
|---|
| 73 | //
|
|---|
| 74 | MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title)
|
|---|
| 75 | : MDisplay(event,geom,type), fHillas(NULL), fNewImage(NULL), fSrcPos(NULL)
|
|---|
| 76 | {
|
|---|
| 77 | fName = name ? name : gsDefName.Data();
|
|---|
| 78 | fTitle = title ? title : gsDefTitle.Data();
|
|---|
| 79 | }
|
|---|
| 80 | // -------------------------------------------------------------------------
|
|---|
| 81 | //
|
|---|
| 82 | // Call for MHillas::PreProcess and look for MHillas and look for the
|
|---|
| 83 | // needed containers
|
|---|
| 84 | //
|
|---|
| 85 | Int_t MHillasDisplay::PreProcess(MParList* pList)
|
|---|
| 86 | {
|
|---|
| 87 | if(!MDisplay::PreProcess(pList))
|
|---|
| 88 | return kFALSE;
|
|---|
| 89 |
|
|---|
| 90 | // Look for the MHillas container
|
|---|
| 91 | if(!fHillas)
|
|---|
| 92 | fHillas = (MHillas*)pList->FindObject(AddSerialNumber("MHillas"), "MHillas");
|
|---|
| 93 | if(!fHillas)
|
|---|
| 94 | *fLog << warn << "MHillasDisplay::PreProcess Warning: MHillas object not found" << endl;
|
|---|
| 95 | else
|
|---|
| 96 | {
|
|---|
| 97 | gPad->cd(1);
|
|---|
| 98 | Draw();
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | // Look for the MNewImagePar container
|
|---|
| 102 | if(!fNewImage)
|
|---|
| 103 | fNewImage = (MNewImagePar*)pList->FindObject(AddSerialNumber("MNewImagePar"), "MNewImagePar");
|
|---|
| 104 | if(!fNewImage)
|
|---|
| 105 | *fLog << warn << "MHillasDisplay::PreProcess Warning: MNewImagePar object not found" << endl;
|
|---|
| 106 |
|
|---|
| 107 | // Look for the MSrcPosCam container
|
|---|
| 108 | if(!fSrcPos)
|
|---|
| 109 | fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"), "MSrcPosCam");
|
|---|
| 110 | if(!fSrcPos)
|
|---|
| 111 | *fLog << warn << "MHillasDisplay::PreProcess Warning: MSrcPosCam object not found" << endl;
|
|---|
| 112 |
|
|---|
| 113 | // Look for the MIslands container
|
|---|
| 114 | if(!fIslands)
|
|---|
| 115 | fIslands = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"), "MIslands");
|
|---|
| 116 | if(!fIslands)
|
|---|
| 117 | *fLog << warn << "MHillasDisplay::PreProcess Warning: MIslands object not found" << endl;
|
|---|
| 118 |
|
|---|
| 119 | return kTRUE;
|
|---|
| 120 | }
|
|---|
| 121 | // -------------------------------------------------------------------------
|
|---|
| 122 | //
|
|---|
| 123 | // Display event AND hillas parameters
|
|---|
| 124 | //
|
|---|
| 125 | Int_t MHillasDisplay::Process()
|
|---|
| 126 | {
|
|---|
| 127 | // draw the hillas parameters
|
|---|
| 128 | if(GetPauseMode())
|
|---|
| 129 | {
|
|---|
| 130 | if(fHillas)
|
|---|
| 131 | fHillas->Print();
|
|---|
| 132 | if(fNewImage)
|
|---|
| 133 | fNewImage->Print();
|
|---|
| 134 | if(fIslands)
|
|---|
| 135 | fIslands->Print();
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | // draw the event
|
|---|
| 139 | if(!MDisplay::Process())
|
|---|
| 140 | return kFALSE;
|
|---|
| 141 | return kTRUE;
|
|---|
| 142 | }
|
|---|
| 143 | // -------------------------------------------------------------------------
|
|---|
| 144 | //
|
|---|
| 145 | // Stuff to be painted when canvas will be updated
|
|---|
| 146 | //
|
|---|
| 147 | void MHillasDisplay::Paint(Option_t* option)
|
|---|
| 148 | {
|
|---|
| 149 | const Float_t OffsetW=20.0;
|
|---|
| 150 | const Float_t OffsetL=300.0;
|
|---|
| 151 |
|
|---|
| 152 | Float_t meanX = fHillas->GetMeanX();
|
|---|
| 153 | Float_t meanY = fHillas->GetMeanY();
|
|---|
| 154 | Float_t length = fHillas->GetLength();
|
|---|
| 155 | Float_t width = fHillas->GetWidth();
|
|---|
| 156 | Float_t delta = fHillas->GetDelta();
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 | if (length<=0 || width<=0)
|
|---|
| 160 | return;
|
|---|
| 161 |
|
|---|
| 162 | // Length line
|
|---|
| 163 | TLine lineL(-(length+OffsetL)*cos(delta) + meanX,
|
|---|
| 164 | -(length+OffsetL)*sin(delta) + meanY,
|
|---|
| 165 | (length+OffsetL)*cos(delta) + meanX,
|
|---|
| 166 | (length+OffsetL)*sin(delta) + meanY);
|
|---|
| 167 |
|
|---|
| 168 | lineL.SetLineWidth(1);
|
|---|
| 169 | lineL.SetLineColor(2);
|
|---|
| 170 | lineL.Paint();
|
|---|
| 171 |
|
|---|
| 172 | // Width line
|
|---|
| 173 | TLine lineW((width+OffsetW)*sin(delta) + meanX,
|
|---|
| 174 | -(width+OffsetW)*cos(delta) + meanY,
|
|---|
| 175 | -(width+OffsetW)*sin(delta) + meanX,
|
|---|
| 176 | (width+OffsetW)*cos(delta) + meanY);
|
|---|
| 177 |
|
|---|
| 178 | lineW.SetLineWidth(1);
|
|---|
| 179 | lineW.SetLineColor(2);
|
|---|
| 180 | lineW.Paint();
|
|---|
| 181 |
|
|---|
| 182 | // Coordinate system
|
|---|
| 183 | Float_t xSrc = fSrcPos? fSrcPos->GetX() : 0.;
|
|---|
| 184 | Float_t ySrc = fSrcPos? fSrcPos->GetY() : 0.;
|
|---|
| 185 | Float_t radius = GetGeomCam()->GetMaxRadius();
|
|---|
| 186 | TLine lineX(-radius,ySrc,radius,ySrc);
|
|---|
| 187 | TLine lineY(xSrc,-radius,xSrc,radius);
|
|---|
| 188 | lineX.SetLineWidth(1);
|
|---|
| 189 | lineX.SetLineColor(108);
|
|---|
| 190 | lineY.SetLineWidth(1);
|
|---|
| 191 | lineY.SetLineColor(108);
|
|---|
| 192 | lineX.Paint();
|
|---|
| 193 | lineY.Paint();
|
|---|
| 194 |
|
|---|
| 195 | // COG line
|
|---|
| 196 | TLine lineMean(xSrc,ySrc,meanX,meanY);
|
|---|
| 197 | lineMean.SetLineWidth(1);
|
|---|
| 198 | lineMean.SetLineColor(2);
|
|---|
| 199 | lineMean.Paint();
|
|---|
| 200 |
|
|---|
| 201 | // Hillas ellipse
|
|---|
| 202 | TEllipse ellipse(meanX,meanY,length,width,0,360,delta*kRad2Deg+180);
|
|---|
| 203 | ellipse.SetLineWidth(2);
|
|---|
| 204 | ellipse.SetLineColor(2);
|
|---|
| 205 | ellipse.Paint();
|
|---|
| 206 | }
|
|---|