Changeset 1463 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 07/31/02 18:03:51 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MH.cc
r1449 r1463 56 56 57 57 #include "MLog.h" 58 #include "MLogManip.h" 59 60 #include "MParList.h" 61 #include "MParContainer.h" 58 62 59 63 #include "MBinning.h" … … 228 232 } 229 233 230 void MH::SetBinning(TH1 *h, const TArrayD *binsx)234 void MH::SetBinning(TH1 *h, const TArrayD &binsx) 231 235 { 232 236 MBinning bx; 233 bx.SetEdges( *binsx);237 bx.SetEdges(binsx); 234 238 SetBinning(h, &bx); 235 239 } 236 240 237 void MH::SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy)241 void MH::SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy) 238 242 { 239 243 MBinning bx; 240 244 MBinning by; 241 bx.SetEdges( *binsx);242 by.SetEdges( *binsy);245 bx.SetEdges(binsx); 246 by.SetEdges(binsy); 243 247 SetBinning(h, &bx, &by); 244 248 } 245 249 246 void MH::SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)250 void MH::SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz) 247 251 { 248 252 MBinning bx; 249 253 MBinning by; 250 254 MBinning bz; 251 bx.SetEdges( *binsx);252 by.SetEdges( *binsy);253 bz.SetEdges( *binsz);255 bx.SetEdges(binsx); 256 by.SetEdges(binsy); 257 bz.SetEdges(binsz); 254 258 SetBinning(h, &bx, &by, &bz); 255 259 } … … 263 267 bx[nx] = binsx->GetXmax(); 264 268 265 SetBinning(h, &bx);269 SetBinning(h, bx); 266 270 } 267 271 … … 278 282 by[ny] = binsy->GetXmax(); 279 283 280 SetBinning(h, &bx, &by);284 SetBinning(h, bx, by); 281 285 } 282 286 … … 297 301 bz[nz] = binsz->GetXmax(); 298 302 299 SetBinning(h, &bx, &by, &bz);303 SetBinning(h, bx, by, bz); 300 304 } 301 305 … … 319 323 } 320 324 321 void MH::ScaleA xis(TArrayD &bins, Double_t f)325 void MH::ScaleArray(TArrayD &bins, Double_t f) 322 326 { 323 327 for (int i=0; i<bins.GetSize(); i++) … … 325 329 } 326 330 331 TArrayD MH::ScaleAxis(TAxis &axe, Double_t f) 332 { 333 TArrayD arr(axe.GetNbins()+1); 334 335 for (int i=1; i<=axe.GetNbins()+1; i++) 336 arr[i-1] = axe.GetBinLowEdge(i); 337 338 ScaleArray(arr, f); 339 340 return arr; 341 } 342 327 343 void MH::ScaleAxis(TH1 *h, Double_t fx, Double_t fy, Double_t fz) 328 344 { 329 345 if (h->InheritsFrom(TH3::Class())) 330 ScaleAxis(*((TH3*)h)->GetZaxis()->GetXbins(), fz); 346 { 347 SetBinning((TH3*)h, 348 ScaleAxis(*h->GetXaxis(), fx), 349 ScaleAxis(*h->GetYaxis(), fy), 350 ScaleAxis(*h->GetZaxis(), fz)); 351 return; 352 } 331 353 332 354 if (h->InheritsFrom(TH2::Class())) 333 ScaleAxis(*((TH2*)h)->GetYaxis()->GetXbins(), fy); 355 { 356 SetBinning((TH2*)h, 357 ScaleAxis(*h->GetXaxis(), fx), 358 ScaleAxis(*h->GetYaxis(), fy)); 359 return; 360 } 334 361 335 362 if (h->InheritsFrom(TH1::Class())) 336 ScaleAxis(*h->GetXaxis()->GetXbins(), fx); 363 SetBinning(h, ScaleAxis(*h->GetXaxis(), fx)); 364 } 365 366 Bool_t MH::ApplyBinning(const MParList &plist, TString name, TH1 *h) 367 { 368 const MBinning *bins = (MBinning*)plist.FindObject("Binning"+name); 369 if (!bins) 370 { 371 gLog << warn << "Object 'Binning" << name << "' [MBinning] not found... no binning applied." << endl; 372 return kFALSE; 373 } 374 375 SetBinning(h, bins); 376 return kTRUE; 337 377 } 338 378 -
trunk/MagicSoft/Mars/mhist/MH.h
r1449 r1463 34 34 static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz); 35 35 36 static void SetBinning(TH1 *h, const TArrayD *binsx);37 static void SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy);38 static void SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);36 static void SetBinning(TH1 *h, const TArrayD &binsx); 37 static void SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy); 38 static void SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz); 39 39 40 40 static void SetBinning(TH1 *h, const TAxis *binsx); … … 44 44 static void SetBinning(TH1 *h, TH1 *x); 45 45 46 static void ScaleAxis(TArrayD &bins, Double_t f); 47 static void ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1); 46 static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h); 47 48 static void ScaleArray(TArrayD &bins, Double_t f); 49 static TArrayD ScaleAxis(TAxis &axe, Double_t f); 50 static void ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1); 48 51 49 52 static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger); -
trunk/MagicSoft/Mars/mhist/MHHillas.cc
r1441 r1463 59 59 // 60 60 MHHillas::MHHillas(const char *name, const char *title) 61 : fMm2Deg(1), fUseMmScale(k FALSE)61 : fMm2Deg(1), fUseMmScale(kTRUE) 62 62 { 63 63 // … … 67 67 fTitle = title ? title : "Source independent image parameters"; 68 68 69 fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300); 69 fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 296.7); 70 fWidth = new TH1F("Width", "Width of Ellipse", 100, 0, 296.7); 71 fDistC = new TH1F("DistC", "Distance from center of camera", 100, 0, 445); 72 fDelta = new TH1F("Delta", "Angle (Main axis - x-axis)", 101, -90, 90); 73 70 74 fLength->SetDirectory(NULL); 75 fWidth->SetDirectory(NULL); 76 fDistC->SetDirectory(NULL); 77 fDelta->SetDirectory(NULL); 78 71 79 fLength->SetXTitle("Length [mm]"); 80 fWidth->SetXTitle("Width [mm]"); 81 fDistC->SetXTitle("Distance [mm]"); 82 fDelta->SetXTitle("Delta [\\circ]"); 83 72 84 fLength->SetYTitle("Counts"); 73 74 fWidth = new TH1F("Width", "Width of Ellipse", 100, 0, 300);75 fWidth->SetDirectory(NULL);76 fWidth->SetXTitle("Width [mm]");77 85 fWidth->SetYTitle("Counts"); 78 79 fDistC = new TH1F("DistC", "Distance from center of camera", 100, 0, 600);80 fDistC->SetDirectory(NULL);81 fDistC->SetXTitle("Distance [mm]");82 86 fDistC->SetYTitle("Counts"); 83 84 fDelta = new TH1F("Delta", "Angle (Main axis - x-axis)", 100, -90, 90);85 fDelta->SetDirectory(NULL);86 fDelta->SetXTitle("Delta [\\circ]");87 87 fDelta->SetYTitle("Counts"); 88 88 … … 101 101 MH::SetBinning(fSize, &bins); 102 102 103 fCenter = new TH2F("Center", "Center of Ellipse", 60, -600, 600, 60, -600, 600);103 fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445); 104 104 fCenter->SetDirectory(NULL); 105 105 fCenter->SetXTitle("x [mm]"); … … 136 136 Bool_t MHHillas::SetupFill(const MParList *plist) 137 137 { 138 const MBinning *binsw = (MBinning*)plist->FindObject("BinningWidth");139 const MBinning *binsl = (MBinning*)plist->FindObject("BinningLength");140 const MBinning *binsd = (MBinning*)plist->FindObject("BinningDist");141 const MBinning *binsc = (MBinning*)plist->FindObject("BinningCamera");142 143 if (!binsw || !binsl || !binsd || !binsc)144 {145 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;146 return kFALSE;147 }148 149 SetBinning(fWidth, binsw);150 SetBinning(fLength, binsl);151 SetBinning(fDistC, binsd);152 SetBinning(fCenter, binsc, binsc);153 154 138 const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam"); 155 139 if (!geom) 156 {157 140 *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl; 158 return kTRUE; 159 } 160 161 fMm2Deg = geom->GetConvMm2Deg(); 162 fUseMmScale = kFALSE; 163 164 fLength->SetXTitle("Length [\\circ]"); 165 fWidth->SetXTitle("Width [\\circ]"); 166 fDistC->SetXTitle("Distance [\\circ]"); 167 fCenter->SetXTitle("x [\\circ]"); 168 fCenter->SetYTitle("y [\\circ]"); 141 else 142 { 143 fMm2Deg = geom->GetConvMm2Deg(); 144 SetMmScale(kFALSE); 145 } 146 147 ApplyBinning(*plist, "Width", fWidth); 148 ApplyBinning(*plist, "Length", fLength); 149 ApplyBinning(*plist, "Dist", fDistC); 150 ApplyBinning(*plist, "Camera", fCenter); 151 ApplyBinning(*plist, "Delta", fDelta); 152 ApplyBinning(*plist, "Size", fSize); 169 153 170 154 return kTRUE; … … 208 192 } 209 193 210 if (fUseMmScale) 211 { 212 MH::ScaleAxis(fLength, 1./fMm2Deg); 213 MH::ScaleAxis(fWidth, 1./fMm2Deg); 214 MH::ScaleAxis(fDistC, 1./fMm2Deg); 215 MH::ScaleAxis(fCenter, 1./fMm2Deg, 1./fMm2Deg); 216 194 const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg; 195 MH::ScaleAxis(fLength, scale); 196 MH::ScaleAxis(fWidth, scale); 197 MH::ScaleAxis(fDistC, scale); 198 MH::ScaleAxis(fCenter, scale, scale); 199 200 if (mmscale) 201 { 217 202 fLength->SetXTitle("Length [mm]"); 218 203 fWidth->SetXTitle("Width [mm]"); 204 fDistC->SetXTitle("Distance [mm]"); 219 205 fCenter->SetXTitle("x [mm]"); 220 206 fCenter->SetYTitle("y [mm]"); … … 222 208 else 223 209 { 224 MH::ScaleAxis(fLength, fMm2Deg);225 MH::ScaleAxis(fWidth, fMm2Deg);226 MH::ScaleAxis(fDistC, fMm2Deg);227 MH::ScaleAxis(fCenter, fMm2Deg, fMm2Deg);228 229 210 fLength->SetXTitle("Length [\\circ]"); 230 211 fWidth->SetXTitle("Width [\\circ]"); … … 247 228 248 229 const Double_t d = sqrt(h.GetMeanX()*h.GetMeanX() + h.GetMeanY()*h.GetMeanY()); 249 250 if (fUseMmScale) 251 { 252 fLength->Fill(h.GetLength()); 253 fWidth ->Fill(h.GetWidth()); 254 fDistC ->Fill(d); 255 fCenter->Fill(h.GetMeanX(), h.GetMeanY()); 256 } 257 else 258 { 259 fLength->Fill(fMm2Deg*h.GetLength()); 260 fWidth ->Fill(fMm2Deg*h.GetWidth()); 261 fDistC ->Fill(fMm2Deg*d); 262 fCenter->Fill(fMm2Deg*h.GetMeanX(), fMm2Deg*h.GetMeanY()); 263 } 264 265 fDelta->Fill(kRad2Deg*h.GetDelta()); 266 fSize->Fill(h.GetSize()); 230 const Double_t scale = fUseMmScale ? 1 : fMm2Deg; 231 232 fLength->Fill(scale*h.GetLength()); 233 fWidth ->Fill(scale*h.GetWidth()); 234 fDistC ->Fill(scale*d); 235 fCenter->Fill(scale*h.GetMeanX(), scale*h.GetMeanY()); 236 fDelta ->Fill(kRad2Deg*h.GetDelta()); 237 fSize ->Fill(h.GetSize()); 267 238 268 239 return kTRUE; … … 275 246 void MHHillas::SetColors() const 276 247 { 248 // FIXME: This must be redone each time the canvas is repainted.... 277 249 gStyle->SetPalette(51, NULL); 278 250 Int_t c[50]; … … 292 264 TObject *MHHillas::DrawClone(Option_t *opt) const 293 265 { 294 TCanvas *c = MakeDefCanvas("Hillas", fTitle, 7 00, 750);266 TCanvas *c = MakeDefCanvas("Hillas", fTitle, 720, 810); 295 267 c->Divide(2,3); 296 268 … … 332 304 { 333 305 if (!gPad) 334 MakeDefCanvas("Hillas", fTitle, 7 00, 750);306 MakeDefCanvas("Hillas", fTitle, 720, 810); 335 307 336 308 gPad->Divide(2,3); -
trunk/MagicSoft/Mars/mhist/MHHillas.h
r1441 r1463 14 14 private: 15 15 16 TH1F *fLength; 17 TH1F *fWidth; 16 TH1F *fLength; //-> 17 TH1F *fWidth; //-> 18 18 19 TH1F *fDistC; 20 TH1F *fDelta; 19 TH1F *fDistC; //-> 20 TH1F *fDelta; //-> 21 21 22 TH1F *fSize; 23 TH2F *fCenter; 22 TH1F *fSize; //-> 23 TH2F *fCenter; //-> 24 24 25 25 void SetColors() const; -
trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
r1442 r1463 68 68 // connect all the histogram with the container fHist 69 69 // 70 fAlpha = new TH1F("Alpha", "Alpha of Ellipse", 90, 0, 90);71 fDist = new TH1F("Dist", "Dist of Ellipse", 100, 0, 600);72 fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse", 45, 0, 90);73 fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse", 10 0,-1, 1);70 fAlpha = new TH1F("Alpha", "Alpha of Ellipse", 90, 0, 90); 71 fDist = new TH1F("Dist", "Dist of Ellipse", 100, 0, 445); 72 fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse", 101, -445, 445); 73 fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse", 101, -1, 1); 74 74 75 75 fAlpha->SetDirectory(NULL); … … 80 80 fAlpha->SetXTitle("\\alpha [\\circ]"); 81 81 fDist->SetXTitle("Dist [mm]"); 82 fHeadTail->SetXTitle("Head-Tail [ \\circ]");82 fHeadTail->SetXTitle("Head-Tail [mm]"); 83 83 fCosDA->SetXTitle("cos(\\delta,\\alpha) [mm]"); 84 84 … … 113 113 Bool_t MHHillasSrc::SetupFill(const MParList *plist) 114 114 { 115 const MBinning* binsa = (MBinning*)plist->FindObject("BinningAlpha");116 const MBinning* binsd = (MBinning*)plist->FindObject("BinningDist");117 if (!binsa || !binsd)118 {119 *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;120 return kFALSE;121 }122 123 SetBinning(fAlpha, binsa);124 SetBinning(fDist, binsd);125 126 115 const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam"); 127 116 if (!geom) 128 {129 117 *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl; 130 return kTRUE; 131 } 132 133 fDist->SetXTitle("Dist [\\circ]"); 134 135 fMm2Deg = geom->GetConvMm2Deg(); 136 fUseMmScale = kFALSE; 118 else 119 { 120 fMm2Deg = geom->GetConvMm2Deg(); 121 SetMmScale(kFALSE); 122 } 123 124 ApplyBinning(*plist, "Alpha", fAlpha); 125 ApplyBinning(*plist, "Dist", fDist); 126 ApplyBinning(*plist, "HeadTail", fHeadTail); 137 127 138 128 return kTRUE; … … 150 140 fAlpha ->Fill(fabs(h.GetAlpha())); 151 141 fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist()); 152 fHeadTail->Fill( h.GetHeadTail());142 fHeadTail->Fill(fUseMmScale ? h.GetHeadTail() : fMm2Deg*h.GetHeadTail()); 153 143 fCosDA ->Fill(h.GetCosDeltaAlpha()); 154 144 155 145 return kTRUE; 146 } 147 148 // -------------------------------------------------------------------------- 149 // 150 // Use this function to setup your own conversion factor between degrees 151 // and millimeters. The conversion factor should be the one calculated in 152 // MGeomCam. Use this function with Caution: You could create wrong values 153 // by setting up your own scale factor. 154 // 155 void MHHillasSrc::SetMm2Deg(Float_t mmdeg) 156 { 157 if (mmdeg<0) 158 { 159 *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl; 160 return; 161 } 162 163 if (fMm2Deg>=0) 164 *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl; 165 166 fMm2Deg = mmdeg; 167 } 168 169 // -------------------------------------------------------------------------- 170 // 171 // With this function you can convert the histogram ('on the fly') between 172 // degrees and millimeters. 173 // 174 void MHHillasSrc::SetMmScale(Bool_t mmscale) 175 { 176 if (fUseMmScale == mmscale) 177 return; 178 179 if (fMm2Deg<0) 180 { 181 *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl; 182 return; 183 } 184 185 const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg; 186 MH::ScaleAxis(fDist, scale); 187 MH::ScaleAxis(fHeadTail, scale); 188 189 if (mmscale) 190 { 191 fDist->SetXTitle("Dist [mm]"); 192 fHeadTail->SetXTitle("Head-Tail [mm]"); 193 } 194 else 195 { 196 fDist->SetXTitle("Dist [\\circ]"); 197 fHeadTail->SetXTitle("Head-Tail [\\circ]"); 198 } 199 200 fUseMmScale = mmscale; 156 201 } 157 202 … … 187 232 188 233 c->cd(4); 234 gPad->SetLogy(); 189 235 fCosDA->DrawCopy(); 190 236 … … 221 267 222 268 gPad->cd(2); 269 gPad->SetLogy(); 223 270 fCosDA->Draw(); 224 271 -
trunk/MagicSoft/Mars/mhist/MHHillasSrc.h
r1442 r1463 12 12 { 13 13 private: 14 TH1F *fAlpha; 15 TH1F *fDist; 16 TH1F *fHeadTail; 17 TH1F *fCosDA; 14 TH1F *fAlpha; //-> 15 TH1F *fDist; //-> 16 TH1F *fHeadTail; //-> 17 TH1F *fCosDA; //-> 18 18 19 19 Float_t fMm2Deg; … … 24 24 ~MHHillasSrc(); 25 25 26 void SetUseMmScale(Bool_t mmscale=kTRUE) { fUseMmScale = mmscale; } 26 void SetMmScale(Bool_t mmscale=kTRUE); 27 void SetMm2Deg(Float_t mmdeg); 27 28 28 29 Bool_t SetupFill(const MParList *pList);
Note:
See TracChangeset
for help on using the changeset viewer.