00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #include <iostream>
00014 using std::cout;
00015 using std::endl;
00016
00017 #include "MessageService/MsgStream.h"
00018 #include "MessageService/MsgService.h"
00019 #include "MinosObjectMap/MomNavigator.h"
00020 #include "RawData/RawRecord.h"
00021
00022 #include "Persistency/test/PerValidate.h"
00023 #include "Persistency/PerInputStream.h"
00024 #include "Persistency/PerRecordTags.h"
00025
00026
00027
00028
00029
00030
00031
00032 PerValidate::PerValidate() : fFileName("pervld.root") {
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 }
00044
00045 PerValidate::~PerValidate() {
00046
00047
00048
00049
00050
00051
00052 }
00053
00054 bool PerValidate::StreamTagsSeq() {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 bool pass = true;
00069
00070 Int_t snlInd[5][2] = { {0,0},{1,1},{2,2},{3,3},{4,4} };
00071 Int_t monInd[5][2] = { {0,0},{1,3},{4,5},{6,7},{8,9} };
00072
00073 PerInputStream* instream = dynamic_cast<PerInputStream*>
00074 (fInputStreamManager.GetOpenedStream("DaqSnarl"));
00075 PerRecordTags tags = instream -> NextTags();
00076 Int_t set = -1;
00077 while ( !tags.IsEnd() ) {
00078 set++;
00079
00080 if ( tags.GetIndexLo() != snlInd[set][0]
00081 || tags.GetIndexHi() != snlInd[set][1]) {
00082 return false;
00083 }
00084 tags = instream -> NextTags();
00085 }
00086
00087 tags = instream -> PrevTags();
00088 while ( !tags.IsBegin() ) {
00089
00090 if ( tags.GetIndexLo() != snlInd[set][0]
00091 || tags.GetIndexHi() != snlInd[set][1]) {
00092 return false;
00093 }
00094 tags = instream -> PrevTags();
00095 set--;
00096 }
00097
00098 tags = instream -> NextTags();
00099 set = -1;
00100 while ( !tags.IsEnd() ) {
00101 set++;
00102
00103 if ( tags.GetIndexLo() != snlInd[set][0]
00104 || tags.GetIndexHi() != snlInd[set][1]) {
00105 return false;
00106 }
00107 tags = instream -> NextTags();
00108 }
00109
00110 tags = instream -> PrevTags();
00111 while ( !tags.IsBegin() ) {
00112
00113 if ( tags.GetIndexLo() != snlInd[set][0]
00114 || tags.GetIndexHi() != snlInd[set][1]) {
00115 return false;
00116 }
00117 tags = instream -> PrevTags();
00118 set--;
00119 }
00120
00121 instream = dynamic_cast<PerInputStream*>
00122 (fInputStreamManager.GetOpenedStream("DaqMonitor"));
00123 tags = instream -> NextTags();
00124 while ( !tags.IsEnd() ) {
00125
00126 set++;
00127 if ( tags.GetIndexLo() != monInd[set][0]
00128 || tags.GetIndexHi() != monInd[set][1]) {
00129 return false;
00130 }
00131 tags = instream -> NextTags();
00132 }
00133
00134 tags = instream -> PrevTags();
00135 while ( !tags.IsBegin() ) {
00136
00137 if ( tags.GetIndexLo() != monInd[set][0]
00138 || tags.GetIndexHi() != monInd[set][1]) {
00139 return false;
00140 }
00141 tags = instream -> PrevTags();
00142 set--;
00143 }
00144
00145 tags = instream -> NextTags();
00146 while ( !tags.IsEnd() ) {
00147
00148 set++;
00149 if ( tags.GetIndexLo() != monInd[set][0]
00150 || tags.GetIndexHi() != monInd[set][1]) {
00151 return false;
00152 }
00153 tags = instream -> NextTags();
00154 }
00155
00156 tags = instream -> PrevTags();
00157 while ( !tags.IsBegin() ) {
00158
00159 if ( tags.GetIndexLo() != monInd[set][0]
00160 || tags.GetIndexHi() != monInd[set][1]) {
00161 return false;
00162 }
00163 tags = instream -> PrevTags();
00164 set--;
00165 }
00166
00167 return pass;
00168
00169 }
00170
00171 bool PerValidate::StreamMgrTagsSeq() {
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 bool pass = true;
00186
00187 Int_t fwdInd[10][2] = { {0,0},{1,3},{4,5},{0,0},{1,1},{6,7},{2,2},{3,3},
00188 {4,4},{8,9} };
00189 Int_t rewInd[10][2] = { {8,9},{6,7},{4,4},{3,3},{2,2},{1,1},{0,0},{4,5},
00190 {1,3},{0,0} };
00191
00192 MomNavigator* mom = new MomNavigator();
00193 Int_t nadv = fInputStreamManager.Next(mom);
00194 Int_t set = -1;
00195 while ( nadv > 0 ) {
00196 set++;
00197
00198
00199 TIter fiter = mom ->FragmentIter();
00200 RawRecord* rawrecord;
00201 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00202
00203
00204
00205
00206
00207
00208 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00209 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00210 return false;
00211 }
00212 mom -> Clear();
00213 nadv = fInputStreamManager.Next(mom);
00214 }
00215
00216 Int_t nprev = fInputStreamManager.Previous(mom);
00217 set = -1;
00218 while ( nprev > 0 ) {
00219 set++;
00220
00221
00222 TIter fiter = mom ->FragmentIter();
00223 RawRecord* rawrecord;
00224 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00225
00226
00227
00228
00229
00230
00231 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00232 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00233 return false;
00234 }
00235 mom -> Clear();
00236 nprev = fInputStreamManager.Previous(mom);
00237 }
00238
00239 nadv = fInputStreamManager.Next(mom);
00240 set = -1;
00241 while ( nadv > 0 ) {
00242 set++;
00243
00244
00245 TIter fiter = mom ->FragmentIter();
00246 RawRecord* rawrecord;
00247 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00248
00249
00250
00251
00252
00253
00254 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00255 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00256 return false;
00257 }
00258 mom -> Clear();
00259 nadv = fInputStreamManager.Next(mom);
00260 }
00261
00262 nprev = fInputStreamManager.Previous(mom);
00263 set = -1;
00264 while ( nprev > 0 ) {
00265 set++;
00266
00267
00268 TIter fiter = mom ->FragmentIter();
00269 RawRecord* rawrecord;
00270 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00271
00272
00273
00274
00275
00276
00277 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00278 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00279 return false;
00280 }
00281 mom -> Clear();
00282 nprev = fInputStreamManager.Previous(mom);
00283 }
00284 if ( mom ) delete mom; mom = 0;
00285
00286 return pass;
00287
00288 }
00289
00290 bool PerValidate::StreamMgrParallelFileSeq() {
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 bool pass = true;
00307
00308 Int_t fwdInd[20][2] = { {0,0},{1,3},{4,5},{0,0},{1,1},{6,7},{2,2},{3,3},
00309 {4,4},{8,9},
00310 {0,0},{0,1},{1,1},{2,2},{3,3},{2,3},{4,5},{6,7},
00311 {4,4},{5,5} };
00312 Int_t rewInd[20][2] = { {5,5},{4,4},{6,7},{4,5},{2,3},{3,3},{2,2},{1,1},
00313 {0,1},{0,0},
00314 {8,9},{6,7},{4,4},{3,3},{2,2},{1,1},{0,0},{4,5},
00315 {1,3},{0,0} };
00316
00317 fInputStreamManager.CloseFile();
00318 fInputStreamManager.AddFile("pervld.root",-1,"DaqSnarl");
00319 fInputStreamManager.AddFile("pervld2.root",-1,"DaqSnarl");
00320 fInputStreamManager.AddFile("pervld.root",-1,"DaqMonitor");
00321 fInputStreamManager.AddFile("pervld2.root",-1,"DaqMonitor");
00322
00323 MomNavigator* mom = new MomNavigator();
00324 Int_t nadv = fInputStreamManager.Next(mom);
00325 Int_t set = -1;
00326 while ( nadv > 0 ) {
00327 set++;
00328
00329 TIter fiter = mom ->FragmentIter();
00330 RawRecord* rawrecord;
00331 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00332
00333
00334
00335
00336
00337
00338
00339 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00340 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00341 return false;
00342 }
00343 mom -> Clear();
00344 nadv = fInputStreamManager.Next(mom);
00345 }
00346
00347 Int_t nprev = fInputStreamManager.Previous(mom);
00348 set = -1;
00349 while ( nprev > 0 ) {
00350 set++;
00351
00352 TIter fiter = mom ->FragmentIter();
00353 RawRecord* rawrecord;
00354 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00355
00356
00357
00358
00359
00360
00361
00362 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00363 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00364 return false;
00365 }
00366 mom -> Clear();
00367 nprev = fInputStreamManager.Previous(mom);
00368 }
00369
00370 nadv = fInputStreamManager.Next(mom);
00371 set = -1;
00372 while ( nadv > 0 ) {
00373 set++;
00374
00375 TIter fiter = mom ->FragmentIter();
00376 RawRecord* rawrecord;
00377 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00378
00379
00380
00381
00382
00383
00384 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00385 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00386 return false;
00387 }
00388 mom -> Clear();
00389 nadv = fInputStreamManager.Next(mom);
00390 }
00391
00392 nprev = fInputStreamManager.Previous(mom);
00393 set = -1;
00394 while ( nprev > 0 ) {
00395 set++;
00396
00397 TIter fiter = mom ->FragmentIter();
00398 RawRecord* rawrecord;
00399 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00400
00401
00402
00403
00404
00405
00406 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00407 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00408 return false;
00409 }
00410 mom -> Clear();
00411 nprev = fInputStreamManager.Previous(mom);
00412 }
00413 if ( mom ) delete mom; mom = 0;
00414
00415 cout << "Resetting file list " << endl;
00416 fInputStreamManager.RecordsAt(0,Per::GetVldEnd());
00417 fInputStreamManager.RemoveFile();
00418
00419 fInputStreamManager.CloseFile();
00420 fInputStreamManager.SetFile("*",fFileName,Per::kRead);
00421
00422 return pass;
00423
00424 }
00425
00426 bool PerValidate::StreamMgrFileChangeSeq() {
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 bool pass = true;
00441
00442 Int_t fwdInd[10][2] = { {0,0},{1,3},{4,5},{0,0},{1,1},{6,7},{2,2},{3,3},
00443 {4,4},{8,9} };
00444 Int_t rewInd[10][2] = { {8,9},{6,7},{4,4},{3,3},{2,2},{1,1},{0,0},{4,5},
00445 {1,3},{0,0} };
00446
00447 MomNavigator* mom = new MomNavigator();
00448 Int_t nadv = fInputStreamManager.Next(mom);
00449 Int_t set = -1;
00450 while ( nadv > 0 ) {
00451 set++;
00452
00453
00454 TIter fiter = mom ->FragmentIter();
00455 RawRecord* rawrecord;
00456 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00457
00458
00459
00460
00461
00462
00463 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00464 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00465 return false;
00466 }
00467 mom -> Clear();
00468 nadv = fInputStreamManager.Next(mom);
00469 }
00470
00471 Int_t nprev = fInputStreamManager.Previous(mom);
00472 set = -1;
00473 while ( nprev > 0 ) {
00474 set++;
00475
00476
00477 TIter fiter = mom ->FragmentIter();
00478 RawRecord* rawrecord;
00479 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00480
00481
00482
00483
00484
00485
00486 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00487 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00488 return false;
00489 }
00490 mom -> Clear();
00491 nprev = fInputStreamManager.Previous(mom);
00492 }
00493
00494 fInputStreamManager.CloseFile();
00495 fInputStreamManager.SetFile("*",fFileName,Per::kRead);
00496
00497 nadv = fInputStreamManager.Next(mom);
00498 set = -1;
00499 while ( nadv > 0 ) {
00500 set++;
00501
00502 TIter fiter = mom ->FragmentIter();
00503 RawRecord* rawrecord;
00504 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00505
00506
00507
00508
00509
00510
00511 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00512 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00513 return false;
00514 }
00515 mom -> Clear();
00516 nadv = fInputStreamManager.Next(mom);
00517 }
00518
00519 nprev = fInputStreamManager.Previous(mom);
00520 set = -1;
00521 while ( nprev > 0 ) {
00522 set++;
00523
00524
00525 TIter fiter = mom ->FragmentIter();
00526 RawRecord* rawrecord;
00527 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00528
00529
00530
00531
00532
00533
00534 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00535 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00536 return false;
00537 }
00538 mom -> Clear();
00539 nprev = fInputStreamManager.Previous(mom);
00540 }
00541 if ( mom ) delete mom; mom = 0;
00542
00543 return pass;
00544
00545 }
00546
00547 bool PerValidate::StreamMgrTagsSeqZigZag() {
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561 bool pass = true;
00562
00563 Int_t fwdInd[4][2] = { {0,0},{1,3},{4,5},{0,0} };
00564 Int_t rewInd[4][2] = { {4,5},{1,3} };
00565 Int_t fwdInd2[8][2] = { {4,5},{0,0},{1,1},{6,7},{2,2},{3,3},{4,4},{8,9} };
00566 Int_t rewInd2[10][2] = { {8,9},{6,7},{4,4},{3,3},{2,2},{1,1},{0,0},{4,5},
00567 {1,3},{0,0} };
00568
00569 MomNavigator* mom = new MomNavigator();
00570 Int_t nadv = fInputStreamManager.Next(mom);
00571 Int_t set = -1;
00572 while ( nadv > 0 && set < 3 ) {
00573 set++;
00574
00575 TIter fiter = mom ->FragmentIter();
00576 RawRecord* rawrecord;
00577 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00578
00579
00580
00581
00582
00583
00584 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00585 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00586 return false;
00587 }
00588 mom -> Clear();
00589 if ( set < 3 ) nadv = fInputStreamManager.Next(mom);
00590 }
00591
00592 Int_t nprev = fInputStreamManager.Previous(mom);
00593 set = -1;
00594 while ( nprev > 0 && set < 1 ) {
00595 set++;
00596
00597
00598 TIter fiter = mom ->FragmentIter();
00599 RawRecord* rawrecord;
00600 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00601
00602
00603
00604
00605
00606
00607 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00608 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00609 return false;
00610 }
00611 mom -> Clear();
00612 if ( set < 1 ) nprev = fInputStreamManager.Previous(mom);
00613 }
00614
00615 nadv = fInputStreamManager.Next(mom);
00616 set = -1;
00617 while ( nadv > 0 ) {
00618 set++;
00619
00620 TIter fiter = mom ->FragmentIter();
00621 RawRecord* rawrecord;
00622 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00623
00624
00625
00626
00627
00628
00629 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd2[set][0]
00630 ||rawrecord->GetTempTags().GetInt("index") > fwdInd2[set][1] )
00631 return false;
00632 }
00633 mom -> Clear();
00634 nadv = fInputStreamManager.Next(mom);
00635 }
00636
00637 nprev = fInputStreamManager.Previous(mom);
00638 set = -1;
00639 while ( nprev > 0 ) {
00640 set++;
00641
00642 TIter fiter = mom ->FragmentIter();
00643 RawRecord* rawrecord;
00644 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00645
00646
00647
00648
00649
00650
00651 if ( rawrecord->GetTempTags().GetInt("index") < rewInd2[set][0]
00652 ||rawrecord->GetTempTags().GetInt("index") > rewInd2[set][1] )
00653 return false;
00654 }
00655 mom -> Clear();
00656 nprev = fInputStreamManager.Previous(mom);
00657 }
00658 if ( mom ) delete mom; mom = 0;
00659
00660 return pass;
00661
00662 }
00663
00664 bool PerValidate::StreamMgrSelectionSeq() {
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678 bool pass = true;
00679
00680 Int_t fwdInd[3][2] = { {4,5},{3,3} };
00681 Int_t rewInd[3][2] = { {4,4},{4,5} };
00682
00683 fInputStreamManager.SetSelection("DaqSnarl",
00684 "((RawDaqSnarlHeader*)fHeader)->GetSnarl()>1");
00685 MomNavigator* mom = new MomNavigator();
00686 Int_t nadv = fInputStreamManager.Next(mom,3);
00687
00688 Int_t set = -1;
00689 while ( nadv > 0 ) {
00690 set++;
00691
00692 TIter fiter = mom ->FragmentIter();
00693 RawRecord* rawrecord;
00694 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00695
00696
00697
00698
00699
00700
00701 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00702 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00703 return false;
00704 }
00705 mom -> Clear();
00706 nadv = fInputStreamManager.Next(mom,3);
00707 }
00708
00709 Int_t nprev = fInputStreamManager.Previous(mom,3);
00710 set = -1;
00711 while ( nprev > 0 ) {
00712 set++;
00713
00714 TIter fiter = mom ->FragmentIter();
00715 RawRecord* rawrecord;
00716 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00717
00718
00719
00720
00721
00722
00723 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00724 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00725 return false;
00726 }
00727 mom -> Clear();
00728 nprev = fInputStreamManager.Previous(mom,3);
00729 }
00730
00731 nadv = fInputStreamManager.Next(mom,3);
00732 set = -1;
00733 while ( nadv > 0 ) {
00734 set++;
00735
00736 TIter fiter = mom ->FragmentIter();
00737 RawRecord* rawrecord;
00738 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00739
00740
00741
00742
00743
00744
00745 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00746 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00747 return false;
00748 }
00749 mom -> Clear();
00750 nadv = fInputStreamManager.Next(mom,3);
00751 }
00752
00753 nprev = fInputStreamManager.Previous(mom,3);
00754 set = -1;
00755 while ( nprev > 0 ) {
00756 set++;
00757
00758 TIter fiter = mom ->FragmentIter();
00759 RawRecord* rawrecord;
00760 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00761
00762
00763
00764
00765
00766
00767 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00768 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00769 return false;
00770 }
00771 mom -> Clear();
00772 nprev = fInputStreamManager.Previous(mom,3);
00773 }
00774 if ( mom ) delete mom; mom = 0;
00775
00776 fInputStreamManager.SetSelection("DaqSnarl","");
00777
00778 return pass;
00779
00780 }
00781
00782 bool PerValidate::StreamMgrSkipByTwoSeq() {
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795 bool pass = true;
00796
00797 Int_t fwdInd[5][2] = { {1,3},{0,0},{6,7},{3,3},{8,9} };
00798 Int_t rewInd[5][2] = { {6,7},{3,3},{1,1},{4,5},{0,0} };
00799
00800 MomNavigator* mom = new MomNavigator();
00801 Int_t nadv = fInputStreamManager.Next(mom,2);
00802 Int_t set = -1;
00803 while ( nadv > 0 ) {
00804 set++;
00805
00806 TIter fiter = mom ->FragmentIter();
00807 RawRecord* rawrecord;
00808 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00809
00810
00811
00812
00813
00814
00815 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00816 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00817 return false;
00818 }
00819 mom -> Clear();
00820 nadv = fInputStreamManager.Next(mom,2);
00821 }
00822
00823 Int_t nprev = fInputStreamManager.Previous(mom,2);
00824 set = -1;
00825 while ( nprev > 0 ) {
00826 set++;
00827
00828 TIter fiter = mom ->FragmentIter();
00829 RawRecord* rawrecord;
00830 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00831
00832
00833
00834
00835
00836
00837 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00838 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00839 return false;
00840 }
00841 mom -> Clear();
00842 nprev = fInputStreamManager.Previous(mom,2);
00843 }
00844
00845 nadv = fInputStreamManager.Next(mom,2);
00846 set = -1;
00847 while ( nadv > 0 ) {
00848 set++;
00849
00850 TIter fiter = mom ->FragmentIter();
00851 RawRecord* rawrecord;
00852 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00853
00854
00855
00856
00857
00858
00859 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00860 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00861 return false;
00862 }
00863 mom -> Clear();
00864 nadv = fInputStreamManager.Next(mom,2);
00865 }
00866
00867 nprev = fInputStreamManager.Previous(mom,2);
00868 set = -1;
00869 while ( nprev > 0 ) {
00870 set++;
00871
00872 TIter fiter = mom ->FragmentIter();
00873 RawRecord* rawrecord;
00874 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00875
00876
00877
00878
00879
00880
00881 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00882 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00883 return false;
00884 }
00885 mom -> Clear();
00886 nprev = fInputStreamManager.Previous(mom,2);
00887 }
00888 if ( mom ) delete mom; mom = 0;
00889
00890 return pass;
00891
00892 }
00893
00894 bool PerValidate::StreamMgrSkipByThreeSeq() {
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908 bool pass = true;
00909
00910 Int_t fwdInd[3][2] = { {4,5},{6,7},{4,4} };
00911 Int_t rewInd[3][2] = { {4,4},{1,1},{1,3} };
00912
00913 MomNavigator* mom = new MomNavigator();
00914 Int_t nadv = fInputStreamManager.Next(mom,3);
00915
00916 Int_t set = -1;
00917 while ( nadv > 0 ) {
00918 set++;
00919
00920 TIter fiter = mom ->FragmentIter();
00921 RawRecord* rawrecord;
00922 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00923
00924
00925
00926
00927
00928
00929 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00930 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00931 return false;
00932 }
00933 mom -> Clear();
00934 nadv = fInputStreamManager.Next(mom,3);
00935 }
00936
00937 Int_t nprev = fInputStreamManager.Previous(mom,3);
00938 set = -1;
00939 while ( nprev > 0 ) {
00940 set++;
00941
00942 TIter fiter = mom ->FragmentIter();
00943 RawRecord* rawrecord;
00944 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00945
00946
00947
00948
00949
00950
00951 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00952 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00953 return false;
00954 }
00955 mom -> Clear();
00956 nprev = fInputStreamManager.Previous(mom,3);
00957 }
00958
00959 nadv = fInputStreamManager.Next(mom,3);
00960 set = -1;
00961 while ( nadv > 0 ) {
00962 set++;
00963
00964 TIter fiter = mom ->FragmentIter();
00965 RawRecord* rawrecord;
00966 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00967
00968
00969
00970
00971
00972
00973 if ( rawrecord->GetTempTags().GetInt("index") < fwdInd[set][0]
00974 ||rawrecord->GetTempTags().GetInt("index") > fwdInd[set][1] )
00975 return false;
00976 }
00977 mom -> Clear();
00978 nadv = fInputStreamManager.Next(mom,3);
00979 }
00980
00981 nprev = fInputStreamManager.Previous(mom,3);
00982 set = -1;
00983 while ( nprev > 0 ) {
00984 set++;
00985
00986 TIter fiter = mom ->FragmentIter();
00987 RawRecord* rawrecord;
00988 while ((rawrecord = dynamic_cast<RawRecord*>(fiter.Next())) ) {
00989
00990
00991
00992
00993
00994
00995 if ( rawrecord->GetTempTags().GetInt("index") < rewInd[set][0]
00996 ||rawrecord->GetTempTags().GetInt("index") > rewInd[set][1] )
00997 return false;
00998 }
00999 mom -> Clear();
01000 nprev = fInputStreamManager.Previous(mom,3);
01001 }
01002 if ( mom ) delete mom; mom = 0;
01003
01004 return pass;
01005
01006 }
01007
01008 bool PerValidate::StreamFileAdd() {
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019 cout << "Before: " << endl;
01020 fInputStreamManager.ListFile(cout);
01021 fInputStreamManager.AddFile("pervld.root");
01022 fInputStreamManager.AddFile("pervld2.root");
01023 fInputStreamManager.AddFile("pervld3.root",0);
01024 fInputStreamManager.AddFile("pervld4.root",1);
01025 cout << "After adding pervld at end, 2 at end, 3 at 0, 4 at 1: " << endl;
01026 fInputStreamManager.ListFile(cout);
01027
01028 return true;
01029
01030 }
01031
01032 bool PerValidate::StreamFileRemove() {
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043 cout << "Before: " << endl;
01044 fInputStreamManager.ListFile(cout);
01045 fInputStreamManager.RemoveFile("pervld.root");
01046 cout << "After removal of pervld.root: " << endl;
01047 fInputStreamManager.ListFile(cout);
01048 fInputStreamManager.RemoveFile("pervld2.root");
01049 cout << "After attempt to remove pervld2.root:" << endl;
01050 fInputStreamManager.ListFile(cout);
01051
01052 return true;
01053
01054 }
01055
01056 bool PerValidate::StreamFilePrev() {
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067 cout << "Before: " << endl;
01068 fInputStreamManager.ListFile(cout);
01069 fInputStreamManager.PrevFile();
01070 cout << "After rewind of 1 file: " << endl;
01071 fInputStreamManager.ListFile(cout);
01072 fInputStreamManager.PrevFile(2);
01073 cout << "After rewind of 2 files:" << endl;
01074 fInputStreamManager.ListFile(cout);
01075
01076 return true;
01077
01078 }
01079
01080 bool PerValidate::StreamFileNext() {
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091 cout << "Before: " << endl;
01092 fInputStreamManager.ListFile(cout);
01093 fInputStreamManager.NextFile(2);
01094 cout << "After advance of 2 files: " << endl;
01095 fInputStreamManager.ListFile(cout);
01096 fInputStreamManager.NextFile(4);
01097 cout << "After advance of 4 files:" << endl;
01098 fInputStreamManager.ListFile(cout);
01099 fInputStreamManager.PrevFile(1);
01100 cout << "After rewind of 1 file:" << endl;
01101 fInputStreamManager.ListFile(cout);
01102
01103 return true;
01104
01105 }
01106
01107 bool PerValidate::StreamFileGoToByIndex() {
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118 cout << "Before: " << endl;
01119 fInputStreamManager.ListFile(cout);
01120 fInputStreamManager.GoToFile(0);
01121 cout << "After GoToFile index 0: " << endl;
01122 fInputStreamManager.ListFile(cout);
01123 fInputStreamManager.GoToFile(1);
01124 cout << "After GoToFile index 1:" << endl;
01125 fInputStreamManager.ListFile(cout);
01126 fInputStreamManager.GoToFile(-1);
01127 cout << "After GoToFile index -1:" << endl;
01128 fInputStreamManager.ListFile(cout);
01129 fInputStreamManager.GoToFile(3);
01130 cout << "After GoToFile index 3:" << endl;
01131 fInputStreamManager.ListFile(cout);
01132
01133 return true;
01134
01135 }
01136
01137 bool PerValidate::StreamFileGoToByName() {
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148 cout << "Before: " << endl;
01149 fInputStreamManager.ListFile(cout);
01150 fInputStreamManager.GoToFile("pervld.root");
01151 cout << "After GoToFile pervld.root: " << endl;
01152 fInputStreamManager.ListFile(cout);
01153 fInputStreamManager.GoToFile("");
01154 cout << "After GoToFile null:" << endl;
01155 fInputStreamManager.ListFile(cout);
01156 fInputStreamManager.GoToFile("pervld4.root");
01157 cout << "After GoToFile pervld4.root:" << endl;
01158 fInputStreamManager.ListFile(cout);
01159
01160 return true;
01161
01162 }
01163
01164 bool PerValidate::StreamMgrFileList() {
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175 fInputStreamManager.ListFile(cout);
01176 fInputStreamManager.ListFile(cout,"DaqSnarl");
01177 fInputStreamManager.ListFile(cout,"DaqMonitor");
01178 fInputStreamManager.ListFile(cout,"LightInjection");
01179
01180 return true;
01181
01182 }
01183
01184 bool PerValidate::OutputStreamMgr() {
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195 MsgStream* msper = MsgService::Instance() -> GetStream("Per");
01196 msper -> SetLogLevel(Msg::kVerbose);
01197
01198 fOutputStreamManager.OpenStream("DaqSnarl","mytree","RecMinos","","",
01199 Per::kRecSplit);
01200 fOutputStreamManager.SetFile("DaqSnarl","testdaq.root",Per::kRecreate);
01201
01202 MomNavigator* mom = new MomNavigator();
01203 RecMinos* record = new RecMinos();
01204 mom -> AdoptFragment(record);
01205 record->GetTempTags().Print();
01206 cout << "Persisting record" << endl;
01207 fOutputStreamManager.Put(mom);
01208 cout << "Persisting same record again" << endl;
01209 fOutputStreamManager.Put(mom);
01210
01211 record -> HasBeenModified();
01212 cout << "Persisting modified record" << endl;
01213 fOutputStreamManager.Put(mom);
01214 record->GetTempTags().Print();
01215
01216 fOutputStreamManager.Write();
01217 fOutputStreamManager.CloseFile();
01218 fOutputStreamManager.CloseStream();
01219
01220 delete mom; mom = 0;
01221
01222 return true;
01223
01224 }
01225
01226 bool PerValidate::RunAllTests() {
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239 bool allPassed = true;
01240
01241 fInputStreamManager.OpenStream("DaqSnarl","DaqSnarl");
01242 fInputStreamManager.OpenStream("DaqMonitor","DaqMonitor");
01243
01244 if ( !fInputStreamManager.SetFile("*",fFileName,Per::kRead) ) {
01245 cout << " Must run 'loon -bq Persistency/test/pervld.C' to generate file pervld.root first"
01246 << "\n Validity test aborted. " << endl;
01247 return false;
01248 }
01249
01250 int iloop = 0;
01251 while ( iloop < 2 ) {
01252 cout << "*** Test input stream record tags sequencing *** " << endl;
01253 if ( this -> StreamTagsSeq() ) cout << "*** Passed ***" << endl;
01254 else {
01255 cout << "*** Failed ***" << endl;
01256 allPassed = false;
01257 }
01258
01259 cout << "*** Test input stream manager record tags sequencing *** " << endl;
01260 if ( this -> StreamMgrTagsSeq() ) cout << "*** Passed ***" << endl;
01261 else {
01262 cout << "*** Failed ***" << endl;
01263 allPassed = false;
01264 }
01265
01266 cout << "*** Test input stream manager record tags zig-zag sequencing *** " << endl;
01267 if ( this -> StreamMgrTagsSeqZigZag() ) cout << "*** Passed ***" << endl;
01268 else {
01269 cout << "*** Failed ***" << endl;
01270 allPassed = false;
01271 }
01272
01273 cout << "*** Test input stream manager skip-by-two sequencing *** " << endl;
01274 if ( this -> StreamMgrSkipByTwoSeq() ) cout << "*** Passed ***" << endl;
01275 else {
01276 cout << "*** Failed ***" << endl;
01277 allPassed = false;
01278 }
01279
01280 cout << "*** Test input stream manager skip-by-three sequencing *** "<< endl;
01281 if ( this -> StreamMgrSkipByThreeSeq() ) cout << "*** Passed ***" << endl;
01282 else {
01283 cout << "*** Failed ***" << endl;
01284 allPassed = false;
01285 }
01286
01287 cout << "*** Test input stream manager selection sequencing *** "<< endl;
01288 if ( this -> StreamMgrSelectionSeq() ) cout << "*** Passed ***" << endl;
01289 else {
01290 cout << "*** Failed ***" << endl;
01291 allPassed = false;
01292 }
01293
01294 cout << "*** Test input stream manager file change sequencing *** "<< endl;
01295 if ( this -> StreamMgrFileChangeSeq() ) cout << "*** Passed ***" << endl;
01296 else {
01297 cout << "*** Failed ***" << endl;
01298 allPassed = false;
01299 }
01300
01301 cout << "*** Test input stream manager parallel input file seq *** "<<endl;
01302 if ( this -> StreamMgrParallelFileSeq() ) cout << "*** Passed ***" << endl;
01303 else {
01304 cout << "*** Failed ***" << endl;
01305 allPassed = false;
01306 }
01307
01308 if ( iloop == 0 ) {
01309 cout << "*** Switching to updatemode and rerunning tests *** "<< endl;
01310 fInputStreamManager.SetUpdateMode(true);
01311 }
01312 iloop++;
01313 }
01314
01315 cout << "*** Test input stream file management***" << endl;
01316 cout << "***StreamFileAdd***" << endl;
01317 if ( this -> StreamFileAdd() ) cout << "*** Passed ***" << endl;
01318 else {
01319 cout << "*** Failed ***" << endl;
01320 allPassed = false;
01321 }
01322
01323 cout << "***StreamFileRemove***" << endl;
01324 if ( this -> StreamFileRemove() ) cout << "*** Passed ***" << endl;
01325 else {
01326 cout << "*** Failed ***" << endl;
01327 allPassed = false;
01328 }
01329
01330 cout << "***StreamFilePrev***" << endl;
01331 if ( this -> StreamFilePrev() ) cout << "*** Passed ***" << endl;
01332 else {
01333 cout << "*** Failed ***" << endl;
01334 allPassed = false;
01335 }
01336
01337 cout << "***StreamFileNext***" << endl;
01338 if ( this -> StreamFileNext() ) cout << "*** Passed ***" << endl;
01339 else {
01340 cout << "*** Failed ***" << endl;
01341 allPassed = false;
01342 }
01343
01344 cout << "***StreamFileGoToByIndex***" << endl;
01345 if ( this -> StreamFileGoToByIndex() ) cout << "*** Passed ***" << endl;
01346 else {
01347 cout << "*** Failed ***" << endl;
01348 allPassed = false;
01349 }
01350
01351 cout << "***StreamFileGoToByName***" << endl;
01352 if ( this -> StreamFileGoToByName() ) cout << "*** Passed ***" << endl;
01353 else {
01354 cout << "*** Failed ***" << endl;
01355 allPassed = false;
01356 }
01357
01358 cout << "***StreamMgrFileList***" << endl;
01359 if ( this -> StreamMgrFileList() ) cout << "*** Passed ***" << endl;
01360 else {
01361 cout << "*** Failed ***" << endl;
01362 allPassed = false;
01363 }
01364
01365 cout << "***OutputStreamMgr***" << endl;
01366 if ( this -> OutputStreamMgr() ) cout << "*** Passed ***" << endl;
01367 else {
01368 cout << "*** Failed ***" << endl;
01369 allPassed = false;
01370 }
01371
01372 return allPassed;
01373
01374 }
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392