Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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.15 2008/01/09 18:06:17 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

int gVetoOnly = 0


Function Documentation

template<class T>
bool alwaysTrue const T *   ) 
 

Definition at line 519 of file UgliDbiTables.cxx.

Referenced by UgliDbiTables::WriteCSVFiles().

00519 { return true; }

CVSID "$Id: UgliDbiTables cxx,
v 1.15 2008/01/09 18:06:17 rhatcher Exp $" 
 

void UgliDbiTablesInitDefaults  ) 
 

Definition at line 37 of file UgliDbiTables.cxx.

References gSystem(), 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  ) 
 

Definition at line 535 of file UgliDbiTables.cxx.

References gVetoOnly.

Referenced by UgliDbiTables::WriteCSVFiles().

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

template<class T>
bool vetoPln const T *  dbirow  ) 
 

Definition at line 522 of file UgliDbiTables.cxx.

References gVetoOnly.

Referenced by UgliDbiTables::WriteCSVFiles().

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

template<class T>
bool vetoStrip const T *  dbirow  ) 
 

Definition at line 548 of file UgliDbiTables.cxx.

References UgliDbiStrip::GetStripEndId(), gVetoOnly, and PlexPlaneId::IsVetoShield().

Referenced by UgliDbiTables::WriteCSVFiles().

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

template<class T>
void WriteTableToCSVFile const DbiResultPtr< T > &  tbl,
string  basename,
bool   testFunc(const T *)
 

Definition at line 563 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(), VldTimeStamp::Print(), and timer().

Referenced by UgliDbiTables::WriteCSVFiles().

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


Variable Documentation

int gVetoOnly = 0 [static]
 

Definition at line 516 of file UgliDbiTables.cxx.

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


Generated on Mon Feb 15 11:08:15 2010 for loon by  doxygen 1.3.9.1