Changeset 1489
- Timestamp:
- 08/08/02 11:58:59 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1487 r1489 1 1 -*-*- END -*-*- 2 3 2002/08/08: Thomas Bretz 4 5 * manalysis/MHillasSrc.cc: 6 - use double dist instead of single fDist for calculation 7 8 * manalysis/MMultiDimDistCalc.[h,cc]: 9 - added support for the kernel method 10 - added stream primitive 11 - changed version number to 1 12 - adapted to new MHMatrix (using MDataArray) 13 14 * mdata/MDataArray.[h,cc]: 15 - added 16 17 * mdata/DataLinkDef.h, madata/Makefile: 18 - added MDataArray 19 20 * mfileio/MWriteRootFile.cc: 21 - fixed some bugs in StreamPrimitive 22 - StreamPrimtive doesn't write the default name/title anymore 23 24 * mhist/MHMatrix.[h,cc]: 25 - replaced the Arrays for the rules by a MDataArray 26 - implemented StreamPrimitive 27 - implement the use of the kernel function for num<0 28 - multiply fM2 by nevts-1 29 - added sanity check in case of dists[i]<0 30 31 * mhist/MHHillas.[h,cc]: 32 - added fUsedPix, fCorePix 33 - added fUsedPix, fCorePix to plots 34 - changed layout of plots 35 - changed name and title of MakeDefCanvas 36 37 * mhist/MHHillasSrc.[h,cc]: 38 - changed plot of Alpha from fabs(fAlpha) to fAlpha 39 - changed name and title of MakeDefCanvas 40 41 * mhist/MHillasExt.[h,cc]: 42 - changed layout of plots 43 - changed name and title of MakeDefCanvas 44 45 * mbase/MTask.cc: 46 - fixed wrong streaming of filter name 47 48 * macros/starplot.C: 49 - added 50 51 * macros/dohtml.C: 52 - added starplot.C 53 54 2 55 3 56 2002/08/07: Thomas Bretz -
trunk/MagicSoft/Mars/macros/dohtml.C
r1487 r1489 52 52 html.Convert("trigrate.C", "MARS - Calculate Trigger Rate from a MC root file"); 53 53 html.Convert("star.C", "MARS - (St)andard (A)nalysis and (R)econstruction"); 54 html.Convert("starplot.C", "MARS - Plot parameters from file created with star.C"); 54 55 html.Convert("comprob.C", "MARS - Calculation of composite probabilities for G/H-Seperation"); 55 56 html.Convert("multidimdist.C", "MARS - Calculation of multidimensional distances for G/H-Seperation"); -
trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc
r1488 r1489 69 69 { 70 70 fName = name ? name : "MHillasSrc"; 71 fTitle = title ? title : " parameters depending in source position";71 fTitle = title ? title : "Parameters depending in source position"; 72 72 } 73 73 -
trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc
r1488 r1489 52 52 #include "MParList.h" 53 53 #include "MDataChain.h" 54 #include "MDataArray.h" 54 55 55 56 #include "MHadroness.h" … … 65 66 // 66 67 MMultiDimDistCalc::MMultiDimDistCalc(const char *name, const char *title) 67 : fNum(0), fUseKernel(kFALSE) 68 : fNum(0), fUseKernel(kFALSE), fData(NULL) 68 69 { 69 70 // … … 73 74 fTitle = title ? title : gsDefTitle.Data(); 74 75 75 fData = new TList; 76 fData->SetOwner(); 76 /* 77 fData = new TList; 78 fData->SetOwner(); 79 */ 77 80 } 78 81 … … 83 86 MMultiDimDistCalc::~MMultiDimDistCalc() 84 87 { 85 delete fData;88 // delete fData; 86 89 } 87 90 … … 119 122 } 120 123 124 /* 121 125 TIter Next(fMGammas->GetRules()); 122 126 TObject *data=NULL; … … 130 134 } 131 135 fData->Add(chain); 136 } 137 */ 138 fData = fMGammas->GetColumns(); 139 if (!fData) 140 { 141 *fLog << err << dbginf << "Error matrix doesn't contain columns... aborting." << endl; 142 return kFALSE; 143 } 144 145 if (!fData->PreProcess(plist)) 146 { 147 *fLog << err << dbginf << "PreProcessing of the MDataArray failed for the columns failed... aborting." << endl; 148 return kFALSE; 132 149 } 133 150 … … 156 173 TVector event(ncols); 157 174 175 for (int i=0; i<fData->GetNumEntries(); i++) 176 event(i) = (*fData)(i); 177 178 /* 158 179 Int_t n=0; 159 180 TIter Next(fData); … … 161 182 while ((data=(MData*)Next())) 162 183 event(n++) = data->GetValue(); 184 */ 163 185 164 186 Double_t numg = fNum; -
trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h
r1488 r1489 9 9 class MParList; 10 10 class MHadroness; 11 class MDataArray; 11 12 12 13 class MMultiDimDistCalc : public MTask … … 21 22 MHadroness *fHadroness; //! Output container for calculated hadroness 22 23 23 TList *fData;//! Used to store the MDataChains to get the event values24 MDataArray *fData; //! Used to store the MDataChains to get the event values 24 25 25 26 void StreamPrimitive(ofstream &out) const; -
trunk/MagicSoft/Mars/mbase/MTask.cc
r1479 r1489 281 281 282 282 fFilter->SavePrimitive(out); 283 out << " " << ToLower(fName) << ".SetFilter(&" << ToLower(fFilter->GetName()) <<");" << endl;284 283 */ 285 } 284 out << " " << GetUniqueName() << ".SetFilter(&" << fFilter->GetUniqueName() <<");" << endl; 285 } -
trunk/MagicSoft/Mars/mhist/MHHillas.cc
r1487 r1489 67 67 fTitle = title ? title : "Source independent image parameters"; 68 68 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); 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 fUsedPix = new TH1F("UsedPix", "Number of used pixels", 150, 0, 150); 74 fCorePix = new TH1F("CorePix", "Number of core pixels", 150, 0, 150); 73 75 74 76 fLength->SetDirectory(NULL); … … 76 78 fDistC->SetDirectory(NULL); 77 79 fDelta->SetDirectory(NULL); 80 fUsedPix->SetDirectory(NULL); 81 fCorePix->SetDirectory(NULL); 78 82 79 83 fLength->SetXTitle("Length [mm]"); … … 81 85 fDistC->SetXTitle("Distance [mm]"); 82 86 fDelta->SetXTitle("Delta [\\circ]"); 87 fUsedPix->SetXTitle("Number of Pixels"); 88 fCorePix->SetXTitle("Number of Pixels"); 83 89 84 90 fLength->SetYTitle("Counts"); … … 86 92 fDistC->SetYTitle("Counts"); 87 93 fDelta->SetYTitle("Counts"); 94 fUsedPix->SetYTitle("Counts"); 95 fCorePix->SetYTitle("Counts"); 88 96 89 97 MBinning bins; … … 122 130 delete fSize; 123 131 delete fCenter; 132 133 delete fUsedPix; 134 delete fCorePix; 124 135 } 125 136 … … 150 161 ApplyBinning(*plist, "Delta", fDelta); 151 162 ApplyBinning(*plist, "Size", fSize); 163 ApplyBinning(*plist, "Pixels", fUsedPix); 164 ApplyBinning(*plist, "Pixels", fCorePix); 152 165 153 166 const MBinning *bins = (MBinning*)plist->FindObject("BinningCamera"); … … 235 248 const Double_t scale = fUseMmScale ? 1 : fMm2Deg; 236 249 237 fLength->Fill(scale*h.GetLength()); 238 fWidth ->Fill(scale*h.GetWidth()); 239 fDistC ->Fill(scale*d); 240 fCenter->Fill(scale*h.GetMeanX(), scale*h.GetMeanY()); 241 fDelta ->Fill(kRad2Deg*h.GetDelta()); 242 fSize ->Fill(h.GetSize()); 250 fLength ->Fill(scale*h.GetLength()); 251 fWidth ->Fill(scale*h.GetWidth()); 252 fDistC ->Fill(scale*d); 253 fCenter ->Fill(scale*h.GetMeanX(), scale*h.GetMeanY()); 254 fDelta ->Fill(kRad2Deg*h.GetDelta()); 255 fSize ->Fill(h.GetSize()); 256 fUsedPix->Fill(h.GetNumUsedPixels()); 257 fCorePix->Fill(h.GetNumCorePixels()); 243 258 244 259 return kTRUE; … … 269 284 TObject *MHHillas::DrawClone(Option_t *opt) const 270 285 { 271 TCanvas *c = MakeDefCanvas( "Hillas", fTitle, 720, 810);286 TCanvas *c = MakeDefCanvas(this, 720, 810); 272 287 c->Divide(2,3); 273 288 … … 275 290 276 291 c->cd(1); 277 fLength->DrawCopy(); 292 fWidth->DrawCopy(); 293 fLength->SetLineColor(kBlue); 294 fLength->DrawCopy("same"); 278 295 279 296 c->cd(2); 280 fWidth->DrawCopy();281 282 c->cd(3);283 297 gPad->SetLogx(); 284 298 fSize->DrawCopy(); 299 300 c->cd(3); 301 fCorePix->SetLineColor(kRed); 302 fCorePix->DrawCopy(); 303 fUsedPix->SetLineColor(kGreen); 304 fUsedPix->DrawCopy("same"); 285 305 286 306 c->cd(4); … … 309 329 { 310 330 if (!gPad) 311 MakeDefCanvas( "Hillas", fTitle, 720, 810);331 MakeDefCanvas(this, 720, 810); 312 332 313 333 gPad->Divide(2,3); 314 334 315 335 gPad->cd(1); 316 fLength->Draw(); 336 fWidth->Draw(); 337 fLength->SetLineColor(kBlue); 338 fLength->Draw("same"); 317 339 318 340 gPad->cd(2); 319 fWidth->Draw();320 321 gPad->cd(3);322 341 gPad->SetLogx(); 323 342 fSize->Draw(); 343 344 gPad->cd(3); 345 fCorePix->SetLineColor(kRed); 346 fCorePix->Draw(); 347 fUsedPix->SetLineColor(kGreen); 348 fUsedPix->Draw("same"); 324 349 325 350 gPad->cd(4); -
trunk/MagicSoft/Mars/mhist/MHHillas.h
r1463 r1489 22 22 TH1F *fSize; //-> 23 23 TH2F *fCenter; //-> 24 25 TH1F *fUsedPix; //-> 26 TH1F *fCorePix; //-> 24 27 25 28 void SetColors() const; -
trunk/MagicSoft/Mars/mhist/MHHillasExt.cc
r1465 r1489 62 62 // 63 63 fName = name ? name : "MHHillasExt"; 64 fTitle = title ? title : "Container for Hillas (ext)histograms";64 fTitle = title ? title : "Container for extended Hillas histograms"; 65 65 66 66 // … … 69 69 // connect all the histogram with the container fHist 70 70 // 71 fHConc1.SetLineColor(kBlue); 72 fHConc.SetFillStyle(0); 73 71 74 fHConc.SetDirectory(NULL); 72 75 fHConc1.SetDirectory(NULL); … … 220 223 TObject *MHHillasExt::DrawClone(Option_t *opt) const 221 224 { 222 TCanvas &c = *MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 223 720, 810); 224 c.Divide(2, 3); 225 TCanvas &c = *MakeDefCanvas(this, 720, 540); 226 c.Divide(2, 2); 225 227 226 228 gROOT->SetSelectedPad(NULL); 227 229 228 // 229 // This is necessary to get the expected bahviour of DrawClone 230 // 230 231 231 c.cd(1); 232 ((TH1F&)fHConc).DrawCopy(); 232 ((TH1F)fHConc1).DrawCopy(); 233 ((TH1F)fHConc).DrawCopy("same"); 233 234 234 235 c.cd(2); 235 ((TH1F&)fHConc1).DrawCopy(); 236 237 c.cd(5); 238 ((TH1F&)fHAsym).DrawCopy(); 236 ((TH1F)fHAsym).DrawCopy(); 239 237 240 238 c.cd(3); 241 ((TH1F &)fHM3Long).DrawCopy();239 ((TH1F)fHM3Long).DrawCopy(); 242 240 243 241 c.cd(4); 244 ((TH1F &)fHM3Trans).DrawCopy();242 ((TH1F)fHM3Trans).DrawCopy(); 245 243 246 244 c.Modified(); … … 261 259 { 262 260 if (!gPad) 263 MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 264 720, 810); 265 266 gPad->Divide(2, 3); 261 MakeDefCanvas(this, 720, 540); 262 263 gPad->Divide(2, 2); 267 264 268 265 gPad->cd(1); 269 fHConc.DrawCopy(); 266 fHConc1.SetLineColor(kBlue); 267 fHConc1.Draw(); 268 fHConc.Draw("same"); 270 269 271 270 gPad->cd(2); 272 fHConc1.DrawCopy(); 273 274 gPad->cd(5); 275 fHAsym.DrawCopy(); 271 fHAsym.Draw(); 276 272 277 273 gPad->cd(3); 278 fHM3Long.Draw Copy();274 fHM3Long.Draw(); 279 275 280 276 gPad->cd(4); 281 fHM3Trans.Draw Copy();277 fHM3Trans.Draw(); 282 278 283 279 gPad->Modified(); -
trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
r1465 r1489 68 68 // connect all the histogram with the container fHist 69 69 // 70 fAlpha = new TH1F("Alpha", "Alpha of Ellipse", 90,0, 90);70 fAlpha = new TH1F("Alpha", "Alpha of Ellipse", 181, -90, 90); 71 71 fDist = new TH1F("Dist", "Dist of Ellipse", 100, 0, 445); 72 72 fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse", 101, -445, 445); … … 81 81 fDist->SetXTitle("Dist [mm]"); 82 82 fHeadTail->SetXTitle("Head-Tail [mm]"); 83 fCosDA->SetXTitle("cos(\\delta,\\alpha) [mm]");83 fCosDA->SetXTitle("cos(\\delta,\\alpha)"); 84 84 85 85 fAlpha->SetYTitle("Counts"); … … 138 138 const MHillasSrc &h = *(MHillasSrc*)par; 139 139 140 fAlpha ->Fill( fabs(h.GetAlpha()));140 fAlpha ->Fill(h.GetAlpha()); 141 141 fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist()); 142 142 fHeadTail->Fill(fUseMmScale ? h.GetHeadTail() : fMm2Deg*h.GetHeadTail()); … … 211 211 TObject *MHHillasSrc::DrawClone(Option_t *opt) const 212 212 { 213 TCanvas *c = MakeDefCanvas("HillasSrc", "Histograms of Source dependant Parameters", 214 700, 500); 213 TCanvas *c = MakeDefCanvas(this, 700, 500); 215 214 c->Divide(2, 2); 216 215 … … 250 249 { 251 250 if (!gPad) 252 MakeDefCanvas("HillasSrc", "Histograms of Src dependant Parameters", 253 700, 500); 251 MakeDefCanvas(this, 700, 500); 254 252 255 253 // FIXME: Display Source position -
trunk/MagicSoft/Mars/mhist/MHMatrix.cc
r1355 r1489 45 45 #include "MHMatrix.h" 46 46 47 #include <fstream.h> 48 47 49 #include <TList.h> 48 50 #include <TArrayD.h> … … 54 56 #include "MParList.h" 55 57 56 #include "MDataChain.h" 58 #include "MData.h" 59 #include "MDataArray.h" 57 60 58 61 ClassImp(MHMatrix); 59 62 60 // -------------------------------------------------------------------------- 61 // 62 // Default Constructor 63 static const TString gsDefName = "MHMatrix"; 64 static const TString gsDefTitle = "Multidimensional Matrix"; 65 66 // -------------------------------------------------------------------------- 67 // 68 // Default Constructor 63 69 // 64 70 MHMatrix::MHMatrix(const char *name, const char *title) 65 : fNumRow(0) 66 { 67 fName = name ? name : "MHMatrix"; 68 fTitle = title ? title : "Multidimensional Matrix"; 69 70 fData = new TList; 71 fData->SetOwner(); 72 73 fRules = new TList; 74 fRules->SetOwner(); 75 } 76 77 // -------------------------------------------------------------------------- 78 // 79 // Destructor 71 : fNumRow(0), fData(NULL) 72 { 73 fName = name ? name : gsDefName.Data(); 74 fTitle = title ? title : gsDefTitle.Data(); 75 } 76 77 // -------------------------------------------------------------------------- 78 // 79 // Constructor. Initializes the columns of the matrix with the entries 80 // from a MDataArray 81 // 82 MHMatrix::MHMatrix(MDataArray *mat, const char *name, const char *title) 83 : fNumRow(0), fData(mat) 84 { 85 fName = name ? name : gsDefName.Data(); 86 fTitle = title ? title : gsDefTitle.Data(); 87 } 88 89 // -------------------------------------------------------------------------- 90 // 91 // Destructor. Does not deleted a user given MDataArray, except IsOwner 92 // was called. 80 93 // 81 94 MHMatrix::~MHMatrix() 82 95 { 83 delete fData;84 delete fRules;96 if (TestBit(kIsOwner) && fData) 97 delete fData; 85 98 } 86 99 … … 99 112 } 100 113 101 MDataChain &chain = *new MDataChain(rule); 102 if (!chain.IsValid()) 103 { 104 *fLog << err << "Error - Rule cannot be translated... ignored." << endl; 105 delete &chain; 114 if (!fData) 115 { 116 fData = new MDataArray; 117 SetBit(kIsOwner); 118 } 119 120 fData->AddEntry(rule); 121 } 122 123 void MHMatrix::AddColumns(MDataArray *matrix) 124 { 125 if (fM.IsValid()) 126 { 127 *fLog << warn << "Warning - matrix is already in use. Can't add new columns... skipped." << endl; 106 128 return; 107 129 } 108 fData->Add(&chain); 109 110 TNamed *name = new TNamed(rule, rule); // Fimxe, in 3.02/07 the title can't be "", why? 111 fRules->Add(name); 112 } 113 114 void MHMatrix::AddColumns(const MHMatrix *matrix) 115 { 116 TIter Next(matrix->fRules); 117 TObject *rule=NULL; 118 while ((rule=Next())) 119 AddColumn(rule->GetName()); 130 131 if (fData) 132 *fLog << warn << "Warning - columns already added... replacing." << endl; 133 134 if (fData && TestBit(kIsOwner)) 135 { 136 delete fData; 137 ResetBit(kIsOwner); 138 } 139 140 fData = matrix; 120 141 } 121 142 … … 127 148 Bool_t MHMatrix::SetupFill(const MParList *plist) 128 149 { 129 if ( fData->GetSize()==0)130 { 131 *fLog << err << "Error - No Column specified... aborting." << endl;150 if (!fData) 151 { 152 *fLog << err << "Error - No Columns initialized... aborting." << endl; 132 153 return kFALSE; 133 154 } 134 155 135 TIter Next(fData); 136 MData *data = NULL; 137 while ((data=(MData*)Next())) 138 if (!data->PreProcess(plist)) 139 return kFALSE; 140 141 return kTRUE; 156 return fData->PreProcess(plist); 142 157 } 143 158 … … 155 170 if (!fM.IsValid()) 156 171 { 157 fM.ResizeTo(1, fData->Get Size());172 fM.ResizeTo(1, fData->GetNumEntries()); 158 173 return; 159 174 } … … 161 176 TMatrix m(fM); 162 177 163 fM.ResizeTo(fM.GetNrows()*2, fData->Get Size());178 fM.ResizeTo(fM.GetNrows()*2, fData->GetNumEntries()); 164 179 165 180 for (int x=0; x<m.GetNcols(); x++) … … 176 191 AddRow(); 177 192 178 int col=0; 179 TIter Next(fData); 180 MData *data = NULL; 181 while ((data=(MData*)Next())) 182 fM(fNumRow-1, col++) = data->GetValue(); 193 for (int col=0; col<fData->GetNumEntries(); col++) 194 fM(fNumRow-1, col) = (*fData)(col); 183 195 184 196 return kTRUE; … … 195 207 // It's not a fatal error so we don't need to stop PostProcessing... 196 208 // 197 if (fData->Get Size()<1|| fNumRow<1)209 if (fData->GetNumEntries()==0 || fNumRow<1) 198 210 return kTRUE; 199 211 200 212 TMatrix m(fM); 201 213 202 fM.ResizeTo(fNumRow, fData->Get Size());214 fM.ResizeTo(fNumRow, fData->GetNumEntries()); 203 215 204 216 for (int x=0; x<fM.GetNcols(); x++) … … 287 299 void MHMatrix::Print(Option_t *) const 288 300 { 289 int n=0; 290 291 TIter Next(fData->GetSize() ? fData : fRules); 292 MData *data = NULL; 293 while ((data=(MData*)Next())) 294 { 295 *fLog << all << " Column " << setw(3) << n++ << ": " << flush; 296 data->Print(); 297 *fLog << endl; 298 } 301 if (fData) 302 fData->Print(); 303 else 304 *fLog << all << "Sorry, no column information available." << endl; 299 305 300 306 fM.Print(); … … 336 342 } 337 343 344 // -------------------------------------------------------------------------- 345 // 346 // Calculated the distance of vector evt from the reference sample 347 // represented by the covariance metrix m. 348 // - If n<0 the kernel method is applied and 349 // sum(epx(-d)/n is returned. 350 // - For n>=0 the n nearest neighbors are summed and 351 // sqrt(sum(d))/n is returned. 352 // - if n==0 all distances are summed 353 // 338 354 Double_t MHMatrix::CalcDist(const TMatrix &m, const TVector &evt, Int_t num) const 339 355 { 356 if (num==0) // may later be used for another method 357 { 358 TVector d = evt; 359 d *= m; 360 return sqrt(d*evt); 361 } 362 340 363 const Int_t rows = fM.GetNrows(); 341 364 const Int_t cols = fM.GetNcols(); … … 358 381 359 382 dists[i] = d2*d; // square of distance 383 384 // 385 // This corrects for numerical uncertanties in cases of very 386 // small distances... 387 // 388 if (dists[i]<0) 389 dists[i]=0; 360 390 } 361 391 … … 363 393 TMath::Sort(dists.GetSize(), dists.GetArray(), idx.GetArray(), kFALSE); 364 394 365 const Int_t n = num<rows ? num : rows; 366 367 Double_t res = 0; 368 for (int i=0; i<n; i++) 369 res += dists[idx[i]]; 370 371 return sqrt(res)/n; 372 } 373 395 const Int_t n = abs(num)<rows ? abs(num) : rows; 396 397 if (num<0) 398 { 399 // 400 // Kernel function sum 401 // 402 const Double_t h = 1; 403 404 Double_t res = 0; 405 for (int i=0; i<n; i++) 406 res += exp(-dists[idx[i]]/h); 407 408 return log(res/n); 409 } 410 else 411 { 412 // 413 // Nearest Neighbor sum 414 // 415 Double_t res = 0; 416 for (int i=0; i<n; i++) 417 res += dists[idx[i]]; 418 419 return sqrt(res/n); 420 } 421 } 422 423 // -------------------------------------------------------------------------- 424 // 425 // Calls calc dist. In the case of the first call the covariance matrix 426 // fM2 is calculated. 427 // - If n<0 it is divided by (nrows-1)/h while h is the kernel factor. 428 // 374 429 Double_t MHMatrix::CalcDist(const TVector &evt, Int_t num) 375 430 { … … 379 434 fM2.ResizeTo(m); 380 435 fM2 = m; 436 fM2 *= fM.GetNrows()-1; 381 437 delete &m; 382 438 } … … 391 447 fM.ResizeTo(m); 392 448 fM = m; 393 394 TIter Next(fRules); 395 TObject *obj = NULL; 396 while ((obj=Next())) 397 fData->Add(new MDataChain(obj->GetName())); 398 } 449 } 450 451 void MHMatrix::StreamPrimitive(ofstream &out) const 452 { 453 Bool_t data = fData && !TestBit(kIsOwner); 454 455 if (data) 456 { 457 fData->SavePrimitive(out); 458 out << endl; 459 } 460 461 out << " MHMatrix " << GetUniqueName(); 462 463 if (data || fName!=gsDefName || fTitle!=gsDefTitle) 464 { 465 out << "("; 466 if (data) 467 out << "&" << fData->GetUniqueName(); 468 if (fName!=gsDefName || fTitle!=gsDefTitle) 469 { 470 if (data) 471 out << ", "; 472 out << "\"" << fName << "\""; 473 if (fTitle!=gsDefTitle) 474 out << ", \"" << fTitle << "\""; 475 } 476 } 477 out << ");" << endl; 478 479 if (fData && TestBit(kIsOwner)) 480 for (int i=0; i<fData->GetNumEntries(); i++) 481 out << " " << GetUniqueName() << ".AddColumn(\"" << (*fData)[i].GetRule() << "\");" << endl; 482 } -
trunk/MagicSoft/Mars/mhist/MHMatrix.h
r1355 r1489 9 9 #endif 10 10 11 class MData Chain;11 class MDataArray; 12 12 13 13 class MHMatrix : public MH 14 14 { 15 15 protected: 16 Int_t fNumRow; //! Number of dimensions of histogram17 TMatrix fM; // Matrix to be filled16 Int_t fNumRow; //! Number of dimensions of histogram 17 TMatrix fM; // Matrix to be filled 18 18 19 TMatrix fM2; //!19 TMatrix fM2; //! 20 20 21 TList *fData; //! List of data members (columns) 22 TList *fRules; // List of data members as text for storage 21 MDataArray *fData; // List of data members (columns) 22 23 enum { 24 kIsOwner = BIT(14) 25 }; 23 26 24 27 void AddRow(); … … 28 31 Bool_t Finalize(); 29 32 33 void StreamPrimitive(ofstream &out) const; 34 30 35 public: 31 36 MHMatrix(const char *name=NULL, const char *title=NULL); 37 MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL); 32 38 ~MHMatrix(); 33 39 34 40 void AddColumn(const char *name); 35 void AddColumns( const MHMatrix *matrix);41 void AddColumns(MDataArray *mat); 36 42 37 // TMatrix &GetM() { return fM; } 43 MDataArray *GetColumns() { return fData; } 44 38 45 const TMatrix &GetM() const { return fM; } 39 const TList *GetRules() const { return fRules; }40 46 41 47 //void Draw(Option_t *opt=NULL); … … 49 55 Double_t CalcDist(const TVector &v, Int_t num = 25); 50 56 57 void SetIOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); } 58 51 59 void Reassign(); 52 60
Note:
See TracChangeset
for help on using the changeset viewer.