Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LIStreamHunter.cxx

Go to the documentation of this file.
00001 
00002 
00003 //                                                                     
00004 // Program name and version: LIStreamHunter.cxx 1.0         
00005 //                                                                     
00006 // Package: LISummary 
00007 //
00008 // Coded by Jeff Hartnell Nov/2002  
00009 //
00010 // Purpose: To find runs containing the LI stream
00011 //                                                                    
00012 // Contact: jeffrey.hartnell@physics.ox.ac.uk   
00014 
00015 #include "TDatime.h"
00016 
00017 #include "JobControl/JobCModuleRegistry.h"
00018 #include "JobControl/JobCommand.h"
00019 #include "MessageService/MsgService.h"
00020 #include "MinosObjectMap/MomNavigator.h"
00021 #include "RawData/RawLIAdcSummary.h"
00022 #include "RawData/RawDaqHeader.h"
00023 #include "RawData/RawDaqSnarlHeader.h"
00024 #include "RawData/RawLIAdcSummaryBlock.h"
00025 #include "RawData/RawRecord.h"
00026 #include "RawData/RawLIHeader.h" 
00027 
00028 #include "LISummary/LIStreamHunter.h"
00029 
00030 #include <cassert>
00031 
00032 ClassImp(LIStreamHunter)
00033 
00034 JOBMODULE(LIStreamHunter,"LIStreamHunter","A module to find runs containing the LI stream");
00035 
00036 CVSID("$Id: LIStreamHunter.cxx,v 1.1 2003/07/28 11:05:17 hartnell Exp $");
00037 
00038 //......................................................................
00039 
00040 LIStreamHunter::LIStreamHunter()
00041 {
00042   MSG("LIStreamHunter",Msg::kDebug) 
00043     << "Running LIStreamHunter Constructor..." << endl;
00044 
00045   runNumber=0;
00046   runNumberSub=0;
00047   runType=0;
00048 
00049   lastRunNumber=-1;
00050   lastRunNumberSub=-1;
00051   foundSummaries=0;
00052 
00053   timeSec=-1;
00054   timeNanoSec=-1;
00055   calibPoint=-1;
00056   pulserBox=-1;
00057   led=-1;
00058   pulseHeight=-1;
00059   pulseWidth=-1;
00060   
00061   lastLed=0;
00062   lastPulseHeight=0;
00063   lastPulseWidth=0;
00064   lastPulserBox=0;
00065   lastCalibPoint=0;
00066 
00067   numSummaries=0;
00068   numSummariesSub=0;
00069 
00070   MSG("LIStreamHunter",Msg::kDebug) 
00071     << "Finished LIStreamHunter Constructor" << endl;
00072 };
00073 
00074 //......................................................................
00075 
00076 LIStreamHunter::~LIStreamHunter(){
00077 
00078   MSG("LIStreamHunter",Msg::kDebug) 
00079     << "Running LIStreamHunter destructor..." << endl;
00080 
00081 
00082   MSG("LIStreamHunter",Msg::kDebug) 
00083     << "Finished LIStreamHunter destructor" << endl;
00084 }
00085 
00086 //......................................................................
00087 
00088 JobCResult LIStreamHunter::Ana(const MomNavigator *mom)
00089 {
00090   JobCResult result(JobCResult::kPassed);
00091 
00092   //check that mom exists.
00093   assert(mom);
00094   
00095   //find raw record in mom
00096   RawRecord *rawrec = dynamic_cast<RawRecord *>
00097     (mom->GetFragment("RawRecord"));
00098   
00099   if (!rawrec) {
00100     MSG("LIStreamHunter",Msg::kInfo) 
00101       <<"No raw record found"<<endl;
00102     result.SetError().SetFailed();
00103     return result;
00104   }
00105 
00106   //get raw header
00107   const RawDaqHeader *RawHdr=
00108      dynamic_cast<const RawDaqHeader*>(rawrec->GetRawHeader());
00109   if (RawHdr){
00110     runNumber=RawHdr->GetRun();
00111     runNumberSub=RawHdr->GetSubRun();
00112     runType=RawHdr->GetRunType();
00113   }
00114 
00115   //print number of summaries in previous sub run
00116   if (runNumberSub!=lastRunNumberSub){
00117     if (foundSummaries==1 && numSummariesSub==0){
00118       MSG("LIStreamHunter",Msg::kInfo) 
00119         << " ** Empty LightInjection stream **" << endl;
00120     }
00121     else if (numSummariesSub>0){
00122       MSG("LIStreamHunter",Msg::kInfo) 
00123         << numSummariesSub << " summaries found" << endl << endl;
00124     }  
00125     numSummariesSub=0;
00126     foundSummaries=0;
00127   }
00128 
00129   if (runNumber>lastRunNumber){
00130     MSG("LIStreamHunter",Msg::kInfo) 
00131       << "***************************" << endl
00132       << "** New Run Number: " << runNumber << " **" << endl 
00133       << "***************************" << endl; 
00134     lastRunNumberSub=-1;//might only have one sub run so reset here
00135   }
00136   lastRunNumber=runNumber;
00137   if (runNumberSub!=lastRunNumberSub){
00138     MSG("LIStreamHunter",Msg::kInfo) 
00139       << "Analysing Sub Run " << runNumberSub << " ..." << endl; 
00140   }
00141   lastRunNumberSub=runNumberSub;
00142 
00143   //get LI Summary block from rawdatablock
00144   const RawLIAdcSummaryBlock *rawliadcsummaryblock=0;
00145   rawliadcsummaryblock=dynamic_cast<const RawLIAdcSummaryBlock*>
00146   (rawrec->FindRawBlock("RawLIAdcSummaryBlock"));
00147 
00148 //   const RawDaqSnarlHeader *rawdaqsnarlheader= 
00149 //     dynamic_cast<const RawDaqSnarlHeader*>
00150 //     (rawrec->FindRawBlock("RawDaqSnarlHeader"));
00151 
00152 //   if(!rawdaqsnarlheader){  
00153 //     //result.SetError().SetFailed();
00154 //     //return result;
00155 //     MSG("LIStreamHunter",Msg::kInfo) 
00156 //       << "not rawdaqsnarlheader=" << rawdaqsnarlheader << endl;
00157 //   }
00158 //   else{
00159 //     MSG("LIStreamHunter",Msg::kInfo) 
00160 //       << "Found rawdaqsnarlheader=" << rawdaqsnarlheader << endl
00161 //       << "TrigSrc=" << rawdaqsnarlheader->GetTrigSrc() << endl
00162 //       << "ErrorCode=" << rawdaqsnarlheader->GetErrorCode() << endl
00163 //       << "NumRawDigits=" << rawdaqsnarlheader->GetNumRawDigits()<< endl;
00164 //   }
00165   
00166   if(!rawliadcsummaryblock){ 
00167     MSG("LIStreamHunter",Msg::kInfo) 
00168       <<"No rawliadcsummaryblock found"<<endl;
00169     result.SetError().SetFailed();
00170     return result;
00171   }
00172 
00173   timeStamp=rawliadcsummaryblock->GetTimeStamp();
00174   timeSec=timeStamp.GetSec();
00175   timeNanoSec=timeStamp.GetNanoSec();
00176   calibPoint=rawliadcsummaryblock->GetCalibPoint();
00177   pulserBox=rawliadcsummaryblock->GetPulserBox();
00178   led=rawliadcsummaryblock->GetLed();
00179   pulseHeight=rawliadcsummaryblock->GetPulseHeight();
00180   pulseWidth=rawliadcsummaryblock->GetPulseWidth();
00181   
00182   if(led!=lastLed || pulseHeight!=lastPulseHeight ||
00183      pulseWidth!=lastPulseWidth || pulserBox!=lastPulserBox ||
00184      calibPoint!=lastCalibPoint){
00185     
00186     TDatime datime;
00187     datime.Set(timeSec);
00188     MSG("LIStreamHunter",Msg::kVerbose)  
00189       << "PB=" << pulserBox 
00190       << " Led=" << led
00191       << " calpt=" << calibPoint
00192       << " Hgt=" << pulseHeight
00193       << " Wth=" << pulseWidth
00194       << " at " << datime.GetTime() 
00195       << " on " << datime.GetDate() << endl;   
00196   }
00197   lastLed=led;
00198   lastPulseHeight=pulseHeight;
00199   lastPulseWidth=pulseWidth;
00200   lastPulserBox=pulserBox;
00201   lastCalibPoint=calibPoint;
00202 
00203   //count number of summaries
00204   numSummariesSub+=rawliadcsummaryblock->GetNumberOfSummaries();
00205   //set control flag
00206   foundSummaries=1;
00207   
00208   return result;
00209 }
00210 
00211 //......................................................................
00212 
00213 void LIStreamHunter::EndJob() 
00214 {
00215   if (foundSummaries==0){
00216     MSG("LIStreamHunter",Msg::kInfo) 
00217       <<endl
00218       << " ** No LightInjection stream found **" 
00219       <<endl
00220       <<endl;
00221   }
00222   else if (foundSummaries==1 && numSummariesSub==0){
00223     MSG("LIStreamHunter",Msg::kInfo) 
00224       << " ** Empty LightInjection stream **" << endl;
00225   }
00226   else if (numSummariesSub>0){
00227     MSG("LIStreamHunter",Msg::kInfo) 
00228       << numSummariesSub << " summaries found" << endl << endl;
00229   }
00230   return;
00231 }
00232 
00233 //......................................................................

Generated on Mon Jun 16 14:57:31 2008 for loon by  doxygen 1.3.9.1