fdhwlib  2.0.25
/home/kopmann/git-mirror/fdhwlib/fdhwlib/FEdata/TsBackgroundBase.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     tsbackgroundbase.h  -  description
00003 
00004     begin                : Sat Jun 16 2001
00005     copyright            : (C) 2001 by A Kopmann
00006     email                : kopmann@hpe.fzk.de
00007     status               :
00008     test                 :
00009     history              :
00010  ***************************************************************************/
00011 
00012 
00013 #ifndef TSBACKGROUNDBASE_H
00014 #define TSBACKGROUNDBASE_H
00015 
00016 
00017 // Don't allow ROOT CINT the access to the hardware definitions
00018 // This is only a class for writing TFile in this case
00019 #ifdef __CINT__
00020 //# define USE_ROOT
00021 #else
00022 # include <FEdata/tsdef.h>
00023 #endif // USE_ROOT
00024 
00025 
00026 #ifdef USE_ROOT
00027 # include <TObject.h>
00028 # include <TArrayS.h>
00029 
00030 # warning 'USE_ROOT' is set !
00031 #else
00032 // Define the root types
00033 typedef unsigned char   UChar_t;
00034 typedef unsigned short  UShort_t;
00035 typedef int             Int_t;
00036 typedef unsigned int    UInt_t;
00037 typedef float           Float_t;
00038 #endif // USE_ROOT
00039 
00040 #ifdef USE_MYSQL
00041 # include <mysql/mysql.h>
00042 #endif // USE_MYSQL
00043 
00044 #ifndef __CINT__
00045 # include <Hw/subrackbase.h>
00046 #endif // __CINT__
00047 
00048 // --- forward declaration(s)
00049 
00050 class TsBackgroundLoop;
00051 
00052 namespace hw4 {
00053   class TsBackground;
00054   
00055   class FltCmds;
00056 }
00057 
00322 class TsBackgroundData
00323 #ifdef USE_ROOT
00324  : public TObject
00325 #endif // USE_ROOT
00326  {
00327   friend class TsBackgroundBase;
00328   friend class TsBackground;
00329   friend class hw4::TsBackground;
00330   friend class TsBackgroundLoop;
00331   friend class TsBackgroundReader;
00332   
00333   friend class FltCmds;
00334   friend class hw4::FltCmds;
00335 
00336 public:
00338   TsBackgroundData()
00339    : tTransferPC(0), tFilePC(0), tDatabasePC(0) { }
00340 
00341   
00342 private:
00343 
00345   Int_t telescopeId;
00346 
00352   UInt_t tRef;
00353 
00355   Float_t m_iBgPeriod;
00356 
00358   Int_t index;
00359 
00361   Int_t firstCol;
00362 
00364   UChar_t m_bSlotAvail[20];
00365 
00372   UInt_t tStartPC;
00373 
00376   UInt_t tStartMiliSecPC;
00377 
00379   UInt_t tStartMicroSecPC;
00380 
00382   UInt_t tDurationPC;
00383 
00385   UInt_t tTransferPC;
00386 
00388   UInt_t tFilePC;
00389 
00391   UInt_t tDatabasePC;
00392   
00394   UInt_t time;
00395 
00397   UInt_t subsec;
00398 
00400   UInt_t duration;
00401 
00403   static char paramString[][20];
00404 
00406   UShort_t current[20][24];
00407 
00409   Int_t lSum[20][24]; // Int_t 4 Bytes length
00410 
00412   UInt_t lSumSq[20][24]; // UInt_t 4 Bytes length
00413 
00415   Int_t m_iSamples[20];
00416 
00418   Int_t m_iOffset[20];
00419 
00421   Int_t variance[20][24];
00422 
00424   UShort_t threshold[20][24];  //TODO: for V4 thresholds are 18 bit !!!!!!!!!-tb-
00425   //UInt_t threshold[20][24];  //TODO: <<---this is necessary for V4!!!!!!!!!-tb-
00426   //#warning WARNING: Ts4Background::get: Rounding thresholds (18 bit) to 16 bit!
00427   //see Ts4Background::get for more info -tb-
00428 
00430   //UShort_t hitrate[20][22];
00431   UShort_t hitrate[20][24];    //TODO: for the future the hitrate should be 32 bit !!!!!!!!!-tb-
00432 
00434   Float_t meanCurrent;
00435 
00437   Float_t meanVariance;
00438 
00440   Float_t meanThreshold;
00441 
00443   Float_t meanSum;
00444 
00446   Float_t meanHitrate;
00447 
00449   Float_t varCurrent;
00450 
00452   Float_t varVariance;
00453 
00455   Float_t varThreshold;
00456 
00458   Float_t varSum;
00459 
00461   Float_t varHitrate;
00462 
00464   Int_t nPixel;
00465 
00467   Float_t meanCurrentV;
00468 
00470   Float_t meanVarianceV;
00471 
00473   Float_t meanSumV;
00474 
00476   Float_t varCurrentV;
00477 
00479   Float_t varVarianceV;
00480 
00482   Float_t varSumV;
00483 
00485   Int_t nPixelV;
00486 
00487 #ifdef USE_ROOT
00488   ClassDef(TsBackgroundData,1)
00489 #endif // USE_ROOT
00490 };
00491 
00492 
00515 #ifdef USE_ROOT
00516 class TsBackgroundBase : public TObject
00517 #else
00518 class TsBackgroundBase
00519 #endif
00520 {
00521   friend class TsBackgroundLoop;
00522   friend class TsBackgroundReader;
00523   
00524   friend class FltCmds;
00525   friend class hw4::FltCmds;
00526   
00527 public:
00529   TsBackgroundBase();
00531   virtual ~TsBackgroundBase();
00532 
00549   virtual int getPixelNo(int col, int row);
00550 
00551   virtual void setParameter(bool *isPresent, int *nSamples);
00552 
00554   virtual bool isAvailable(int col);
00555 
00556   
00562   virtual char * getParameterName(int nr);
00563 
00564   void setIndex(int i);
00565 
00566   int getIndex();
00567   
00568   void setTRef(unsigned long time);
00569 
00570   unsigned long getTRef();
00571 
00572   void setPeriod(int time);
00573 
00574   void setPeriod(float time);
00575 
00576   void setTelescopeId(int id);
00577 
00578   int getTelescopeId();
00579 
00585   unsigned long getAgeOfDataset(FILE *fout = 0);
00586 
00587 #ifndef __CINT__
00588 
00597   virtual int get(SubrackBase *s, int select=0);
00598 
00602   virtual int set(SubrackBase *s, int select=0);
00603 #endif // __CINT__
00604 
00615   virtual void calcStatistics(int matrix[][24], Float_t *mean, Float_t *var,
00616                        Int_t *n, Int_t type = 0);
00617 
00628   virtual void calcStatistics(unsigned short matrix[][24], Float_t *mean, Float_t *var,
00629                          Int_t *n, Int_t type = 0);
00630 
00634   virtual void analyse(int select=0);
00635 
00637   virtual void displaySummary(FILE *fout,int select);
00638 
00643   virtual int getParameterSet(FILE *fin);
00644 
00646   virtual void displayParameterSet(FILE *fout, int select);
00647 
00649   virtual void displayHeader(FILE *fout, int select);
00650 
00661   int loadAMFormat(FILE *fin, int select=0);
00662 
00673   int saveAMFormat(FILE *fout, int select=0);
00674 
00675   void dump(FILE *fout);
00676 
00677 protected:
00678 
00680   TsBackgroundData fData;
00681   
00682 #ifdef USE_ROOT
00683   ClassDef(TsBackgroundBase,1)
00684 #endif // USE_ROOT
00685 };
00686 
00687 #endif // TSBACKGROUNDBASE_H
00688