StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtPedReader.h
1 
6 /***************************************************************************
7  *
8  * $Id: StFgtPedReader.h,v 1.1 2012/01/31 08:52:51 sgliske Exp $
9  * Author: S. Gliske, Sept 2011
10  *
11  ***************************************************************************
12  *
13  * Description: Reads the pedistals from file, and provides querying
14  * of pedistals in a similar manner as the DB. Note: this is not a Maker.
15  *
16  ***************************************************************************
17  *
18  * $Log: StFgtPedReader.h,v $
19  * Revision 1.1 2012/01/31 08:52:51 sgliske
20  * StFgtPedMaker moved to StFgtPool
21  *
22  * Revision 1.4 2012/01/27 13:24:50 sgliske
23  * updated to correspond with new PedMakers
24  * Now keyed by elecId
25  *
26  * Revision 1.3 2012/01/26 13:13:11 sgliske
27  * Updated to use StFgtConsts, which
28  * replaces StFgtEnums and StFgtGeomDefs
29  *
30  * Revision 1.2 2011/09/24 02:14:09 sgliske
31  * updated FGT cosmic QA
32  *
33  * Revision 1.1 2011/09/22 21:21:10 sgliske
34  * first working version
35  *
36  *
37  **************************************************************************/
38 
39 #ifndef _ST_FGT_PED_READER_
40 #define _ST_FGT_PED_READER_
41 
42 #include <string>
43 #include <vector>
44 #include <Rtypes.h>
45 
46 #include "StRoot/StFgtUtil/StFgtConsts.h"
47 
49  public:
50  // constructors
51  StFgtPedReader( const Char_t* filename = "" );
52 
53  // default OK
54  // StFgtPedReader(const StFgtPedReader&);
55 
56  // equals operator -- default OK
57  // StFgtPedReader& operator=(const StFgtPedReader&);
58 
59  // deconstructor
60  virtual ~StFgtPedReader();
61 
62  // initialize
63  Int_t Init();
64 
65  // accessor: input is elecId and timebin, output is ped and
66  // st. dev. (err).
67  void getPed( Int_t elecId, Int_t timebin, Float_t& ped, Float_t& err ) const;
68 
69  // setting time bin mask will reduce the number of peds read from
70  // the file, and increase the access time for each individual
71  // pedistal.
72  void setTimeBinMask( Short_t mask = 0xFF );
73 
74  // ped structure
75  struct ped_t {
76  Float_t ped;
77  Float_t err;
78 
79  ped_t( Float_t p=0, Float_t err=1e10 );
80  operator float() const;
81  Float_t getPed();
82  Float_t getErr();
83  };
84 
85  protected:
86  // mask for which time bins to read
87  Short_t mTimeBinMask;
88 
89  // input file
90  std::string mFilename;
91 
92  // key structure
93  struct key_t {
94  Int_t code;
95 
96  key_t( Int_t elecId = 0, Int_t timeBin = 0);
97  //Bool_t operator<( const key_t& rhs ) const;
98  operator int() const;
99  };
100 
101  typedef std::vector< ped_t > PedVec_t;
102  PedVec_t mPedVec;
103 
104  private:
105  ClassDef(StFgtPedReader,1);
106 
107 };
108 
109 // inline functions
110 
111 // deconstructor
112 inline StFgtPedReader::~StFgtPedReader(){ /* */ };
113 
114 // modifier
115 inline void StFgtPedReader::setTimeBinMask( Short_t mask ){ mTimeBinMask = mask; };
116 
117 // key_t functions
118 inline StFgtPedReader::key_t::key_t( Int_t elecId, Int_t timeBin ){
119  code = elecId*kFgtNumTimeBins + timeBin;
120 };
121 
122 inline StFgtPedReader::key_t::operator int() const {
123  return code;
124 };
125 
126 // ped_t functions
127 inline StFgtPedReader::ped_t::ped_t( Float_t p, Float_t e ) : ped(p), err(e) { /* */ };
128 
129 
130 #endif