Changeset 1283 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 04/22/02 11:28:38 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/HistLinkDef.h
r1228 r1283 8 8 9 9 #pragma link C++ class MH+; 10 #pragma link C++ class MH3+; 10 11 #pragma link C++ class MHFadcCam+; 11 12 #pragma link C++ class MHFadcPix+; 12 13 #pragma link C++ class MHHillas+; 13 14 #pragma link C++ class MHHillasSrc+; 15 #pragma link C++ class MHHillasExt+; 14 16 #pragma link C++ class MHStarMap+; 15 17 #pragma link C++ class MHEnergyTime+; -
trunk/MagicSoft/Mars/mhist/MFillH.cc
r1211 r1283 238 238 const TString name = ExtractName(fHName); 239 239 240 TObject *obj = pList->FindCreateObj(cls, name); 240 TObject *obj=NULL; 241 if (cls==name) 242 obj = pList->FindObject(fHName); 243 244 if (!obj) 245 obj = pList->FindCreateObj(cls, name); 246 241 247 if (!obj) 242 248 return kFALSE; … … 277 283 // list. If it could not be found we cannot proceed. 278 284 // 285 if (fParContainerName.IsNull()) 286 { 287 fParContainer = pList; 288 return kTRUE; 289 } 290 279 291 fParContainer = (MParContainer*)pList->FindObject(fParContainerName); 280 292 if (fParContainer) 281 293 return kTRUE; 282 294 283 *fLog << err << dbginf << fParContainerName << "[MParContainer] not found... aborting." << endl;295 *fLog << err << dbginf << "'" << fParContainerName << "' [MParContainer] not found... aborting." << endl; 284 296 return kFALSE; 285 297 } -
trunk/MagicSoft/Mars/mhist/MH.cc
r1276 r1283 66 66 // set the name and title of this object 67 67 // 68 fName = name ? name : "MH" 69 fTitle = title ? title : "Base class for Mars histograms" 68 fName = name ? name : "MH"; 69 fTitle = title ? title : "Base class for Mars histograms"; 70 70 } 71 71 … … 83 83 // number of all existing canvases plus one) 84 84 // 85 TCanvas *MH::MakeDefCanvas( const char *name, const char *title,85 TCanvas *MH::MakeDefCanvas(TString name, const char *title, 86 86 const UInt_t w, const UInt_t h) 87 87 { 88 88 const TList *list = (TList*)gROOT->GetListOfCanvases(); 89 89 90 const char *def = name ? name : gROOT->GetDefCanvasName(); 91 92 TCanvas *c; 93 if (list->FindObject(def)) 94 { 95 const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1)); 96 c = new TCanvas(n, title, w, h); 97 delete [] n; 98 } 99 else 100 c = new TCanvas(def, title, w, h); 101 102 return c; 90 if (name.IsNull()) 91 name = gROOT->GetDefCanvasName(); 92 93 if (list->FindObject(name)) 94 name += Form(" <%d>", list->GetSize()+1); 95 96 return new TCanvas(name, title, w, h); 103 97 } 104 98 -
trunk/MagicSoft/Mars/mhist/MH.h
r1207 r1283 22 22 virtual Bool_t Fill(const MParContainer *par) = 0; 23 23 24 static TCanvas *MakeDefCanvas( const char *name=NULL, const char *title="",24 static TCanvas *MakeDefCanvas(TString name="", const char *title="", 25 25 const UInt_t w=700, const UInt_t h=500); 26 26 static TCanvas *MakeDefCanvas(const TObject *obj, -
trunk/MagicSoft/Mars/mhist/MHHillas.cc
r1277 r1283 53 53 // 54 54 MHHillas::MHHillas(const char *name, const char *title) 55 : fMm2Deg(-1), fUseMmScale(k FALSE)55 : fMm2Deg(-1), fUseMmScale(kTRUE) 56 56 { 57 57 // … … 72 72 fWidth->SetDirectory(NULL); 73 73 74 fLength-> GetXaxis()->SetTitle("Length [mm]");75 fWidth-> GetXaxis()->SetTitle("Width [mm]");76 77 fLength-> GetYaxis()->SetTitle("Counts");78 fWidth-> GetYaxis()->SetTitle("Counts");74 fLength->SetXTitle("Length [mm]"); 75 fWidth->SetXTitle("Width [mm]"); 76 77 fLength->SetYTitle("Counts"); 78 fWidth->SetYTitle("Counts"); 79 79 } 80 80 … … 119 119 } 120 120 121 fLength->GetXaxis()->SetTitle("Length [\\circ]"); 122 fWidth->GetXaxis()->SetTitle("Width [\\circ]"); 123 124 fMm2Deg = geom->GetConvMm2Deg(); 121 fLength->SetXTitle("Length [\\circ]"); 122 fWidth->SetXTitle("Width [\\circ]"); 123 124 fMm2Deg = geom->GetConvMm2Deg(); 125 fUseMmScale = kFALSE; 125 126 126 127 return kTRUE; … … 189 190 if (fUseMmScale) 190 191 { 191 fLength-> GetXaxis()->SetTitle("Length [mm]");192 fWidth-> GetXaxis()->SetTitle("Width [mm]");192 fLength->SetXTitle("Length [mm]"); 193 fWidth->SetXTitle("Width [mm]"); 193 194 194 195 fLength->Scale(1./fMm2Deg); … … 197 198 else 198 199 { 199 fLength-> GetXaxis()->SetTitle("Length [\\circ]");200 fWidth-> GetXaxis()->SetTitle("Width [\\circ]");200 fLength->SetXTitle("Length [\\circ]"); 201 fWidth->SetXTitle("Width [\\circ]"); 201 202 202 203 fLength->Scale(fMm2Deg); -
trunk/MagicSoft/Mars/mhist/MHHillas.h
r1263 r1283 7 7 8 8 class TH1F; 9 class MHillas;10 9 11 10 class MHHillas : public MH … … 15 14 TH1F *fLength; 16 15 16 protected: 17 17 Float_t fMm2Deg; 18 18 … … 24 24 25 25 void SetMmScale(Bool_t mmscale=kTRUE); 26 v oid SetMm2Deg(Float_t mmdeg);26 virtual void SetMm2Deg(Float_t mmdeg); 27 27 28 28 Bool_t SetupFill(const MParList *pList); -
trunk/MagicSoft/Mars/mhist/MHStarMap.cc
r1263 r1283 39 39 #include <TCanvas.h> // TCanvas 40 40 41 #include "MLog.h" 42 #include "MLogManip.h" 43 44 #include "MParList.h" 45 46 #include "MGeomCam.h" 41 47 #include "MHillas.h" 48 #include "MBinning.h" 42 49 43 50 ClassImp(MHStarMap); … … 48 55 // 49 56 MHStarMap::MHStarMap(const char *name, const char *title) 57 : fMm2Deg(-1), fUseMmScale(kTRUE) 50 58 { 51 59 // … … 57 65 // set the name and title of this object 58 66 // 59 60 67 fName = name ? name : "MHStarMap" ; 61 68 fTitle = title ? title : "Container for a Star Map" ; … … 88 95 // -------------------------------------------------------------------------- 89 96 // 97 // Setup the Binning for the histograms automatically if the correct 98 // instances of MBinning (with the names 'BinningWidth' and 'BinningLength') 99 // are found in the parameter list 100 // Use this function if you want to set the conversion factor which 101 // is used to convert the mm-scale in the camera plain into the deg-scale 102 // used for histogram presentations. The conversion factor is part of 103 // the camera geometry. Please create a corresponding MGeomCam container. 104 // 105 Bool_t MHStarMap::SetupFill(const MParList *plist) 106 { 107 const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam"); 108 if (geom) 109 { 110 fMm2Deg = geom->GetConvMm2Deg(); 111 fUseMmScale = kFALSE; 112 113 fStarMap->SetXTitle("x [\\circ]"); 114 fStarMap->SetYTitle("y [\\circ]"); 115 } 116 117 const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap"); 118 if (!bins) 119 { 120 float r = geom ? geom->GetMaxRadius() : 600; 121 r *= 2./3; 122 if (!fUseMmScale) 123 r *= fMm2Deg; 124 125 MBinning b; 126 b.SetEdges(100, -r, r); 127 SetBinning(fStarMap, &b, &b); 128 } 129 else 130 SetBinning(fStarMap, bins, bins); 131 132 if (!geom) 133 { 134 *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl; 135 return kTRUE; 136 } 137 138 return kTRUE; 139 } 140 141 // -------------------------------------------------------------------------- 142 // 90 143 // Fill the four histograms with data from a MHillas-Container. 91 144 // Be careful: Only call this with an object of type MHillas … … 98 151 99 152 const float m = tan(delta); 100 const float t = h.GetMeanY() - m*h.GetMeanX(); 153 154 float t = h.GetMeanY() - m*h.GetMeanX(); 155 156 if (!fUseMmScale) 157 t *= fMm2Deg; 101 158 102 159 if (m>-1 && m<1) 103 for (int x=-298; x<298; x+=4) 160 { 161 TAxis &axe = *fStarMap->GetXaxis(); 162 163 const int N = axe.GetXbins()->GetSize(); 164 for (int i=0; i<N; i++) 104 165 { 166 const float x = axe.GetBinCenter(i); 105 167 const float y = m*x+t; 106 168 107 169 fStarMap->Fill(x, y); 108 170 } 171 } 109 172 else 110 for (int y=-298; y<298; y+=4) 173 { 174 TAxis &axe = *fStarMap->GetYaxis(); 175 176 const int N = axe.GetXbins()->GetSize(); 177 for (int i=0; i<N; i++) 111 178 { 179 const float y = axe.GetBinCenter(i); 112 180 const float x = (y-t)/m; 113 181 114 182 fStarMap->Fill(x, y); 115 183 } 184 } 116 185 117 186 return kTRUE; 187 } 188 189 // -------------------------------------------------------------------------- 190 // 191 // Use this function to setup your own conversion factor between degrees 192 // and millimeters. The conversion factor should be the one calculated in 193 // MGeomCam. Use this function with Caution: You could create wrong values 194 // by setting up your own scale factor. 195 // 196 void MHStarMap::SetMm2Deg(Float_t mmdeg) 197 { 198 if (mmdeg<0) 199 { 200 *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl; 201 return; 202 } 203 204 if (fMm2Deg>=0) 205 *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl; 206 207 fMm2Deg = mmdeg; 208 } 209 210 // -------------------------------------------------------------------------- 211 // 212 // With this function you can convert the histogram ('on the fly') between 213 // degrees and millimeters. 214 // 215 void MHStarMap::SetMmScale(Bool_t mmscale) 216 { 217 if (fUseMmScale == mmscale) 218 return; 219 220 if (fMm2Deg<0) 221 { 222 *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl; 223 return; 224 } 225 226 if (fUseMmScale) 227 { 228 fStarMap->SetXTitle("x [mm]"); 229 fStarMap->SetYTitle("y [mm]"); 230 231 fStarMap->Scale(1./fMm2Deg); 232 } 233 else 234 { 235 fStarMap->SetXTitle("x [\\circ]"); 236 fStarMap->SetYTitle("y [\\circ]"); 237 238 fStarMap->Scale(1./fMm2Deg); 239 } 240 241 fUseMmScale = mmscale; 118 242 } 119 243 -
trunk/MagicSoft/Mars/mhist/MHStarMap.h
r1207 r1283 17 17 TH2F *fStarMap; 18 18 19 Float_t fMm2Deg; 20 21 Bool_t fUseMmScale; 22 19 23 void PrepareDrawing() const; 20 24 … … 23 27 ~MHStarMap(); 24 28 29 void SetMmScale(Bool_t mmscale=kTRUE); 30 void SetMm2Deg(Float_t mmdeg); 31 32 Bool_t SetupFill(const MParList *pList); 25 33 Bool_t Fill(const MParContainer *par); 26 34 -
trunk/MagicSoft/Mars/mhist/Makefile
r1228 r1283 31 31 MBinning.cc \ 32 32 MH.cc \ 33 MH3.cc \ 33 34 MHFadcPix.cc \ 34 35 MHFadcCam.cc \ 35 36 MHHillas.cc \ 36 37 MHHillasSrc.cc \ 38 MHHillasExt.cc \ 37 39 MHStarMap.cc \ 38 40 MHEnergyTime.cc \
Note:
See TracChangeset
for help on using the changeset viewer.