00001 #ifndef __EMCCALFEM_H__
00002 #define __EMCCALFEM_H__
00003
00004 #ifndef __EMCMANAGEABLE_H__
00005 #include "emcManageable.h"
00006 #endif
00007 #ifndef __PHTIMESTAMP_H__
00008 #include "PHTimeStamp.h"
00009 #endif
00010 #include <string>
00011 #include <iostream>
00012 #include <ctime>
00013
00035 class emcCalFEM : public emcManageable
00036 {
00037 public:
00038
00040 virtual ~emcCalFEM();
00041
00042 virtual emcCalFEM* clone(void) const = 0;
00043
00044 virtual emcCalFEM* create(void) const = 0;
00045
00047 bool operator==(const emcCalFEM& obj) const
00048 {
00049 return IsEqual(obj);
00050 }
00051
00052 bool operator!=(const emcCalFEM& obj) const
00053 {
00054 return !IsEqual(obj);
00055 }
00056
00061 int AbsolutePosition(void) const
00062 {
00063 return fAbsPosition;
00064 }
00065
00067 virtual float DefaultReturnValue(void) const
00068 {
00069 return 0.0;
00070 }
00071
00073 std::string Description(void) const
00074 {
00075 return fDescription;
00076 }
00077
00080 virtual const char* GetCategory(void) const = 0;
00081
00090
00092 virtual float getValue(int ichannel) const
00093 {
00094 return getValueFast(ichannel);
00095 }
00096
00098 virtual float getValue(int ichannel, time_t x) const
00099 {
00100 return getValueFast(ichannel, x);
00101 }
00102
00104 virtual float getValue(int ichannel, int x) const
00105 {
00106 return getValueFast(ichannel, x);
00107 }
00108
00110 virtual float getValue(int ichannel, int amucell, const char* kind) const
00111 {
00112 return getValueFast(ichannel, amucell, std::string(kind));
00113 }
00114
00116 virtual float getValue(int , int ,
00117 const std::string& ) const
00118 {
00119 return DefaultReturnValue();
00120 }
00121
00123 virtual float getValue(int , const std::string& ,
00124 float& output) const
00125 {
00126 output = 0.0;
00127 return DefaultReturnValue();
00128 }
00129
00131 virtual float getValue(int i, const char* kind, float& output) const
00132 {
00133 return getValue(i, std::string(kind), output);
00134 }
00136
00137
00139
00141 virtual float getValueFast(int ) const
00142 {
00143 return DefaultReturnValue();
00144 }
00145
00147 virtual float getValueFast(int , time_t ) const
00148 {
00149 return DefaultReturnValue();
00150 }
00151
00153 virtual float getValueFast(int , int ) const
00154 {
00155 return DefaultReturnValue();
00156 }
00157
00159 virtual float getValueFast(int ichannel, int amucell,
00160 const char* kind) const
00161 {
00162 return getValueFast(ichannel, amucell, std::string(kind));
00163 }
00164
00166 virtual float getValueFast(int , int ,
00167 const std::string& )
00168 const
00169 {
00170 return DefaultReturnValue();
00171 }
00172
00174 virtual float getValueFast(int , const std::string& ,
00175 float& output) const
00176 {
00177 output = 0.0;
00178 return DefaultReturnValue();
00179 }
00180
00182 virtual float getValueFast(int i, const char* kind, float& output) const
00183 {
00184 return getValueFast(i, std::string(kind), output);
00185 }
00186
00188
00189
00191 const PHTimeStamp& GetEndValTime(void) const
00192 {
00193 return fEnd;
00194 }
00195
00197 virtual size_t GetNumberOfChannels(void) const = 0;
00198
00200 const PHTimeStamp& GetStartValTime(void) const
00201 {
00202 return fStart;
00203 }
00204
00206 bool IsDefault(void) const
00207 {
00208 return fDefault;
00209 }
00210
00212 bool IsDraft(void) const
00213 {
00214 return fDraft;
00215 }
00216
00218 virtual bool IsEqual(const emcCalFEM&) const = 0;
00219
00221 virtual bool IsValid(const PHTimeStamp& ) const;
00222
00224 int PinNumber(void) const
00225 {
00226 return fPinNumber;
00227 }
00228
00230 virtual std::ostream& Print(std::ostream& out = std::cout, int level = 0) const;
00231
00233 virtual void Reset(void) = 0;
00234
00236 void SetDescription(const char* description)
00237 {
00238 fDescription = std::string(description);
00239 }
00240
00242 void SetDefault(bool def = false)
00243 {
00244 fDefault = def;
00245 }
00246
00248 void SetDraft(bool draft = false)
00249 {
00250 fDraft = draft;
00251 }
00252
00254 virtual void SetNumberOfChannels(int = 144)
00255 {}
00256
00258 void SetPinNumber(int pinNumber)
00259 {
00260 fPinNumber = pinNumber;
00261 }
00262
00264 void SetValidityPeriod(const PHTimeStamp& t1, const PHTimeStamp& t2)
00265 {
00266 fStart = t1;
00267 fEnd = t2;
00268 }
00269
00271 void SetVersion(int version = 0)
00272 {
00273 fVersion = version;
00274 }
00275
00280
00281
00282 time_t GetXmin(void) const
00283 {
00284 return fXmin;
00285 }
00287 time_t GetXmax(void) const
00288 {
00289 return fXmax;
00290 }
00292 void SetXmin(time_t xmin)
00293 {
00294 fXmin = xmin;
00295 }
00297 void SetXmax(time_t xmax)
00298 {
00299 fXmax = xmax;
00300 }
00301
00303
00305 size_t size(void) const
00306 {
00307 return GetNumberOfChannels();
00308 }
00309
00316 virtual void updateValue(int , int ,
00317 float , const char* )
00318 {
00319 }
00320
00321
00323 int Version(void) const
00324 {
00325 return fVersion;
00326 }
00327
00328
00329
00335 static int FEMCode(int absPosition, int pinNumber,
00336 int post_pre, int tac_pre);
00337
00341 static void FEMDecode(int id, int& absPosition, int& pinNumber,
00342 int& post_pre, int& tac_pre);
00343
00345 static int NumberOfInstances(void)
00346 {
00347 return fgNemcCalFEM;
00348 }
00349
00351
00352 protected:
00353
00355 emcCalFEM(int absPosition);
00356
00358 emcCalFEM(int absPosition,
00359 const PHTimeStamp& tStart,
00360 const PHTimeStamp& tEnd);
00361
00363 emcCalFEM(const emcCalFEM&);
00364
00366 emcCalFEM& operator=(const emcCalFEM&);
00367
00369 void Copy(emcCalFEM&) const;
00370
00371 private:
00372 PHTimeStamp fStart;
00373 PHTimeStamp fEnd;
00374 int fAbsPosition;
00375 #ifndef __CINT__
00376
00377 time_t fXmin;
00378 time_t fXmax;
00379 #endif
00380
00381 bool fDraft;
00382 int fVersion;
00383 std::string fDescription;
00384 int fPinNumber;
00385 bool fDefault;
00386
00387 public:
00388 static int fgNemcCalFEM;
00389
00390 };
00391
00392 inline
00393 std::ostream& operator<<(std::ostream& out, const emcCalFEM& tfem)
00394 {
00395 return tfem.Print(out, 1);
00396 }
00397
00398 #endif