Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

ArchPipelineTestResult.cpp

00001 #include "ArchPipelineTestResult.h"
00002 #include "ArchivingManager.h"
00003 #include <TFile.h>
00004 #include <TKey.h>
00005 #include <TDirectory.h>
00006 #include <TSystem.h>
00007 #include <TNamed.h>
00008 #include <TObject.h>
00009 #include <TString.h>
00010 #include <TObjString.h>
00011 #include <TH1.h>
00012 #include <TH2.h>
00013 #include <TCanvas.h>
00014 #include <TROOT.h>
00015 #include <TVector.h>
00016 #include <is/isinfo.h>
00017 #include <iostream>
00018 #include <vector>
00019 #include "SummaryWriter/SummaryWriter.h"
00020 #include "SummaryWriter/SummaryManager.h"
00021 
00022 
00023 bool ArchPipelineTestResult::inMap = ArchivingManager::instance().addTestArchiver("SctData::PipelineTestResult", shared_ptr<ArchTestResult>(new ArchPipelineTestResult()));  
00024 
00025 
00026 /***********************  Constructor  *************** */
00027 
00028 ArchPipelineTestResult::ArchPipelineTestResult(): ArchTestResult()  {
00029 
00030   //cout<< "I am in the ArchPipelineTestResult Default Constructor"<< endl;
00031   
00032   
00033   
00034 }
00035 
00036 
00037 ArchPipelineTestResult::ArchPipelineTestResult(shared_ptr<PipelineTestResult> Ptest): ArchTestResult(Ptest)  {
00038 
00039   //cout<< "I am in the PipelineTestResult Constructor"<< endl;
00040   
00041   /*--- Initialisation ---*/
00042 
00043 
00044   //Retrieve Test Summary from IS
00045   try{
00046     TestSummary(Ptest);
00047   } catch(...) {
00048     cout<<" ERROR in retrieving Test Summary from IS" <<endl;
00049   }
00050 
00051 
00052 
00053 }
00054 
00055 
00056 
00057 /**********************  Other Member Functions  *********************/
00058 
00059 
00060 ArchPipelineTestResult::~ArchPipelineTestResult()  {
00061   
00062   //cout << "I am in the ArchPipelineTestResult destructor" << endl;
00063   
00064 
00065   
00066 }
00067 
00068 
00069 
00070 void ArchPipelineTestResult::SavePipelineTestDataOnly() {
00071 
00072   cout<<"Saving PipelineTestData "<<endl;
00073   //TO DO : Save time and date of first and last saving  
00074 
00075   string filename = names->getfilename();
00076   string moduleID = names->getModuleID(); 
00077   string testType  = names->getTestType(); 
00078   string runID = names->getRunID();
00079   
00080   
00081 
00082   
00083   /* OPENING TEST FILE  */
00084   //cout << "Opening file..."<<endl; 
00085  
00086   TFile *storage_file = new TFile(filename.c_str(),"update");
00087   //storage_file->ls();
00088   //cout << "The file .root succesfully open"<<endl; 
00089 
00090   
00091 
00092 
00093   /* CREATING DIRECTORIES and SAVING DATA  */
00094   
00095     
00096     /* Making RunNumber   */
00097     //cout<<"I am making RunNumber Dir"<<endl;
00098     //storage_file->GetListOfKeys()->Print();
00099     TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str());
00100     //cout<<"The RUN is "<< runID <<endl;
00101     
00102     if (!this_run) {
00103       //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00104       this_run = storage_file->mkdir(runID.c_str());
00105       //cout<<"New RunNumber Dir made "<<endl;
00106     }
00107     storage_file->GetListOfKeys()->Print();
00108     this_run->cd();  //make this_run the current directory
00109     
00110    
00111     /* Saving RunNumber as a TVector: it is saved only once, just the first time   */
00112     TObject* pers_runnumber = gDirectory->FindObjectAny(runID.c_str()); 
00113     if (!pers_runnumber) {
00114       double frunNumber = runNumber;
00115       TVector run(1,1,frunNumber, "END");
00116       run.Write(runID.c_str());
00117     }
00118     
00119     
00120     /* Making moduleNumber   */
00121     
00122     TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00123     //cout<<"The MODULE is "<< moduleID <<endl;
00124     if (!this_module) {
00125       //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00126       this_module =gDirectory ->mkdir(moduleID.c_str());
00127     }
00128     
00129     
00130     /* Making TestType   */
00131     //cout<<"I am making TestType Dir "<<endl;
00132     this_module->cd();  //make this_module the current directory 
00133     TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00134     //cout<<"The test Type is "<< testType <<endl;
00135     
00136     if (!this_testType) {
00137       //cout<<"This NEW test "<< testType <<" doesn't exist"<<endl;
00138       this_testType = gDirectory->mkdir(testType.c_str());
00139     }
00140     this_testType->cd();
00141 
00142 
00143     
00144 
00145     //Save TestSummary (if it has been retrieved)
00146     if(testSummary != NULL) {
00147       //cout<<"testSummary != NULL...";
00148       TObject* pers_testSummary = gDirectory->FindObjectAny(names->getTestSummaryID().c_str());
00149       if (!pers_testSummary) {
00150     testSummary->Write(names->getTestSummaryID().c_str());
00151     //cout<<"testSummary SAVED"<<endl;
00152       }
00153     }
00154    
00155 
00156 
00157 
00158 
00159     /* CLOSING FILE  */
00160     //cout << "I am Closing File " << endl;
00161     storage_file->Close();
00162     delete storage_file;
00163     //cout << "File closed " << endl;
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 }
00172 
00173 
00174 
00175 
00176 
00177 void ArchPipelineTestResult::Save() {
00178 
00179   ArchTestResult::Save();
00180   SavePipelineTestDataOnly();
00181   //SaveRawScans();
00182   //SaveFitScans();
00183   AddTestToIndex();
00184 
00185 }
00186 
00187 
00188 
00189 void ArchPipelineTestResult::TestSummary(shared_ptr<PipelineTestResult> Ptest) {
00190   
00191   ostringstream datastream;
00192   shared_ptr<const SctData::TestSummary::SummaryWriter> writer = 
00193     SctData::TestSummary::SummaryManager::instance().getWriter(Ptest->getClassName());
00194   writer->writeHeader(*(Ptest.get()), datastream);
00195   writer->write(*(Ptest.get()), datastream);
00196   string myString = datastream.str();
00197   //cout<< "TestSummary = " << myString;
00198 
00199   testSummary = new TObjString(myString.c_str());
00200 
00201   
00202 
00203 
00204   return;
00205 
00206 
00207 }
00208 

Generated on Thu Jul 15 09:50:43 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5