Changeset 2117 for trunk/MagicSoft/Mars/mdata
- Timestamp:
- 05/16/03 13:11:23 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mdata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mdata/MDataChain.cc
r2098 r2117 82 82 // randl(x) returns gRandom->Landau(0, x) 83 83 // 84 // 85 // Constants are implemented in ParseDataMember, namely: 86 // kPi: TMath::Pi() 87 // kRad2Deg: 180/kPi 88 // kDeg2Rad: kPi/180 89 // 90 // You can also defined constants which are defined in TMath by: 91 // kLn10 for static Double_t TMath::Ln10(); 92 // kLogE for static Double_t TMath::LogE(); 93 // kRadToDeg for static Double_t TMath::RadToDeg(); 94 // kDegToRad for static Double_t TMath::DegToRad(); 95 // Remark: In older root versions only Pi() and E() are implemented in 96 // TMath. 97 // 98 // 84 99 // REMARK: 85 100 // - All the random functions are returning 0 if gRandom==0 … … 100 115 101 116 #include <TRandom.h> 117 #include <TMethodCall.h> 102 118 103 119 #include "MLog.h" … … 126 142 // -------------------------------------------------------------------------- 127 143 // 128 // Default constructor129 //130 MDataChain::MDataChain()131 : fMember(NULL), fOperatorType(kENoop)132 {133 }134 135 // --------------------------------------------------------------------------136 //137 144 // Constructor taking a rule as an argument. For more details see 138 145 // class description 139 146 // 140 147 MDataChain::MDataChain(const char *rule, const char *name, const char *title) 141 : f OperatorType(kENoop)148 : fMember(NULL), fOperatorType(kENoop) 142 149 { 143 150 fName = name ? name : "MDataChain"; 144 151 fTitle = title ? title : rule; 152 153 if (TString(rule).IsNull()) 154 return; 145 155 146 156 *fLog << inf << "Trying to resolve rule... " << flush; … … 259 269 // -------------------------------------------------------------------------- 260 270 // 271 // Here the names of data members are interpreted. This can be used to 272 // check for constants. 273 // 274 MData *MDataChain::ParseDataMember(TString txt) 275 { 276 //txt.ToLower(); 277 278 if (txt=="kRad2Deg") return new MDataValue(kRad2Deg); 279 if (txt=="kDeg2Rad") return new MDataValue(1./kRad2Deg); 280 281 if (!txt.BeginsWith("k")) 282 return new MDataMember(txt.Data()); 283 284 const TString name = txt(1, txt.Length()); 285 TMethodCall call(TMath::Class(), name, ""); 286 switch (call.ReturnType()) 287 { 288 case TMethodCall::kLong: 289 Long_t l; 290 call.Execute(l); 291 return new MDataValue(l); 292 case TMethodCall::kDouble: 293 Double_t d; 294 call.Execute(d); 295 return new MDataValue(d); 296 default: 297 break; 298 } 299 300 return new MDataMember(txt.Data()); 301 } 302 303 // -------------------------------------------------------------------------- 304 // 261 305 // Core of the data chain. Here the chain is constructed out of the rule. 262 306 // … … 418 462 if ((txt.IsNull() || txt[0]!='(') && text[0]!='-' && text[0]!='+') 419 463 { 420 newmember = new MDataMember(text.Data());464 newmember = ParseDataMember(text.Data()); 421 465 break; 422 466 } … … 469 513 if (!fMember) 470 514 { 471 *fLog << warn << "MDataChain not valid." << endl;515 //*fLog << warn << "MDataChain not valid." << endl; 472 516 return 0; 473 517 } -
trunk/MagicSoft/Mars/mdata/MDataChain.h
r1853 r2117 59 59 60 60 MData *ParseString(TString txt, Int_t level); 61 MData *ParseDataMember(TString txt); 61 62 62 63 MDataChain(const char *rule, OperatorType_t op); 63 64 64 65 public: 65 MDataChain(); 66 MDataChain(const char *rule, const char *name=NULL, const char *title=NULL); 66 MDataChain(const char *rule=NULL, const char *name=NULL, const char *title=NULL); 67 67 ~MDataChain(); 68 68
Note:
See TracChangeset
for help on using the changeset viewer.