calfemCheckList.C

Go to the documentation of this file.
00001 // Macro to check emcCalFEM object features.
00002 // Last time used : 13-FEB-2004. Here are the results:
00003 //
00004 // Class                          Flavor      Factory R-ASCII W-ASCII R-OBJY W-OBJY
00005 // emcGainFEM                     Gains         ok      ok      ok     ok      ok
00006 // emcHLRatioFEM                  HLRatios      ok      ok      ok     ok      ok
00007 // emcLCTofFEM                    LCTofs        ok      ok      ok     ok      ok
00008 // emcPedestalFEM (version 0)     Pedestals     ok      -       -      -       - 
00009 // emcPedestalFEM (version 1)     Pedestals5    ok      -       -      -       -
00010 // emcQAFEM                       QAs           ok      ok      -      -       -
00011 // emcTacPedFEM                   TacPeds       ok      -       -      -       - 
00012 // emcTofT0FEM (version 0)        TofT0s        ok      ok      ok     ok      ok
00013 // emcTofT0FEM (version 1)        TofT0Bs       ok      ok      ok     ok      ok
00014 // emcWalkTofFEM                  WalkTofFEM    ok      ok      ok     ok      ok
00015 //
00016 // - means not tested (if does not mean it's not supposed to work...)
00017 // R=Read
00018 // W=Write
00019 //
00020 // To use this macro you need to :
00021 // root[0] gSystem->Load("libemcCalib.so");
00022 // root[1] .L calfemCheckList.C
00023 // root[2] bool write_objy = false; //or true...
00024 // root[3] emcCalFEM* f = calfemCheckList("Gains",write_objy);
00025 // enjoy the messages if any.
00026 //
00027 //_____________________________________________________________________________
00028 emcCalFEM* error(const char* test)
00029 {
00030   std::cout << "calfemCheckList failure for " << test << std::endl;
00031   return 0;
00032 }
00033 
00034 //_____________________________________________________________________________
00035 emcCalFEM* calfemCheckList
00036 (const char* flavor, 
00037  bool writeObjy=false,
00038  const char* directory="/home/aphecetc/CALIB/")
00039 {
00040   // Check 1 : ask the factory to build an object.
00041 
00042   emcCalFEM* calfem = emcCalFEMFactory::Create(flavor,0);
00043 
00044   if ( !calfem )
00045     {
00046       return error("Factory");
00047     }
00048 
00049   // Check 2 : ask the DataManager to read from ASCII file.
00050 
00051   gSystem->Load("libemcOMascii.so");
00052 
00053   emcDataManager* dm = emcDataManager::GetInstance();
00054   dm->SetVerboseLevel(10);
00055 
00056   dm->SetSourceDir(directory);
00057   calfem->SetSource(emcManageable::kFile_ASCII);
00058 
00059   PHTimeStamp now;
00060 
00061   bool ok = dm->Read(*calfem,now);
00062 
00063   if (!ok)
00064     {
00065       return error("Read ASCII");
00066     }
00067 
00068   calfem->Print(std::cout,1);
00069 
00070   // Check 3 : ask the DM to write to ASCII file.
00071 
00072   dm->SetDestinationDir("$AFSHOME/tmp");
00073 
00074   calfem->SetDestination(emcManageable::kFile_ASCII);
00075 
00076   ok = dm->Write(*calfem);
00077 
00078   if (!ok)
00079     {
00080       return error("Write ASCII");
00081     }
00082 
00083   gSystem->Load("libemcOM.so");
00084 
00085   if ( writeObjy == true ) 
00086     {
00087       // Check 4 : ask the DM to write to Objy.
00088 
00089       calfem->SetDestination(emcManageable::kDB_Objy);
00090       PHTimeStamp start(2030,12,30,15,15,15);
00091       PHTimeStamp end(PHTimeStamp::PHFarFuture);
00092       calfem->SetValidityPeriod(start,end);
00093       ok = dm->Write(*calfem);
00094 
00095       if (!ok)
00096         {
00097           return error("Write Objy");
00098         }
00099 
00100     }
00101 
00102   // Check 5 : read from Objy
00103 
00104   calfem->SetSource(emcManageable::kDB_Objy);
00105   PHTimeStamp when(2030,12,31,23,59,0);
00106   ok = dm->Read(*calfem,when);
00107 
00108   if (!ok)
00109     {
00110       return error("Read Objy");
00111     }
00112 
00113   std::cout << "All tests successfull!" << std::endl;
00114   return calfem;
00115 }