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

RawDcsHvMonitorBlock.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawDcsHvMonitorBlock.cxx,v 1.11 2005/08/26 19:04:53 rhatcher Exp $
00003 // 
00004 // RawDcsHvMonitorBlock 
00005 // 
00006 // RawDcsHvMonitorBlock is a Dcs High Voltage Monitor Block
00007 //
00008 // Author:  R. Hatcher 2003.02.26
00009 //
00011 
00012 #include "RawData/RawDcsHvMonitorBlock.h"
00013 
00014 UInt_t RawDcsHvMonitorBlock::fgDebugFlags = 0;
00015 
00016 #include "MessageService/MsgService.h"
00017 CVSID("$Id: RawDcsHvMonitorBlock.cxx,v 1.11 2005/08/26 19:04:53 rhatcher Exp $");
00018 #include "MessageService/MsgFormat.h"
00019 
00020 #include "RawData/RawBlockRegistry.h"
00021 REGISTERRAWBLOCK(RawDcsHvMonitorBlock,kMdBlockDcsHvMonitor,kMdBlockSourceDcs);
00022 
00023 ClassImp(RawDcsHvMonitorBlock)
00024 
00025 enum EDcsHvMonitorBlkPos {
00026    indx_size      = 0,
00027    indx_checksum  = 1,
00028    indx_blockid   = 2,
00029    zzzz_last      = 3
00030 };
00031 
00032 //_____________________________________________________________________________
00033 RawDcsHvMonitorBlock::RawDcsHvMonitorBlock()
00034   : HvArray(0)
00035 {
00036    // Default constructor
00037 }
00038 
00039 //_____________________________________________________________________________
00040 RawDcsHvMonitorBlock::RawDcsHvMonitorBlock(const Int_t *block)
00041   : RawDataBlock(block), HvArray(0)
00042 {
00043    //  stored block format is:
00044    //---------------------
00045    //  0   i = # words in block
00046    //  1   checksum
00047    //  2   Block Id
00048 
00049    /*
00050     * The data has the following repeating structure from here
00051     *  Int_t n = ((i-3)/6) = num blocks (test modulo for errors);
00052     *  Int_t d[n*6];  d = block+3;
00053     *  Int_t indx;
00054     *  d[(indx*6)+0] = timestamp (long secs)
00055     *  d[(indx*6)+1] = mfcdch (long)
00056     *  d[(indx*6)+2] = geom(long)
00057     *  d[(indx*6)+3] = setv(signed long)
00058     *  d[(indx*6)+4] = readv(signed long)
00059     *  d[(indx*6)+5] = alarm(long)
00060     *  indx++;(test if indx is greater than n, if so, finito)
00061 
00062     *  version 1 has timestamp off by 1 hour in sm2 records between 
00063     *  2003-06-03 12:24:00 and 2003-06-11 03:22:26 in GMT time.  
00064     *  add one hour to these when making final record.
00065 
00066     *  version 2 has some recs with order screwed up, check this by 
00067     *  checking whether mfcdch or geom is negative.  if so, then 
00068     *  swap mfcdch with setv and geom with readv.(version 1 also)
00069 
00070     *  version 3 has none of these problems, and also has the 
00071     *  new shield and trig pmt values (of adding 10000 to shield and 20000 to trig)
00072     */
00073 }
00074 
00075 //_____________________________________________________________________________
00076 RawDcsHvMonitorBlock::~RawDcsHvMonitorBlock()
00077 {
00078    // dtor
00079 }
00080 
00081 //_____________________________________________________________________________
00082 std::ostream& RawDcsHvMonitorBlock::FormatToOStream(ostream& os, 
00083                                                     Option_t *option) const
00084 {
00085         RawDataBlock::FormatToOStream(os,option);
00086         if (option[0] == 'X') return os;
00087 
00088         Int_t numEntries=GetNumEntries();
00089         os << " Number of Entries " << numEntries 
00090         << " Number of Events " << GetNumEvents() << endl;
00091         for(Int_t i = 0; i < numEntries; i++)
00092         {
00093                 os << "Timestamp " << GetTimeStamp(i).AsString("c")
00094                 <<" Mainframe " << GetMainframe(i) << " Card " 
00095                 << GetCard(i)
00096                 << " Channel " << GetChannel(i);
00097                 if (GetHvDetector()==Detector::kFar)
00098                 {
00099                         if (GetFarIsShield(i))
00100                                 os << " Shield Plane " << GetFarShieldPlane(i);
00101                         else
00102                                 if (GetFarIsTriggerPmt(i))
00103                                         os << " Trigger Pmt ";
00104                                 else
00105                                         os << " Plane " << GetPlane(i);
00106                         os << " Side " << GetSide(i) << " Pmt " << GetPmt(i);
00107                 }
00108                 if (GetHvDetector()==Detector::kNear)
00109                 {
00110                         if (GetNearIsTriggerPmt(i))
00111                                 os << "  Is Trigger Pmt ";
00112                         else
00113                                 os << "  Near Plane: " << GetPlane(i);
00114                 }
00115                 os << " Set Voltage " << GetSetVoltage(i) << " Read Voltage " 
00116                 << GetReadVoltage(i) << " Alarms " << GetAlarmbits(i) << endl;
00117         }
00118         return os;
00119 }
00120 
00121 //_____________________________________________________________________________
00122 
00123 void RawDcsHvMonitorBlock::FillHvArray() const
00124 {
00125         //off by 3 since the first three are 1: num words, 2: checksum
00126         // and 3:block ID
00127         HvArray = 3 + GetData();
00128 }
00129 
00130 Int_t RawDcsHvMonitorBlock::GetNumEntries() const
00131 {
00132         // remember, all versions
00133         // have offset of 3 due to first 3 longs)
00134         if((fSize-3)%6)
00135         {
00136                 MSG("RawData",Msg::kError)
00137                         << " Size of Hv Block screwed up.  Have: " 
00138                         << (fSize-3)%6 << " left over from modulo 6."
00139                         << endl;
00140                 return -1;
00141         }
00142         return ((fSize-3)/6);
00143 }
00144 
00145 Int_t RawDcsHvMonitorBlock::GetNumEvents() const
00146 {
00147         return 1;
00148 }
00149 
00150 VldContext RawDcsHvMonitorBlock::GetVldContext() const
00151 {
00152            // build validity context
00153         RawBlockId rbid = GetBlockId();
00154         return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTimeStamp(0));
00155 }
00156 
00157 Int_t RawDcsHvMonitorBlock::GetFarIsShield(Int_t indx) const
00158 {
00159         if (GetMinorId()<3)
00160         {
00161                 if ( (GetPlane(indx)<100) && (GetCard(indx)==12) )
00162                         return 1;
00163         }
00164         else if (GetMinorId()==3)
00165         {
00166                 if ((GetRawGeometry(indx) > 10000)&& (GetRawGeometry(indx)<20000) )
00167                         return 1;
00168         }
00169         return 0;
00170 }
00171 
00172 Int_t RawDcsHvMonitorBlock::GetFarShieldPlane(Int_t indx) const
00173 {
00174         if (GetFarIsShield(indx)==0)
00175                 return 0;
00176         if (GetMinorId()<3)
00177         {
00178                 return GetPlane(indx);
00179         }
00180         return ((GetRawGeometry(indx)/10)-1000);
00181 }
00182 
00183 Int_t RawDcsHvMonitorBlock::GetFarIsTriggerPmt(Int_t indx) const
00184 {
00185         if ( (GetMinorId()<3) && (GetRawChannel(indx)==3015) )
00186                 return 1;
00187         if (GetMinorId()==3)
00188                 if (GetRawGeometry(indx)>=20000)
00189                         return 1;
00190         return 0;
00191 }
00192 
00193 Int_t RawDcsHvMonitorBlock::GetNearIsTriggerPmt(Int_t indx) const
00194 {
00195         return GetFarIsTriggerPmt(indx);
00196 }
00197 
00198 Int_t RawDcsHvMonitorBlock::GetChannel(Int_t indx) const
00199 {
00200         Int_t nRawChan = GetRawChannel(indx);
00201         Int_t temp = nRawChan/1000;
00202         nRawChan = nRawChan - (temp*1000);
00203         Int_t nCard = nRawChan/16;
00204         return (nRawChan-(nCard*16));
00205 }
00206 
00207 Int_t RawDcsHvMonitorBlock::GetMainframe(Int_t indx) const
00208 {
00209         return (GetRawChannel(indx)/1000);
00210 }
00211 
00212 Int_t RawDcsHvMonitorBlock::GetCard(Int_t indx) const
00213 {
00214         Int_t nRawChan = GetRawChannel(indx);
00215         Int_t temp = nRawChan/1000;
00216         nRawChan = nRawChan - (temp*1000);
00217         return (nRawChan/16);
00218 }
00219 
00220 Int_t RawDcsHvMonitorBlock::GetHvDetector() const
00221 {
00222         RawBlockId rbid = GetBlockId();
00223         return rbid.GetDetector();
00224 }
00225 
00226 Int_t RawDcsHvMonitorBlock::GetPlane(Int_t indx) const
00227 {
00228         if (GetHvDetector()==Detector::kFar)
00229         {
00230                 if ( (GetFarIsTriggerPmt(indx)) || ( ((GetRawGeometry(indx)/10)<100) && (GetCard(indx)==12)) )
00231                         return 0;
00232         }
00233         return (GetRawGeometry(indx)/10);
00234 }
00235 
00236 Int_t RawDcsHvMonitorBlock::GetSide(Int_t indx) const
00237 {
00238         Int_t iRawGeom = GetRawGeometry(indx);
00239         Int_t iTemp = iRawGeom/10;
00240         iRawGeom = iRawGeom - (iTemp*10);
00241         return (iRawGeom/3);
00242 }
00243 
00244 Int_t RawDcsHvMonitorBlock::GetPmt(Int_t indx) const
00245 {
00246         Int_t iRawGeom = GetRawGeometry(indx);
00247         Int_t iTemp = iRawGeom/10;
00248         iRawGeom = iRawGeom - (iTemp*10);
00249         iTemp = iRawGeom/3;
00250         return (iRawGeom-(iTemp*3));
00251 }
00252 
00253 Int_t RawDcsHvMonitorBlock::GetRawChannel(Int_t indx) const
00254 {
00255         FillHvArray();
00256         Int_t hvtemp = HvArray[(indx*6)+1];
00257         if (GetMinorId()==3)
00258                 return hvtemp;
00259         if (hvtemp<0)
00260                 return HvArray[(indx*6)+3];
00261         return hvtemp;
00262 }
00263 
00264 Int_t RawDcsHvMonitorBlock::GetRawGeometry(Int_t indx) const
00265 {
00266         FillHvArray();
00267         Int_t hvtemp = HvArray[(indx*6)+2];
00268         if (GetMinorId()==3)
00269                 return hvtemp;
00270         if (hvtemp<0)
00271                 return HvArray[(indx*6)+4];
00272         return hvtemp;
00273 }
00274 
00275 Int_t RawDcsHvMonitorBlock::GetSetVoltage(Int_t indx) const
00276 {
00277         FillHvArray();
00278         Int_t hvtemp = HvArray[(indx*6)+1];
00279         if (hvtemp<0)
00280                 return hvtemp;
00281         return HvArray[(indx*6)+3];
00282 }
00283 
00284 Int_t RawDcsHvMonitorBlock::GetReadVoltage(Int_t indx) const
00285 {
00286         FillHvArray();
00287         Int_t hvtemp = HvArray[(indx*6)+2];
00288         if (hvtemp<0)
00289                 return hvtemp;
00290         return HvArray[(indx*6)+4];
00291 }
00292 
00293 VldTimeStamp RawDcsHvMonitorBlock::GetTimeStamp(Int_t indx) const
00294 {
00295         FillHvArray();
00296         Int_t temptime=HvArray[(indx*6)];
00297         if (GetMinorId()==1)
00298 /* fix the temptime offset to be between 2003-06-03 12:24 and 2003011 03:22:26 */
00299                 if ((temptime>1054643040)&&(temptime<1055301756))
00300                         if ((GetMainframe(indx)<=8)&&(GetMainframe(indx)>=5))
00301                                 temptime=temptime+3600;
00302         return VldTimeStamp(temptime,0);
00303 }
00304 

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