15 const FairDb::
Task& task,
17 Bool_t findFullTimeWindow
20 fIsExtendedContext(kFALSE),
30 const string& tableName = proxy.GetTableName();
31 Int_t sumTimeWindows = 0;
32 Int_t numTimeWindows = 0;
35 this->MakeGapRec(vc, tableName, findFullTimeWindow);
44 unsigned int numVRecIn = 0;
46 if ( ! proxy.TableExists() ) {
48 cout <<
"FairDbValidityRecBuilder::Query for table:"
49 << proxy.GetTableName()
50 <<
", table does not exist!" << endl;
57 UInt_t numDb = proxy.GetNumDb();
58 Bool_t foundData = kFALSE;
60 for ( UInt_t dbNo = 0; dbNo < numDb && ! foundData; ++dbNo ) {
63 if ( ! proxy.TableExists(dbNo) ) {
continue; }
64 if ( selectDbNo >= 0 && selectDbNo != (
int) dbNo ) {
continue; }
71 FairDbSimFlagAssociation::SimList_t::iterator listItr = simList.begin();
72 FairDbSimFlagAssociation::SimList_t::iterator listItrEnd = simList.end();
73 while ( listItr != listItrEnd && ! foundData ) {
95 for (UInt_t row = 0; row < numRows; ++row) {
102 Int_t index = this->IndexOfAggno(aggNo);
103 if ( index < 0 ) { index = this->AddNewGap(aggNo); }
110 curRec.
Trim(curVTS, *vr);
111 if ( ! curRec.
IsGap() ) {
122 || earliestCreate.
GetSec() == 0 )
130 if ( timeInterval < 5 ) {
132 cout <<
"Detected suspiciously small validity time interval in \n"
133 <<
"table " << tableName <<
" validity rec " << *vr << endl;
135 sumTimeWindows += timeInterval;
142 if ( findFullTimeWindow ) {
144 proxy.FindTimeBoundaries(vcTry,fTask,dbNo,earliestCreate,start,end);
145 cout <<
"Trimming validity records to "
146 << start <<
" .. " << end << endl;
147 std::vector<FairDbValidityRec>::iterator itr(fVRecs.begin()), itrEnd(fVRecs.end());
148 for( ; itr != itrEnd; ++itr ) { itr->AndTimeWindow(start,end); }
149 fGap.AndTimeWindow(start,end);
161 if ( sim != simTry ) {
162 cout <<
"Imposing SimFlag of " << sim <<
" on FairDbValidityRecs which matched " << simTry << endl;
163 for (
unsigned int irec = 0; irec < GetNumValidityRec(); ++irec ) {
166 ValRange vr_mod(vr.GetDetectorMask(),sim,vr.GetTimeStart(),vr.GetTimeEnd(),vr.GetDataSource());
171 cout <<
"FairDbValidityRecBuilder:" << endl
172 <<
" Query: " << vc.AsString() << endl
175 <<
" found " << numVRecIn
176 <<
" vrecs in database, for " << fVRecs.size()
177 <<
" aggregates:-." << endl;
179 for (
unsigned int irec = 0; irec < GetNumValidityRec(); ++irec ) {
182 cout <<
" " << irec <<
" " << GetValidityRec(irec) << endl;
189 if ( numTimeWindows > 0 ) {
190 Int_t timeGateCalc = 3 * fVRecs.size() * sumTimeWindows/numTimeWindows;
192 if ( timeGateCalc > 100*24*60*60 || timeGateCalc < 0
193 ) { timeGateCalc = 100*24*60*60; }
195 if ( timeGateCurr < timeGateCalc/10
196 || timeGateCurr > timeGateCalc*10
201 cout <<
"The ignored time gate setting was calculated with the following data:-"
202 <<
"\n Context: " << vc <<
" task " << task <<
" findFullTimeWindow " << findFullTimeWindow
203 <<
"\n Number of vrecs " << numTimeWindows
204 <<
" total time (secs) of all vrecs " << sumTimeWindows
205 <<
" Number of aggregates " << fVRecs.size() << endl;
215 const string& context,
218 fIsExtendedContext(kTRUE),
224 cout <<
"Creating FairDbValidityRecBuilder"
225 <<
" for extended context " << context << endl;
230 cout<<
"Initialising with gap record " <<
fGap << endl;
235 unsigned int numVRecIn = 0;
238 cout <<
"FairDbValidityRecBuilder::Query for table:"
240 <<
", table does not exist!" << endl;
243 else if ( context ==
"" ) {
244 cout <<
"FairDbValidityRecBuilder::Null query for table:"
253 Bool_t foundData = kFALSE;
255 for ( UInt_t dbNo = 0; dbNo < numDb && ! foundData; ++dbNo ) {
270 for (UInt_t row = 0; row < numRows; ++row) {
275 Int_t index =
fVRecs.size();
282 fVRecs[index].SetDbNo(dbNo);
290 cout <<
"FairDbValidityRecBuilder:" << endl
291 <<
" Extended context query: " << context << endl
292 <<
" found " << numVRecIn
293 <<
" vrecs in database, for " <<
fVRecs.size()
294 <<
" records:-." << endl;
308 const std::string tableName)
310 fIsExtendedContext(kFALSE),
320 vrange.GetTimeStart());
340 std::vector<FairDbValidityRec>::const_iterator itr =
fVRecs.begin();
341 std::vector<FairDbValidityRec>::const_iterator end =
fVRecs.end();
343 for (; itr != end; ++itr) {
345 if ( ! vr.
IsGap() ) {
358 if ( seqLo == 0 ) {
return ""; }
371 if ( index >=0 ) {
return index; }
387 fVRecs[index].SetAggregateNo(aggNo);
407 std::vector<FairDbValidityRec>::const_iterator itr =
fVRecs.begin();
408 std::vector<FairDbValidityRec>::const_iterator end =
fVRecs.end();
410 for (; itr != end; ++itr)
if ( itr->GetSeqNo() == SeqNo ) {
return *itr; }
418 std::map<Int_t,UInt_t>::const_iterator itr =
fAggNoToIndex.find(aggNo);
427 const string& tableName,
428 Bool_t findFullTimeWindow)
434 contextSec += 2*timeGate;
436 if ( findFullTimeWindow ) {