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