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

ArchStrobeDelayTestResult.cpp

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

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