#include <RawLinearizedDataBlock.h>
Inheritance diagram for RawLinearizedDataBlock:

Public Member Functions | |
| RawLinearizedDataBlock () | |
| RawLinearizedDataBlock (const Int_t *block) | |
| virtual | ~RawLinearizedDataBlock () |
| Int_t | GetRun () const |
| Short_t | GetSubRun () const |
| Short_t | GetRunType () const |
| VldTimeStamp | GetTimeStamp () const |
| Detector::Detector_t | GetDetector () const |
| ElecType::Elec_t | GetElecType () const |
| Bool_t | GetPedMode () const |
| Bool_t | GetSparsMode () const |
| Bool_t | GetCommonMode () const |
| UShort_t | GetCrate () const |
| Int_t | GetCrateIdInfo () const |
| Int_t | GetTimeFrameNum () const |
| UInt_t | GetNumLocations () const |
| UInt_t | GetLocation (UInt_t indx) const |
| UInt_t | GetNumPoints (UInt_t loc) const |
| UInt_t | GetNumEntries (UInt_t loc, UInt_t ipt) const |
| Double_t | GetMean (UInt_t loc, UInt_t ipt) const |
| Double_t | GetRms (UInt_t loc, UInt_t ipt) const |
| UInt_t | GetSum (UInt_t loc, UInt_t ipt) const |
| unsigned long long | GetSumSqr (UInt_t loc, UInt_t ipt) const |
| Double_t | GetMean (UInt_t loc) const |
| Double_t | GetRms (UInt_t loc) const |
| Int_t | GetTimeFrameNo () const |
| virtual std::ostream & | FormatToOStream (std::ostream &os, Option_t *option="") const |
| RawLinearizedDataBlock (const RawLinearizedDataBlock &rhs) | |
| RawLinearizedDataBlock & | operator= (const RawLinearizedDataBlock &rhs) |
Static Public Member Functions | |
| void | SetDebugFlags (const UInt_t dbgflgs) |
| UInt_t | GetDebugFlags () |
Protected Member Functions | |
| void | FillCrateId () const |
| UInt_t | FillLocStart () const |
| const Int_t * | StartOfLocPoint (UInt_t loc, UInt_t ipt) const |
Protected Attributes | |
| std::vector< UInt_t > | fLocation |
| std::map< UInt_t, const Int_t * > | fLocStart |
| list of locations | |
| RawChannelId | fCrateId |
| where sub-block starts | |
Static Private Attributes | |
| UInt_t | fgDebugFlags = 0 |
| unpacked crateinfo | |
|
|
Definition at line 54 of file RawLinearizedDataBlock.cxx. 00055 : RawDataBlock() 00056 { 00057 // Default constructor 00058 }
|
|
|
Definition at line 61 of file RawLinearizedDataBlock.cxx. 00062 : RawDataBlock(block) 00063 { 00064 // stored block format is: 00065 //--------------------- 00066 // version 0 version 1 00067 // 0 # words in block # words in block 00068 // 1 checksum checksum 00069 // 2 Block Id Block Id 00070 //----- 00071 // 3 run # run # 00072 // 4 {subrun #| run type} {subrun #| run type} 00073 // 5 trigger time (sec) trigger time (sec) 00074 // 6 trigger time (nsec) trigger time (nsec) 00075 // 7 timeframe # crateid 00076 // 8 --n/a-- timeframe # 00077 // 9 --n/a-- nlocations 00078 /* 00079 * The data has the following reapeating structure until 00080 * all channels are completed: 00081 * long unsigned int location; -- bit packed 00082 * long nPoints; 00083 * nPoints * struct { long nEntries; 00084 * long unsigned int sum; 00085 * long unsigned int sum_sqr(high word); 00086 * long unsigned int sum_sqr(low word); 00087 * } 00088 */ 00089 00090 }
|
|
|
Definition at line 93 of file RawLinearizedDataBlock.cxx. 00094 {
00095 // dtor
00096 }
|
|
|
Definition at line 72 of file RawLinearizedDataBlock.h. References fCrateId, fLocation, and fLocStart. 00073 : RawDataBlock(rhs), fCrateId() { fLocation.clear(); fLocStart.clear(); }
|
|
|
Definition at line 329 of file RawLinearizedDataBlock.cxx. References fCrateId, RawDataBlock::GetBlockId(), GetCrateIdInfo(), GetDetector(), RawDataBlock::GetMinorId(), RawChannelId::IsNull(), MSG, and RawChannelId::SetDetector(). Referenced by FormatToOStream(), GetCommonMode(), GetCrate(), GetDetector(), GetElecType(), GetPedMode(), and GetSparsMode(). 00330 {
00331 // unpack crate info
00332 if (!fCrateId.IsNull()) return;
00333 if (GetMinorId() <= 0) {
00334 fCrateId.SetDetector(GetBlockId().GetDetector());
00335 MSG("RawData",Msg::kWarning)
00336 << " No crate info for minor version " << GetMinorId() << endl;
00337 return;
00338 }
00339 fCrateId = RawChannelId(GetBlockId().GetDetector(),GetCrateIdInfo(),0x1fff);
00340 }
|
|
|
Definition at line 343 of file RawLinearizedDataBlock.cxx. References fLocation, fLocStart, RawDataBlock::GetMinorId(), and MSG. Referenced by GetLocation(), GetNumLocations(), GetNumPoints(), and StartOfLocPoint(). 00344 {
00345 // calculate how many distinct locations are recorded
00346 // each might have a different number of points recorded
00347 // fill vector of pointers to start of each location's data
00348 // if already filled just return
00349
00350 if (!fLocStart.empty()) return fLocStart.size();
00351
00352 int zzzz_last_v = zzzz_last;
00353 if (GetMinorId() <= 0) zzzz_last_v = zzzz_last_v0;
00354 const Int_t *ptr = fRawBlock + zzzz_last_v; // start of packed data
00355 const Int_t *end = fRawBlock + fSize; // one beyond end
00356
00357 while ( ptr < end ) {
00358 Int_t loc = *ptr;
00359 Int_t npts = *(ptr+1);
00360 // bitch wildly if already an entry for this "location"
00361 if (fLocStart[loc])
00362 MSG("RawData",Msg::kError)
00363 << " Already have an sub-block unit for 'location' 0x"
00364 << hex << setfill('0') << setw(8) << loc
00365 << setfill(' ') << dec << endl
00366 << " at offset 0x"
00367 << hex << setfill('0') << setw(8) << (fLocStart[loc]-fRawBlock)
00368 << setfill(' ') << dec
00369 << " found again at 0x"
00370 << hex << setfill('0') << setw(8) << (ptr-fRawBlock)
00371 << setfill(' ') << dec
00372 << endl;
00373 fLocation.push_back(loc);
00374 fLocStart[loc] = ptr;
00375 // skip loc+npts + npts*(entries,range,s,s2)
00376 Int_t skip = 2 + npts*linDataPointIntSize;
00377 ptr += skip;
00378 }
00379
00380 if ( ptr != end )
00381 MSG("RawData",Msg::kError) << endl
00382 << "FillLocStart() unpacking did not end evenly at block boundary"
00383 << endl;
00384
00385 return fLocStart.size();
00386 }
|
|
||||||||||||
|
Reimplemented from RawDataBlock. Definition at line 418 of file RawLinearizedDataBlock.cxx. References RawChannelId::AsString(), VldTimeStamp::AsString(), fCrateId, FillCrateId(), RawDataBlock::FormatToOStream(), GetLocation(), GetMean(), RawDataBlock::GetMinorId(), GetNumEntries(), GetNumLocations(), GetNumPoints(), GetRms(), GetRun(), GetRunType(), GetSubRun(), GetSum(), GetSumSqr(), GetTimeFrameNum(), GetTimeStamp(), and option. 00420 {
00421
00422 RawDataBlock::FormatToOStream(os,option);
00423 if (option[0] == 'X') return os;
00424
00425 // additional block specific formatted output is done here
00426
00427 os << " Run " << GetRun() << " SubRun " << GetSubRun()
00428 << " RunType " << GetRunType() << " TimeFrame " << GetTimeFrameNum()
00429 << endl
00430 << " TimeStamp " << GetTimeStamp().AsString("c") << endl;
00431 if (GetMinorId()>0) {
00432 FillCrateId();
00433 os << " CrateId " << fCrateId.AsString("C") << ", ";
00434 }
00435 UInt_t nloc = GetNumLocations();
00436 os << " " << nloc << " 'locations' "<< endl;
00437
00438 // xx'location'
00439 // xxxx[123] range entries mean RMS
00440 // 0x12345678 has ?? points
00441 // [123] 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890
00442 os << " ----- entries mean RMS Sum SumSqr" << endl;
00443 for (UInt_t indx = 0; indx < nloc; ++indx) {
00444 UInt_t loc = GetLocation(indx);
00445 UInt_t npt = GetNumPoints(loc);
00446 os << " location 0x"
00447 << hex << setfill('0') << setw(8) << loc << setfill(' ') << dec
00448 << " ( index = " << setw(3) << indx << " )"
00449 << " has " << npt << " points" << endl;
00450 for (UInt_t ipt = 0; ipt < npt; ++ipt) {
00451 os << " [" << setw(3) << ipt << "] "
00452 //<< setw(8) << GetRange(loc,ipt) << " "
00453 << " "
00454 << setw(8) << GetNumEntries(loc,ipt) << " "
00455 << setw(12) << GetMean(loc,ipt) << " "
00456 << setw(12) << GetRms(loc,ipt) << " "
00457 << setw(10) << GetSum(loc,ipt) << " "
00458 << setw(12) << GetSumSqr(loc,ipt)
00459 << endl;
00460 }
00461 }
00462 return os;
00463 }
|
|
|
Definition at line 115 of file RawLinearizedDataBlock.h. References fCrateId, FillCrateId(), and RawChannelId::GetCommonMode(). 00116 { FillCrateId(); return fCrateId.GetCommonMode(); }
|
|
|
Definition at line 118 of file RawLinearizedDataBlock.h. References fCrateId, FillCrateId(), and RawChannelId::GetCrate(). 00119 { FillCrateId(); return fCrateId.GetCrate(); }
|
|
|
Definition at line 148 of file RawLinearizedDataBlock.cxx. References RawDataBlock::GetMinorId(). Referenced by FillCrateId(). 00149 {
00150 // get the crate id word
00151 if (GetMinorId() <= 0) return -1; // didn't exist in this version
00152 if (fSize > indx_crateid) return fRawBlock[indx_crateid];
00153 return -1;
00154 }
|
|
|
Definition at line 69 of file RawLinearizedDataBlock.h. 00069 { return fgDebugFlags; }
|
|
|
Definition at line 103 of file RawLinearizedDataBlock.h. References fCrateId, FillCrateId(), and RawChannelId::GetDetector(). Referenced by FillCrateId(). 00104 { FillCrateId(); return fCrateId.GetDetector(); }
|
|
|
Definition at line 106 of file RawLinearizedDataBlock.h. References fCrateId, FillCrateId(), and RawChannelId::GetElecType(). 00107 { FillCrateId(); return fCrateId.GetElecType(); }
|
|
|
Definition at line 186 of file RawLinearizedDataBlock.cxx. References FillLocStart(), fLocation, and MSG. Referenced by FormatToOStream(). 00187 {
00188 // report "location" associated with sub-block index by "indx"
00189
00190 UInt_t nloc = FillLocStart();
00191 if ( indx >= nloc) { // zero based indexing
00192 MSG("RawData",Msg::kError)
00193 << "indx " << indx << " out of range: there are only "
00194 << nloc << " entries" << endl;
00195 return illegalLocation;
00196 }
00197 return fLocation[indx];
00198 }
|
|
|
Definition at line 279 of file RawLinearizedDataBlock.cxx. References GetNumPoints(), LinDataPoint::nEntries, StartOfLocPoint(), and LinDataPoint::sum. 00280 {
00281 // the "range" that the sub-sub-block corresponds to
00282 // "location", averaged over all points
00283
00284 // use 'long long' to accumulate multiple points
00285 // before conversion to double to avoid potential loss of precision
00286 unsigned long long sumofentries = 0;
00287 unsigned long long sumofsums = 0;
00288
00289 UInt_t npts = GetNumPoints(loc);
00290 for (UInt_t ipt = 0; ipt < npts; ++ipt) {
00291 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00292 sumofentries += ptr->nEntries;
00293 sumofsums += ptr->sum;
00294 }
00295 if (sumofentries) return 0; // don't divide by zero
00296 return (Double_t)sumofsums/(Double_t)sumofentries;
00297 }
|
|
||||||||||||
|
Definition at line 223 of file RawLinearizedDataBlock.cxx. References LinDataPoint::nEntries, StartOfLocPoint(), and LinDataPoint::sum. Referenced by FormatToOStream(). 00224 {
00225 // the "range" that the sub-sub-block corresponds to
00226 // "location" and point # "ipt"
00227
00228 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00229 if (!ptr) return 0;
00230 if (!ptr->nEntries) return 0; // don't divide by zero
00231 return (Double_t)ptr->sum/(Double_t)ptr->nEntries;
00232 }
|
|
||||||||||||
|
Definition at line 212 of file RawLinearizedDataBlock.cxx. References LinDataPoint::nEntries, and StartOfLocPoint(). Referenced by FormatToOStream(). 00213 {
00214 // the number of entries that went into the sub-sub-block
00215 // related to "location" and point # "ipt"
00216
00217 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00218 if (!ptr) return 0;
00219 return ptr->nEntries;
00220 }
|
|
|
Definition at line 167 of file RawLinearizedDataBlock.cxx. References FillLocStart(), RawDataBlock::GetMinorId(), and MSG. Referenced by FormatToOStream(). 00168 {
00169 // calculate how many distinct locations are recorded
00170 // each might have a different number of points recorded
00171
00172 UInt_t minor = GetMinorId();
00173 UInt_t nloc_unpacked = FillLocStart();
00174 if (minor > 0) {
00175 UInt_t nloc_stored = fRawBlock[indx_nloc];
00176 if (nloc_stored != nloc_unpacked)
00177 MSG("RawData",Msg::kError)
00178 << " Unpacking found " << nloc_unpacked
00179 << " 'location', while data claims " << nloc_stored
00180 << " were stored" << endl;
00181 }
00182 return nloc_unpacked;
00183 }
|
|
|
Definition at line 201 of file RawLinearizedDataBlock.cxx. References FillLocStart(), and fLocStart. Referenced by FormatToOStream(), GetMean(), and GetRms(). 00202 {
00203
00204 // treat each sub-block as indexed by "location"
00205
00206 FillLocStart();
00207 const Int_t* ptr = fLocStart[loc]; // this is "location"
00208 return *(ptr+1); // this is "nPoints"
00209 }
|
|
|
Definition at line 109 of file RawLinearizedDataBlock.h. References fCrateId, FillCrateId(), and RawChannelId::GetPedMode(). 00110 { FillCrateId(); return fCrateId.GetPedMode(); }
|
|
|
Definition at line 300 of file RawLinearizedDataBlock.cxx. References GetNumPoints(), LinDataPoint::nEntries, StartOfLocPoint(), LinDataPoint::sum, LinDataPoint::sum_sqr_high, and LinDataPoint::sum_sqr_low. 00301 {
00302 // the RMS that the sub-sub-block corresponds to
00303 // "location", averaged over all points
00304
00305 // use 'long long' to accumulate multiple points
00306 // before conversion to double to avoid potential loss of precision
00307 unsigned long long sumofentries = 0;
00308 unsigned long long sumofsums = 0;
00309 unsigned long long sumofsumsqrs = 0;
00310
00311 UInt_t npts = GetNumPoints(loc);
00312 for (UInt_t ipt = 0; ipt < npts; ++ipt) {
00313 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00314 sumofentries += ptr->nEntries;
00315 sumofsums += ptr->sum;
00316 //sumofsumsqrs += ptr->sum_sqr;
00317 unsigned long long this_sum_sqr =
00318 ( (unsigned long long)ptr->sum_sqr_high << 32) | ( ptr->sum_sqr_low );
00319 sumofsumsqrs += this_sum_sqr;
00320 }
00321 if (sumofentries) return 0; // don't divide by zero
00322 Double_t mean = (Double_t)sumofsums/(Double_t)sumofentries;
00323 Double_t sumx2byn = (Double_t)sumofsumsqrs/(Double_t)sumofentries;
00324 return TMath::Sqrt(sumx2byn - mean*mean);
00325
00326 }
|
|
||||||||||||
|
Definition at line 235 of file RawLinearizedDataBlock.cxx. References GetSumSqr(), LinDataPoint::nEntries, StartOfLocPoint(), and LinDataPoint::sum. Referenced by FormatToOStream(). 00236 {
00237 // the RMS that the sub-sub-block corresponds to
00238 // "location" and point # "ipt"
00239
00240 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00241 if (!ptr) return 0;
00242 if (!ptr->nEntries) return 0; // don't divide by zero
00243 Double_t n = (Double_t)ptr->nEntries;
00244 Double_t sumx = (Double_t)ptr->sum;
00245 unsigned long long isumx2 = GetSumSqr(loc,ipt);
00246 Double_t sumx2 = (Double_t)isumx2;
00247 Double_t mean = sumx/n;
00248 return TMath::Sqrt(sumx2/n - mean*mean);
00249
00250 }
|
|
|
Definition at line 114 of file RawLinearizedDataBlock.cxx. Referenced by FormatToOStream(). 00115 {
00116 // get the run number
00117 if (fSize > indx_run) return fRawBlock[indx_run];
00118 return -1;
00119 }
|
|
|
Definition at line 130 of file RawLinearizedDataBlock.cxx. Referenced by FormatToOStream(). 00131 {
00132 // get the run type
00133 if (fSize > indx_runtype) return fRawBlock[indx_runtype]&0xffff;
00134 return -1;
00135 }
|
|
|
Definition at line 112 of file RawLinearizedDataBlock.h. References fCrateId, FillCrateId(), and RawChannelId::GetSparsMode(). 00113 { FillCrateId(); return fCrateId.GetSparsMode(); }
|
|
|
Definition at line 122 of file RawLinearizedDataBlock.cxx. Referenced by FormatToOStream(). 00123 {
00124 // get the subrun number
00125 if (fSize > indx_subrun) return (fRawBlock[indx_subrun]>>16)&0xffff;
00126 return -1;
00127 }
|
|
||||||||||||
|
Definition at line 253 of file RawLinearizedDataBlock.cxx. References StartOfLocPoint(), and LinDataPoint::sum. Referenced by FormatToOStream(). 00254 {
00255 // the sum that the sub-sub-block corresponds to
00256 // "location" and point # "ipt"
00257
00258 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00259 if (!ptr) return 0;
00260 return ptr->sum;
00261
00262 }
|
|
||||||||||||
|
Definition at line 265 of file RawLinearizedDataBlock.cxx. References StartOfLocPoint(), LinDataPoint::sum_sqr_high, and LinDataPoint::sum_sqr_low. Referenced by FormatToOStream(), and GetRms(). 00266 {
00267 // the sum^2 that the sub-sub-block corresponds to
00268 // "location" and point # "ipt"
00269
00270 const LinDataPoint* ptr = (const LinDataPoint*)StartOfLocPoint(loc,ipt);
00271 if (!ptr) return 0;
00272 unsigned long long sum2 =
00273 ( (unsigned long long)ptr->sum_sqr_high << 32) | ( ptr->sum_sqr_low );
00274 return sum2;
00275
00276 }
|
|
|
Definition at line 63 of file RawLinearizedDataBlock.h. References GetTimeFrameNum(). 00063 { return GetTimeFrameNum(); }
|
|
|
Definition at line 157 of file RawLinearizedDataBlock.cxx. References RawDataBlock::GetMinorId(). Referenced by FormatToOStream(), and GetTimeFrameNo(). 00158 {
00159 // get the timeframe number
00160 int indx_tf_v = indx_tf;
00161 if (GetMinorId() <= 0) indx_tf_v--;
00162 if (fSize > indx_tf_v) return fRawBlock[indx_tf_v];
00163 return -1;
00164 }
|
|
|
Definition at line 138 of file RawLinearizedDataBlock.cxx. References indx_nsec, and indx_sec. Referenced by FormatToOStream(). 00139 {
00140 // get the trigger time
00141 if (fSize > indx_nsec)
00142 return VldTimeStamp(fRawBlock[indx_sec],fRawBlock[indx_nsec]);
00143
00144 return VldTimeStamp((time_t)0,(Int_t)0);
00145 }
|
|
|
Definition at line 100 of file RawLinearizedDataBlock.cxx. References fCrateId, fLocation, fLocStart, and RawDataBlock::operator=(). 00101 {
00102 // deep copy assignment
00103 if (this != &rhs) {
00104 RawDataBlock::operator=(rhs);
00105 fCrateId = rhs.fCrateId;
00106 // clear these to allow them to be re-filled
00107 fLocation.clear();
00108 fLocStart.clear();
00109 }
00110 return *this;
00111 }
|
|
|
Definition at line 68 of file RawLinearizedDataBlock.h. References fgDebugFlags. 00068 {fgDebugFlags=dbgflgs;}
|
|
||||||||||||
|
Definition at line 389 of file RawLinearizedDataBlock.cxx. References FillLocStart(), fLocStart, and MSG. Referenced by GetMean(), GetNumEntries(), GetRms(), GetSum(), and GetSumSqr(). 00390 {
00391
00392 // treat each sub-block as indexed by "location"
00393 // sub-sub-structures are indexed by "iptr" and offset by fixed amounts
00394
00395 FillLocStart(); // make sure we've scanned to find each sub-block
00396 const Int_t* ptr = fLocStart[loc];
00397 if (!ptr) {
00398 MSG("RawData",Msg::kError)
00399 << " No entry for 'location' 0x"
00400 << hex << setfill(' ') << setw(8) << loc
00401 << setfill(' ') << dec << endl;
00402 return 0;
00403 }
00404 UInt_t npts = *(ptr+1); // this is "nPoints";
00405 if ( ipt >= npts ) { // zero based indexing
00406 MSG("RawData",Msg::kError)
00407 << "ipt " << ipt << " for 'location' 0x"
00408 << hex << setfill(' ') << setw(8) << loc << setfill(' ') << dec
00409 << " that has only " << npts << " points" << endl;
00410 return 0;
00411 }
00412 // 2 skips loc+npoints, each struct is 4 long
00413 ptr += (2 + ipt*linDataPointIntSize);
00414 return ptr;
00415 }
|
|
|
where sub-block starts
Definition at line 93 of file RawLinearizedDataBlock.h. Referenced by FillCrateId(), FormatToOStream(), GetCommonMode(), GetCrate(), GetDetector(), GetElecType(), GetPedMode(), GetSparsMode(), operator=(), and RawLinearizedDataBlock(). |
|
|
unpacked crateinfo
Definition at line 15 of file RawLinearizedDataBlock.cxx. Referenced by SetDebugFlags(). |
|
|
Definition at line 90 of file RawLinearizedDataBlock.h. Referenced by FillLocStart(), GetLocation(), operator=(), and RawLinearizedDataBlock(). |
|
|
list of locations
Definition at line 91 of file RawLinearizedDataBlock.h. Referenced by FillLocStart(), GetNumPoints(), operator=(), RawLinearizedDataBlock(), and StartOfLocPoint(). |
1.3.9.1