Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TRunHisto.C

Go to the documentation of this file.
00001 
00002 // Class TRun
00003 //
00004 // Author     : F. Cassol Brunner
00005 // Created    : 24/10/2002
00006 // Last update: 
00007 //          by: 
00008 // Comment: class to perform job steering in programs that fill histograms
00010 
00011 #ifndef __TRUNHISTO
00012 #include "Marana/TRunHisto.h"
00013 
00014 
00015 TRunHisto::TRunHisto(string par_file): TRun(par_file)
00016 {
00017    
00018 try{
00019 
00020   
00021   out_file_mods_hat="";
00022   
00023   string out_file;
00024 
00025    
00026 //... read specific parameters from the Parameter file 
00027   ifstream inParams(par_file.c_str());
00028   if(!inParams)    
00029   {
00030       throw string("TRunHisto::TRunHisto = Error in opening steering file!");
00031 
00032   } 
00033 
00034   char item[255];
00035   while(inParams >> item)
00036   {
00037     
00038     if (strcmp(item,"in_histo_par:") == 0)    
00039     { 
00040       inParams >> histo_par_file ;
00041       cout << "histo_par_file= " <<histo_par_file<< endl;
00042     }  
00043     if (strcmp(item,"out_file_histo:") == 0)
00044     { 
00045       inParams >> out_file ;
00046       cout << "out_file_histo= " <<out_file << endl;
00047     }   
00048 // //---- to write out H1eventlist of selected events
00049 //     if (strcmp(item,"out_file_list:") == 0)
00050 //     { 
00051 //       inParams >> out_file_list ;
00052 //       cout << "out_file_list= " <<out_file_list << endl;
00053 //     }   
00054 
00055     if (strcmp(item,"write_mods_hat:") == 0)
00056     { 
00057       string tag="";
00058       Int_t num=0;  
00059       cout << "write_mods_hat= ";
00060       inParams >> out_file_mods_hat >> num;
00061       cout <<out_file_mods_hat << " " <<num;
00062 
00063       for (Int_t i=0;i<num;i++){
00064        inParams >> tag;
00065        TagToBeWritten.push_back(tag); 
00066        cout << " " << tag;
00067       }
00068       cout <<  endl;
00069     }   
00070     if (strcmp(item,"systematics:") == 0){
00071        cout << "systematics= ";
00072        inParams >>  Syst;
00073        cout << Syst ;
00074     }
00075 
00076   }
00077   cout <<endl;
00078     
00079 //... close the Parameters file
00080   inParams.close(); 
00081  
00082  
00083 // //... Open H1Eventlist 
00084 // //    cout << " avant le event list " << endl;
00085 //   output_file_list= new TFile(out_file_list.c_str(),"RECREATE","Event list file");
00086 //   list= new H1EventList("mylist");
00087 // 
00088 //   if (output_file_list==NULL)
00089 //   {
00090 //     ostrstream error;
00091 //     error << "TRunHisto::TRunHisto = Error in opening H1Eventlist file! "
00092 //           << out_file_list << " - stop" << ends;
00093 //     string mess=error.str();      
00094 //     throw mess;     
00095 //   }
00096  
00097 
00098 //... open output histo file 
00099   output_file_root= new TFile(out_file.c_str(),"RECREATE","Histos from ModsHat",2);
00100 
00101   if (output_file_root==NULL)
00102   {
00103     ostringstream error;
00104     error << "TRunHisto::TRunHisto = Error in opening output file! "
00105           << out_file<< " - stop" << ends;
00106     string mess=error.str();      
00107     throw mess;     
00108   }
00109 
00110 //... make output directories
00111   output_file_root->cd();
00112 
00113   
00114   for(list<string>::iterator i=Syst.ScalesToBeDone.begin();i!=Syst.ScalesToBeDone.end();i++){
00115      string dir=(*i);  
00116      if(dir=="/")continue; 
00117      TDirectory* DirPtr=output_file_root->mkdir(dir.c_str());
00118       
00119      if(DirPtr==0) throw string("TRunHisto::TRunHisto = problem in mkdir");
00120     
00121   }
00122 
00123  
00124 
00125 } //... try 
00126 catch(string error)
00127 {
00128     cout << error <<endl;;
00129     exit(0); 
00130   
00131 }
00132 catch(...)
00133 {
00134      throw string("TRunHisto::TRunHisto = Undefined error! - stop");
00135      exit(0); 
00136 }     
00137 
00138   return;   
00139 
00140 };
00141 
00142 
00143 TRunHisto::~TRunHisto()
00144 {
00145  gDebug=0;
00146  
00147 // gDirectory->ls();
00148 // output_file_root->ls();
00149 
00150 // output_file_root->Print();
00151 
00152  output_file_root->Close(); 
00153  
00154 
00155  delete output_file_root;
00156  
00157 }
00158 
00159 
00160 // void TRunHisto::AddToList()
00161 // {
00162 //   list->Enter();
00163 // }
00164 // 
00165 // 
00166 // void TRunHisto::CloseList()
00167 // {
00168 // 
00169 //  output_file_list->cd();
00170 // 
00171 //  list->Write();
00172 // 
00173 //  list->Print();
00174 // 
00175 // //...Write event list to file 
00176 // 
00177 //  output_file_list->Write(); 
00178 //  output_file_list->Close(); 
00179 // }
00180 
00181 
00182 
00183 #endif

Generated on Thu Jul 28 11:48:53 2005 for SFHMarana by doxygen 1.3.2