UgliDbiTables.cxx File Reference

#include "UgliGeometry/UgliDbiTables.h"
#include "Plex/PlexPlaneId.h"
#include "Conventions/Munits.h"
#include "TMath.h"
#include "MessageService/MsgService.h"
#include "TSystem.h"
#include "TStopwatch.h"
#include <set>
#include <fstream>

Go to the source code of this file.

Functions

 CVSID ("$Id: UgliDbiTables.cxx,v 1.16 2013/07/30 21:01:16 rhatcher Exp $")
void UgliDbiTablesInitDefaults ()
template<class T >
bool alwaysTrue (const T *)
template<class T >
bool vetoPln (const T *dbirow)
template<class T >
bool vetoMdl (const T *dbirow)
template<class T >
bool vetoStrip (const T *dbirow)
template<class T >
void WriteTableToCSVFile (const DbiResultPtr< T > &tbl, string basename, bool testFunc(const T *))

Variables

static int gVetoOnly = 0

Function Documentation

template<class T >
bool alwaysTrue ( const T *   )  [inline]

Definition at line 523 of file UgliDbiTables.cxx.

Referenced by UgliDbiTables::WriteCSVFiles().

00523 { return true; }

CVSID ( "$Id: UgliDbiTables.  cxx,
v 1.16 2013/07/30 21:01:16 rhatcher Exp $"   
)
void UgliDbiTablesInitDefaults (  ) 

Definition at line 37 of file UgliDbiTables.cxx.

References UgliDbiTables::fgAlgorithmic, UgliDbiTables::fgCutOnPlnInstall, gSystem(), Detector::kCalDet, Detector::kFar, Msg::kInfo, Detector::kMapper, Detector::kNear, Detector::kTestStand, Detector::kUnknown, and MSG.

Referenced by UgliDbiTables::IsAlgorithmic(), UgliDbiTables::IsCutOnPlnInstall(), UgliDbiTables::SetAlgorithmic(), and UgliDbiTables::SetCutOnPlnInstall().

00038 {
00039   static bool first = true;
00040   if (!first) return;
00041   first = false;
00042 
00043   bool algdflt = false;
00044   if (gSystem->Getenv("ALG_UGLI")) {
00045     MSG("Ugli",Msg::kInfo)
00046       << "UgliDbiTables::InitDefaults saw ALG_UGLI"
00047       << endl;
00048     algdflt = true;
00049   }
00050   // ensure the algorithmic approach is off for each detector
00051   UgliDbiTables::fgAlgorithmic[Detector::kUnknown  ] = algdflt;
00052   UgliDbiTables::fgAlgorithmic[Detector::kNear     ] = algdflt;
00053   UgliDbiTables::fgAlgorithmic[Detector::kFar      ] = algdflt;
00054   UgliDbiTables::fgAlgorithmic[Detector::kCalDet   ] = algdflt;
00055   UgliDbiTables::fgAlgorithmic[Detector::kTestStand] = algdflt;
00056   UgliDbiTables::fgAlgorithmic[Detector::kMapper   ] = algdflt;
00057 
00058   bool cutdflt = false;
00059   if (gSystem->Getenv("CUT_UGLI")) {
00060     MSG("Ugli",Msg::kInfo)
00061       << "UgliDbiTables::InitDefaults saw CUT_UGLI"
00062       << endl;
00063     cutdflt = true;
00064   }
00065   // ensure the algorithmic approach is off for each detector
00066   UgliDbiTables::fgCutOnPlnInstall[Detector::kUnknown  ] = cutdflt;
00067   UgliDbiTables::fgCutOnPlnInstall[Detector::kNear     ] = cutdflt;
00068   UgliDbiTables::fgCutOnPlnInstall[Detector::kFar      ] = cutdflt;
00069   UgliDbiTables::fgCutOnPlnInstall[Detector::kCalDet   ] = cutdflt;
00070   UgliDbiTables::fgCutOnPlnInstall[Detector::kTestStand] = cutdflt;
00071   UgliDbiTables::fgCutOnPlnInstall[Detector::kMapper   ] = cutdflt;
00072 
00073 }

template<class T >
bool vetoMdl ( const T *  dbirow  )  [inline]

Definition at line 539 of file UgliDbiTables.cxx.

References gVetoOnly.

Referenced by UgliDbiTables::WriteCSVFiles().

00540 {
00541     if ( gVetoOnly == 0 ) return true;
00542     bool isVeto = dbirow->GetScintMdlId().IsVetoShield();
00543     bool keep = true;
00544     if ( gVetoOnly > 0 && ! isVeto ) keep = false;
00545     if ( gVetoOnly < 0 &&   isVeto ) keep = false;
00546     //cout  << dbirow->GetPlaneId() << " keep = " 
00547     //      << ((keep)?"YES":"no") << endl;
00548     return keep;
00549 }

template<class T >
bool vetoPln ( const T *  dbirow  )  [inline]

