Changeset 1235 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 03/07/02 15:28:30 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1229 r1235 217 217 // Write out a data member given as a TDataMember object to an output stream. 218 218 // 219 Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member ) const219 Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member, Double_t scale) const 220 220 { 221 221 if (!member) … … 245 245 Double_t d; 246 246 call->Execute((void*)this, d); // FIXME: const, root 247 out << d<< " ";247 out << (scale*d) << " "; 248 248 return kTRUE; 249 249 … … 260 260 // Write out a data member given by name to an output stream. 261 261 // 262 Bool_t MParContainer::WriteDataMember(ostream &out, const char *member ) const262 Bool_t MParContainer::WriteDataMember(ostream &out, const char *member, Double_t scale) const 263 263 { 264 264 /*const*/ TClass *cls = IsA()->GetBaseDataMember(member); … … 266 266 return kFALSE; 267 267 268 return WriteDataMember(out, cls->GetDataMember(member) );268 return WriteDataMember(out, cls->GetDataMember(member), scale); 269 269 } 270 270 -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1222 r1235 66 66 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } 67 67 68 Bool_t WriteDataMember(ostream &out, const char *member ) const;69 Bool_t WriteDataMember(ostream &out, const TDataMember *member ) const;68 Bool_t WriteDataMember(ostream &out, const char *member, Double_t scale=1) const; 69 Bool_t WriteDataMember(ostream &out, const TDataMember *member, Double_t scale=1) const; 70 70 Bool_t WriteDataMember(ostream &out, const TList *list) const; 71 71 -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r1222 r1235 148 148 while ((cont=(MParContainer*)NextCont())) 149 149 { 150 const TObject *memb =NextMemb();150 const MScale *memb = (MScale*)NextMemb(); 151 151 152 152 if (!cont->IsReadyToSave()) … … 160 160 else 161 161 { 162 if (!cont->WriteDataMember(*fOut, memb->GetName() ))162 if (!cont->WriteDataMember(*fOut, memb->GetName(), memb->GetScale())) 163 163 continue; 164 164 } … … 196 196 Bool_t MWriteAsciiFile::GetContainer(MParList *pList) 197 197 { 198 TObject*obj = NULL;198 MScale *obj = NULL; 199 199 200 200 TIter Next(&fContNames); 201 201 202 while ((obj= Next()))202 while ((obj=(MScale*)Next())) 203 203 { 204 204 const char *name = obj->GetName(); … … 211 211 } 212 212 213 AddContainer(cont, obj->GetTitle() );213 AddContainer(cont, obj->GetTitle(), obj->GetScale()); 214 214 } 215 215 … … 223 223 // If you want to write only one data member of the container 224 224 // specify the name of the data member (eg. fAlpha) Make sure, 225 // that a "GetteMethod" for this data type exists (stri fthe f and225 // that a "GetteMethod" for this data type exists (strip the f and 226 226 // replace it by Get) 227 // 228 void MWriteAsciiFile::AddContainer(const char *cname, const char *member) 229 { 230 TNamed *named = new TNamed(cname, member); 231 fContNames.AddLast(named); 227 // If you specify a single data member you can add a scale-factor which 228 // is (in case of the data member being a floating point value) multiplied 229 // with the data member value. This is usefull if you are want to 230 // change the scale (unit) of a data member for writing (eg. 231 // writing degrees for the hillas parameters instead of the internally 232 // used millimeters) 233 // 234 void MWriteAsciiFile::AddContainer(const char *cname, const char *member, Double_t scale) 235 { 236 MScale *name = new MScale(cname, member, scale); 237 fContNames.AddLast(name); 232 238 } 233 239 … … 238 244 // If you want to write only one data member of the container 239 245 // specify the name of the data member (eg. fAlpha) Make sure, 240 // that a "GetteMethod" for this data type exists (stri fthe f and246 // that a "GetteMethod" for this data type exists (strip the f and 241 247 // replace it by Get) 242 // 243 void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member) 248 // If you specify a single data member you can add a scale-factor which 249 // is (in case of the data member being a floating point value) multiplied 250 // with the data member value. This is usefull if you are want to 251 // change the scale (unit) of a data member for writing (eg. 252 // writing degrees for the hillas parameters instead of the internally 253 // used millimeters) 254 // 255 void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member, Double_t scale) 244 256 { 245 257 fContainer.AddLast(cont); 246 258 247 TNamed *named = new TNamed(member, "");248 fMembers.AddLast(name d);249 } 250 259 MScale *name = new MScale(member, "", scale); 260 fMembers.AddLast(name); 261 } 262 -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h
r1219 r1235 12 12 { 13 13 private: 14 class MScale : public TNamed 15 { 16 private: 17 Double_t fScale; 18 public: 19 MScale(const char *name, const char *title, Double_t scale) 20 : TNamed(name, title), fScale(scale) {} 21 Double_t GetScale() const { return fScale; } 22 }; 23 14 24 ofstream *fOut; 15 25 … … 17 27 TObjArray fContainer; 18 28 TObjArray fMembers; 29 TObjArray fScale; 19 30 20 31 TString fNameFile; … … 34 45 ~MWriteAsciiFile(); 35 46 36 void AddContainer(const char *cname, const char *member="" );37 void AddContainer(MParContainer *cont, const char *member="" );47 void AddContainer(const char *cname, const char *member="", Double_t scale=1); 48 void AddContainer(MParContainer *cont, const char *member="", Double_t scale=1); 38 49 39 50 ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file
Note:
See TracChangeset
for help on using the changeset viewer.