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

TRun.C

Go to the documentation of this file.
00001 
00002 // Class TRun
00003 //
00004 // Author     : F. Cassol Brunner
00005 // Created    : 1/10/2002
00006 // Last update: 
00007 //          by: 
00008 // Comment: class to perform open/close operation of the data files
00010 
00011 #ifndef __TRUN
00012 #include "Marana/TRun.h"
00013 
00014 
00015 TRun::TRun(string par_file)
00016 {
00017 
00018  try {
00019 
00020    string in_file;
00021    
00022 
00023 //...initialize the parameters
00024 
00025    debug=0;
00026    nMaxEvt=10000000;
00027    lumi_file="not_given";
00028    lumi_file_bad_runs="not_given";
00029    Type="Data.0";
00030    Year="9900";
00031    HfsCalib=1;
00032    ElCalib=0;
00033    Lumi=1;
00034 
00035 //... read Parameter file 
00036   ifstream inParams(par_file.c_str());
00037    
00038   if(!inParams)    
00039   {
00040       throw string("TRun::TRun = Error in opening steering file!\n");
00041 
00042 
00043   } 
00044 
00045 
00046   cout << endl;
00047   cout << "<=========================================================>" << endl;
00048   cout << " Parameters file in use: " << par_file <<endl;
00049   cout << "<=========================================================>" << endl;
00050   cout << endl << " The read parameters are: "<<endl;
00051 
00052   char item[255];
00053   while(inParams >> item)
00054   {
00055    
00056     if (strcmp(item,"in_file_list:") == 0)
00057     { 
00058       inParams >> in_file ;
00059       cout << "in_file_list= " <<in_file << endl;
00060     }  
00061 
00062     if (strcmp(item,"nMaxEvt:") == 0)
00063     { 
00064       inParams >> nMaxEvt ;
00065       cout << "nMaxEvt= " <<nMaxEvt << endl;
00066     }
00067     if (strcmp(item,"debug:") == 0)
00068     { 
00069       inParams >> debug ;
00070       cout << "debug= " <<debug << endl;
00071     }
00072     if (strcmp(item,"runlist:") == 0) { 
00073       inParams >>  lumi_file;
00074       cout << "runlist= " <<lumi_file << endl;
00075     }
00076 
00077     if (strcmp(item,"lumi:") == 0) { 
00078       inParams >> Lumi;
00079       cout << "lumi= " << Lumi<< " "<<endl;
00080     }
00081     if (strcmp(item,"genCut:") == 0) {
00082        cout <<  "genCut= "<< endl;
00083         TMarCutMCList newList;
00084         inParams >> newList;
00085         cout  << newList << endl;
00086         genCut.push_back(newList);  
00087               
00088     }
00089 
00090     if (strcmp(item,"run_type:") == 0) {
00091       inParams >> Year  >> Type;
00092       cout << "run_type = "<<Year <<" "<<  Type <<endl;
00093      
00094     
00095     }
00096     if (strcmp(item,"calibration:") == 0) {
00097       inParams >>  HfsCalib;
00098       cout << "calibration (Hfs)= "<< HfsCalib <<endl;
00099     }    
00100     if (strcmp(item,"elcalibration:") == 0) {
00101       inParams >>  ElCalib;
00102       cout << "calibration (electrons)= "<< ElCalib <<endl;
00103     }    
00104 
00105   }
00106   cout <<endl;
00107    
00108 //... close the Parameters file
00109   inParams.close(); 
00110 
00111 
00112 #if USERTREE
00113   // Make user event
00114   UserEvent *myUserEvent = new UserEvent();
00115 #endif
00116  
00117 //...create  tree
00118   H1Tree::Instance();
00119 
00120 //... open input file
00121   fstream in;
00122   in.open(in_file.c_str(),ios::in);     // open file 
00123 
00124   if (!in){
00125     ostringstream error;
00126     error << "Run::Run = Error in opening input list file! "
00127           <<in_file << " - stop" << ends;
00128     string mess=error.str();      
00129     throw mess;   
00130   }
00131 
00132 
00133 //...read data files
00134   string filename="", type="";
00135   Int_t i=0; 
00136   while(1) { 
00137     in >> filename >> type; 
00138     
00139     if(filename[0]=='#')continue;
00140     
00141     if (!in.good()||in.eof()) break; 
00142 
00143     if (type=="LIST"){//---- to read eventlist files 
00144         gH1Tree->AddList(filename.c_str());
00145         string filename_short=filename.substr(filename.find_last_of("/")+1);
00146         list_files.push_back(filename_short);
00147     } else {//--- otherwise read mods/hat/usertree list
00148 #if USERTREE
00149         if(type=="USER") gH1Tree->AddFile(filename.c_str(), "User", myUserEvent); 
00150         else gH1Tree->AddFile(filename.c_str(),type.c_str());  
00151 #else
00152         gH1Tree->AddFile(filename.c_str(),type.c_str());
00153 #endif
00154     
00155         string filename_short=filename.substr(filename.find_last_of("/")+1);
00156   
00157         if(type=="HAT") hat_files.push_back(filename_short);
00158         else if(type=="MODS") mods_files.push_back(filename_short);
00159         else if(type=="ODS") ods_files.push_back(filename_short);
00160         else if(type=="USER") user_files.push_back(filename_short);
00161     }
00162     i++; 
00163   }  
00164   in.close();
00165 
00166   cout <<"\n >>>>>> Total of "<<i<<" files opened  <<<<<<<\n"<<endl;   
00167 
00168 
00169 
00170 //... Open fields in the Tree  
00171   gH1Tree->Open();  
00172 
00173 
00174  }
00175 //... try 
00176  catch(string error)
00177  {
00178     cout << error <<endl;;
00179     exit(0); 
00180   
00181  }
00182  catch(...)
00183  {
00184      throw string("TRun::TRun = Undefined error! - stop");
00185      exit(0); 
00186  }     
00187   
00188 
00189 };
00190 
00191 TRun::~TRun(){
00192 
00193 
00194   gH1Tree->Close();
00195 
00196 }
00197 #endif

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