#include <RecValidate.h>
Public Member Functions | |
| RecValidate () | |
| virtual | ~RecValidate () |
| bool | TestDataRecord (void) |
| bool | TestReadRecord (void) |
| bool | TestReadRecordOld (void) |
| bool | TestWriteRecord (void) |
| bool | TestWriteRecordOld (void) |
| bool | TestArrayAllocator (void) |
| bool | TestRecordTempTags (void) |
| bool | RunAllTests (void) |
|
|
Definition at line 34 of file RecValidate.cc. 00034 {
00035 //
00036 // Purpose: Default constructor.
00037 //
00038 // Arguments: none.
00039 //
00040 // Return: n/a.
00041 //
00042 // Contact: S. Kasahara
00043 //
00044
00045 }
|
|
|
Definition at line 47 of file RecValidate.cc. 00047 {
00048 //
00049 // Purpose: Destructor.
00050 //
00051 // Contact: S. Kasahara
00052 //
00053
00054 }
|
|
|
Definition at line 361 of file RecValidate.cc. References TestArrayAllocator(), TestDataRecord(), TestReadRecord(), TestReadRecordOld(), TestRecordTempTags(), TestWriteRecord(), and TestWriteRecordOld(). Referenced by main(). 00361 {
00362 //
00363 // Purpose: Run sequence of Record package validity tests.
00364 //
00365 // Arguments: none.
00366 //
00367 // Return: pass (if all tests successful) or fail
00368 //
00369 // Contact: S. Kasahara
00370 //
00371 // Notes:
00372 //
00373
00374 bool allPassed = true;
00375
00376 cout << "*** TestArrayAllocator *** " << endl;
00377 if ( this -> TestArrayAllocator() ) cout << "*** Passed ***" << endl;
00378 else {
00379 cout << "*** Failed ***" << endl;
00380 allPassed = false;
00381 }
00382 cout << "*** TestDataRecord *** " << endl;
00383 if ( this -> TestDataRecord() ) cout << "*** Passed ***" << endl;
00384 else {
00385 cout << "*** Failed ***" << endl;
00386 allPassed = false;
00387 }
00388 cout << "*** TestWriteRecordOld *** " << endl;
00389 if ( this -> TestWriteRecordOld() ) cout << "*** Passed ***" << endl;
00390 else {
00391 cout << "*** Failed ***" << endl;
00392 allPassed = false;
00393 }
00394 cout << "*** TestReadRecordOld *** " << endl;
00395 if ( this -> TestReadRecordOld() ) cout << "*** Passed ***" << endl;
00396 else {
00397 cout << "*** Failed ***" << endl;
00398 allPassed = false;
00399 }
00400 cout << "*** TestWriteRecord *** " << endl;
00401 if ( this -> TestWriteRecord() ) cout << "*** Passed ***" << endl;
00402 else {
00403 cout << "*** Failed ***" << endl;
00404 allPassed = false;
00405 }
00406 cout << "*** TestReadRecord *** " << endl;
00407 if ( this -> TestReadRecord() ) cout << "*** Passed ***" << endl;
00408 else {
00409 cout << "*** Failed ***" << endl;
00410 allPassed = false;
00411 }
00412 cout << "*** TestRecordTempTags *** " << endl;
00413 if ( this -> TestRecordTempTags() ) cout << "*** Passed ***" << endl;
00414 else {
00415 cout << "*** Failed ***" << endl;
00416 allPassed = false;
00417 }
00418
00419 return allPassed;
00420
00421 }
|
|
|
Definition at line 122 of file RecValidate.cc. References RecArrayAllocator::GetArray(), RecArrayAllocator::GetNumArray(), RecArrayAllocator::Instance(), and RecArrayAllocator::ReleaseArray(). Referenced by RunAllTests(). 00122 {
00123 //
00124 // Purpose: Test RecArrayAllocator class.
00125 //
00126 // Contact: S. Kasahara
00127 //
00128
00129 bool isPass = true;
00130
00131 RecArrayAllocator& mgr = RecArrayAllocator::Instance();
00132 cout << "Request 3 arrays " << endl;
00133 TClonesArray* array1 = mgr.GetArray("RecPhysicsHeader");
00134 TClonesArray* array2 = mgr.GetArray("RecPhysicsHeader");
00135 TClonesArray* array3 = mgr.GetArray("RecDataHeader");
00136 if (mgr.GetNumArray() != 3 ) isPass = false;
00137 cout << mgr << endl;
00138
00139 cout << "Releasing one of RecPhysicsHeader arrays." << endl;
00140 mgr.ReleaseArray(array2); array2 = 0;
00141 if (mgr.GetNumArray() != 3 ) isPass = false;
00142 cout << mgr << endl;
00143
00144 cout << "Request new array to replace released array." << endl;
00145 array2 = mgr.GetArray("RecPhysicsHeader");
00146 if (mgr.GetNumArray() != 3 ) isPass = false;
00147 cout << mgr << endl;
00148
00149 cout << "And release all 3." << endl;
00150 mgr.ReleaseArray(array3); array3 = 0;
00151 mgr.ReleaseArray(array2); array2 = 0;
00152 mgr.ReleaseArray(array1); array1 = 0;
00153 if (mgr.GetNumArray() != 3 ) isPass = false;
00154 cout << mgr << endl;
00155
00156 return isPass;
00157
00158 }
|
|
|
Definition at line 56 of file RecValidate.cc. References RecDataRecord< T >::AdoptComponent(), RecDataRecord< T >::FindComponent(), and RecDataRecord< T >::HasComponent(). Referenced by RunAllTests(). 00056 {
00057 //
00058 // Purpose: Fill a RecDataRecord and test associated methods.
00059 //
00060 // Contact: S. Kasahara
00061 //
00062
00063 time_t sec = 7;
00064 Int_t nsec = 8;
00065 VldTimeStamp vldt(sec,nsec);
00066 DetectorType::Detector_t detType = DetectorType::kFar;
00067 SimFlag::SimFlag_t simFlag = SimFlag::kData;
00068
00069 VldContext vldc(detType,simFlag,vldt);
00070
00071 Int_t run = 9;
00072 Short_t subrun = 10;
00073 Short_t runtype = 11;
00074 UInt_t errorcode = 0x0012;
00075 Int_t snarl = 13;
00076 UInt_t trigsrc = 0x0014;
00077 Int_t timeframe = 15;
00078 Int_t spilltype = 0;
00079
00080 RecPhysicsHeader hdr(vldc,run,subrun,runtype,errorcode,snarl,trigsrc,
00081 timeframe,spilltype);
00082 RecDataRecord<RecPhysicsHeader> rec(hdr);
00083
00084 TObject *tobject = new TObject();
00085 rec.AdoptComponent(tobject);
00086 if ( !rec.HasComponent("TObject") ) {
00087 cerr << "HasComponent failed to find TObject" << endl;
00088 return false;
00089 }
00090 if ( !rec.FindComponent("TObject") ) {
00091 cerr << "FindComponent failed to find TObject" << endl;
00092 return false;
00093 }
00094
00095 TNamed *tnamed = new TNamed("RecValidate","TestDataRecord");
00096 rec.AdoptComponent(tnamed);
00097
00098 cout << rec << endl;
00099 if ( !rec.HasComponent("TNamed") ) {
00100 cerr << "HasComponent failed to find TNamed object by class" << endl;
00101 return false;
00102 }
00103 if ( !rec.HasComponent("TNamed","RecValidate") ) {
00104 cerr << "HasComponent failed to find TNamed object by cls&obj name" <<endl;
00105 return false;
00106 }
00107
00108 if ( !rec.FindComponent("TNamed") ) {
00109 cerr << "FindComponent failed to find TNamed object by class" << endl;
00110 return false;
00111 }
00112 if ( !rec.FindComponent("TNamed","RecValidate") ) {
00113 cerr << "FindComponent failed to find TNamed object by cls&obj name"<<endl;
00114 return false;
00115 }
00116
00117 return true;
00118
00119 }
|
|
|
Definition at line 270 of file RecValidate.cc. Referenced by RunAllTests(). 00270 {
00271 //
00272 // Purpose: Test read of records to tree class.
00273 //
00274 // Contact: S. Kasahara
00275 //
00276
00277 bool isPass = true;
00278
00279 TFile* file = new TFile("testfile.root","READ");
00280 cout << "Retrieving records:" << endl;
00281 if ( file ) {
00282 TTree* tree = (TTree*)(file->Get("test"));
00283 RecDataRecord<RecCandHeader>* record = 0;
00284 for ( Int_t i = 0; i < tree->GetEntries(); i++ ) {
00285 tree ->SetBranchAddress("RecDataRecord",&record);
00286 Int_t nbytes = tree->GetEntry(i);
00287 cout << "Read " << nbytes << " bytes from entry " << i << endl;
00288 cout << *record;
00289 cout << record->GetName() << "," << record->GetTitle() << endl;
00290 delete record; record = 0;
00291 }
00292 delete file; file = 0;
00293 }
00294 else isPass = false;
00295
00296 return isPass;
00297
00298 }
|
|
|
Definition at line 240 of file RecValidate.cc. References RecMinos::Print(). Referenced by RunAllTests(). 00240 {
00241 //
00242 // Purpose: Test read of records to tree class.
00243 //
00244 // Contact: S. Kasahara
00245 //
00246
00247 bool isPass = true;
00248
00249 TFile* file = new TFile("testfileold.root","READ");
00250 cout << "Retrieving records:" << endl;
00251 if ( file ) {
00252 TTree* tree = (TTree*)(file->Get("test"));
00253 RecMinos* record = 0;
00254 for ( Int_t i = 0; i < tree->GetEntries(); i++ ) {
00255 tree ->SetBranchAddress("RecMinos",&record);
00256 Int_t nbytes = tree->GetEntry(i);
00257 cout << "Read " << nbytes << " bytes from entry " << i << endl;
00258 record->Print();
00259 cout << record->GetName() << endl;
00260 delete record; record = 0;
00261 }
00262 delete file; file = 0;
00263 }
00264 else isPass = false;
00265
00266 return isPass;
00267
00268 }
|
|
|
Definition at line 300 of file RecValidate.cc. References RecRecordImp< T >::IsPersistedToOutputStream(), RecRecordImp< T >::IsTransient(), and RecRecordImp< T >::Print(). Referenced by RunAllTests(). 00300 {
00301 //
00302 // Purpose: Test methods that make use of Record fTempTags data member.
00303 //
00304 // Contact: S. Kasahara
00305 //
00306
00307 bool isPass = true;
00308
00309 RecRecordImp<RecHeader>* record = new RecRecordImp<RecHeader>;
00310 cout << "New record temptags:" << endl;
00311 record -> GetTempTags().Print();
00312 record -> PersistedToOutputStream("streamA","fileA","treeA",0);
00313 record -> PersistedToOutputStream("streamB","fileB","treeB",0);
00314 cout << "Record temptags after marking as persisted:" << endl;
00315 record -> GetTempTags().Print();
00316 if ( !record->IsPersistedToOutputStream("streamA","fileA","treeA") ) {
00317 cout << "Error testing IsPersisted for streamA,fileA,treeA"<< endl;
00318 return false;
00319 }
00320 if ( !record->IsPersistedToOutputStream("streamA","","treeA") ) {
00321 cout << "Error testing IsPersisted for streamA,treeA"<< endl;
00322 return false;
00323 }
00324 if ( record->IsPersistedToOutputStream("streamB","","treeA") ) {
00325 cout << "Error testing IsPersisted for streamB,treeA"<< endl;
00326 return false;
00327 }
00328 if ( !record->IsPersistedToOutputStream("streamB","fileB","treeB") ) {
00329 cout << "Error testing IsPersisted for streamB,fileB,treeB"<< endl;
00330 return false;
00331 }
00332 if ( !record->IsPersistedToOutputStream("streamA","","treeA",0) ) {
00333 cout << "Error testing IsPersisted for streamA,treeA,0"<< endl;
00334 return false;
00335 }
00336 if ( !record->IsPersistedToOutputStream() ) {
00337 cout << "Error testing IsPersisted for no arguments"<< endl;
00338 return false;
00339 }
00340
00341 record -> HasBeenModified();
00342 cout << "Record temptags post call to HasBeenModified:" << endl;
00343 record -> GetTempTags().Print();
00344
00345 if ( !record->IsTransient() ) {
00346 cout << "Error, record is not in default state of IsTransient " << endl;
00347 return false;
00348 }
00349
00350 record -> SetTransient(false);
00351 if ( record->IsTransient() ) {
00352 cout << "Error setting record to non-transient" << endl;
00353 return false;
00354 }
00355
00356 return isPass;
00357
00358 }
|
|
|
Definition at line 160 of file RecValidate.cc. References RecDataRecord< T >::AdoptComponent(). Referenced by RunAllTests(). 00160 {
00161 //
00162 // Purpose: Test write of record to tree class.
00163 //
00164 // Contact: S. Kasahara
00165 //
00166
00167 bool isPass = true;
00168
00169 TFile* file = new TFile("testfile.root","RECREATE");
00170 cout << "Writing records:" << endl;
00171 if ( file ) {
00172 TTree* tree = new TTree("test","test tree");
00173 RecDataRecord<RecCandHeader>* record = 0;
00174 // splitting to 99 only works with cvs ROOT post 11/26/02.
00175 tree ->Branch("RecDataRecord","RecDataRecord<RecCandHeader>",&record,64000,99);
00176 for ( Int_t i = 0; i < 3; i++ ) {
00177 VldContext vld(DetectorType::kFar,SimFlag::kData,
00178 VldTimeStamp((time_t)i,2));
00179 RecCandHeader hdr(vld,3,4,5,6,7,8,9,10,11);
00180 record = new RecDataRecord<RecCandHeader>(hdr);
00181 record -> Print();
00182 TObject *tobject = new TObject();
00183 record->AdoptComponent(tobject);
00184 TNamed *tnamed = new TNamed("RecValidate","TestDataRecord");
00185 record->AdoptComponent(tnamed);
00186 cout << " " << *record;
00187 record->SetName("MyName");
00188 record->SetTitle("MyTitle");
00189 cout << record->GetName() << "," << record->GetTitle() << endl;
00190 tree -> Fill();
00191 delete record; record = 0;
00192 }
00193 tree->Write();
00194 file->Close();
00195 delete file; file = 0;
00196 }
00197 else isPass = false;
00198
00199 return isPass;
00200
00201 }
|
|
|
Definition at line 203 of file RecValidate.cc. Referenced by RunAllTests(). 00203 {
00204 //
00205 // Purpose: Test write of record to tree class.
00206 //
00207 // Contact: S. Kasahara
00208 //
00209
00210 bool isPass = true;
00211
00212 TFile* file = new TFile("testfileold.root","RECREATE");
00213 cout << "Writing old records:" << endl;
00214 if ( file ) {
00215 TTree* tree = new TTree("test","test tree");
00216 RecMinos* record = 0;
00217 tree ->Branch("RecMinos","RecMinos",&record,64000,99);
00218 for ( Int_t i = 0; i < 3; i++ ) {
00219 VldContext vld(DetectorType::kFar,SimFlag::kData,
00220 VldTimeStamp((time_t)i,2));
00221 RecMinosHdr* hdr = new RecMinosHdr(vld);
00222 cout << "Creating record " << endl;
00223 record = new RecMinos(hdr);
00224 record -> SetName("PrimaryCandidateRecord");
00225 record -> Print();
00226 cout << record->GetName() << endl;
00227 tree -> Fill();
00228 delete record; record = 0;
00229 }
00230 tree->Write();
00231 file->Close();
00232 delete file; file = 0;
00233 }
00234 else isPass = false;
00235
00236 return isPass;
00237
00238 }
|
1.3.9.1