Changeset 2607 for trunk/MagicSoft/Mars
- Timestamp:
- 12/05/03 16:06:34 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2606 r2607 9 9 - removed wrong comment in MHMcCollectionArea::CalcEfficiency2 10 10 11 12 11 13 2003/12/05: Thomas Bretz 12 14 … … 27 29 mfileio/MReadReports.cc, mhist/MHPixVsTime.cc, 28 30 mhist/MHVsTime.cc, mmain/MOnlineDump.cc, 29 mmontecarlo/MMcTimeGenerate.cc, mreport/MReport.cc 31 mmontecarlo/MMcTimeGenerate.cc, mreport/MReport.cc, 32 manalysis/MEventRateCalc.cc: 30 33 - adapted to new MTime 31 34 … … 47 50 * mfileio/Makefile, mfileio/FileIOLinkDef.h: 48 51 - removed MReadCurrent 52 53 * readdaq.cc: 54 - changed to display board information on request 55 (MRawCrateArray) 56 57 * mfileio/MReadMarsFile.cc: 58 - small changes to output 59 60 * mfileio/MReadReports.[h,cc]: 61 - added 'Master' tree as a workaround for reading RunHeaders 62 63 * mfileio/MReadTree.cc: 64 - call Notify() of all members of fNotify in Notify() 65 66 * mraw/MRawCrateArray.[h,cc]: 67 - added Print() member function 68 49 69 50 70 -
trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc
r2590 r2607 94 94 Int_t MEventRateCalc::Process() 95 95 { 96 fTime-> SetTime(gSystem->Now());96 fTime->Now(); 97 97 98 98 const ULong_t exec = GetNumExecutions(); -
trunk/MagicSoft/Mars/mbase/MTime.cc
r2580 r2607 38 38 // - removed fTimeStamp[2] 39 39 // 40 // Version 3: 41 // ---------- 42 // - removed fDurtaion - we may put it back when it is needed 43 // - complete rewrite of the data members (old ones completely replaced) 44 // 40 45 ///////////////////////////////////////////////////////////////////////////// 41 46 #include "MTime.h" 42 47 43 48 #include <iomanip> 49 #include <sys/time.h> // struct timeval 44 50 45 51 #include <TTime.h> 46 52 47 53 #include "MLog.h" 54 #include "MAstro.h" 48 55 49 56 ClassImp(MTime); … … 51 58 using namespace std; 52 59 53 void MTime:: SetTime(const TTime &t)60 void MTime::GetDate(UShort_t &y, Byte_t &m, Byte_t &d) const 54 61 { 55 SetTime((ULong_t)t); 62 MAstro::Mjd2Ymd((Long_t)fTime<0?fMjd-1:fMjd, y, m, d); 63 } 64 65 Bool_t MTime::Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h, Byte_t min, Byte_t s, UShort_t ms, UInt_t ns) 66 { 67 if (h>23 || min>59 || s>59 || ms>999 || ns>999999) 68 return kFALSE; 69 70 const Int_t mjd = MAstro::Ymd2Mjd(y, m, d); 71 if (mjd<0) 72 return kFALSE; 73 74 const ULong_t tm = ((((h*60+min)*60)+s)*1000)+ms; 75 76 return Set(mjd, tm, ns); 77 } 78 79 void MTime::SetSystemTimer(const struct timeval &tv) 80 { 81 const ULong_t hor = 3600000; // One Hour in milliseconds 82 83 const UInt_t mjd = tv.tv_sec/(60*60*24) + 40587; 84 const Long_t tm = (tv.tv_usec/1000)%(24*hor); 85 86 Set(mjd, tm, tv.tv_usec*1000); 87 } 88 89 void MTime::Now() 90 { 91 #ifdef __LINUX__ 92 struct timeval tv; 93 gettimeofday(&tv, NULL); 94 SetSystemTimer(tv); 95 #else 96 Reset(); 97 #endif 56 98 } 57 99 58 100 void MTime::Print(Option_t *) const 59 101 { 60 *fLog << GetDescriptor() << ": " << dec << setfill('0'); 61 *fLog << setw(2) << (int)fHour << ":"; 62 *fLog << setw(2) << (int)fMin << ":"; 63 *fLog << setw(2) << (int)fSec << "."; 64 *fLog << setw(9) << fNanoSec << endl; 102 UShort_t yea, ms; 103 Byte_t mon, day, h, m, s; 104 105 GetDate(yea, mon, day); 106 GetTime(h, m, s, ms); 107 108 *fLog << GetDescriptor() << ": "; 109 *fLog << Form("%4d/%02d/%02d %02d:%02d:%02d.%03d (+%dns)", 110 yea, mon, day, h, m, s, ms, fNanoSec) << endl; 65 111 } -
trunk/MagicSoft/Mars/mbase/MTime.h
r2580 r2607 14 14 #endif 15 15 16 class TTime; 16 #ifndef ROOT_TTime 17 #include <TTime.h> 18 #endif 19 20 struct timeval; 17 21 18 22 class MTime : public MParContainer 19 23 { 24 friend bool operator==(MTime &t1, MTime &t2); 25 friend bool operator!=(MTime &t1, MTime &t2); 26 friend bool operator< (MTime &t1, MTime &t2); 27 friend bool operator> (MTime &t1, MTime &t2); 28 //friend bool operator<=(MTime &t1, MTime &t2); 29 //friend bool operator>=(MTime &t1, MTime &t2); 30 20 31 private: 21 //UInt_t fTimeStamp[2]; // type of raw event which should be processed by this task 22 UInt_t fDuration; // time of validity 32 UInt_t fMjd; // [d] Day in the century (Day of sun rise) 33 TTime fTime; // [ms] Time of Day (-11h<=x<13h) 34 UInt_t fNanoSec; // [ns] NanoSec part of TimeOfDay (<1000000) 23 35 24 Byte_t fHour; 25 Byte_t fMin; 26 Byte_t fSec; 27 UInt_t fNanoSec; 28 29 /* 30 UInt_t fMjd; // Day in the century (Day of sun rise) 31 TTime fTime; // Time of Day (43,200,000<x<43,200,000) 32 UShort_t fNanoSec; // NanoSec part of TimeOfDay (<1000) 33 */ 36 ULong_t GetTime24() const 37 { 38 const ULong_t hor = 3600000; // One Hour in milliseconds 39 return (Long_t)fTime<0 ? (Long_t)fTime+24*hor : (ULong_t)fTime; 40 } 34 41 35 42 public: … … 39 46 fTitle = title; 40 47 41 SetTime((ULong_t)0);48 Reset(); 42 49 } 43 50 44 51 MTime(MTime& t) { *this = t; } 45 52 53 void Reset() { fMjd=0; fTime=0; fNanoSec=0; } 54 46 55 void operator=(MTime &t) 47 56 { 48 fDuration = t.fDuration; 49 fHour = t.fHour; 50 fMin = t.fMin; 51 fSec = t.fSec; 52 fNanoSec = t.fNanoSec; 57 fMjd = t.fMjd; 58 fTime = t.fTime; 59 fNanoSec = t.fNanoSec; 53 60 } 54 61 55 62 void Print(Option_t *t=NULL) const; 56 63 57 void SetCT1Time(UInt_t t1, UInt_t t0) 64 void Now(); 65 66 Double_t GetMjd() const 67 { 68 return fMjd+((Long_t)fTime+fNanoSec/1e6)/1000; 69 } 70 71 void SetSystemTimer(const struct timeval &tv); 72 73 Bool_t Set(UInt_t mjd, ULong_t ms, UInt_t ns=0) 74 { 75 const ULong_t hor = 3600000; // One Hour in milliseconds 76 if (ms>24*hor-1 || ns>999999) 77 return kFALSE; 78 79 const Bool_t am = ms < hor*13; 80 81 fMjd = am ? mjd : mjd + 1; 82 fTime = (Long_t)(am ? ms : ms - hor*24); 83 fNanoSec = ns%1000000; 84 85 return kTRUE; 86 } 87 88 Bool_t Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h, Byte_t min, Byte_t s, UShort_t ms, UInt_t ns=0); 89 90 void SetCT1Time(UInt_t mjd, UInt_t t1, UInt_t t0) 58 91 { 59 92 // int isecs_since_midday; // seconds passed since midday before sunset (JD of run start) 60 93 // int isecfrac_200ns; // fractional part of isecs_since_midday 61 94 // fTime->SetTime(isecfrac_200ns, isecs_since_midday); 62 fNanoSec = 200*t1; 63 fSec = t0%60; 64 t0 /= 60; 65 fMin = t0%60; 66 t0 /= 60; 67 fHour = (t0+12)%24; 95 const ULong_t hor = 3600000; // One Hour in milliseconds 96 97 fNanoSec = (200*t1)%1000000; 98 const ULong_t ms = (200*t1)/1000000 + t0+12*hor; 99 100 fTime = (Long_t)(ms<13*hor ? ms : ms-24*hor); 101 102 fMjd = mjd+1; 68 103 } 69 70 void Set Time(ULong_t t)104 /* 105 void SetSystemTime(const TTime &tm) 71 106 { 72 // t [millisec] 73 fNanoSec = (t*1000000)%1000; 74 t /= 1000; 75 fSec = t%60; 76 t /= 60; 77 fMin = t%60; 78 t /= 60; 79 fHour = t%24; 107 fTime = (ULong_t)tm%(24*hor); 80 108 } 81 82 void SetTime(const TTime &t); 83 84 void SetTime(Double_t t) 85 { 86 // t [s] 87 fNanoSec = (UInt_t)(fmod(t, 1)*1e9); 88 fSec = (Byte_t)fmod(t, 60); 89 t /= 60; 90 fMin = (Byte_t)fmod(t, 60); 91 t /= 60; 92 fHour = (Byte_t)fmod(t, 24); 93 } 94 95 void SetTime(Byte_t h, Byte_t m, Byte_t s, UInt_t ns) 96 { 97 fHour = h; 98 fMin = m; 99 fSec = s; 100 fNanoSec = ns; 101 } 102 103 void SetDuration(UInt_t t) 104 { 105 fDuration = t; 106 } 107 108 UInt_t GetDuration() 109 { 110 return fDuration; 111 } 112 109 */ 113 110 operator double() const //[s] 114 111 { 115 return f NanoSec/1e9+(fHour*60*60+fMin*60+fSec);112 return fMjd*24*3600+((Long_t)fTime+fNanoSec*1e6)*1000; 116 113 } 117 114 double operator()() const //[s] … … 120 117 } 121 118 122 Byte_t GetHour() const { return fHour; } 123 Byte_t GetMin() const { return fMin; } 124 Byte_t GetSec() const { return fSec; } 125 UInt_t GetNanoSec() const { return fNanoSec; } 119 void GetDate(UShort_t &y, Byte_t &m, Byte_t &d) const; 120 void GetTime(Byte_t &h, Byte_t &m, Byte_t &s, UShort_t &ms) const // Time of Day returned in the range [0h, 24h) 121 { 122 Long_t tm = GetTime24(); 123 ms = tm%1000; 124 tm /= 1000; 125 s = tm%60; 126 tm /= 60; 127 m = tm%60; 128 tm /= 60; 129 h = tm; 130 } 131 Long_t GetTime() const // Time of Day returned in the range [-11h, 13h) 132 { return (Long_t)fTime; } 126 133 127 ClassDef(MTime, 2) //A generalized MARS time stamp 134 void GetTime(Byte_t &h, Byte_t &m, Byte_t &s) const 135 { 136 UShort_t ms; 137 GetTime(h, m, s, ms); 138 } 139 140 ClassDef(MTime, 3) //A generalized MARS time stamp 128 141 }; 129 142 130 inline Double_t operator-(MTime &t1, MTime &t2)143 inline bool operator<(MTime &t1, MTime &t2) 131 144 { 132 return t1()-t2(); 145 if (t1.fMjd<t2.fMjd) 146 return true; 147 if (t1.fMjd==t2.fMjd && t1.fTime<t2.fTime) 148 return true; 149 if (t1.fMjd==t2.fMjd && t1.fTime==t2.fTime && t1.fNanoSec<t2.fNanoSec) 150 return true; 151 return false; 133 152 } 134 135 inline Bool_t operator<(MTime &t1, MTime &t2) 153 inline bool operator>(MTime &t1, MTime &t2) 136 154 { 137 return t1()<t2(); 155 if (t1.fMjd>t2.fMjd) 156 return true; 157 if (t1.fMjd==t2.fMjd && t1.fTime>t2.fTime) 158 return true; 159 if (t1.fMjd==t2.fMjd && t1.fTime==t2.fTime && t1.fNanoSec>t2.fNanoSec) 160 return true; 161 return false; 138 162 } 139 140 inline Bool_t operator>(MTime &t1, MTime &t2) 163 inline bool operator<=(MTime &t1, MTime &t2) 141 164 { 142 return t1()>t2();165 return !(t1>t2); 143 166 } 144 145 inline Bool_t operator<=(MTime &t1, MTime &t2) 167 inline bool operator>=(MTime &t1, MTime &t2) 146 168 { 147 return t1<=t2();169 return !(t1<t2); 148 170 } 149 150 inline Bool_t operator>=(MTime &t1, MTime &t2) 171 inline bool operator==(MTime &t1, MTime &t2) 151 172 { 152 return t1 ()>=t2();173 return t1.fNanoSec==t2.fNanoSec && t1.fTime==t2.fTime && t1.fMjd==t2.fMjd; 153 174 } 154 155 inline Bool_t operator==(MTime &t1, MTime &t2) 175 inline bool operator!=(MTime &t1, MTime &t2) 156 176 { 157 return t1 ()==t2();177 return t1.fNanoSec!=t2.fNanoSec || t1.fTime!=t2.fTime || t1.fMjd!=t2.fMjd; 158 178 } 159 160 179 #endif -
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
r2206 r2607 190 190 //MReadTree::Notify(); 191 191 192 *fLog << err << "ERROR - ReInit of '" << tlist->Get Name() << "' failed." << endl;192 *fLog << err << "ERROR - ReInit of '" << tlist->GetDescriptor() << "' failed." << endl; 193 193 return kFALSE; 194 194 } -
trunk/MagicSoft/Mars/mfileio/MReadReports.cc
r2604 r2607 70 70 #include "MTime.h" 71 71 #include "MParList.h" 72 #include "MReadTree.h"73 72 #include "MTaskList.h" 73 74 #include "MReadMarsFile.h" 74 75 75 76 ClassImp(MReadReports); … … 124 125 // name in time. 125 126 // 126 // All calls to AddTree _must_ be beforethe calls to AddFile!127 // 128 void MReadReports::AddTree(const char *tree, const char *time )127 // All calls to AddTree _must_ be BEFORE the calls to AddFile! 128 // 129 void MReadReports::AddTree(const char *tree, const char *time, Bool_t master) 129 130 { 130 131 /* … … 136 137 } 137 138 */ 138 MReadTree *t = new MReadTree(tree); 139 140 if (master && TestBit(kHasMaster)) 141 { 142 *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl; 143 master = kFALSE; 144 } 145 146 MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree); 139 147 t->SetName(tree); 140 148 t->SetTitle(time?time:""); 149 if (master) 150 t->SetBit(kHasMaster); 141 151 142 152 if (!fEnableAutoScheme) … … 154 164 // Schedule a file or several files (using widcards) for reading. 155 165 // 156 // All calls to AddTree _must_ be beforethe calls to AddFile!166 // All calls to AddTree _must_ be BEFORE the calls to AddFile! 157 167 // 158 168 Int_t MReadReports::AddFile(const char *fname, Int_t entries) … … 188 198 while ((tree=(MReadTree*)NextT())) 189 199 { 200 if (((TChain*)tree->fChain)->GetListOfFiles()->GetEntries()==0) 201 { 202 *fLog << warn << "No files for Tree " << tree->GetName() << "... skipped." << endl; 203 continue; 204 } 205 190 206 TString tn(tree->GetTitle()); 191 207 if (tn.IsNull()) … … 224 240 } 225 241 226 fPos .Set(i);242 fPosEntry.Set(i); 227 243 228 244 return fTrees->CallPreProcess(plist); … … 241 257 // -------------------------------------------------------------------------- 242 258 // 259 // Do not use if fChains->GetSize()==0 !!! 260 // 261 Int_t MReadReports::FindNextTime() 262 { 263 Int_t i=0; 264 265 TIter NextC(fChains); 266 TChain *c=0; 267 268 Int_t nmin=0; 269 MTime tmin(**GetTime((TChain*)NextC())); 270 271 while ((c=(TChain*)NextC())) 272 { 273 MTime &t = **GetTime(c); 274 i++; 275 276 if (t >= tmin) 277 continue; 278 279 tmin = t; 280 nmin = i; 281 } 282 return nmin; 283 } 284 285 /* 286 Bool_t MReadReports::Notify() 287 { 288 Bool_t same = kTRUE; 289 for (int i=1; i<fPosTree.GetSize(); i++) 290 if (fPosTree[i]!=fPosTree[0]) 291 { 292 same = kFALSE; 293 break; 294 } 295 296 Int_t tn = chain->GetTreeNumber(); 297 298 Bool_t read=kFALSE; 299 if (fPosTree[nmin] != tn) 300 { 301 fPosTree[nmin] = tn; 302 read = kTRUE; 303 } 304 305 if (!same || !read) 306 return kTRUE; 307 308 309 *fLog << dbg << "Read Run Headers!" << endl; 310 311 return kTRUE; 312 } 313 */ 314 315 // -------------------------------------------------------------------------- 316 // 243 317 // Check which is the next tree to read from. Read an event from this tree. 244 318 // Sets the StreamId accordingly. … … 248 322 while (fChains->GetSize()) 249 323 { 250 Int_t i=0; 251 252 MTime tmin; 253 254 Int_t nmin=0; 255 256 TIter NextC(fChains); 257 TChain *c=0; 258 while ((c=(TChain*)NextC())) 324 const Int_t nmin=FindNextTime(); 325 326 TChain *chain = (TChain*)fChains->At(nmin); 327 328 //Int_t before = chain->GetTreeNumber(); 329 if (chain->GetEntry(++fPosEntry[nmin])>0) 259 330 { 260 MTime &t = **GetTime(c); 261 262 if (i==0) 263 tmin = t; 264 265 if (t < tmin) 331 MTask *task = (MTask*)fTrees->GetList()->At(nmin); 332 333 if (task->CallProcess()) 266 334 { 267 tmin = t;268 nmin = i;335 fList->SetStreamId(task->GetName()); 336 return kTRUE; 269 337 } 270 i++;271 }272 273 TChain *chain = (TChain*)fChains->At(nmin);274 275 chain->GetEntry(++fPos[nmin]);276 277 // FIXME: Use Stream ID and call CallProcess() ?278 Bool_t rc = ((MTask*)fTrees->GetList()->At(nmin))->CallProcess();279 if (rc)280 {281 fList->SetStreamId(fTrees->GetList()->At(nmin)->GetName());282 return kTRUE;283 338 } 284 339 -
trunk/MagicSoft/Mars/mfileio/MReadReports.h
r2604 r2607 17 17 { 18 18 private: 19 MTaskList *fTrees; // Hold the trees which are scheduled for reading20 TList *fChains; // Hold TChains to read the times in advance19 MTaskList *fTrees; // Hold the trees which are scheduled for reading 20 TList *fChains; // Hold TChains to read the times in advance 21 21 22 TArrayL fPos; // Store the position in each tree/chain 22 TArrayL fPosEntry; // Store the position in each tree/chain 23 TArrayL fPosTree; // Number of Tree in file. 23 24 24 MTask *fList; // pointer to the task list to set the stream id25 MTask *fList; // pointer to the task list to set the stream id 25 26 26 27 Bool_t fEnableAutoScheme; 27 28 28 29 MTime** GetTime(TChain *c) const; 30 Int_t FindNextTime(); 29 31 30 32 UInt_t GetEntries() { return 0; } … … 34 36 Int_t PostProcess(); 35 37 38 //Bool_t Notify(); 39 40 enum { 41 //MReadTree::kChainWasChanged = BIT(14) 42 kHasMaster = BIT(15) 43 }; 44 36 45 public: 37 46 MReadReports(); 38 47 ~MReadReports(); 39 48 40 void AddTree(const char *tree, const char *time=NULL); 49 void AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE); 50 void AddTree(const char *tree, Bool_t master) 51 { 52 AddTree(tree, NULL, master); 53 } 41 54 Int_t AddFile(const char *fname, Int_t entries=-1); 42 55 void AddToBranchList(const char *name); … … 44 57 void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const; 45 58 46 void EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } 59 void EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } // Must be called BEFORE AddTree! 47 60 48 61 ClassDef(MReadReports, 0) // Reads events and reports from a root file ordered in time -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r2532 r2607 192 192 continue; 193 193 194 *fLog << err << "ERROR - File corrupt tion detected:" << endl;194 *fLog << err << "ERROR - File corruption detected:" << endl; 195 195 *fLog << " Due to several circumstances (such at a bug in MReadTree or wrong" << endl; 196 196 *fLog << " usage of the file UPDATE mode) you may have produced a file in which" << endl; … … 232 232 *fLog << GetNumEntry()-1 << ")" << endl; 233 233 234 //fNotify->Notify(); 234 if (!fNotify) 235 return kTRUE; 236 237 TIter Next(fNotify); 238 TObject *o=NULL; 239 while ((o=Next())) 240 if (!o->Notify()) 241 { 242 *fLog << err << "Calling Notify() for object " << o->GetName() << " failed... abort." << endl; 243 return kFALSE; 244 } 235 245 236 246 return kTRUE; -
trunk/MagicSoft/Mars/mraw/MRawCrateArray.cc
r1082 r2607 81 81 } 82 82 83 void MRawCrateArray::Print(Option_t *t) const 84 { 85 fArray->Print(); 86 } 87 83 88 void MRawCrateArray::SetSize(Int_t i) 84 89 { -
trunk/MagicSoft/Mars/mraw/MRawCrateArray.h
r1031 r2607 24 24 25 25 void Clear(Option_t *opt=NULL); 26 void Print(Option_t *t=NULL) const; 26 27 27 28 void SetSize(Int_t i); -
trunk/MagicSoft/Mars/readdaq.cc
r2580 r2607 54 54 gLog << " -vn: Verbosity level n [default=2]" << endl; 55 55 gLog << " -d1: print data in decimal values" << endl; 56 gLog << " -c1: print MRawCrateArray data" << endl; 56 57 gLog << " -?/-h: This help" << endl << endl; 57 58 } … … 80 81 gLog.SetNoColors(); 81 82 82 const bool kDecimal = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1; 83 const bool kDecimal = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1; 84 const bool kPrintArray = arg.HasOption("-c") && arg.GetIntAndRemove("-c")==1; 83 85 84 86 // … … 164 166 tasks.AddToList(&print1); 165 167 tasks.AddToList(&print2); 166 tasks.AddToList(&print3); 168 if (kPrintArray) 169 tasks.AddToList(&print3); 167 170 tasks.AddToList(&print4); 168 171
Note:
See TracChangeset
for help on using the changeset viewer.