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

ArchNoiseOccupancyTestResult.cpp

Go to the documentation of this file.
00001 #include "ArchNoiseOccupancyTestResult.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 #include "Sct/SctParameters.h"
00024 
00025 using namespace Sct;
00026 using namespace SctData;
00027 
00028 
00029 /********************************** ArchScan Methods Definitions ************************/
00030 
00031 
00032 /***********************  Constructor  *************** */
00033 
00034 ArchNoiseOccupancyTestResult::ArchNoiseOccupancyTestResult(): ArchTestResult()  {
00035 
00036   //cout<< "I am in the ArchNoiseOccupancyTestResult Default Constructor"<< endl;
00037   
00038   
00039   
00040 }
00041   
00042   
00043 ArchNoiseOccupancyTestResult::ArchNoiseOccupancyTestResult(NoiseOccupancyTestResult& NOtest): ArchTestResult(NOtest)  {
00044 
00045   //cout<< "I am in the ArchNoiseOccupancyTestResult Constructor"<< endl;
00046   
00047   //Save chipNoise as TVectorD's  
00048   double x[nChipModule];
00049 
00050   /*--- Initialisation ---*/
00051   for (unsigned int i = 0; i<nChipModule;i++) { 
00052     ChipNOResult& result = NOtest.getChipResult(i);
00053     chipNOGraph.push_back(result.graph.get());
00054     chipNOFit.push_back(result.fit.get());    
00055     x[i] = result.getNoise() ;
00056   }
00057 
00058   vchipNoise = new TVectorD(12 ,x);
00059 
00060   
00061   //Retrieve Test Summary from IS
00062   try{
00063     TestSummary(NOtest);
00064   } catch(...) {
00065     cout<<" ERROR in retrieving Test Summary from IS" <<endl;
00066   }
00067 
00068 
00069 }
00070 
00071 
00072 
00073 /**********************  Other Member Functions  *********************/
00074 
00075 ArchNoiseOccupancyTestResult::~ArchNoiseOccupancyTestResult()  {
00076   
00077   //cout << "I am in the destructor" << endl;
00078   
00079 
00080   
00081 }
00082 
00083 
00084 
00085 
00086 
00087 void ArchNoiseOccupancyTestResult::SaveNOTestDataOnly() {
00088 
00089   cout<<"Saving NoiseOccupancyTestData "<<endl;
00090      
00091 //TO DO : Save time and date of first and last saving  
00092   
00093   string filename = names->getfilename();
00094   string moduleID = names->getModuleID(); 
00095   string testType  = names->getTestType(); 
00096   string runID = names->getRunID();
00097   string vchipNoiseID = names->getChipNONoiseID();
00098   string chipNOFitID = names->getChipNOFitID();
00099   string chipNOGraphID = names->getChipNOGraphID();
00100 
00101   /* OPENING TEST FILE  */
00102   //cout << "Opening file..."<<endl; 
00103  
00104 
00105   TFile *storage_file = new TFile(filename.c_str(),"update");
00106   //storage_file->ls();
00107   //cout << "The file .root succesfully open"<<endl; 
00108 
00109   
00110 
00111 
00112   /* CREATING DIRECTORIES and SAVING DATA  */
00113   
00114     
00115     /* Making RunNumber   */
00116     //cout<<"I am making RunNumber Dir"<<endl;
00117     //storage_file->GetListOfKeys()->Print();
00118     TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str());
00119     //cout<<"The RUN is "<< runID <<endl;
00120     
00121     if (!this_run) {
00122       //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00123       this_run = storage_file->mkdir(runID.c_str());
00124       //cout<<"New RunNumber Dir made "<<endl;
00125     }
00126     storage_file->GetListOfKeys()->Print();
00127     this_run->cd();  //make this_run the current directory
00128     
00129    
00130     /* Saving RunNumber as a TVector: it is saved only once, just the first time   */
00131     TObject* pers_runnumber = gDirectory->FindObjectAny(runID.c_str()); 
00132     if (!pers_runnumber) {
00133       double frunNumber = runNumber;
00134       TVector run(1,1,frunNumber, "END");
00135       run.Write(runID.c_str());
00136     }
00137     
00138     
00139     /* Making moduleNumber   */
00140     
00141     TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00142     //cout<<"The MODULE is "<< moduleID <<endl;
00143     if (!this_module) {
00144       //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00145       this_module =gDirectory ->mkdir(moduleID.c_str());
00146     }
00147     
00148 
00149     
00150     /* Making TestType   */
00151     //cout<<"I am making TestType Dir "<<endl;
00152     this_module->cd();  //make this_module the current directory 
00153     TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00154     //cout<<"The test Type is "<< testType <<endl;
00155     
00156     if (!this_testType) {
00157       //cout<<"This NEW test "<< testType <<" doesn't exist"<<endl;
00158       this_testType = gDirectory->mkdir(testType.c_str());
00159     }
00160     this_testType->cd();
00161 
00162 
00163     /* Saving chipNOFit */
00164     TDirectory* pers_ChipNOFit = (TDirectory*) gDirectory->Get(chipNOFitID.c_str());
00165     if (!pers_ChipNOFit) {
00166       //cout << "The ChipNOFit never saved before...saving now"<<endl;
00167       pers_ChipNOFit = this_testType->mkdir(chipNOFitID.c_str());
00168       
00169     }
00170     pers_ChipNOFit->cd();
00171 
00172     unsigned int chipN=0;
00173     for (vector<TF1*>::iterator i = chipNOFit.begin(); i!=chipNOFit.end(); i++) {
00174       (*i)->Write(names->getChipNOFitID(chipN).c_str());
00175       ++chipN;
00176     } 
00177     this_testType->cd();
00178 
00179 
00180     /* Saving chipNOGraph */
00181     TDirectory* pers_ChipNOGraph = (TDirectory*) gDirectory->Get(chipNOGraphID.c_str());
00182     if (!pers_ChipNOGraph) {
00183       //cout << "The ChipNOGraph never saved before...saving now"<<endl;
00184       pers_ChipNOGraph = this_testType->mkdir(chipNOGraphID.c_str());
00185       
00186     }
00187     pers_ChipNOGraph->cd();
00188     chipN=0;
00189     for (vector<TGraph*>::iterator i = chipNOGraph.begin(); i!=chipNOGraph.end(); i++) {
00190       (*i)->Write(names->getChipNOGraphID(chipN).c_str());
00191        ++chipN;
00192     }   
00193     this_testType->cd();
00194     
00195     /* Saving ChipNoise as a TVector: always saved!!  */
00196     //cout << "I am Saving ChipNoise as  TVectorD's" << endl;
00197     //TObject* pers_vchipNoise = gDirectory->FindObjectAny(vchipNoiseID.c_str()); 
00198     //if (!pers_vchipNoise) {
00199       //cout << "The ChipNoise never saved before...saving now"<<endl;
00200       vchipNoise->Write(vchipNoiseID.c_str());
00201       //}
00202     
00203 
00204     
00205     //Save TestSummery (if it has been retrieved)
00206     if(testSummary != NULL) {
00207       //cout<<"testSummary != NULL...";
00208       TObject* pers_testSummary = gDirectory->FindObjectAny(names->getTestSummaryID().c_str());
00209       if (!pers_testSummary) {
00210     testSummary->Write(names->getTestSummaryID().c_str());
00211     //cout<<"testSummary SAVED"<<endl;
00212       }
00213     }
00214 
00215     
00216     /* CLOSING FILE  */
00217     //cout << "I am Closing File " << endl;
00218     storage_file->Close();
00219     delete storage_file;
00220     //cout << "File closed " << endl;
00221 
00222 
00223 
00224 
00225 }
00226 
00227 
00228 
00229 void ArchNoiseOccupancyTestResult::SaveNoiseOccupancy() {
00230 
00231   //cout << "I am in SaveNoiseOccupancy() " <<endl;
00232   SaveTestDataOnly();
00233   SaveNOTestDataOnly();
00234   SaveRawScans();
00235   SaveFitScans();
00236   AddTestToIndex();
00237   
00238 
00239 
00240 
00241 
00242 
00243 }
00244 
00245 
00246 
00247 void ArchNoiseOccupancyTestResult::TestSummary(NoiseOccupancyTestResult & NOtest) {
00248   
00249   ostringstream datastream;
00250   shared_ptr<const SctData::TestSummary::SummaryWriter> writer = 
00251     SctData::TestSummary::SummaryManager::instance().getWriter(NOtest.getClassName());
00252   writer->writeHeader(NOtest, datastream);
00253   writer->write(NOtest, 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 Mon Dec 15 19:35:56 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3