Changeset 1218 for trunk/MagicSoft/Mars
- Timestamp:
- 02/21/02 12:08:03 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1217 r1218 1 1 -*-*- END -*-*- 2 3 2002/02/21: Thomas Bretz 4 5 * manalysis/MHillas.[h,cc]: 6 - changed fMeanx and fMeany to fMeanX and fMeanY to match the names 7 of the getter functions, needed by TDataMember::GetterMethod 8 - commented out WriteAscii (replaced by more general in MParContainer 9 and MWriteAsciiFile) 10 11 * manalysis/MHillasSrc.[h,cc], mmc/MMcEvt.[hxx, cxx]: 12 - commented out WriteAscii (replaced by more general in MParContainer 13 and MWriteAsciiFile) 14 15 * mbase/MFilterList.cc: 16 - removed a nonsens comment 17 18 * mbase/MGList.cc: 19 - relay on the bugfix for DynamicCast 20 21 * mbase/MParContainer.[h,cc]: 22 - implemented WriteDataMember to have a more general interface 23 for readable output. 24 - changed ofstream to a more general ostream 25 26 * mbase/MWriteAsciiFile.[cc,h]: 27 - generalized ascii writer to be able to write single data members 28 29 2 30 3 31 2002/02/13: Thomas Bretz -
trunk/MagicSoft/Mars/macros/MagicHillas.C
r1216 r1218 104 104 MFillH hfill2s("HistSource [MHHillasSrc]", "HillasSource"); 105 105 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc"); 106 106 /* 107 107 MWriteRootFile write("hillas.root"); 108 108 write.AddContainer("MHillas", "Hillas"); … … 110 110 write.AddContainer("HillasAntiSrc", "Hillas"); 111 111 write.AddContainer("MHStarMap"); 112 */ 113 MWriteAsciiFile write("hillas.txt"); 114 write.AddContainer("MHillas", "fLength"); 115 write.AddContainer("MHillas", "fWidth"); 116 write.AddContainer("MHillas"); 112 117 113 118 tlist.AddToList(&read); … … 135 140 // Execute your analysis 136 141 // 137 if (!evtloop.Eventloop( ))142 if (!evtloop.Eventloop(5)) 138 143 return; 144 145 return; 139 146 140 147 tlist.PrintStatistics(); -
trunk/MagicSoft/Mars/manalysis/MHillas.cc
r1211 r1218 36 36 // fDelta angle of major axis wrt x-axis 37 37 // fSize total sum of pixels 38 // fMean xx of center of ellipse39 // fMean yy of center of ellipse38 // fMeanX x of center of ellipse 39 // fMeanY y of center of ellipse 40 40 // 41 41 ///////////////////////////////////////////////////////////////////////////// … … 89 89 fDelta = 0; 90 90 fSize = 0; 91 fMean x= 0;92 fMean y= 0;91 fMeanX = 0; 92 fMeanY = 0; 93 93 94 94 Clear(); … … 101 101 void MHillas::Print(Option_t *) const 102 102 { 103 Double_t atg = atan2(fMean y, fMeanx)*kRad2Deg;103 Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg; 104 104 105 105 if (atg<0) … … 110 110 *fLog << " - Length [mm] = " << fLength << endl; 111 111 *fLog << " - Width [mm] = " << fWidth << endl; 112 *fLog << " - Meanx [mm] = " << fMean x<< endl;113 *fLog << " - Meany [mm] = " << fMean y<< endl;112 *fLog << " - Meanx [mm] = " << fMeanX << endl; 113 *fLog << " - Meany [mm] = " << fMeanY << endl; 114 114 *fLog << " - Delta [deg] = " << fDelta*kRad2Deg << endl; 115 115 *fLog << " - atg(y/x) [deg] = " << atg << endl; … … 125 125 { 126 126 fEllipse->SetLineWidth(2); 127 fEllipse->PaintEllipse(fMean x, fMeany, fLength, fWidth,127 fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth, 128 128 0, 360, fDelta*kRad2Deg+180); 129 129 } … … 143 143 Clear(); 144 144 145 fEllipse = new TEllipse(fMean x, fMeany, fLength, fWidth,145 fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth, 146 146 0, 360, fDelta*kRad2Deg+180); 147 147 … … 155 155 fEllipse->SetR2(fWidth); 156 156 fEllipse->SetTheta(fDelta*kRad2Deg+180); 157 fEllipse->SetX1(fMean x);158 fEllipse->SetY1(fMean y);157 fEllipse->SetX1(fMeanX); 158 fEllipse->SetY1(fMeanY); 159 159 160 160 fEllipse->SetLineWidth(2); 161 fEllipse->PaintEllipse(fMean x, fMeany, fLength, fWidth,161 fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth, 162 162 0, 360, fDelta*kRad2Deg+180); 163 163 … … 216 216 // ----------------------------------------------------- 217 217 // 218 fMean x= 0;219 fMean y= 0;218 fMeanX = 0; 219 fMeanY = 0; 220 220 fSize = 0; 221 221 … … 236 236 237 237 fSize += nphot; // [counter] 238 fMean x+= nphot * gpix.GetX(); // [mm]239 fMean y+= nphot * gpix.GetY(); // [mm]238 fMeanX += nphot * gpix.GetX(); // [mm] 239 fMeanY += nphot * gpix.GetY(); // [mm] 240 240 241 241 npix++; … … 248 248 return kFALSE; 249 249 250 fMean x/= fSize; // [mm]251 fMean y/= fSize; // [mm]250 fMeanX /= fSize; // [mm] 251 fMeanY /= fSize; // [mm] 252 252 253 253 // … … 267 267 268 268 const MGeomPix &gpix = geom[pix.GetPixId()]; 269 const float dx = gpix.GetX() - fMean x; // [mm]270 const float dy = gpix.GetY() - fMean y; // [mm]269 const float dx = gpix.GetX() - fMeanX; // [mm] 270 const float dy = gpix.GetY() - fMeanY; // [mm] 271 271 272 272 const float nphot = pix.GetNumPhotons(); // [#phot] … … 311 311 fin >> fDelta; 312 312 fin >> fSize; 313 fin >> fMean x;314 fin >> fMean y;315 } 316 317 // -------------------------------------------------------------------------- 318 / /313 fin >> fMeanX; 314 fin >> fMeanY; 315 } 316 317 // -------------------------------------------------------------------------- 318 /* 319 319 void MHillas::AsciiWrite(ofstream &fout) const 320 320 { … … 323 323 fout << fDelta << " "; 324 324 fout << fSize << " "; 325 fout << fMeanx << " "; 326 fout << fMeany; 327 } 325 fout << fMeanX << " "; 326 fout << fMeanY; 327 } 328 */ -
trunk/MagicSoft/Mars/manalysis/MHillas.h
r1203 r1218 19 19 Float_t fDelta; // [rad] angle of major axis with x-axis 20 20 Float_t fSize; // [#CerPhot] sum of content of all pixels (number of Cherenkov photons) 21 Float_t fMean x; // [mm] x-coordinate of center of ellipse22 Float_t fMean y; // [mm] y-coordinate of center of ellipse21 Float_t fMeanX; // [mm] x-coordinate of center of ellipse 22 Float_t fMeanY; // [mm] y-coordinate of center of ellipse 23 23 24 24 Float_t fSinDelta; //! [1] sin of Delta (to be used in derived classes) … … 53 53 Float_t GetDelta() const { return fDelta; } 54 54 Float_t GetSize() const { return fSize; } 55 Float_t GetMeanX() const { return fMean x; }56 Float_t GetMeanY() const { return fMean y; }55 Float_t GetMeanX() const { return fMeanX; } 56 Float_t GetMeanY() const { return fMeanY; } 57 57 58 58 virtual void AsciiRead(ifstream &fin); 59 virtual void AsciiWrite(ofstream &fout) const;59 //virtual void AsciiWrite(ofstream &fout) const; 60 60 61 61 ClassDef(MHillas, 1) // Storage Container for Hillas Parameter -
trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc
r1211 r1218 101 101 // 102 102 // overloaded MParContainer to write MHillasSrc to an ascii file 103 / /103 /* 104 104 void MHillasSrc::AsciiWrite(ofstream &fout) const 105 105 { 106 106 fout << fAlpha << " " << fDist; 107 107 } 108 */ -
trunk/MagicSoft/Mars/manalysis/MHillasSrc.h
r1203 r1218 37 37 38 38 virtual void AsciiRead(ifstream &fin); 39 virtual void AsciiWrite(ofstream &fout) const;39 //virtual void AsciiWrite(ofstream &fout) const; 40 40 41 41 ClassDef(MHillasSrc, 1) // Container to hold source position dependant parameters -
trunk/MagicSoft/Mars/mbase/MFilterList.cc
r1080 r1218 143 143 const char *name = filter->GetName(); 144 144 145 // FIXME: We agreed to put the task into list in an ordered way.146 147 145 if (fFilters.FindObject(filter)) 148 146 { -
trunk/MagicSoft/Mars/mbase/MGList.cc
r1116 r1218 98 98 // Is this another bug in root? 99 99 // 100 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07) 100 101 if (!obj->IsA()->InheritsFrom(TGWidget::Class())) 101 102 return NULL; 103 #endif 102 104 103 105 return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj); -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1211 r1218 214 214 // -------------------------------------------------------------------------- 215 215 // 216 // Write out a data member given as a TDataMember object to an output stream. 217 // 218 Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const 219 { 220 if (!member) 221 return kFALSE; 222 223 if (!member->IsPersistent()) 224 return kFALSE; 225 226 /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root 227 if (!call) 228 return kFALSE; 229 230 switch (call->ReturnType()) 231 { 232 case TMethodCall::kLong: 233 Long_t l; 234 call->Execute((void*)this, l); // FIXME: const, root 235 out << l << " "; 236 return kTRUE; 237 238 case TMethodCall::kDouble: 239 Double_t d; 240 call->Execute((void*)this, d); // FIXME: const, root 241 out << d << " "; 242 return kTRUE; 243 244 case TMethodCall::kOther: 245 /* someone may want to enhance this? */ 246 return kFALSE; 247 } 248 249 return kFALSE; 250 } 251 252 // -------------------------------------------------------------------------- 253 // 254 // Write out a data member given by name to an output stream. 255 // 256 Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const 257 { 258 return WriteDataMember(out, IsA()->GetDataMember(member)); 259 } 260 261 // -------------------------------------------------------------------------- 262 // 216 263 // If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a 217 264 // container, you may overload this function. If you don't overload it … … 221 268 // floating point (Float_t, Double_t, ...) type are written. 222 269 // 223 void MParContainer::AsciiWrite(o fstream &fout) const270 void MParContainer::AsciiWrite(ostream &out) const 224 271 { 225 272 // *fLog << warn << "To use the the ascii output of " << GetName(); … … 230 277 TIter Next(IsA()->GetListOfDataMembers()); 231 278 while ((data=(TDataMember*)Next())) 232 { 233 if (!data->IsPersistent()) 234 continue; 235 236 /*const*/ TMethodCall *call = data->GetterMethod(); //FIXME: Root 237 if (!call) 238 continue; 239 240 switch (call->ReturnType()) 241 { 242 case TMethodCall::kLong: 243 Long_t l; 244 call->Execute((void*)this, l); // FIXME: const, root 245 fout << l << " "; 246 continue; 247 248 case TMethodCall::kDouble: 249 Double_t d; 250 call->Execute((void*)this, d); // FIXME: const, root 251 fout << d << " "; 252 continue; 253 254 case TMethodCall::kOther: 255 /* someone may want to enhance this? */ 256 continue; 257 } 258 } 259 } 279 WriteDataMember(out, data); 280 } -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1086 r1218 22 22 class ofstream; 23 23 class ifstream; 24 25 class TDataMember; 24 26 25 27 class MParContainer : public TObject … … 64 66 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } 65 67 68 Bool_t WriteDataMember(ostream &out, const char *member) const; 69 Bool_t WriteDataMember(ostream &out, TDataMember *member) const; 70 66 71 virtual void AsciiRead(ifstream &fin); 67 virtual void AsciiWrite(o fstream &fout) const;72 virtual void AsciiWrite(ostream &out) const; 68 73 69 74 ClassDef(MParContainer, 0) //The basis for all parameter containers -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r1192 r1218 44 44 #include <fstream.h> 45 45 46 #include <TClass.h> // IsA 47 #include <TMethodCall.h> // TMethodCall, AsciiWrite 48 #include <TDataMember.h> // TDataMember, AsciiWrite 49 46 50 #include "MLog.h" 47 51 #include "MLogManip.h" … … 81 85 Init(filename, name, title); 82 86 83 AddContainer(contname); 87 if (contname) 88 AddContainer(contname); 84 89 } 85 90 … … 100 105 Init(filename, name, title); 101 106 102 AddContainer(cont); 107 if (cont) 108 AddContainer(cont); 103 109 } 104 110 … … 111 117 { 112 118 fContNames.SetOwner(); 119 fMembers.SetOwner(); 113 120 114 121 delete fOut; … … 130 137 Int_t num = fContainer.GetEntries(); 131 138 132 TIter Next(&fContainer); 133 134 while ((cont=(MParContainer*)Next())) 139 TIter NextCont(&fContainer); 140 TIter NextMemb(&fMembers); 141 142 while ((cont=(MParContainer*)NextCont())) 135 143 { 144 const TObject *memb = NextMemb(); 145 136 146 if (!cont->IsReadyToSave()) 137 147 continue; 138 148 139 cont->AsciiWrite(*fOut); 149 if (memb->GetName()[0]=='\0') 150 cont->AsciiWrite(*fOut); 151 else 152 { 153 if (!cont->WriteDataMember(*fOut, memb->GetName())) 154 continue; 155 } 156 140 157 *fOut << " "; 141 158 written = kTRUE; … … 183 200 } 184 201 185 AddContainer(cont );202 AddContainer(cont, obj->GetTitle()); 186 203 } 187 204 … … 193 210 // Add another container (by name) to be written to the ascii file. 194 211 // The container will be output one after each other in one line. 195 // 196 void MWriteAsciiFile::AddContainer(const char *cname) 197 { 198 TNamed *named = new TNamed(cname, ""); 212 // If you want to write only one data member of the container 213 // specify the name of the data member (eg. fAlpha) Make sure, 214 // that a "GetteMethod" for this data type exists (strif the f and 215 // replace it by Get) 216 // 217 void MWriteAsciiFile::AddContainer(const char *cname, const char *member) 218 { 219 TNamed *named = new TNamed(cname, member); 199 220 fContNames.AddLast(named); 200 221 } … … 204 225 // Add another container (by pointer) to be written to the ascii file. 205 226 // The container will be output one after each other in one line. 206 // 207 void MWriteAsciiFile::AddContainer(MParContainer *cont) 227 // If you want to write only one data member of the container 228 // specify the name of the data member (eg. fAlpha) Make sure, 229 // that a "GetteMethod" for this data type exists (strif the f and 230 // replace it by Get) 231 // 232 void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member) 208 233 { 209 234 fContainer.AddLast(cont); 210 } 211 235 236 TNamed *named = new TNamed(member, ""); 237 fMembers.AddLast(named); 238 } 239
Note:
See TracChangeset
for help on using the changeset viewer.