All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRTTiming.cc
Go to the documentation of this file.
1 #ifndef CRT_TIMING_CC
2 #define CRT_TIMING_CC
3 
4 //#include "./CRTTiming.h"
6 
7 
8 using namespace icarus::crt;
9 
11  fPre = ⪯
12  fRaw = 0;
13  fHasSort = false;
14  fType='p';
16 }
17 
19  fRaw = &raw;
20  fPre = 0;
21  fHasSort = false;
22  fType = 'r';
24 }
25 
27 
28  vector<pair<size_t,uint64_t>> pairs;
29 
30  for(size_t ientry=0; ientry<fNEntries; ientry++) {
31  uint64_t t0=0;
32  if(fType=='p') t0 = fPre->GetAbsTime(ientry);
33  if(fType=='r') t0 = fRaw->GetAbsTime(ientry);
34  pairs.push_back(make_pair(ientry,t0));
35  }
36 
37  std::sort(pairs.begin(),pairs.end(),[](pair<size_t,uint64_t> a, pair<size_t,uint64_t> b) {
38  return a.second < b.second;
39  });
40 
41  for(size_t ientry=0; ientry<fNEntries; ientry++) {
42  fRawToOrdered[pairs[ientry].first] = ientry;
43  fOrderedToRaw[ientry] = pairs[ientry].first;
44  }
45 
46  fHasSort = true;
47 
48  return;
49 }
50 
51 const map<size_t,size_t>* CRTTiming::GetRawToOrderedMap() {
52 
53  if(!fHasSort) TimeOrder();
54 
55  return &fRawToOrdered;
56 }
57 
58 const map<size_t,size_t>* CRTTiming::GetOrderedToRawMap() {
59 
60  if(!fHasSort) TimeOrder();
61 
62  return &fOrderedToRaw;
63 }
64 
65 void CRTTiming::DumpSortedTimes(size_t nmax=0) {
66  for(size_t i=0; i<fNEntries; i++) {
67  if(nmax!=0 && i==nmax) return;
68 
69  if(fType=='p') std::cout << fPre->GetAbsTime(fOrderedToRaw[i]) << std::endl;
70  if(fType=='r') std::cout << fRaw->GetAbsTime(fOrderedToRaw[i]) << std::endl;
71 
72  }
73 }
74 
75 void CRTTiming::DumpRawTimes(size_t nmax=0) {
76  for(size_t i=0; i<fNEntries; i++) {
77  if(nmax!=0 && i==nmax) return;
78 
79  if(fType=='p') std::cout << fPre->GetAbsTime(i) << std::endl;
80  if(fType=='r') std::cout << fRaw->GetAbsTime(i) << std::endl;
81 
82  }
83 }
84 #endif
map< size_t, size_t > fRawToOrdered
Definition: CRTTiming.h:41
size_t GetNEntries() const
Definition: CRTRawTree.cc:40
CRTTiming(CRTPreProcessTree &raw)
Definition: CRTTiming.cc:10
process_name gaushit a
const map< size_t, size_t > * GetRawToOrderedMap()
Definition: CRTTiming.cc:51
uint64_t GetAbsTime(size_t ientry) const
map< size_t, size_t > fOrderedToRaw
Definition: CRTTiming.h:42
void DumpRawTimes(size_t nmax)
Definition: CRTTiming.cc:75
void DumpSortedTimes(size_t nmax)
Definition: CRTTiming.cc:65
uint64_t GetAbsTime(size_t ientry) const
Definition: CRTRawTree.cc:44
const CRTPreProcessTree * fPre
Definition: CRTTiming.h:40
const CRTRawTree * fRaw
Definition: CRTTiming.h:39
process_name crt
BEGIN_PROLOG could also be cout
const map< size_t, size_t > * GetOrderedToRawMap()
Definition: CRTTiming.cc:58