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

ArchFullBypassTestResult.cpp

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

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