Changeset 2728 for trunk/MagicSoft/Mars/mraw
- Timestamp:
- 12/20/03 13:46:17 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mraw
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
r2580 r2728 236 236 } 237 237 238 Bool_t MRawEvtHeader::DecodeTime(UInt_t abstime[2]) const 239 { 240 // BADC|1032 --> DCBA|3210 (Byte swap - exchange MSB and LSB) 241 abstime[0] = (abstime[0]<<16) | (abstime[0]>>16); 242 abstime[1] = (abstime[1]<<16) | (abstime[1]>>16); 243 244 const Byte_t h = (abstime[0]>>18 & 0x30)*10 + (abstime[0]>>14 & 0x0f); 245 const Byte_t m = (abstime[0]>>11 & 0x70)*10 + (abstime[0]>> 7 & 0x0f); 246 const Byte_t s = (abstime[0]>> 4 & 0x70)*10 + (abstime[0]>> 0 & 0x0f); 247 const Int_t ms = 248 ((abstime[1]>>16)&0xf)*1000 + 249 ((abstime[1]>> 8)&0xf)* 100 + 250 ((abstime[1]>> 4)&0xf)* 10 + 251 ((abstime[1]>> 0)&0xf)* 1; 252 253 // hms =3210 --> h=2:4 m=3:4 s=3:4 254 // subsec=DCBA --> subsec? 255 *fLog << dbg << dec; 256 *fLog << (int)(abstime[0]>>18 & 0x30); // h 257 *fLog << (int)(abstime[0]>>14 & 0x0f); // h 258 *fLog << ":"; 259 *fLog << (int)(abstime[0]>>11 & 0x70); // m 260 *fLog << (int)(abstime[0]>> 7 & 0x0f); // m 261 *fLog << ":"; 262 *fLog << (int)(abstime[0]>> 4 & 0x70); // s 263 *fLog << (int)(abstime[0]>> 0 & 0x0f); // s 264 *fLog << " "; 265 *fLog << (int)(abstime[1]>>16 & 0xf) << "."; 266 *fLog << (int)(abstime[1]>> 8 & 0xf) << "."; 267 *fLog << (int)(abstime[1]>> 4 & 0xf) << "."; 268 *fLog << (int)(abstime[1]>> 0 & 0xf); 269 *fLog << endl; 270 271 // Update the time stamp with the current event time. 272 // Make sure, that the time stamp was initialized correctly 273 // with the start-date/time of the run (after reading the run header) 274 // 275 // Here the nanosec precision is ignored... (FIXME!) 276 return fTime->UpdMagicTime(h, m, s, ms); 277 } 278 238 279 // -------------------------------------------------------------------------- 239 280 // … … 241 282 // return FALSE if there is now header anymore, else TRUE 242 283 // 284 // Updates the time stamp with the current event time. 285 // Make sure, that the time stamp was initialized correctly 286 // with the start-date/time of the run (after reading the run header) 287 // 288 // Remark: This 'feature' disallows single runs of more than 11h! 289 // 243 290 int MRawEvtHeader::ReadEvt(istream &fin) 244 291 { 245 292 fin.read((char*)&fDAQEvtNumber, 4); // Total=4 246 293 247 UInt_t abstime[2]; 294 UInt_t abstime[2]; // BADC|1032 248 295 fin.read((char*)abstime, 8); // Total=12 249 250 // 251 // store the time of the event in the corresponding container 252 // 253 /* 254 const Double_t mhz = 9.375; // [1e6 ticks/s] 255 const Double_t t = (Double_t)abstime[0]/mhz; // [ns] 256 const UShort_t ns = (UShort_t)fmod(t*1e-3, 1e9); 257 const Byte_t s = (Byte_t)fmod(t/1e12, 60); 258 const Byte_t m = (Byte_t)fmod(t/60e12, 60); 259 const Byte_t h = (Byte_t)(t/3600e12); 260 fTime->SetTime(h, m, s, ns); 261 */ 296 if (!DecodeTime(abstime)) 297 { 298 *fLog << err << "ERROR - Event time in event header invalid... abort." << endl; 299 return kFALSE; 300 } 262 301 263 302 Byte_t dummy[4]; -
trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h
r2173 r2728 44 44 MArrayB *fPixLoGainOn; //! Array which tell you which pixels have lo gain on 45 45 46 Bool_t DecodeTime(UInt_t abstime[2]) const; 47 46 48 public: 47 48 49 MRawEvtHeader(const char *name=NULL, const char *title=NULL); 49 50 ~MRawEvtHeader(); -
trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
r2675 r2728 151 151 fRawRunHeader->Print(); 152 152 153 return fRawRunHeader->GetMagicNumber()==kMagicNumber; 153 if (fRawRunHeader->GetMagicNumber()!=kMagicNumber) 154 return kFALSE; 155 156 *fRawEvtTime = fRawRunHeader->GetRunStart(); 157 158 return kTRUE; 154 159 } 155 160 -
trunk/MagicSoft/Mars/mraw/MRawRead.cc
r2675 r2728 125 125 } 126 126 127 // -------------------------------------------------------------------------- 128 // 129 // This is a workaround for the oldest runs (run-number<3490) 130 // for which no time stamp was available. 131 // For this runs a fake time stamp is created 132 // 133 // Be carefull: This is NOT thread safe! 134 // 135 void MRawRead::CreateFakeTime() const 136 { 137 static Double_t tm = 0; // Range of roughly 8min 138 const UInt_t ct = (*fRawCrateArray)[0]->GetFADCClockTick(); 139 140 tm = ct<tm ? fmod(tm, (UInt_t)(-1))+(UInt_t)(-1)+ct : ct; 141 142 const Double_t mhz = 9.375; // [1e6 ticks/s] 143 const Double_t t = tm/mhz; // [us] 144 const UInt_t ns = (UInt_t)fmod(t*1e3, 1e6); 145 const UShort_t ms = (UShort_t)fmod(t/1e3, 1e3); 146 const Byte_t s = (Byte_t)fmod(t/1e6, 60); 147 148 // Create an artificial time stamp! 149 UInt_t m = (Byte_t)fmod(t/60e6, 60); 150 //const Byte_t h = (Byte_t)(t/3600e6); 151 m += fRawRunHeader->GetRunNumber()*10; 152 m %= 360; // 6h 153 154 fRawEvtTime->Set(fRawRunHeader->GetRunStart().Year(), 155 fRawRunHeader->GetRunStart().Month(), 156 fRawRunHeader->GetRunStart().Day(), 157 m/60, m%60, s, ms, ns); 158 } 159 160 // -------------------------------------------------------------------------- 161 // 162 // Read a single event from the stream 163 // 127 164 Bool_t MRawRead::ReadEvent(istream &fin) 128 165 { … … 169 206 } 170 207 171 { 172 // FIXME This is a stupid workaround for the missing time stamp! 173 // Might be used depending on the run number in the future 174 static Double_t tm = 0; // Range of roughly 8min 175 const UInt_t ct = (*fRawCrateArray)[0]->GetFADCClockTick(); 176 177 tm = ct<tm ? fmod(tm, (UInt_t)(-1))+(UInt_t)(-1)+ct : ct; 178 179 const Double_t mhz = 9.375; // [1e6 ticks/s] 180 const Double_t t = tm/mhz; // [us] 181 const UInt_t ns = (UInt_t)fmod(t*1e3, 1e6); 182 const UShort_t ms = (UShort_t)fmod(t/1e3, 1e3); 183 const Byte_t s = (Byte_t)fmod(t/1e6, 60); 184 185 // Create an artificial time stamp! 186 UInt_t m = (Byte_t)fmod(t/60e6, 60); 187 //const Byte_t h = (Byte_t)(t/3600e6); 188 m += fRawRunHeader->GetRunNumber()*10; 189 m %= 360; // 6h 190 191 fRawEvtTime->Set(fRawRunHeader->GetRunStart().Year(), 192 fRawRunHeader->GetRunStart().Month(), 193 fRawRunHeader->GetRunStart().Day(), 194 m/60, m%60, s, ms, ns); 195 } 208 // This is a workaround for the oldest runs (run-number<3490) 209 // for which no time stamp was available. 210 // For this runs a fake time stamp is created 211 if (fRawRunHeader->GetRunNumber()<3490) 212 CreateFakeTime(); 213 214 // FIXME: For all other runs we should enhance the precision 215 // of the time-stamp by using the FADCClockTick 216 196 217 return kTRUE; 197 218 } -
trunk/MagicSoft/Mars/mraw/MRawRead.h
r2677 r2728 22 22 MTime *fRawEvtTime; // raw evt time information container to fill from file 23 23 24 void CreateFakeTime() const; 25 24 26 Bool_t ReadEvent(istream &fin); 25 27 Int_t PreProcess(MParList *pList); -
trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc
r2645 r2728 29 29 // Root storage container for the RUN HEADER information 30 30 // 31 // 32 // 33 // Version 2: 34 // ---------- 31 // Format Version 2: 32 // ----------------- 33 // - removed mjd from data 34 // - added start time 35 // - added stop time 36 // 37 // Class Version 2: 38 // ---------------- 35 39 // - removed fMJD, fYear, fMonth, fDay 36 40 // - added fRunStart 37 41 // - added fRunStop 38 42 // 39 // Version 1:40 // ---------- 43 // Class Version 1: 44 // ---------------- 41 45 // - first implementation 42 46 // … … 212 216 for (int i=0; i<GetNumPixel(); i++) 213 217 *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " "; 214 *fLog << hex << endl;215 218 216 219 *fLog << endl; -
trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc
r2675 r2728 252 252 } 253 253 254 *fRawEvtTime = fRawRunHeader->GetRunStart(); 255 254 256 if (!ReadEvent(*fIn)) 255 257 return kFALSE;
Note:
See TracChangeset
for help on using the changeset viewer.