UberHeader Class Reference

#include <UberHeader.h>

List of all members.

Public Member Functions

 UberHeader ()
 ~UberHeader ()
void Print (Option_t *option="") const
Float_t ReadTemperature ()
Float_t ReadBeamMomentum ()
const char * ReadComments ()
const char * ReadRunType ()
Int_t GetRunNo () const
const char * GetRunType () const
time_t GetStartTime () const
Float_t GetTemperature () const
Float_t GetBeamMomentum () const
const char * GetComments () const
void SetRunNo (Int_t r)
void SetRunType (const char *rt)
void SetStartTime (time_t t)
void SetTemperature (Float_t temp)
void SetBeamMomentum (Float_t p)
void SetComments (const char *comm)

Private Attributes

Int_t runno
char * runtype
time_t tstart
char * tstartchar
Float_t tmper
Float_t beamp
char * comments

Detailed Description

Definition at line 8 of file UberHeader.h.


Constructor & Destructor Documentation

UberHeader::UberHeader (  ) 

Definition at line 22 of file UberHeader.cxx.

00022                       :
00023   runno(0),
00024   runtype(),
00025   tstart(0),
00026   tmper(0.),
00027   beamp(0.),
00028   comments()
00029 {
00030   tstartchar = new char[36];
00031 }//end UberHeader()
//_______________________________________________________________________________

UberHeader::~UberHeader (  ) 

Definition at line 33 of file UberHeader.cxx.

References comments, Msg::kDebug, MSG, runtype, and tstartchar.

00034 {
00035   MSG("UberHeader",Msg::kDebug)<<"Deleting UberHeader"<<endl;
00036   if(tstartchar!=0){
00037     delete tstartchar;
00038     tstartchar = 0;
00039   }
00040   if(comments!=0){
00041     delete comments;
00042     comments = 0;
00043   }
00044   if(runtype!=0){
00045     delete runtype;
00046     runtype = 0;
00047   }
00048 
00049 }//end ~UberHeader()


Member Function Documentation

Float_t UberHeader::GetBeamMomentum (  )  const [inline]

Definition at line 51 of file UberHeader.h.

References beamp.

00051 {return beamp;}

const char * UberHeader::GetComments (  )  const [inline]

Definition at line 52 of file UberHeader.h.

References comments.

Referenced by UberDST::EndJob().

00052 {return comments;}

Int_t UberHeader::GetRunNo (  )  const [inline]

Definition at line 47 of file UberHeader.h.

References runno.

00047 {return runno;}

const char * UberHeader::GetRunType (  )  const [inline]

Definition at line 48 of file UberHeader.h.

References runtype.

00048 {return runtype;}

time_t UberHeader::GetStartTime (  )  const [inline]

Definition at line 49 of file UberHeader.h.

References tstart.

Referenced by UberDST::Ana().

00049 {return tstart;}

Float_t UberHeader::GetTemperature (  )  const [inline]

Definition at line 50 of file UberHeader.h.

References tmper.

00050 {return tmper;}

void UberHeader::Print ( Option_t *  option = ""  )  const

Definition at line 51 of file UberHeader.cxx.

References beamp, comments, runno, runtype, tmper, and tstart.

00052 {
00053 
00054   struct tm *t = localtime(&tstart);
00055   char date[33];
00056   strftime(date,32,"%B %d,%Y %X",t);
00057   cout<<"*******UberHeader:"<<endl
00058       <<"Run number "<<runno<<" Run Type "<<runtype<<endl
00059       <<"Start of run "<<date<<endl
00060       <<"Temperature "<<tmper<<" Beam Momentum "<<beamp<<endl
00061       <<"Comments "<<comments<<endl;
00062 }//end Print()

Float_t UberHeader::ReadBeamMomentum (  ) 

Definition at line 137 of file UberHeader.cxx.

References Msg::kDebug, Msg::kError, MSG, and runno.

Referenced by UberDST::Ana().

00138 {
00139   //parse Gordons kvp files which contain the runlog info
00140 
00141   char *rldir = getenv("RUN_LOG_DIR");
00142   string runlogdir;
00143   if(rldir==NULL){
00144     runlogdir ="./";
00145   }
00146   else{
00147     runlogdir = rldir;
00148   }
00149   
00150   stringstream rlf;
00151   rlf<<runlogdir<<"run-"<<runno<<".kvp"<<'\0';
00152   string runlogfile = rlf.str();
00153   //  rlf.freeze(false);
00154   ifstream runlog(runlogfile.c_str());
00155   if(!runlog){
00156     MSG("UberHeader",Msg::kError)<<"Could not find file "
00157                                  <<runlogfile<<"Setting beam momentum to 0"<<endl;
00158     return 0.;
00159   }
00160 
00161   char buffer[20480];
00162   string b;
00163   runlog.getline(buffer,20480,';');
00164   while(!runlog.eof()){
00165     MSG("UberHeader",Msg::kDebug)<<"buffer "<<buffer<<endl;
00166     b = buffer;
00167     if(b.substr(0,11)=="Beam Energy"){
00168       break;
00169     }
00170     runlog.getline(buffer,20480,';');
00171   }
00172   
00173   string be = b.substr(b.find_first_of('=')+1,b.find_first_of('G')-1);
00174   MSG("UberHeader",Msg::kDebug)<<"beam energy "<<atof(be.c_str())<<endl;
00175   return atof(be.c_str());
00176 
00177 }//end ReadBeamMomentum()

