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
00025
00026 ArchStrobeDelayTestResult::ArchStrobeDelayTestResult(): ArchTestResult() {
00027
00028
00029
00030
00031
00032 }
00033
00034
00035 ArchStrobeDelayTestResult::ArchStrobeDelayTestResult(StrobeDelayTestResult& SDtest): ArchTestResult(SDtest) {
00036
00037
00038
00039
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
00049 vfraction = new TVectorD(1,1,fraction,"END");
00050
00051
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
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
00074
00075
00076 ArchStrobeDelayTestResult::~ArchStrobeDelayTestResult() {
00077
00078
00079
00080
00081
00082 }
00083
00084
00085
00086 void ArchStrobeDelayTestResult::SaveStrobeDelayTestDataOnly() {
00087
00088 cout<<"Saving StrobeDelayTestData "<<endl;
00089
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
00101
00102
00103 TFile *storage_file = new TFile(filename.c_str(),"update");
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str());
00117
00118
00119 if (!this_run) {
00120
00121 this_run = storage_file->mkdir(runID.c_str());
00122
00123 }
00124 storage_file->GetListOfKeys()->Print();
00125 this_run->cd();
00126
00127
00128
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
00138
00139 TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str());
00140
00141 if (!this_module) {
00142
00143 this_module =gDirectory ->mkdir(moduleID.c_str());
00144 }
00145
00146
00147
00148
00149 this_module->cd();
00150 TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00151
00152
00153 if (!this_testType) {
00154
00155 this_testType = gDirectory->mkdir(testType.c_str());
00156 }
00157 this_testType->cd();
00158
00159
00160
00161
00162
00163
00164 TObject* pers_vfraction = gDirectory->FindObjectAny(vfractionID.c_str());
00165 if (!pers_vfraction) {
00166
00167 vfraction->Write(vfractionID.c_str());
00168 }
00169
00170
00171 TObject* pers_voptima = gDirectory->FindObjectAny(voptimaID.c_str());
00172 if (!pers_voptima) {
00173
00174 voptima->Write(voptimaID.c_str());
00175 }
00176
00177
00178
00179
00180 if(testSummary != NULL) {
00181
00182 TObject* pers_testSummary = gDirectory->FindObjectAny(names->getTestSummaryID().c_str());
00183 if (!pers_testSummary) {
00184 testSummary->Write(names->getTestSummaryID().c_str());
00185
00186 }
00187 }
00188
00189
00190
00191
00192
00193
00194 storage_file->Close();
00195 delete storage_file;
00196
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
00231
00232 testSummary = new TObjString(myString.c_str());
00233
00234
00235
00236
00237 return;
00238
00239
00240 }
00241