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

ArchNMaskTestResult.cpp

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

Generated on Mon Dec 15 19:35:56 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3