00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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* )
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* ) 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
00095 }
00096
00097
00098 bool PulserGainLog::Add(const PulserGainLog &pgl)
00099 {
00100 if (fIdent!=pgl.GetIdent()) return false;
00101
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
00111 if (pgl.GetFirstPoint()==1+fLast) {
00112
00113 fLast = pgl.GetLastPoint();
00114 fTimeEnd = pgl.GetTimeEnd();
00115 }
00116 else if(pgl.GetLastPoint()==fFirst-1) {
00117
00118 fFirst = pgl.GetFirstPoint();
00119 fTimeStart = pgl.GetTimeStart();
00120 }
00121 else {
00122
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
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
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
00170 return true;
00171 }