const char * UberHeader::ReadComments (  ) 

Definition at line 179 of file UberHeader.cxx.

References Msg::kDebug, Msg::kError, MSG, and runno.

Referenced by UberDST::Ana().

00180 {
00181   //parse Gordons kvp files which contain the runlog info
00182 
00183   char *rldir = getenv("RUN_LOG_DIR");
00184   string runlogdir;
00185   if(rldir==NULL){
00186     runlogdir ="./";
00187   }
00188   else{
00189     runlogdir = rldir;
00190   }
00191   
00192   stringstream rlf;
00193   rlf<<runlogdir<<"run-"<<runno<<".kvp"<<'\0';
00194   string runlogfile = rlf.str();
00195   //  rlf.freeze(false);
00196   ifstream runlog(runlogfile.c_str());
00197   if(!runlog){
00198     MSG("UberHeader",Msg::kError)<<"Could not find file "
00199                                  <<runlogfile
00200                                  <<"Setting coments to empty string"<<endl;
00201     return ";";
00202   }
00203 
00204   char buffer[20480];
00205   string b;
00206   string be="";
00207   runlog.getline(buffer,20480,';');
00208   while(!runlog.eof()){
00209     MSG("UberHeader",Msg::kDebug)<<"buffer "<<buffer<<endl;
00210     b = buffer;
00211     if(b.substr(0,8)=="comments"){
00212       //      break;
00213       be += b.substr(b.find_first_of('=')+1);
00214       be+=";";
00215     }
00216     
00217     runlog.getline(buffer,20480,';');
00218   }
00219   
00220   MSG("UberHeader",Msg::kDebug)<<"comments "<<be.c_str()<<endl;
00221   return be.c_str();
00222 
00223 }//end ReadComments()

const char * UberHeader::ReadRunType (  ) 

Definition at line 242 of file UberHeader.cxx.

References Msg::kDebug, Msg::kError, MSG, and runno.

Referenced by UberDST::Ana().

00243 {
00244   //parse Gordons kvp files which contain the runlog info
00245 
00246   char *rldir = getenv("RUN_LOG_DIR");
00247   string runlogdir;
00248   if(rldir==NULL){
00249     runlogdir ="./";
00250   }
00251   else{
00252     runlogdir = rldir;
00253   }
00254   
00255   stringstream rlf;
00256   rlf<<runlogdir<<"run-"<<runno<<".kvp"<<'\0';
00257   string runlogfile = rlf.str();
00258   //  rlf.freeze(false);
00259   ifstream runlog(runlogfile.c_str());
00260   if(!runlog){
00261     MSG("UberHeader",Msg::kError)<<"Could not find file "
00262                                  <<runlogfile
00263                                  <<"Setting coments to empty string"<<endl;
00264     return "";
00265   }
00266 
00267   char buffer[20480];
00268   string b;
00269   runlog.getline(buffer,20480,';');
00270   while(!runlog.eof()){
00271     MSG("UberHeader",Msg::kDebug)<<"buffer "<<buffer<<endl;
00272     b = buffer;
00273     if(b.substr(0,11)=="runTypeName"){
00274       break;
00275     }
00276     runlog.getline(buffer,20480,';');
00277   }
00278   
00279   string be = b.substr(b.find_first_of('=')+1);
00280 
00281   MSG("UberHeader",Msg::kDebug)<<"RunType "<<(be.c_str())<<endl;
00282   return be.c_str();
00283 
00284 }//end ReadRunType()

Float_t UberHeader::ReadTemperature (  ) 

Definition at line 73 of file UberHeader.cxx.

References TempReader::AddTemps(), fname, TempReader::GetTempFromTime(), it, Msg::kDebug, Msg::kError, MSG, and tstart.

Referenced by UberDST::Ana().

