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

PulserGainLog.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PulserGainLog.cxx,v 1.4 2007/03/01 17:06:40 rhatcher Exp $
00003 //
00004 // PulserGainLog
00005 //
00006 // Dbi object
00007 //
00008 // Author: Phil Adamson 7/2003
00009 //
00010 // $Log: PulserGainLog.cxx,v $
00011 // Revision 1.4  2007/03/01 17:06:40  rhatcher
00012 // fix a bunch of CVSID lines.  The quoted string must be "$Id: $" (especially
00013 // common is to leave off the trailing $).
00014 //
00015 // Revision 1.3  2004/10/21 10:20:16  west
00016 // gcc 3.4: Replace DbiReader/DbiWriter.cxx -> .tpl and move after CVSID
00017 //
00018 // Revision 1.2  2004/10/05 21:39:48  murgia
00019 // Fixed code to write points with low light levels. Added call to EndFile.
00020 //
00021 // Revision 1.1  2004/09/08 21:50:51  pa
00022 // Checkin of new PulserCalibration version. MIght even work
00023 //
00024 //
00026 
00027 #include "PulserCalibration/PulserGainLog.h"
00028 #include "MessageService/MsgService.h"
00029 #include "DatabaseInterface/DbiResultSet.h"
00030 #include "DatabaseInterface/DbiValidityRec.h"
00031 ClassImp(PulserGainLog)
00032 
00033 CVSID("$Id: PulserGainLog.cxx,v 1.4 2007/03/01 17:06:40 rhatcher Exp $");
00034 
00035   //........
00036   
00037 #include "DatabaseInterface/DbiResultPtr.tpl"
00038   template class DbiResultPtr<PulserGainLog>;
00039 #include "DatabaseInterface/DbiWriter.tpl"
00040   template class DbiWriter<PulserGainLog>;
00041 
00042 
00043 PulserGainLog::PulserGainLog() : fTimeStart(0,0) , fTimeEnd(0,0) 
00044 {
00045   fCodeVer = 0;
00046   fAggregateNo = 0;
00047   fFirst = fLast = fNumPoints = 0;
00048   for (int i=0;i<40;i++) fHeight[i] = fWidth[i] = fNum[i] = fTriggers[i] = 0;
00049 }
00050 
00051 PulserGainLog::PulserGainLog(Int_t codever) : fCodeVer(codever), 
00052   fTimeStart(0,0) , fTimeEnd(0,0) 
00053 {
00054   fFirst = fLast = fNumPoints = fAggregateNo = 0;
00055   for (int i=0;i<40;i++) fHeight[i] = fWidth[i] = fNum[i] = fTriggers[i] = 0;
00056 }
00057 
00058  
00059 void PulserGainLog::Fill(DbiResultSet& rs,
00060                           const DbiValidityRec* /* vrec */)
00061 {
00062   rs >> fAggregateNo;
00063   rs >> fCodeVer;
00064   rs >> fIdent;
00065   rs >> fNumPoints;
00066   rs >> fFirst >> fLast;
00067   rs >> fTimeStart >> fTimeEnd;
00068   for (int i=0;i<40;i++) rs >> fHeight[i];
00069   for (int i=0;i<40;i++) rs >> fWidth[i];
00070   for (int i=0;i<40;i++) rs >> fNum[i];
00071   for (int i=0;i<40;i++) rs >> fTriggers[i];
00072 } 
00073 
00074 void PulserGainLog::Store(DbiOutRowStream& ors,
00075                            const DbiValidityRec* /* vrec */) const
00076 {
00077   ors << fAggregateNo;
00078   ors << fCodeVer;
00079   ors << fIdent;
00080   ors << fNumPoints;
00081   ors << fFirst << fLast;
00082   ors << fTimeStart << fTimeEnd;
00083   for (int i=0;i<40;i++) ors << fHeight[i];
00084   for (int i=0;i<40;i++) ors << fWidth[i];
00085   for (int i=0;i<40;i++) ors << fNum[i];
00086   for (int i=0;i<40;i++) ors << fTriggers[i];
00087 }
00088 
00089 
00090 bool PulserGainLog::IsComplete() const
00091 {
00092   MSG("Pulser",Msg::kDebug)<<"fFirst, fNumPoints "<< fFirst << ", " << fNumPoints <<endl;
00093     return ((fFirst==1)&&(fLast==fNumPoints));
00094   //  return ((fFirst==1)&&(fLast==20));
00095 }
00096 
00097 
00098 bool PulserGainLog::Add(const PulserGainLog &pgl)
00099 {
00100   if (fIdent!=pgl.GetIdent()) return false; 
00101 // Don't add if our current gc has different (led, num points etc.) from pgl. 
00102 
00103 
00104   const Float_t *height = pgl.GetHeight();
00105   const Float_t *width = pgl.GetWidth();
00106   const Float_t *numpulses = pgl.GetNumPulses();
00107   const Float_t *numtriggers = pgl.GetNumTriggers();
00108 
00109 
00110   // Allow Add() to add to either end of the curve.
00111   if (pgl.GetFirstPoint()==1+fLast) {
00112     // add to end
00113     fLast = pgl.GetLastPoint();
00114     fTimeEnd = pgl.GetTimeEnd();
00115   }
00116   else if(pgl.GetLastPoint()==fFirst-1) {
00117     // add to start
00118     fFirst = pgl.GetFirstPoint();
00119     fTimeStart = pgl.GetTimeStart();
00120   }
00121   else {
00122     // Fragments don't join up
00123     return false;
00124   }
00125 
00126   for (int i = pgl.GetFirstPoint();i<=pgl.GetLastPoint();i++) {
00127     fHeight[i-1] = height[i-1];
00128     fWidth[i-1] = width[i-1];
00129     fNum[i-1] = numpulses[i-1];
00130     fTriggers[i-1] = numtriggers[i-1];
00131     //    ++fNumPoints;
00132   }
00133 
00134   return true;
00135 }
00136 
00137 bool PulserGainLog::Add(const PulserSummaryList* psl)
00138 {
00139 
00140 
00141     MSG("Pulser",Msg::kDebug)<<"In GainLog Add(psl). Aggregate Number: " << fAggregateNo << endl; 
00142     MSG("Pulser",Msg::kDebug)<<"In GainLog Add(psl). fFirst, fLast, fIdent: " << fFirst << ", " << fLast << ", " << fIdent << endl;
00143     MSG("Pulser",Msg::kDebug)<<"In GainLog Add(psl). Trying to add point: " << psl->GetPointIndex()  << ", " << psl->GetIdent() << endl;
00144 
00145   if (fAggregateNo != 0) {
00146     // We already have some data
00147     if (fAggregateNo != psl->GetAggregateNo()) return false;
00148     if (fIdent != psl->GetIdent()) return false;
00149     if (fLast != (psl->GetPointIndex()-1)) return false;
00150   } 
00151   else {
00152     fAggregateNo = psl->GetAggregateNo();
00153     fIdent = psl->GetIdent();
00154     fFirst = psl->GetPointIndex();
00155     fTimeStart = psl->GetVldContext().GetTimeStamp();
00156     fNumPoints = psl->GetExpectedPoints();
00157   }
00158   fLast = psl->GetPointIndex();
00159   fTimeEnd = psl->GetVldContext().GetTimeStamp();
00160   fHeight[fLast-1] = psl->GetHeight();
00161   fWidth[fLast-1] = psl->GetWidth();
00162   fNum[fLast-1] = psl->GetNumPulses();
00163   fTriggers[fLast-1] = psl->GetTriggers();
00164 
00165     MSG("Pulser",Msg::kDebug)<<"In GainLog Add(psl). Aggregate Number: " << fAggregateNo << endl; 
00166     MSG("Pulser",Msg::kDebug)<<"In GainLog Add(psl). fFirst, fLast, fIdent: " << fFirst << ", " << fLast << ", " << fIdent << endl;
00167     MSG("Pulser",Msg::kDebug)<<"In GainLog Add(psl). Trying to add point: " << psl->GetPointIndex()  << ", " << psl->GetIdent() << endl;
00168  
00169     //  ++fNumPoints;
00170   return true;
00171 }

Generated on Mon Feb 15 11:07:26 2010 for loon by  doxygen 1.3.9.1