1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <assert.h> 5 #include "StFileI.h" 6 7 ClassImp(StFileI) 8 //______________________________________________________________________________ 9 StUKey::StUKey(const char *name,UInt_t *uk,int nk) 10 { 11 if (name) SetName(name); 12 SetUrr(uk,nk); 13 } 14 //______________________________________________________________________________ 15 StUKey::StUKey(const char *name,UInt_t uk) 16 { 17 if (name) SetName(name); 18 SetUrr(&uk,1); 19 } 20 //______________________________________________________________________________ 21 StUKey::StUKey(UInt_t uRun,UInt_t uEvent) 22 { 23 UInt_t u[2]; u[0]=uRun; u[1]=uEvent; 24 int n = 1; if (u[1]) n=2; 25 SetUrr(u,n); 26 } 27 //______________________________________________________________________________ 28 void StUKey::SetUrr(const UInt_t *uk,int nk) 29 { 30 int n; 31 fNUrr = 1; 32 fUrr[0] = 0; 33 if (!uk) return; 34 for (n=1;n<nk && uk[n]; n++){} 35 fNUrr = n; 36 memcpy(fUrr,uk,nk*sizeof(UInt_t)); 37 } 38 //______________________________________________________________________________ 39 StUKey &StUKey::operator=( const StUKey &from) 40 { 41 SetName(from.GetName()); 42 SetUrr(from.fUrr,from.fNUrr); 43 return *this; 44 } 45 //______________________________________________________________________________ 46 StUKey &StUKey::operator=( UInt_t from) 47 { 48 SetUrr(&from,1); 49 return *this; 50 } 51 //______________________________________________________________________________ 52 StUKey &StUKey::operator=( const char *from) 53 { 54 SetName(from); 55 return *this; 56 } 57 //______________________________________________________________________________ 58 void StUKey::Update( const StUKey &from, const char *name) 59 { 60 SetUrr(from.fUrr,from.fNUrr); 61 if (name) SetName(name); 62 } 63 //______________________________________________________________________________ 64 TString StUKey::GetKey() const 65 { 66 char ubuf[12]; 67 TString tk(fName); 68 for (int i=0;i<fNUrr;i++){ 69 tk +="."; 70 sprintf(ubuf,"%010u",fUrr[i]); 71 tk +=ubuf;} 72 return tk; 73 } 74 //______________________________________________________________________________ 75 void StUKey::SetKey(const char *key) 76 { 77 const char *cc; 78 int n = strchr(key,'.') - key; 79 assert(n>0 && n<100); 80 fName.Replace(0,999,key,n); 81 for (fNUrr = 0,cc=key+n;*cc=='.'; cc+=11) 82 fUrr[fNUrr++] = strtoul(cc+1,0,10); 83 } 84 //______________________________________________________________________________ 85 UInt_t StUKey::GetSum() const 86 { 87 UInt_t s = fUrr[0]; 88 for (int i=1;i<fNUrr;i++) s^=fUrr[i]; 89 return s; 90 } 91 //______________________________________________________________________________ 92 StUKey StFileI::GetNextEvent() 93 { 94 UInt_t u[9] = {0,0,0,0,0,0,0,0,0}; 95 int ret = GetNextEvent(u); 96 if (ret) u[0]=kUMAX; 97 StUKey uk(0,u,9); 98 return uk; 99 } 100 101