00001 #include "ArchRawScanResult.h"
00002 #include "ArchivingManager.h"
00003 #include <TFile.h>
00004 #include <TKey.h>
00005 #include <TDirectory.h>
00006 #include <TSystem.h>
00007 #include <TNamed.h>
00008 #include <TObject.h>
00009 #include <TObjArray.h>
00010 #include <TString.h>
00011 #include <TObjString.h>
00012 #include <TBuffer.h>
00013 #include <TVector.h>
00014 #include <TVectorD.h>
00015 #include <TH1.h>
00016 #include <TH2.h>
00017 #include <TCanvas.h>
00018 #include <TROOT.h>
00019 #include <is/isinfo.h>
00020 #include <iostream>
00021 #include <vector>
00022
00023
00024
00025
00026
00027
00028 bool ArchRawScanResult::inMap = ArchivingManager::instance().addScanArchiver("SctData::RawScanResult", shared_ptr<ArchScanResult>(new ArchRawScanResult()));
00029
00030
00031
00032 ArchRawScanResult::ArchRawScanResult(): ArchScanResult() {
00033
00034 cout<< "I am in the ArchRawScanResult Default Constructor"<< endl;
00035
00036
00037 }
00038
00039
00040 ArchRawScanResult::ArchRawScanResult(shared_ptr<const RawScanResult> raw): ArchScanResult(raw) {
00041
00042 cout<< "I am in the ArchRawScanResult Constructor"<< endl;
00043
00044
00045
00046
00047 theRaw=raw;
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 }
00065
00066
00067
00068
00069
00070
00071 ArchRawScanResult::~ArchRawScanResult() {
00072
00073 cout << "I am in the ArchRawScanResult destructor" << endl;
00074
00075
00076
00077 }
00078
00079
00080
00081
00082 void ArchRawScanResult::SetRawScan(shared_ptr<RawScanResult> raw) {
00083
00084
00085 theRaw=raw;
00086
00087 SetScan(raw);
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 }
00099
00100
00101
00102 void ArchRawScanResult::SaveRawScan() {
00103
00104
00105
00106 string TH2Dlink0 = names->getTH2Dlink0();
00107 string TH2Dlink1 = names->getTH2Dlink1();
00108 string ScanPointsID = names->getScanPointsID() ;
00109 string vpointsID = names->getvpointsID();
00110 string vNEventsID = names->getvNEventsID();
00111 string vNErrorEventsID = names->getvNErrorEventsID();
00112 string filename = names->getfilename();
00113
00114 string variable = names->getVariable();
00115 string moduleID = names->getModuleID();
00116 string testType = names->getTestType();
00117 string runID = names->getRunID();
00118 string scanID = names->getScanID();
00119 string RODID = names->getRODID();
00120 string DCSID = names->getDCSID();
00121 string RawID = names->getRawID();
00122 string FitID = names->getFitID();
00123 string ModuleConfigID = names->getModuleConfigID();
00124
00125
00126
00127
00128 cout << "Opening file..."<<endl;
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 TFile *storage_file = new TFile(filename.c_str(),"update");
00144
00145 cout << "The file .root succesfully open"<<endl;
00146
00147
00148
00149
00150
00151
00152
00153
00154 cout<<"I am making RunNumber Dir"<<endl;
00155
00156 TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str());
00157 cout<<"The RUN is "<< runID <<endl;
00158
00159 if (!this_run) {
00160 cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00161 this_run = storage_file->mkdir(runID.c_str());
00162
00163 }
00164
00165 this_run->cd();
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str());
00183 cout<<"The MODULE is "<< moduleID <<endl;
00184 if (!this_module) {
00185
00186 this_module =gDirectory ->mkdir(moduleID.c_str());
00187 }
00188
00189
00190
00191
00192
00193 cout<<"I am making TestType Dir "<<endl;
00194 this_module->cd();
00195 TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00196
00197
00198 if (!this_testType) {
00199
00200 this_testType = gDirectory->mkdir(testType.c_str());
00201 }
00202
00203
00204
00205 cout<<"I am making scanType Dir "<<endl;
00206 this_testType->cd();
00207 TDirectory* this_variable = (TDirectory*) gDirectory->Get(variable.c_str());
00208
00209
00210
00211 if (!this_variable) {
00212
00213 this_variable = gDirectory->mkdir(variable.c_str());
00214 }
00215
00216
00217
00218
00219
00220 cout<<"I am making variable Dir "<<endl;
00221 this_variable->cd();
00222 TDirectory* this_scan = (TDirectory*) gDirectory->Get(scanID.c_str());
00223
00224
00225 if (!this_scan) {
00226
00227 this_scan =gDirectory ->mkdir(scanID.c_str());
00228 }
00229 this_scan->cd();
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 cout<<"I am making ROD Dir"<<endl;
00324 this_scan->cd();
00325 TDirectory* this_ROD = (TDirectory*) this_scan->Get(RODID.c_str());
00326
00327
00328 if (!this_ROD) {
00329
00330 this_ROD = this_scan->mkdir(RODID.c_str());
00331 }
00332
00333
00334
00335
00336
00337
00338 cout<<"I am making Raw Dir"<<endl;
00339 this_ROD->cd();
00340 TDirectory* this_raw = (TDirectory*) this_ROD->Get(RawID.c_str());
00341
00342
00343 if (!this_raw) {
00344
00345 this_raw = this_ROD->mkdir(RawID.c_str());
00346 }
00347
00348
00349
00350
00351 cout << "I am Saving ROD raw RawScanResult Data Members " << endl;
00352 this_raw->cd();
00353
00354
00355
00356
00357
00358 cout<<"I am before Saving RawData_links"<<endl;
00359
00360
00361
00362 theRaw->getScanData(0).Write(TH2Dlink0.c_str());
00363 theRaw->getScanData(1).Write(TH2Dlink1.c_str());
00364
00365 cout<<"I am after Saving RawData_links"<<endl;
00366
00367
00368
00369 cout << "I am Closing File " << endl;
00370 storage_file->Close();
00371 delete storage_file;
00372 cout << "File closed " << endl;
00373
00374 }
00375
00376
00377
00378
00379 void ArchRawScanResult::SaveRawScan(shared_ptr<RawScanResult> s) {
00380
00381 ArchRawScanResult tmp_receiver(s);
00382 tmp_receiver.SaveRawScan();
00383
00384 }
00385
00386 void ArchRawScanResult::Save() {
00387
00388 ArchScanResult::Save();
00389 SaveRawScan();
00390
00391 }
00392
00393
00394 void ArchRawScanResult::Save(shared_ptr<RawScanResult> s) {
00395
00396 ArchRawScanResult tmp_receiver(s);
00397 tmp_receiver.Save();
00398
00399 }
00400
00401
00402 bool ArchRawScanResult::RawScanIsPersisted() {
00403
00404
00405
00406
00407 string TH2Dlink0 = names->getTH2Dlink0();
00408 string TH2Dlink1 = names->getTH2Dlink1();
00409 string ScanPointsID = names->getScanPointsID() ;
00410 string vpointsID = names->getvpointsID();
00411 string vNEventsID = names->getvNEventsID();
00412 string vNErrorEventsID = names->getvNErrorEventsID();
00413 string filename = names->getfilename();
00414
00415 string variable = names->getVariable();
00416 string moduleID = names->getModuleID();
00417 string testType = names->getTestType();
00418 string runID = names->getRunID();
00419 string scanID = names->getScanID();
00420 string RODID = names->getRODID();
00421 string DCSID = names->getDCSID();
00422 string RawID = names->getRawID();
00423 string FitID = names->getFitID();
00424 string thresholdID = names->getThresholdID();
00425
00426
00427
00428 TFile *inspect_file = new TFile(filename.c_str(),"read");
00429 if (inspect_file->IsZombie() == true) {
00430 cout << "The RawScanResult has NOT been saved in any file"<<endl;
00431 return 1;
00432 }
00433
00434
00435 gDirectory->cd(runID.c_str());
00436 TDirectory* inspect_dir = (TDirectory*) gDirectory->Get(moduleID.c_str());
00437 if (!inspect_dir) {
00438 cout<<"The RawScanResult has NOT been saved"<<endl;
00439 return 1;
00440 }
00441 gDirectory->cd(moduleID.c_str());
00442
00443
00444 gDirectory->cd(testType.c_str());
00445
00446
00447 gDirectory->cd(variable.c_str());
00448 inspect_dir = (TDirectory*) gDirectory->Get(scanID.c_str());
00449 if (!inspect_dir) {
00450 cout<<"The RawScanResult has NOT been saved"<<endl;
00451 return 1;
00452 }
00453 gDirectory->cd(scanID.c_str());
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465 TObject* pers_RawTH1 = gDirectory->FindObjectAny(ScanPointsID.c_str());
00466 if (!pers_RawTH1) {
00467 cout << "The RawScanResult has NOT been saved"<<endl;
00468 return 1;
00469 }
00470
00471
00472
00473 TObject* pers_points = gDirectory->FindObjectAny(vpointsID.c_str());
00474 if (!pers_points) {
00475 cout << "The RawScanResult has NOT been saved...ScanPoints"<<endl;
00476 return 1;
00477 }
00478 TObject* pers_Nevents = gDirectory->FindObjectAny(vNEventsID.c_str());
00479 if (!pers_Nevents) {
00480 cout << "The RawScanResult has NOT been saved...ScanPoints"<<endl;
00481 return 1;
00482 }
00483 TObject* pers_vNErrorEvents = gDirectory->FindObjectAny(vNErrorEventsID.c_str());
00484 if (!pers_vNErrorEvents) {
00485 cout << "The RawScanResult has NOT been saved...ScanPoints"<<endl;
00486 return 1;
00487 }
00488
00489 gDirectory->cd(RODID.c_str());
00490 gDirectory->cd(RawID.c_str());
00491
00492 cout << "Looking for persisted histograms in Raw Data" << endl;
00493
00494
00495
00496
00497 TObject* pers_RawTH2link0 = gDirectory->FindObjectAny(TH2Dlink0.c_str());
00498 if (!pers_RawTH2link0) {
00499 cout << "The RawScanResult has NOT been saved"<<endl;
00500 return 1;
00501 }
00502
00503 TObject* pers_RawTH2link1 = gDirectory->FindObjectAny(TH2Dlink1.c_str());
00504 if (!pers_RawTH2link1) {
00505 cout << "The RawScanResult has NOT been saved"<<endl;
00506 return 1;
00507 }
00508
00509 inspect_file->Close();
00510 delete inspect_file;
00511
00512 cout << "RawScanResult has been PERSISTED" << endl;
00513 return 0;
00514
00515
00516 }
00517
00518
00519
00520
00521
00522
00523 bool ArchRawScanResult::RawScanIsPersisted(long scanNumber, long runNumber, string moduleName, const ConfigurationVariable& variable, unsigned int cycle) {
00524
00525
00526
00527 ArchScanNames *new_names= new ArchScanNames(runNumber,moduleName,scanNumber, variable, cycle );
00528
00529 string TH2Dlink0 = new_names->getTH2Dlink0();
00530 string TH2Dlink1 = new_names->getTH2Dlink1();
00531 string ScanPointsID = new_names->getScanPointsID() ;
00532 string vpointsID = new_names->getvpointsID();
00533 string vNEventsID = new_names->getvNEventsID();
00534 string vNErrorEventsID = new_names->getvNErrorEventsID();
00535 string filename = new_names->getfilename();
00536
00537 string sVariable = new_names->getVariable();
00538 string moduleID = new_names->getModuleID();
00539 string testType = new_names->getTestType();
00540 string runID = new_names->getRunID();
00541 string scanID = new_names->getScanID();
00542 string RODID = new_names->getRODID();
00543 string DCSID = new_names->getDCSID();
00544 string RawID = new_names->getRawID();
00545 string FitID = new_names->getFitID();
00546 string thresholdID = new_names->getThresholdID();
00547
00548
00549
00550
00551
00552
00553
00554
00555 TFile *inspect_file = new TFile(filename.c_str(),"read");
00556 if (inspect_file->IsZombie() == true) {
00557 cout << "The RawScanResult has NOT been saved in any file"<<endl;
00558 return 1;
00559 }
00560
00561
00562 gDirectory->cd(runID.c_str());
00563 TDirectory* inspect_dir = (TDirectory*) gDirectory->Get(moduleID.c_str());
00564 if (!inspect_dir) {
00565 cout<<"The RawScanResult has NOT been saved...moduleID"<<endl;
00566 return 1;
00567 }
00568 gDirectory->cd(moduleID.c_str());
00569
00570
00571 TDirectory* testType_dir = (TDirectory*) gDirectory->Get(testType.c_str());
00572 if (!testType_dir) {
00573 cout<<"The RawScanResult has NOT been saved...testType"<<endl;
00574 return 1;
00575 }
00576 gDirectory->cd(testType.c_str());
00577
00578
00579 TDirectory* pers_variable = (TDirectory*) gDirectory->Get(sVariable.c_str());
00580 if (!pers_variable) {
00581 cout<<"The RawScanResult has NOT been saved...variable"<<endl;
00582 return 1;
00583 }
00584 gDirectory->cd(sVariable.c_str());
00585
00586
00587 inspect_dir = (TDirectory*) gDirectory->Get(scanID.c_str());
00588 if (!inspect_dir) {
00589 cout<<"The RawScanResult has NOT been saved...scanID"<<endl;
00590 return 1;
00591 }
00592 gDirectory->cd(scanID.c_str());
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603 TObject* pers_RawTH1 = gDirectory->FindObjectAny(ScanPointsID.c_str());
00604 if (!pers_RawTH1) {
00605 cout << "The RawScanResult has NOT been saved...ScanPointsID"<<endl;
00606 return 1;
00607 }
00608
00609
00610 TObject* pers_points = gDirectory->FindObjectAny(vpointsID.c_str());
00611 if (!pers_points) {
00612 cout << "The RawScanResult has NOT been saved...ScanPoints"<<endl;
00613 return 1;
00614 }
00615 TObject* pers_Nevents = gDirectory->FindObjectAny(vNEventsID.c_str());
00616 if (!pers_Nevents) {
00617 cout << "The RawScanResult has NOT been saved...ScanPoints"<<endl;
00618 return 1;
00619 }
00620 TObject* pers_vNErrorEvents = gDirectory->FindObjectAny(vNErrorEventsID.c_str());
00621 if (!pers_vNErrorEvents) {
00622 cout << "The RawScanResult has NOT been saved...ScanPoints"<<endl;
00623 return 1;
00624 }
00625
00626
00627 gDirectory->cd(RODID.c_str());
00628 gDirectory->cd(RawID.c_str());
00629
00630 cout << "Looking for persisted histograms in Raw Data" << endl;
00631
00632
00633
00634
00635 TObject* pers_RawTH2link0 = gDirectory->FindObjectAny(TH2Dlink0.c_str());
00636 if (!pers_RawTH2link0) {
00637 cout << "The RawScanResult has NOT been saved...TH2Dlink0"<<endl;
00638 return 1;
00639 }
00640
00641 TObject* pers_RawTH2link1 = gDirectory->FindObjectAny(TH2Dlink1.c_str());
00642 if (!pers_RawTH2link1) {
00643 cout << "The RawScanResult has NOT been saved...TH2Dlink1"<<endl;
00644 return 1;
00645 }
00646
00647
00648 cout << "RawScanResult has been PERSISTED" << endl;
00649 return 0;
00650
00651
00652 }
00653
00654
00655
00656
00657
00658
00659
00660
00661 bool ArchRawScanResult::RawScanIsPersisted(shared_ptr<RawScanResult> rawdata) {
00662
00663 ArchRawScanResult temp_dir(rawdata);
00664 return temp_dir.RawScanIsPersisted();
00665
00666 }
00667
00668
00669
00670
00671 RawScanResult* ArchRawScanResult::CreateRawScanResult() {
00672
00673
00674 string Pers_Modulename;
00675
00676 if ( RawScanIsPersisted() == 0 )
00677 {
00678
00679 cout << "...creating new RawScanResult obj from persistency" << endl;
00680
00681 int dot = Archheader->getModuleName().find('.');
00682 string Pers_ModuleID = Archheader->getModuleName().substr(0, dot).c_str();
00683 Pers_Modulename = Pers_ModuleID + ".Persisted";
00684
00685
00686
00687 } else {
00688
00689 cout << "WARNING: the RawScanResult has NOT been persisted!!" <<endl;
00690
00691 int dot = Archheader->getModuleName().find('.');
00692 string Pers_ModuleID = Archheader->getModuleName().substr(0, dot).c_str();
00693 Pers_Modulename = Pers_ModuleID + ".Unpersisted";
00694
00695
00696 }
00697
00698
00699 shared_ptr<TH2D> RawData_link0 = shared_ptr<TH2D> ( new TH2D(theRaw->getScanData(0)) );
00700 shared_ptr<TH2D> RawData_link1 = shared_ptr<TH2D> ( new TH2D(theRaw->getScanData(1)) );
00701
00702
00703 ScanHeader s(scanNumber, runNumber, Pers_Modulename , *Archvariable);
00704 RawScanResult* r = new RawScanResult(s, *ArchmoduleConfig, *Archpoints, *RawData_link0, *RawData_link1 );
00705
00706
00707 cout<< r->getHeader().getModuleName()<<endl;
00708
00709 return r;
00710
00711
00712 }
00713
00714
00715
00716
00717
00718 RawScanResult* ArchRawScanResult::CreateRawScanResult(shared_ptr<RawScanResult> raw) {
00719
00720 ArchRawScanResult tmp_createRaw(raw);
00721 return tmp_createRaw.CreateRawScanResult();
00722
00723 }
00724
00725
00726
00727
00728
00729
00730 RawScanResult* ArchRawScanResult::CreateRawScanResult(long scanNumber, long runNumber, string moduleName, const ConfigurationVariable& variable, unsigned int cycle) {
00731
00732
00733 string Pers_Modulename;
00734 ModuleConfiguration m;
00735
00736 TH2D* new_RawData_link0 = NULL;
00737 TH2D* new_RawData_link1 = NULL;
00738
00739
00740 ArchScanNames *new_names= new ArchScanNames(runNumber,moduleName,scanNumber, variable );
00741
00742 string TH2Dlink0 = new_names->getTH2Dlink0();
00743 string TH2Dlink1 = new_names->getTH2Dlink1();
00744 string ScanPointsID = new_names->getScanPointsID() ;
00745 string vpointsID = new_names->getvpointsID();
00746 string vNEventsID = new_names->getvNEventsID();
00747 string vNErrorEventsID = new_names->getvNErrorEventsID();
00748 string filename = new_names->getfilename();
00749
00750 string sVariable = new_names->getVariable();
00751 string moduleID = new_names->getModuleID();
00752 string testType = new_names->getTestType();
00753 string runID = new_names->getRunID();
00754 string scanID = new_names->getScanID();
00755 string RODID = new_names->getRODID();
00756 string DCSID = new_names->getDCSID();
00757 string RawID = new_names->getRawID();
00758 string FitID = new_names->getFitID();
00759 string thresholdID = new_names->getThresholdID();
00760
00761
00762
00763
00764 if ( RawScanIsPersisted(scanNumber, runNumber, moduleName, variable) == 0 )
00765 {
00766
00767 cout << "...creating new RawScanResult obj from persistency" << endl;
00768
00769
00770 int dot = moduleName.find('.');
00771 string Pers_ModuleID = moduleName.substr(0, dot).c_str();
00772 Pers_Modulename = Pers_ModuleID + ".Persisted";
00773
00774
00775
00776 } else {
00777
00778 cout << "WARNING: the RawScanResult has NOT been persisted!!" <<endl;
00779
00780 int dot = moduleName.find('.');
00781 string Pers_ModuleID = moduleName.substr(0, dot).c_str();
00782 Pers_Modulename = Pers_ModuleID + ".Unpersisted";
00783 RawScanResult* r = NULL;
00784 return r;
00785
00786 }
00787
00788
00789
00790
00791
00792
00793
00794 TFile *inspect_file = new TFile(filename.c_str(),"read");
00795 if (inspect_file->IsZombie() == true) {
00796 cout << "Problem in opening the file"<<endl;
00797
00798 }
00799
00800
00801 gDirectory->cd(runID.c_str());
00802 gDirectory->cd(moduleID.c_str());
00803 gDirectory->cd(testType.c_str());
00804 gDirectory->cd(sVariable.c_str());
00805 gDirectory->cd(scanID.c_str());
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816 TObject* pers_vscanpoints = gDirectory->FindObjectAny(vpointsID.c_str());
00817 TVector* vpers_vscanpoints = dynamic_cast<TVector*>(pers_vscanpoints);
00818
00819
00820
00821 float *temp_vpers_vscanpoints = NULL;
00822 temp_vpers_vscanpoints = vpers_vscanpoints->GetElements();
00823
00824 TObject* pers_vNEvents = gDirectory->FindObjectAny(vNEventsID.c_str());
00825 TVector* vpers_vNEvents = dynamic_cast<TVector*>(pers_vNEvents);
00826
00827 int NoElements = vpers_vNEvents->GetNoElements();
00828
00830 unsigned int temp_vpers_vNEvents[NoElements];
00831 unsigned int truncated_vpers_vNEvents;
00832 for (int i=0; i<NoElements; ++i) {
00833 truncated_vpers_vNEvents = int(*vpers_vNEvents->GetElements());
00834
00835 temp_vpers_vNEvents[i] = truncated_vpers_vNEvents;
00836 }
00837
00838
00839 TObject* pers_vNErrorEvents = gDirectory->FindObjectAny(vNErrorEventsID.c_str());
00840 TVector* vpers_vNErrorEvents = dynamic_cast<TVector*>(pers_vNErrorEvents);
00842 unsigned int temp_vpers_vNErrorEvents[NoElements];
00843 unsigned int truncated_vpers_vNErrorEvents;
00844 for (int i=0; i<NoElements; ++i) {
00845 truncated_vpers_vNErrorEvents = int(*vpers_vNErrorEvents->GetElements());
00846 temp_vpers_vNErrorEvents[i] = truncated_vpers_vNErrorEvents;
00847 }
00848
00849
00850 ScanPoints *pts = new ScanPoints( NoElements, temp_vpers_vscanpoints ,temp_vpers_vNEvents ,temp_vpers_vNErrorEvents );
00851
00852
00853
00854
00855
00856 gDirectory->cd(RODID.c_str());
00857 gDirectory->cd(RawID.c_str());
00858
00859
00860
00861 TObject* pers_RawTH2link0 = gDirectory->FindObjectAny(TH2Dlink0.c_str());
00862
00863
00864 new_RawData_link0 = dynamic_cast<TH2D*>(pers_RawTH2link0);
00865
00866
00867 TObject* pers_RawTH2link1 = gDirectory->FindObjectAny(TH2Dlink1.c_str());
00868
00869 new_RawData_link1 = dynamic_cast<TH2D*>(pers_RawTH2link1);
00870
00871
00872
00873
00874
00875
00876 ScanHeader s(scanNumber, runNumber, Pers_Modulename , variable);
00877 RawScanResult* r = new RawScanResult(s, m, *pts, *new_RawData_link0, *new_RawData_link1 );
00878 cout<< r->getHeader().getModuleName()<<endl;
00879 return r;
00880
00881
00882 }
00883
00884
00885
00886
00887
00888
00889 void ArchRawScanResult::SaveRawComment() {
00890
00891
00892
00893 string filename = names->getfilename();
00894 string runID = names->getRunID();
00895 string moduleID = names->getModuleID();
00896 string testType = names->getTestType();
00897 string variable = names->getVariable();
00898 string scanID = names->getScanID();
00899 string RODID = names->getRODID();
00900 string RawID = names->getRawID();
00901
00902 TFile *file = new TFile(filename.c_str(),"update");
00903 if (file->IsZombie() == true) {
00904 cout << "The ScanResult has NOT been saved in any file"<<endl;
00905 return ;
00906 }
00907
00908 TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str());
00909 if (!this_run) {
00910
00911 this_run = file->mkdir(runID.c_str());
00912
00913 }
00914 this_run->cd();
00915
00916
00917
00918 TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str());
00919 if (!this_module) {
00920
00921 this_module =gDirectory ->mkdir(moduleID.c_str());
00922 }
00923 this_module->cd();
00924
00925
00926
00927 TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00928 if (!this_testType) {
00929
00930 this_testType = gDirectory->mkdir(testType.c_str());
00931 }
00932 this_testType->cd();
00933
00934
00935
00936 TDirectory* this_variable = (TDirectory*) gDirectory->Get(variable.c_str());
00937 if (!this_variable) {
00938
00939 this_variable = gDirectory->mkdir(variable.c_str());
00940 }
00941 this_variable->cd();
00942
00943
00944 TDirectory* this_scan = (TDirectory*) gDirectory->Get(scanID.c_str());
00945 if (!this_scan) {
00946
00947 this_scan =gDirectory ->mkdir(scanID.c_str());
00948 }
00949 this_scan->cd();
00950
00951
00952 TDirectory* this_ROD = (TDirectory*) this_scan->Get(RODID.c_str());
00953 if (!this_ROD) {
00954
00955 this_ROD = this_scan->mkdir(RODID.c_str());
00956 }
00957 this_ROD->cd();
00958
00959
00960 TDirectory* this_raw = (TDirectory*) this_ROD->Get(RawID.c_str());
00961 if (!this_raw) {
00962
00963 this_raw = this_ROD->mkdir(RawID.c_str());
00964 }
00965 this_raw->cd();
00966
00967
00968
00969
00970 ifstream in;
00971 in.open(names->getTxtCommentRawName().c_str());
00972
00973 int commentN;
00974 int sz = 1000;
00975 char buf[sz];
00976
00977
00978 int nlines = 0;
00979 while (1) {
00980 in >> commentN;
00981 in.get(buf, sz);
00982 if (!in.good()) break;
00983
00984 TObjString Comment(buf);
00985
00986 TObject* pers_TxtCommentN = gDirectory->FindObjectAny(names->getRawTxtComment(commentN).c_str());
00987 if (!pers_TxtCommentN) {
00988
00989 Comment.Write(names->getRawTxtComment(commentN).c_str());
00990 }
00991 nlines++;
00992 }
00993
00994
00995
00996 in.close();
00997 file->Close();
00998
00999 }
01000