Definition at line 526 of file UgliDbiTables.cxx.

References gVetoOnly.

Referenced by UgliDbiTables::WriteCSVFiles().

00527 {
00528     if ( gVetoOnly == 0 ) return true;
00529     bool isVeto = dbirow->GetPlaneId().IsVetoShield();
00530     bool keep = true;
00531     if ( gVetoOnly > 0 && ! isVeto ) keep = false;
00532     if ( gVetoOnly < 0 &&   isVeto ) keep = false;
00533     //cout  << dbirow->GetPlaneId() << " keep = " 
00534     //      << ((keep)?"YES":"no") << endl;
00535     return keep;
00536 }

template<class T >
bool vetoStrip ( const T *  dbirow  )  [inline]

Definition at line 552 of file UgliDbiTables.cxx.

References gVetoOnly.

Referenced by UgliDbiTables::WriteCSVFiles().

00553 {
00554     if ( gVetoOnly == 0 ) return true;
00555     bool isVeto = dbirow->GetStripEndId().IsVetoShield();
00556     bool keep = true;
00557     if ( gVetoOnly > 0 && ! isVeto ) keep = false;
00558     if ( gVetoOnly < 0 &&   isVeto ) keep = false;
00559     //cout  << dbirow->GetPlaneId() << " keep = " 
00560     //      << ((keep)?"YES":"no") << endl;
00561     return keep;
00562 }

template<class T >
void WriteTableToCSVFile ( const DbiResultPtr< T > &  tbl,
string  basename,
bool   testFuncconst T * 
) [inline]

Definition at line 567 of file UgliDbiTables.cxx.

References VldTimeStamp::AsString(), DbiValidityRec::GetAggregateNo(), DbiValidityRec::GetCreationDate(), VldRange::GetDetectorMask(), DbiValidityRec::GetInsertDate(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), DbiValidityRec::GetSeqNo(), VldRange::GetSimMask(), DbiValidityRec::GetTask(), VldRange::GetTimeEnd(), VldRange::GetTimeStart(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), and timer().

Referenced by UgliDbiTables::WriteCSVFiles().

00570 {
00571 
00572    // write out CSV (comma separated value) text files
00573    string fnamedata = basename + ".csv";
00574    string fnamevld  = basename + "VLD.csv";
00575 
00576    cout << " ---------------- Write " << fnamedata << endl;
00577    TStopwatch timer;
00578    timer.Start();
00579     
00580    ofstream datafile(fnamedata.c_str());
00581    ofstream vldfile(fnamevld.c_str());
00582 
00583    string vldheaderline = "SEQNO INT PRIMARY KEY,TIMESTART DATETIME,TIMEEND DATETIME,DETECTORMASK TINYINT,SIMMASK TINYINT,TASK INT,AGGREGATENO INT,CREATIONDATE DATETIME,INSERTDATE DATETIME";
00584    vldfile << vldheaderline << endl;
00585 
00586    bool doheader = true;
00587    std::set<const DbiValidityRec*> usedvld;
00588    for (UInt_t irow=0; irow < tbl.GetNumRows(); ++irow) {
00589       const T* uglirow = tbl.GetRow(irow);
00590       if ( ! uglirow ) {
00591           cout << "Empty row???" << endl;
00592           continue;
00593       }
00594       // test if it passes a veto criteria (+1=only veto, 0=all, -1=no veto)
00595       if ( ! testFunc(uglirow) ) continue;
00596 
00597       const DbiValidityRec* vldrec = tbl.GetValidityRec(uglirow);
00598       const char* opt = (doheader)? "H,":",";   // CVS w/ or w/o header
00599       uglirow->FormatToOStream(datafile,opt,vldrec);
00600       doheader = false;
00601       if ( usedvld.find(vldrec) == usedvld.end() ) {
00602          VldRange vldr = vldrec->GetVldRange();
00603          vldfile 
00604              << vldrec->GetSeqNo() << ','
00605              << '"' << vldr.GetTimeStart().AsString("sql") << "\","
00606              << '"' << vldr.GetTimeEnd().AsString("sql") << "\","
00607              << vldr.GetDetectorMask() << ','
00608              << vldr.GetSimMask() << ','
00609              << vldrec->GetTask() << ','
00610              << vldrec->GetAggregateNo() << ','
00611              << '"' << vldrec->GetCreationDate().AsString("sql") << "\","
00612              << '"' << vldrec->GetInsertDate().AsString("sql") << '"'
00613              << endl;
00614          usedvld.insert(vldrec);
00615       }
00616    }
00617 
00618    timer.Stop();
00619    timer.Print();
00620 
00621 }


Variable Documentation

int gVetoOnly = 0 [static]

Definition at line 520 of file UgliDbiTables.cxx.

Referenced by vetoMdl(), vetoPln(), vetoStrip(), and UgliDbiTables::WriteCSVFiles().


Generated on 8 Jul 2019 for loon by  doxygen 1.6.1