00001 #define ProofTests_cxx
00002
00003
00004
00005
00006
00007
00008
00009 #include "ProofTests.h"
00010 #include <TEnv.h>
00011 #include <TH1F.h>
00012 #include <TH1I.h>
00013 #include <TMath.h>
00014 #include <TString.h>
00015 #include <TSystem.h>
00016 #include <TParameter.h>
00017
00018
00019 ProofTests::ProofTests()
00020 {
00021
00022
00023 fTestType = 0;
00024 fStat = 0;
00025 }
00026
00027
00028 ProofTests::~ProofTests()
00029 {
00030
00031
00032 }
00033
00034
00035 void ProofTests::ParseInput()
00036 {
00037
00038
00039
00040
00041 TNamed *ntype = dynamic_cast<TNamed*>(fInput->FindObject("ProofTests_Type"));
00042 if (ntype) {
00043 if (!strcmp(ntype->GetTitle(), "InputData")) {
00044 fTestType = 0;
00045 } else if (!strcmp(ntype->GetTitle(), "PackTest1")) {
00046 fTestType = 1;
00047 } else if (!strcmp(ntype->GetTitle(), "PackTest2")) {
00048 fTestType = 2;
00049 } else {
00050 Warning("ParseInput", "unknown type: '%s'", ntype->GetTitle());
00051 }
00052 }
00053 Info("ParseInput", "test type: %d (from '%s')", fTestType, ntype ? ntype->GetTitle() : "undef");
00054 }
00055
00056
00057 void ProofTests::Begin(TTree * )
00058 {
00059
00060
00061
00062
00063
00064 ParseInput();
00065 }
00066
00067
00068 void ProofTests::SlaveBegin(TTree * )
00069 {
00070
00071
00072
00073
00074 TString option = GetOption();
00075
00076
00077 ParseInput();
00078
00079
00080 fStat = new TH1I("TestStat", "Test results", 20, .5, 20.5);
00081 fOutput->Add(fStat);
00082
00083
00084 fStat->Fill(1.);
00085
00086
00087 if (fTestType == 0) {
00088
00089
00090 TList *h1list = dynamic_cast<TList*>(fInput->FindObject("h1list"));
00091 if (h1list) {
00092
00093 TH1F *h1 = dynamic_cast<TH1F*>(h1list->FindObject("h1data"));
00094 if (h1) {
00095 TParameter<Double_t> *h1avg = dynamic_cast<TParameter<Double_t>*>(h1list->FindObject("h1avg"));
00096 TParameter<Double_t> *h1rms = dynamic_cast<TParameter<Double_t>*>(h1list->FindObject("h1rms"));
00097 if (h1avg && h1rms) {
00098 if (TMath::Abs(h1avg->GetVal() - h1->GetMean()) < 0.0001) {
00099 if (TMath::Abs(h1rms->GetVal() - h1->GetRMS()) < 0.0001) {
00100 fStat->Fill(2.);
00101 }
00102 }
00103 } else {
00104 Info("SlaveBegin", "%d: info 'h1avg' or 'h1rms' not found!", fTestType);
00105 }
00106 } else {
00107 Info("SlaveBegin", "%d: input histo 'h1data' not found!", fTestType);
00108 }
00109 } else {
00110 Info("SlaveBegin", "%d: input list 'h1list' not found!", fTestType);
00111 }
00112
00113 TList *h2list = dynamic_cast<TList*>(fInput->FindObject("h2list"));
00114 if (h2list) {
00115
00116 TH1F *h2 = dynamic_cast<TH1F*>(h2list->FindObject("h2data"));
00117 if (h2) {
00118 TParameter<Double_t> *h2avg = dynamic_cast<TParameter<Double_t>*>(h2list->FindObject("h2avg"));
00119 TParameter<Double_t> *h2rms = dynamic_cast<TParameter<Double_t>*>(h2list->FindObject("h2rms"));
00120 if (h2avg && h2rms) {
00121 if (TMath::Abs(h2avg->GetVal() - h2->GetMean()) < 0.0001) {
00122 if (TMath::Abs(h2rms->GetVal() - h2->GetRMS()) < 0.0001) {
00123 fStat->Fill(3.);
00124 }
00125 }
00126 } else {
00127 Info("SlaveBegin", "%d: info 'h2avg' or 'h2rms' not found!", fTestType);
00128 }
00129 } else {
00130 Info("SlaveBegin", "%d: input histo 'h2data' not found!", fTestType);
00131 }
00132 } else {
00133 Info("SlaveBegin", "%d: input list 'h2list' not found!", fTestType);
00134 }
00135
00136 TNamed *iob = dynamic_cast<TNamed*>(fInput->FindObject("InputObject"));
00137 if (iob) {
00138 fStat->Fill(4.);
00139 } else {
00140 Info("SlaveBegin", "%d: input histo 'InputObject' not found!", fTestType);
00141 }
00142 } else if (fTestType == 1) {
00143
00144
00145 TNamed *nm = dynamic_cast<TNamed*>(fInput->FindObject("testenv"));
00146 if (nm) {
00147 if (gEnv->Lookup(nm->GetTitle())) fStat->Fill(2.);
00148 } else {
00149 Info("SlaveBegin", "%d: TNamed with the test env info not found!", fTestType);
00150 }
00151 } else if (fTestType == 2) {
00152
00153
00154 TNamed *nm = dynamic_cast<TNamed*>(fInput->FindObject("testenv"));
00155 if (nm) {
00156 TString nms(nm->GetTitle()), nam;
00157 Int_t from = 0;
00158 while (nms.Tokenize(nam, from, ",")) {
00159 if (gEnv->Lookup(nam)) {
00160 Double_t xx = gEnv->GetValue(nam, -1.);
00161 if (xx > 1.) fStat->Fill(xx);
00162 }
00163 }
00164 } else {
00165 Info("SlaveBegin", "%d: TNamed with the test env info not found!", fTestType);
00166 }
00167 }
00168 }
00169
00170
00171 Bool_t ProofTests::Process(Long64_t)
00172 {
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 return kTRUE;
00192 }
00193
00194
00195 void ProofTests::SlaveTerminate()
00196 {
00197
00198
00199
00200
00201 }
00202
00203
00204 void ProofTests::Terminate()
00205 {
00206
00207
00208
00209
00210 }