00074 {
00075   TempReader tr;
00076   
00077   char *tempdir = getenv("TEMPERATURE_REPROCESS_PATH");
00078   string tmd;
00079   if(tempdir==NULL){
00080     tmd="/data/0/Temperature/reprocessed/";
00081   }
00082   else{
00083     tmd = tempdir;
00084   }
00085   MSG("UberHeader",Msg::kDebug)<<"About to look for temp files in "<<tmd<<endl;
00086 
00087   DIR *dfd;
00088   dirent *dp;
00089   if(!(dfd = opendir(tmd.c_str()))){
00090     MSG("UberHeader",Msg::kError)<<"Could not read directory "
00091                                  <<tmd<<" for temperature logs"<<endl;
00092     return 0.;
00093   }
00094 
00095   set<string> tempnames;
00096   while((dp=readdir(dfd))!=NULL){
00097     if(strstr(dp->d_name,"-reprocessed.txt")!=NULL){
00098       tempnames.insert(dp->d_name);
00099       MSG("UberHeader",Msg::kDebug)<<"Added "<<dp->d_name<<" to set"<<endl;
00100     }
00101   }
00102   
00103   stringstream fname;
00104   struct tm *ts = localtime(&(tstart));
00105   fname<<setw(4)<<setfill('0')<<ts->tm_year+1900
00106        <<"-"<<setw(2)<<setfill('0')<<ts->tm_mon+1
00107        <<"-"<<setw(2)<<setfill('0')<<ts->tm_mday<<"-reprocessed.txt"<<'\0';
00108   string filename = fname.str();
00109   //  fname.freeze(false);
00110   MSG("UberHeader",Msg::kDebug)<<"Looking for "<<filename<<endl;
00111   
00112   set<string>::iterator it(tempnames.lower_bound(filename));
00113   string firstfile ="";
00114   if(it!=tempnames.end()){
00115     firstfile = tmd+(*it);
00116   }
00117   MSG("UberHeader",Msg::kDebug)<<"firstfile "<<firstfile<<endl;
00118   string secondfile = "";
00119   if(it!=tempnames.begin()){
00120     secondfile = tmd+*(--it);
00121   }
00122   MSG("UberHeader",Msg::kDebug)<<"Current time filename "<<filename<<endl
00123                                <<"Lower bound "<<firstfile<<endl
00124                                <<"Previous "<<secondfile<<endl;
00125   tr.AddTemps(firstfile);
00126   tr.AddTemps(secondfile);
00127 
00128   char date[33];
00129   strftime(date, 32, "%B %d,%Y %X", ts);
00130   MSG("UberHeader",Msg::kDebug)<<"DATE "<<date<<endl;
00131 
00132   float temperature = tr.GetTempFromTime(tstart);
00133   MSG("UberHeader",Msg::kDebug)<<"Temperature "<<temperature<<endl;
00134   return temperature;
00135 }//end ReadTemperature()

void UberHeader::SetBeamMomentum ( Float_t  p  )  [inline]

Definition at line 55 of file UberHeader.h.

References beamp.

Referenced by UberDST::Ana().

00055 {beamp = p;}

void UberHeader::SetComments ( const char *  comm  ) 

Definition at line 228 of file UberHeader.cxx.

References comments, Msg::kDebug, and MSG.

Referenced by UberDST::Ana().

00229 {
00230   int i=0;
00231   while(comm[i]!='\0'){
00232     i++;
00233   }
00234   i++;
00235 
00236   comments = new char[i];
00237   sprintf(comments, "%s",comm);
00238 
00239   MSG("UberHeader",Msg::kDebug)<<"comments from set "<<comments<<endl;
00240 }//SetComments()

void UberHeader::SetRunNo ( Int_t  r  )  [inline]

Definition at line 53 of file UberHeader.h.

References runno.

Referenced by UberDST::Get().

00053 {runno = r;}

void UberHeader::SetRunType ( const char *  rt  ) 

Definition at line 289 of file UberHeader.cxx.

References runtype.

Referenced by UberDST::Ana().

00290 {
00291   int i=0;
00292   while(rt[i]!='\0'){
00293     i++;
00294   }
00295   i++;
00296   runtype = new char[i];
00297   sprintf(runtype, "%s",rt);
00298 
00299 }//end SetRunType()

void UberHeader::SetStartTime ( time_t  t  ) 

Definition at line 64 of file UberHeader.cxx.

References tstart, and tstartchar.

Referenced by UberDST::Ana().

00065 {
00066 
00067   //  tstart = mktime(ts);
00068   tstart = t;
00069   struct tm *ts = gmtime(&t);
00070   strftime(tstartchar, 35, "%B %d,%Y %X", ts);
00071 }//end SetStartTime()

void UberHeader::SetTemperature ( Float_t  temp  )  [inline]

Definition at line 54 of file UberHeader.h.

References tmper.

Referenced by UberDST::Ana().

00054 {tmper = temp;}


Member Data Documentation

Float_t UberHeader::beamp [private]

Definition at line 41 of file UberHeader.h.

Referenced by GetBeamMomentum(), Print(), and SetBeamMomentum().

char* UberHeader::comments [private]

Definition at line 42 of file UberHeader.h.

Referenced by GetComments(), Print(), SetComments(), and ~UberHeader().

Int_t UberHeader::runno [private]

Definition at line 36 of file UberHeader.h.

Referenced by GetRunNo(), Print(), ReadBeamMomentum(), ReadComments(), ReadRunType(), and SetRunNo().

char* UberHeader::runtype [private]

Definition at line 37 of file UberHeader.h.

Referenced by GetRunType(), Print(), SetRunType(), and ~UberHeader().

Float_t UberHeader::tmper [private]

Definition at line 40 of file UberHeader.h.

Referenced by GetTemperature(), Print(), and SetTemperature().

time_t UberHeader::tstart [private]

Definition at line 38 of file UberHeader.h.

Referenced by GetStartTime(), Print(), ReadTemperature(), and SetStartTime().

char* UberHeader::tstartchar [private]

Definition at line 39 of file UberHeader.h.

Referenced by SetStartTime(), and ~UberHeader().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1