Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

ArchScanResult.cpp

Go to the documentation of this file.
00001 #include "ArchScanResult.h"
00002 #include <TFile.h>
00003 #include <TKey.h>
00004 #include <TDirectory.h>
00005 #include <TSystem.h>
00006 #include <TNamed.h>
00007 #include <TObject.h>
00008 #include <TObjArray.h>
00009 #include <TString.h>
00010 #include <TObjString.h>
00011 #include <TVector.h>
00012 #include <TVectorD.h>
00013 #include <TH1.h>
00014 #include <TH2.h>
00015 #include <TCanvas.h>
00016 #include <TROOT.h>
00017 #include <is/isinfo.h>
00018 #include <fstream>
00019 #include <iostream>
00020 #include <vector>
00021 
00022 #include "sctConfIPC/configipc.h"
00023 
00024 using namespace SctConfiguration;
00025 
00026 
00027 /********************************** ArchScan Methods Definitions ************************/
00028 
00029 
00030 /***********************  Constructor  *************** */
00031 
00032 ArchScanResult::ArchScanResult()  {
00033 
00034   //cout<< "I am in the ArchScanResult Default Constructor"<< endl;
00035   
00036 
00037   /*--- Initialisation ---*/
00038   Archheader = NULL;
00039   ArchmoduleConfig = NULL;
00040   Archpoints = NULL;
00041   Archvariable = NULL;
00042   //TABCDModuleConfig = NULL;
00043 
00044   runNumber = 0;
00045   scanNumber = 0;
00046   //threshold = 0;
00047 
00048   names = new ArchScanTxtNames();
00049 
00050   
00051 
00052   gpoints = NULL;
00053   vpoints = NULL;
00054   vNEvents = NULL;
00055   vNErrorEvents = NULL;
00056 
00057 }
00058   
00059   
00060 ArchScanResult::ArchScanResult(const ScanResult& scan)  {
00061 
00062   //cout<< "I am in the ArchScanResult Constructor"<< endl;
00063   
00064   
00065 
00066   /*--- SCTData Initialisation ---*/
00067     Archheader = &scan.getHeader();          //These might me deleted at some point
00068     ArchmoduleConfig = &scan.getConfiguration();
00069     Archpoints = &scan.getPoints();
00070     Archvariable = &Archheader->getVariable();
00071     
00072 
00073     // Initialise ModuleConfiguration
00074     ModuleConfigurationIOHelper* ModuleConfigIOHelper;
00075     const ABCDModule ABCDModuleConfig = ModuleConfigIOHelper->getABCDModule(*ArchmoduleConfig);
00076     
00077     
00078 
00079 
00080 
00081   /*--- Archiving Variables Initialisation ---*/
00082 
00083     runNumber = Archheader->getRunNumber() ;
00084     scanNumber = Archheader->getScanNumber() ;
00085     moduleName = Archheader->getModuleName();
00086 
00087 //    threshold = ArchmoduleConfig->threshold;
00088 
00089     //cout<< "runNumber = " <<runNumber<<endl;
00090     //cout<< "scanNumber = " <<scanNumber<<endl;
00091 //    cout<< "threshold = " <<threshold<<endl;
00092 
00093 
00094     names = new ArchScanTxtNames(runNumber, Archheader->getModuleName(), scanNumber, *Archvariable );
00095     objName = scan.getUniqueID();   
00096 
00097     
00098     
00099 
00100     //Save points as a graph
00101     /* Not working
00102       hpoints = new TH1();
00103       TAxis *xaxispoints; 
00104       xaxispoints= hpoints->GetXaxis();
00105       Archpoints->setAxis(*xaxispoints);
00106       cout<<" I am here "<<endl;
00107       double x[Archpoints->getNPoints()] ;
00108       double y[Archpoints->getNPoints()] ;
00109       double w[Archpoints->getNPoints()] ;
00110       for(int i=0;i<Archpoints->getNPoints();++i) {
00111       x[i] = Archpoints->getPoint(i);
00112       y[i] = Archpoints->getNEvents(i);
00113       w[i] = 1.;
00114       }
00115       hpoints->FillN(Archpoints->getNPoints(), y, w);
00116     */
00117     
00118     
00119     float x[Archpoints->getNPoints()], y[Archpoints->getNPoints()],err[Archpoints->getNPoints()] ;
00120     for(unsigned int i=0;i<Archpoints->getNPoints();++i) {
00121       x[i] = Archpoints->getPoint(i);
00122       y[i] = Archpoints->getNEvents(i);
00123       err[i] = Archpoints->getNErrorEvents(i);
00124     }
00125     gpoints = new TGraph(Archpoints->getNPoints(),x,y);
00126     //cout<<" I am here "<<endl;
00127     //TAxis *xaxispoints;
00128     //xaxispoints = gpoints->GetXaxis();
00129     //cout<<" I am here "<<endl;
00130     //Archpoints->setAxis(*xaxispoints);
00131     
00132 
00133     
00134     //Save points as TVector's    
00135     vpoints = new TVector(0, Archpoints->getNPoints(),x);
00136     vNEvents = new TVector(0, Archpoints->getNPoints(),y);
00137     vNErrorEvents = new TVector(0, Archpoints->getNPoints(),err);
00138     
00139     
00140 
00141 
00142 
00143 }
00144 
00145 
00146 
00147 
00148 
00149 /**********************  Other Member Functions  *********************/
00150 
00151 ArchScanResult::~ArchScanResult()  {
00152   
00153   //cout << "I am in the ArchScanResult Destructor" << endl;
00154   
00155   
00156   
00157 
00158   
00159 }
00160 
00161 
00162 
00163 
00164 
00165 TObjString ArchScanResult::getModuleConfigTObjString() {
00166   /*
00167     Gets the current ABCDModule Comfiguration from sctConfig, through IPC, as an xml file, 
00168     and converts it into a TObjString
00169   **/
00170   ConfigIPC config;
00171   string tmp_ModuleConfig = config.getModuleConfigurationString(moduleName, ABCDModuleConfig);
00172   const char* tmp_char = tmp_ModuleConfig.c_str();
00173   TObjString ABCDModuleTObjString(tmp_char);
00174   //TString tmp_string = ABCDModuleTObjString.String();
00175   //cout<< "Module Configuration :" << endl << tmp_string.Data()<<endl;
00176   
00177   return ABCDModuleTObjString;
00178   
00179 
00180 
00181 }
00182     
00183 
00184 
00185 
00186 
00187 
00188 void ArchScanResult::SetScan(ScanResult & scan) {
00189 
00190   /* This functions sets all the ArchScanResult member data*/
00191 
00192 
00193 /*--- SctData Initialisation ---*/
00194     Archheader = &scan.getHeader();          //These might me deleted at some point
00195     ArchmoduleConfig = &scan.getConfiguration();
00196     Archpoints = &scan.getPoints();
00197     Archvariable = &Archheader->getVariable();
00198 
00199 
00200   /*--- Archiving Variables Initialisation ---*/
00201 
00202     runNumber = Archheader->getRunNumber() ;
00203     scanNumber = Archheader->getScanNumber() ;
00204 //    threshold = ArchmoduleConfig->threshold;
00205 
00206     //cout<< "runNumber = " <<runNumber<<endl;
00207     //cout<< "scanNumber = " <<scanNumber<<endl;
00208 //    cout<< "threshold = " <<threshold<<endl;
00209 
00210     
00211     names = new ArchScanTxtNames(runNumber, Archheader->getModuleName(), scanNumber, *Archvariable );
00212     objName = scan.getUniqueID();   
00213 
00214 
00215     
00216 
00217     //Save points as a graph
00218     /* Not working
00219       hpoints = new TH1();
00220       TAxis *xaxispoints; 
00221       xaxispoints= hpoints->GetXaxis();
00222       Archpoints->setAxis(*xaxispoints);
00223       cout<<" I am here "<<endl;
00224       double x[Archpoints->getNPoints()] ;
00225       double y[Archpoints->getNPoints()] ;
00226       double w[Archpoints->getNPoints()] ;
00227       for(int i=0;i<Archpoints->getNPoints();++i) {
00228       x[i] = Archpoints->getPoint(i);
00229       y[i] = Archpoints->getNEvents(i);
00230       w[i] = 1.;
00231       }
00232       hpoints->FillN(Archpoints->getNPoints(), y, w);
00233     */
00234     
00235     
00236     float x[Archpoints->getNPoints()], y[Archpoints->getNPoints()],err[Archpoints->getNPoints()];
00237     for(unsigned int i=0;i<Archpoints->getNPoints();++i) {
00238       x[i] = Archpoints->getPoint(i);
00239       y[i] = Archpoints->getNEvents(i);
00240       err[i] = Archpoints->getNErrorEvents(i);
00241     }
00242     gpoints = new TGraph(Archpoints->getNPoints(),x,y);
00243     
00244 
00245     vpoints = new TVector(0, Archpoints->getNPoints(),x);
00246     vNEvents = new TVector(0, Archpoints->getNPoints(),y);
00247     vNErrorEvents = new TVector(0, Archpoints->getNPoints(),err);
00248 
00249 
00250 
00251 
00252 
00253 
00254 }
00255 
00256 
00257 
00258 
00259 
00260 void ArchScanResult::SetTestType(string tType) {
00261 
00262   names->setTestType( tType );
00263 
00264 }
00265 
00266 
00267 const vector <string>& ArchScanResult::getAllSavedScansList() {
00268 
00269  /* Check if the current RawScanResult of the current Test has been persisted*/
00270    
00271 
00272  
00273   //TO DO: Extend to all files in DataArchive dir and loop over all of them
00274   string filename = names->getfilename(); 
00275   TFile *inspect_file = new TFile(filename.c_str(),"read");
00276   if (inspect_file->IsZombie() == true) {
00277     cout << "Problem in opening file"<<endl; 
00278     return SavedScansList;
00279     
00280   } 
00281   
00282   //TDirectory *gRunDir = new TDirectory();
00283   TDirectory *gModuleDir = new TDirectory();
00284   TDirectory *gRODDir = new TDirectory();
00285   TDirectory *gtestTypeDir = new TDirectory();
00286   TDirectory *gvariableDir = new TDirectory();
00287   TDirectory *gscanDir = new TDirectory();
00288 
00289 
00290   //gDirectory->ls();
00291   TList* runsList = gDirectory->GetListOfKeys();
00292   TListIter itruns(runsList);
00293   while (TObject *runsobj = itruns.Next()) { 
00294     //runsobj->Print();
00295     //cout<< "Run OBJ Name = " << runsobj->GetName() <<endl;
00296     string runID = runsobj->GetName();
00297     if (runsobj->GetTitle() == runID ) {
00298       if (gDirectory->cd(runID.c_str())==1) {
00299     
00300     gModuleDir = gDirectory;
00301     TList* modulesList = gDirectory->GetListOfKeys();
00302     TListIter itmodules(modulesList); 
00303     while (TObject *modulesobj = itmodules.Next()) { 
00304       string moduleID = modulesobj->GetName();
00305       string modulesobjID = modulesobj->GetTitle(); 
00307       if (modulesobj->GetTitle() == moduleID ) {
00308         gModuleDir->cd();
00309         if (gDirectory->cd(moduleID.c_str())== 1) {
00310 
00311           gtestTypeDir = gDirectory;
00312           TList* testTypeList = gDirectory->GetListOfKeys();
00313           TListIter ittestType(testTypeList); 
00314           while (TObject *testTypeobj = ittestType.Next()) { 
00315         string testTypeID = testTypeobj->GetName();
00316         if (testTypeobj->GetTitle() == testTypeID ) {
00317           gtestTypeDir->cd();
00318           if (gDirectory->cd(testTypeID.c_str())==1 ) {
00319             
00320             gvariableDir = gDirectory;
00321             TList* variableList = gDirectory->GetListOfKeys();
00322             TListIter itvariable(variableList); 
00323             while (TObject *variableobj = itvariable.Next()) { 
00324               string variableID = variableobj->GetName();
00325               if (variableobj->GetTitle() == variableID ) {
00326             gvariableDir->cd();
00327             if (gDirectory->cd(variableID.c_str())==1 ) {
00328               gDirectory->Print();
00329 
00330               gscanDir = gDirectory;
00331               TList* scanList = gDirectory->GetListOfKeys();
00332               TListIter itscan(scanList); 
00333               while (TObject *scanobj = itscan.Next()) { 
00334                 string scanID = scanobj->GetName();
00335                 if (scanobj->GetTitle() == scanID ) {
00336                   gscanDir->cd();
00337                   if (gDirectory->cd(scanID.c_str())==1 ) {
00338                 
00339                 if (gDirectory->cd(names->getDCSID().c_str())==1 ) {    // TO BE DONE
00340                   
00341                   gDirectory->cd("../");
00342                   if (gDirectory->cd(names->getRODID().c_str())==1 ) {
00343                     
00344                     
00345                     gRODDir = gDirectory;
00346                     if (gDirectory->cd(names->getRawID().c_str())==1 ) {
00347                       string tmp_SavedScan = gDirectory->GetPath();
00348                       SavedScansList.push_back(tmp_SavedScan);
00349                       
00350                     }  
00351             
00352                     gRODDir->cd();
00353                     if (gDirectory->cd(names->getFitID().c_str())==1 ) {
00354                       string tmp_SavedScan = gDirectory->GetPath();
00355                       SavedScansList.push_back(tmp_SavedScan);
00356                
00357                     }  
00358                   }
00359                 }
00360                   }
00361                 }
00362               }
00363             }
00364               }
00365             }
00366           }
00367         }
00368           }
00369         }
00370       }
00371     }
00372       }
00373     }
00374   }
00375   
00376   
00377 
00378   return SavedScansList;
00379 
00380 }
00381 
00382 
00383 
00384 
00385 void ArchScanResult::AddScanToIndex()  {
00386   
00387   /* Append current Test to the Index  */
00388 
00389   //cout << "I am in AddScanToIndex() " << endl;
00390   string index = names->getIndexFileName(); 
00391   ofstream index_file;
00392   index_file.open(index.c_str(),ios::app);  //append the Index File
00393   //assure(index_file,index.c_str());  //TO DO
00394  
00395   string indexScanName = names->getRunID() + ".";
00396   indexScanName = indexScanName + names->getModuleID();
00397   indexScanName = indexScanName + ".";
00398   indexScanName = indexScanName + names->getTestType() + ".";
00399   indexScanName = indexScanName + names->getScanID();
00400   cout << indexScanName <<endl;
00401   //if(ScanIsPersisted()) {
00402     index_file << indexScanName <<endl;
00403     cout << "Scan appended to Index"<<endl;    
00404   //} else {
00405   //  cout<<"Scan NOT correctly saved in the archive...test NOT added to the Index"<<endl;
00406   //}
00407   
00408   index_file.close(); 
00409   
00410 }
00411 
00412 
00413 void ArchScanResult::SaveFileComment() {
00414 
00415   // Saving Txt Comments at the Fun level
00416 
00417   string filename = names->getfilename();
00418   
00419   TFile *file = new TFile(filename.c_str(),"update");
00420   if (file->IsZombie() == true) {
00421     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00422     return ;
00423   }
00424   
00425 
00426   //...Opening TxtComment file 
00427   ifstream in;
00428   in.open(names->getTxtCommentAllFilesName().c_str());
00429 
00430   int commentN;
00431     int sz = 1000; // Buffer size;
00432     char buf[sz];
00433     
00434     //char FileTxtComment[40];
00435     int nlines = 0;
00436     while (1) {
00437       in >> commentN;
00438       in.get(buf, sz);
00439       if (!in.good()) break;
00440       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00441       TObjString FileComment(buf);
00442       //sprintf(FileTxtComment,"FileTxtComment_%i",commentN);
00443       TObject* pers_FileTxtCommentN = gDirectory->FindObjectAny(names->getAllFilesTxtComment(commentN).c_str());
00444       if (!pers_FileTxtCommentN) {
00445     //cout<<" FileTxtComment Never Persisted...persisting" <<endl;
00446     FileComment.Write(names->getAllFilesTxtComment(commentN).c_str());
00447       }
00448       nlines++;   
00449     }
00450     //printf(" found %d points \n",nlines);
00451     
00452     
00453     in.close();
00454     file->Close();
00455 
00456 }
00457 
00458 
00459 
00460 void ArchScanResult::SaveRunComment() {
00461 
00462   // Saving Txt Comments at the Fun level
00463 
00464   string filename = names->getfilename();
00465   string runID = names->getRunID();
00466   TFile *file = new TFile(filename.c_str(),"update");
00467   if (file->IsZombie() == true) {
00468     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00469     return ;
00470   }
00471   /* Making RunNumber */
00472   TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str()); 
00473   if (!this_run) {
00474     //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00475     this_run = file->mkdir(runID.c_str());
00476     //cout<<"New RunNumber Dir made "<<endl;
00477   }
00478   this_run->cd();  //make this_run the current directory
00479 
00480 
00481   //...Opening TxtComment file 
00482   ifstream in;
00483   in.open(names->getTxtCommentRunName().c_str());
00484 
00485   int commentN;
00486     int sz = 1000; // Buffer size;
00487     char buf[sz];
00488     
00489     //char RunTxtComment[40];
00490     int nlines = 0;
00491     while (1) {
00492       in >> commentN;
00493       in.get(buf, sz);
00494       if (!in.good()) break;
00495       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00496       TObjString RunComment(buf);
00497       //sprintf(RunTxtComment,"RunTxtComment_%i",commentN);
00498       TObject* pers_RunTxtCommentN = gDirectory->FindObjectAny(names->getRunTxtComment(commentN).c_str());
00499       if (!pers_RunTxtCommentN) {
00500     //cout<<" RunTxtComment Never Persisted...persisting" <<endl;
00501     RunComment.Write(names->getRunTxtComment(commentN).c_str());
00502       }
00503       nlines++;   
00504     }
00505     //printf(" found %d points \n",nlines);
00506     
00507     
00508     in.close();
00509     file->Close();
00510 
00511 }
00512 
00513 
00514 void ArchScanResult::SaveModuleComment() {
00515 
00516   // Saving Txt Comments at the Fun level
00517   
00518   string filename = names->getfilename();
00519   string runID = names->getRunID();
00520   string moduleID = names->getModuleID();
00521 
00522   TFile *file = new TFile(filename.c_str(),"update");
00523   if (file->IsZombie() == true) {
00524     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00525     return ;
00526   }
00527   /* Making RunNumber */
00528   TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str()); 
00529   if (!this_run) {
00530     //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00531     this_run = file->mkdir(runID.c_str());
00532     //cout<<"New RunNumber Dir made "<<endl;
00533   }
00534   this_run->cd();  //make this_run the current directory
00535 
00536   /* Making moduleNumber   */
00537   
00538   TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00539   if (!this_module) {
00540     //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00541     this_module =gDirectory ->mkdir(moduleID.c_str());
00542   }
00543   this_module->cd();
00544 
00545   
00546   
00547   //...Opening TxtComment file 
00548   ifstream in;
00549   in.open(names->getTxtCommentModuleName().c_str());
00550   
00551 
00552   int commentN;
00553     int sz = 1000; // Buffer size;
00554     char buf[sz];
00555     
00556     
00557     //char ModuleTxtComment[40];
00558     int nlines = 0;
00559     while (1) {
00560       in >> commentN;
00561       in.get(buf, sz);
00562       if (!in.good()) break;
00563       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00564       TObjString Comment(buf);
00565       //sprintf(ModuleTxtComment,"TxtComment_%i",ModulecommentN);
00566       TObject* pers_ModuleTxtCommentN = gDirectory->FindObjectAny(names->getModuleTxtComment(commentN).c_str());
00567       if (!pers_ModuleTxtCommentN) {
00568     //cout<<" TxtComment Never Persisted...persisting" <<endl;
00569       Comment.Write(names->getModuleTxtComment(commentN).c_str());
00570       }
00571       nlines++;   
00572     }
00573     //printf(" found %d points \n",nlines);
00574     
00575 
00576     in.close();
00577     file->Close();
00578     
00579 
00580 }
00581 
00582 
00583 
00584 void ArchScanResult::SaveTestComment() {
00585 
00586   // Saving Txt Comments at the Fun level
00587   
00588   string filename = names->getfilename();
00589   string runID = names->getRunID();
00590   string moduleID = names->getModuleID();
00591   string testType = names->getTestType();
00592   TFile *file = new TFile(filename.c_str(),"update");
00593   if (file->IsZombie() == true) {
00594     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00595     return ;
00596   }
00597   /* Making RunNumber */
00598   TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str()); 
00599   if (!this_run) {
00600     //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00601     this_run = file->mkdir(runID.c_str());
00602     //cout<<"New RunNumber Dir made "<<endl;
00603   }
00604   this_run->cd();  //make this_run the current directory
00605 
00606   /* Making moduleNumber   */
00607   
00608   TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00609   if (!this_module) {
00610     //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00611     this_module =gDirectory ->mkdir(moduleID.c_str());
00612   }
00613   this_module->cd();
00614 
00615 
00616   /* Making TestType   */
00617   TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00618   if (!this_testType) {
00619     //cout<<"This NEW test "<< testType <<" doesn't exist"<<endl;
00620     this_testType = gDirectory->mkdir(testType.c_str());
00621   }
00622   this_testType->cd();
00623 
00624 
00625 
00626   //...Opening TxtComment file 
00627   ifstream in;
00628   in.open(names->getTxtCommentTestName().c_str());
00629 
00630   int commentN;
00631     int sz = 1000; // Buffer size;
00632     char buf[sz];
00633     
00634     //char TxtComment[40];
00635     int nlines = 0;
00636     while (1) {
00637       in >> commentN;
00638       in.get(buf, sz);
00639       if (!in.good()) break;
00640       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00641       TObjString Comment(buf);
00642       //sprintf(TxtComment,"TxtComment_%i",commentN);
00643       TObject* pers_TxtCommentN = gDirectory->FindObjectAny(names->getTestTxtComment(commentN).c_str());
00644       if (!pers_TxtCommentN) {
00645     //cout<<" TxtComment Never Persisted...persisting" <<endl;
00646     Comment.Write(names->getTestTxtComment(commentN).c_str());
00647       }
00648       nlines++;   
00649     }
00650     //printf(" found %d points \n",nlines);
00651     
00652     
00653     in.close();
00654     file->Close();
00655 
00656 }
00657 
00658 
00659 void ArchScanResult::SaveVariableComment() {
00660 
00661   // Saving Txt Comments at the Fun level
00662   
00663   string filename = names->getfilename();
00664   string runID = names->getRunID();
00665   string moduleID = names->getModuleID();
00666   string testType = names->getTestType();
00667   string variable = names->getVariable();
00668 
00669   TFile *file = new TFile(filename.c_str(),"update");
00670   if (file->IsZombie() == true) {
00671     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00672     return ;
00673   }
00674   /* Making RunNumber */
00675   TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str()); 
00676   if (!this_run) {
00677     //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00678     this_run = file->mkdir(runID.c_str());
00679     //cout<<"New RunNumber Dir made "<<endl;
00680   }
00681   this_run->cd();  //make this_run the current directory
00682 
00683   /* Making moduleNumber   */
00684   
00685   TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00686   if (!this_module) {
00687     //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00688     this_module =gDirectory ->mkdir(moduleID.c_str());
00689   }
00690   this_module->cd();
00691 
00692 
00693   /* Making TestType   */
00694   TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00695   if (!this_testType) {
00696     //cout<<"This NEW test "<< testType <<" doesn't exist"<<endl;
00697     this_testType = gDirectory->mkdir(testType.c_str());
00698   }
00699   this_testType->cd();
00700 
00701   
00702   /* Making Variable   */
00703   TDirectory* this_variable = (TDirectory*) gDirectory->Get(variable.c_str());
00704   
00705   if (!this_variable) {
00706     //cout<<"This NEW test "<< variable <<" doesn't exist"<<endl;
00707     this_variable = gDirectory->mkdir(variable.c_str());
00708   }
00709   this_variable->cd();
00710 
00711 
00712 
00713   //...Opening TxtComment file 
00714   ifstream in;
00715   in.open(names->getTxtCommentVariableName().c_str());
00716 
00717   int commentN;
00718     int sz = 1000; // Buffer size;
00719     char buf[sz];
00720     
00721     //char TxtComment[40];
00722     int nlines = 0;
00723     while (1) {
00724       in >> commentN;
00725       in.get(buf, sz);
00726       if (!in.good()) break;
00727       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00728       TObjString Comment(buf);
00729       //sprintf(TxtComment,"TxtComment_%i",commentN);
00730       TObject* pers_TxtCommentN = gDirectory->FindObjectAny(names->getVariableTxtComment(commentN).c_str());
00731       if (!pers_TxtCommentN) {
00732     //cout<<" TxtComment Never Persisted...persisting" <<endl;
00733     Comment.Write(names->getVariableTxtComment(commentN).c_str());
00734       }
00735       nlines++;   
00736     }
00737     //printf(" found %d points \n",nlines);
00738     
00739     
00740     in.close();
00741     file->Close();
00742 
00743 }
00744 
00745 
00746 
00747 void ArchScanResult::SaveScanNumberComment() {
00748 
00749   // Saving Txt Comments at the Fun level
00750   
00751   string filename = names->getfilename();
00752   string runID = names->getRunID();
00753   string moduleID = names->getModuleID();
00754   string testType = names->getTestType();
00755   string variable = names->getVariable();
00756   string scanID = names->getScanID();
00757 
00758   TFile *file = new TFile(filename.c_str(),"update");
00759   if (file->IsZombie() == true) {
00760     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00761     return ;
00762   }
00763   /* Making RunNumber */
00764   TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str()); 
00765   if (!this_run) {
00766     //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00767     this_run = file->mkdir(runID.c_str());
00768     //cout<<"New RunNumber Dir made "<<endl;
00769   }
00770   this_run->cd();  //make this_run the current directory
00771 
00772   /* Making moduleNumber   */
00773   
00774   TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00775   if (!this_module) {
00776     //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00777     this_module =gDirectory ->mkdir(moduleID.c_str());
00778   }
00779   this_module->cd();
00780 
00781 
00782   /* Making TestType   */
00783   TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00784   if (!this_testType) {
00785     //cout<<"This NEW test "<< testType <<" doesn't exist"<<endl;
00786     this_testType = gDirectory->mkdir(testType.c_str());
00787   }
00788   this_testType->cd();
00789 
00790   
00791   /* Making Variable   */
00792   TDirectory* this_variable = (TDirectory*) gDirectory->Get(variable.c_str());
00793   if (!this_variable) {
00794     //cout<<"This NEW test "<< variable <<" doesn't exist"<<endl;
00795     this_variable = gDirectory->mkdir(variable.c_str());
00796   }
00797   this_variable->cd();
00798 
00799   /* Making scanNumber   */
00800   TDirectory* this_scan = (TDirectory*) gDirectory->Get(scanID.c_str());
00801   if (!this_scan) {
00802     //cout<<"This NEW scan "<< scanID <<" doesn't exist"<<endl;
00803     this_scan =gDirectory ->mkdir(scanID.c_str());
00804   }
00805   this_scan->cd();   
00806 
00807 
00808 
00809   //...Opening TxtComment file 
00810   ifstream in;
00811   in.open(names->getTxtCommentScanNumberName().c_str());
00812 
00813   int commentN;
00814     int sz = 1000; // Buffer size;
00815     char buf[sz];
00816     
00817     //char TxtComment[40];
00818     int nlines = 0;
00819     while (1) {
00820       in >> commentN;
00821       in.get(buf, sz);
00822       if (!in.good()) break;
00823       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00824       TObjString Comment(buf);
00825       //sprintf(TxtComment,"TxtComment_%i",commentN);
00826       TObject* pers_TxtCommentN = gDirectory->FindObjectAny(names->getScanNumberTxtComment(commentN).c_str());
00827       if (!pers_TxtCommentN) {
00828     //cout<<" TxtComment Never Persisted...persisting" <<endl;
00829     Comment.Write(names->getScanNumberTxtComment(commentN).c_str());
00830       }
00831       nlines++;   
00832     }
00833     //printf(" found %d points \n",nlines);
00834     
00835     
00836     in.close();
00837     file->Close();
00838 
00839 }
00840 
00841 
00842 void ArchScanResult::SaveRODComment() {
00843 
00844   // Saving Txt Comments at the Fun level
00845   
00846   string filename = names->getfilename();
00847   string runID = names->getRunID();
00848   string moduleID = names->getModuleID();
00849   string testType = names->getTestType();
00850   string variable = names->getVariable();
00851   string scanID = names->getScanID();
00852   string RODID = names->getRODID();
00853 
00854   TFile *file = new TFile(filename.c_str(),"update");
00855   if (file->IsZombie() == true) {
00856     cout << "The ScanResult has NOT been saved in any file"<<endl; 
00857     return ;
00858   }
00859   /* Making RunNumber */
00860   TDirectory *this_run = (TDirectory*) gDirectory->Get(runID.c_str()); 
00861   if (!this_run) {
00862     //cout<<"This NEW run "<< runID <<" doesn't exist"<<endl;
00863     this_run = file->mkdir(runID.c_str());
00864     //cout<<"New RunNumber Dir made "<<endl;
00865   }
00866   this_run->cd();  //make this_run the current directory
00867 
00868   /* Making moduleNumber   */
00869   
00870   TDirectory* this_module = (TDirectory*) gDirectory->Get(moduleID.c_str()); //Can be made using FindAnyObject
00871   if (!this_module) {
00872     //cout<<"This NEW module "<< moduleID <<" doesn't exist"<<endl;
00873     this_module =gDirectory ->mkdir(moduleID.c_str());
00874   }
00875   this_module->cd();
00876 
00877 
00878   /* Making TestType   */
00879   TDirectory* this_testType = (TDirectory*) gDirectory->Get(testType.c_str());
00880   if (!this_testType) {
00881     //cout<<"This NEW test "<< testType <<" doesn't exist"<<endl;
00882     this_testType = gDirectory->mkdir(testType.c_str());
00883   }
00884   this_testType->cd();
00885 
00886   
00887   /* Making Variable   */
00888   TDirectory* this_variable = (TDirectory*) gDirectory->Get(variable.c_str());
00889   if (!this_variable) {
00890     //cout<<"This NEW test "<< variable <<" doesn't exist"<<endl;
00891     this_variable = gDirectory->mkdir(variable.c_str());
00892   }
00893   this_variable->cd();
00894 
00895   /* Making scanNumber   */
00896   TDirectory* this_scan = (TDirectory*) gDirectory->Get(scanID.c_str());
00897   if (!this_scan) {
00898     //cout<<"This NEW scan "<< scanID <<" doesn't exist"<<endl;
00899     this_scan =gDirectory ->mkdir(scanID.c_str());
00900   }
00901   this_scan->cd();   
00902 
00903   /* Making ROD   */ 
00904   TDirectory* this_ROD = (TDirectory*) this_scan->Get(RODID.c_str());
00905   if (!this_ROD) {
00906     //cout<<"This NEW ROD  doesn't exist"<<endl;
00907     this_ROD = this_scan->mkdir(RODID.c_str());
00908   }
00909   this_ROD->cd();
00910  
00911 
00912   //...Opening TxtComment file 
00913   ifstream in;
00914   in.open(names->getTxtCommentRODName().c_str());
00915 
00916   int commentN;
00917     int sz = 1000; // Buffer size;
00918     char buf[sz];
00919     
00920     //char TxtComment[40];
00921     int nlines = 0;
00922     while (1) {
00923       in >> commentN;
00924       in.get(buf, sz);
00925       if (!in.good()) break;
00926       //cout<< " CommentN = "<< commentN << " String = "<< buf <<endl;
00927       TObjString Comment(buf);
00928       //sprintf(TxtComment,"TxtComment_%i",commentN);
00929       TObject* pers_TxtCommentN = gDirectory->FindObjectAny(names->getRODTxtComment(commentN).c_str());
00930       if (!pers_TxtCommentN) {
00931     //cout<<" TxtComment Never Persisted...persisting" <<endl;
00932     Comment.Write(names->getRODTxtComment(commentN).c_str());
00933       }
00934       nlines++;   
00935     }
00936     //printf(" found %d points \n",nlines);
00937     
00938     
00939     in.close();
00940     file->Close();
00941 
00942 }

Generated on Mon Dec 15 19:35:57 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3