00001 #include "ArchFullBypassTestResult.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 <boost/shared_ptr.hpp>
00021 #include "SummaryWriter/SummaryWriter.h"
00022 #include "SummaryWriter/SummaryManager.h"
00023
00024
00025
00026
00027 ArchFullBypassTestResult::ArchFullBypassTestResult(): ArchTestResult() {
00028
00029
00030
00031
00032
00033 }
00034
00035
00036 ArchFullBypassTestResult::ArchFullBypassTestResult(FullBypassTestResult& FBtest): ArchTestResult(FBtest) {
00037
00038
00039
00040
00041
00042 for (unsigned int i = 0; i<12;i++) {
00043
00044 status_direct.push_back(FBtest.getChipResult(i).status_direct);
00045 shared_ptr<TVector> tmp_v_status_direct (new TVector(1,1,FBtest.getChipResult(i).status_direct,"END"));
00046 v_status_direct.push_back(tmp_v_status_direct);
00047
00048
00049
00050 vdd_direct.push_back(FBtest.getChipResult(i).vdd_direct);
00051 shared_ptr<TVector> tmp_v_vdd_direct (new TVector(1,1,FBtest.getChipResult(i).vdd_direct,"END"));
00052 v_vdd_direct.push_back(tmp_v_vdd_direct);
00053
00054
00055
00056
00057 status_bypass.push_back(FBtest.getChipResult(i).status_bypass);
00058 shared_ptr<TVector> tmp_v_status_bypass (new TVector(1,1,FBtest.getChipResult(i).status_bypass,"END"));
00059 v_status_bypass.push_back(tmp_v_status_bypass);
00060
00061
00062
00063 vdd_bypass.push_back(FBtest.getChipResult(i).vdd_bypass);
00064 shared_ptr<TVector> tmp_v_vdd_bypass (new TVector(1,1,FBtest.getChipResult(i).vdd_bypass,"END"));
00065 v_vdd_bypass.push_back(tmp_v_vdd_bypass);
00066
00067
00068
00069 }
00070
00071
00072
00073
00074
00075
00076
00077 try{
00078 TestSummary(FBtest);
00079 } catch(...) {
00080 cout<<" ERROR in retrieving Test Summary from IS" <<endl;
00081 }
00082
00083
00084
00085 }
00086
00087
00088
00089
00090
00091
00092 ArchFullBypassTestResult::~ArchFullBypassTestResult() {
00093
00094
00095
00096
00097
00098 }
00099
00100
00101
00102 void ArchFullBypassTestResult::SaveFullBypassTestDataOnly() {
00103
00104 cout<<"Saving FullBypassTestData "<<endl;
00105
00106
00107 string filename = names->getfilename();
00108 string moduleID = names->getModuleID();
00109 string testType = names->getTestType();
00110 string runID = names->getRunID();
00111 string status_directID = names->getStatus_directID();
00112 string vdd_directID = names->getVdd_directID();
00113 string status_bypassID = names->getStatus_bypassID();
00114 string vdd_bypassID = names->getVdd_bypassID();
00115
00116
00117
00118
00119
00120
00121 TFile *storage_file = new TFile(filename.c_str(),"update");
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str());
00135
00136
00137 if (!this_run) {
00138
00139 this_run = storage_file->mkdir(runID.c_str());
00140
00141 }
00142 storage_file->GetListOfKeys()->Print();
00143 this_run->cd();
00144
00145
00146
00147 TObject* pers_runnumber = gDirectory->FindObjectAny(runID.c_str());
00148 if (!pers_runnumber) {
00149 double frunNumber = runNumber;
00150 TVector run(1,1,frunNumber, "END");
00151 run.Write(runID.c_str());
00152 }
00153
00154
00155
00156
00157 TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str());
00158
00159 if (!this_module) {
00160
00161 this_module =gDirectory ->mkdir(moduleID.c_str());
00162 }
00163
00164
00165
00166
00167 this_module->cd();
00168 TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00169
00170
00171 if (!this_testType) {
00172
00173 this_testType = gDirectory->mkdir(testType.c_str());
00174 }
00175 this_testType->cd();
00176
00177
00178
00179
00180
00181 for (unsigned int i = 0; i<12;i++) {
00182 string chipN = names->getFBChipN(i);
00183 TDirectory* this_chipN = (TDirectory*) gDirectory->Get(chipN.c_str());
00184
00185 if (!this_chipN) {
00186
00187 this_chipN =gDirectory ->mkdir(chipN.c_str());
00188 }
00189 this_chipN->cd();
00190
00191 v_status_direct[i].get()->Write(status_directID.c_str());
00192 v_vdd_direct[i].get()->Write(vdd_directID.c_str());
00193 v_status_bypass[i].get()->Write(status_bypassID.c_str());
00194 v_vdd_bypass[i].get()->Write(vdd_bypassID.c_str());
00195
00196
00197 this_testType->cd();
00198 }
00199
00200
00201
00202
00203 if(testSummary != NULL) {
00204
00205 TObject* pers_testSummary = gDirectory->FindObjectAny(names->getTestSummaryID().c_str());
00206 if (!pers_testSummary) {
00207 testSummary->Write(names->getTestSummaryID().c_str());
00208
00209 }
00210 }
00211
00212
00213
00214
00215
00216
00217
00218 storage_file->Close();
00219 delete storage_file;
00220
00221
00222
00223
00224
00225 }
00226
00227
00228
00229
00230
00231 void ArchFullBypassTestResult::SaveFullBypass() {
00232
00233 SaveTestDataOnly();
00234 SaveFullBypassTestDataOnly();
00235 SaveRawScans();
00236 SaveFitScans();
00237 AddTestToIndex();
00238
00239 }
00240
00241
00242
00243 void ArchFullBypassTestResult::TestSummary(FullBypassTestResult & FBtest) {
00244
00245 ostringstream datastream;
00246 shared_ptr<const SctData::TestSummary::SummaryWriter> writer =
00247 SctData::TestSummary::SummaryManager::instance().getWriter(FBtest.getClassName());
00248 writer->writeHeader(FBtest, datastream);
00249 writer->write(FBtest, datastream);
00250 string myString = datastream.str();
00251
00252
00253 testSummary = new TObjString(myString.c_str());
00254
00255
00256
00257
00258 return;
00259
00260
00261 }
00262