MarlinTPC  1.2.0
PedestalCalculator.h
1 #ifndef PedestalCalculator_h
2 #define PedestalCalculator_h 1
3 /* PedestalCalculator.h
4  * $Id: PedestalCalculator.h,v 1.1 2006/07/07 08:58:52 mjanssen Exp $
5  */
6 // #define USE_CONDDB
7 //c++ stl
8 #include <utility>
9 
10 //LCIO
11 #include "lcio.h"
12 
13 //MARLIN
14 #include "marlin/Processor.h"
15 
16 //TPCCondData
17 #include "Pedestal.h"
18 
19 //LCCD
20 #include <lccd.h>
21 #include <lccd/DBInterface.hh>
22 
23 namespace marlintpc
24 {
25 
27 
53  class PedestalCalculator : public marlin::Processor
54  {
55 
56  public:
57 
58 
60  virtual Processor* newProcessor() { return new PedestalCalculator ; }
61 
63 
64 // PedestalCalculator( const std::string &typeName ) : DBEntryMaker( typeName ){};
65 
69  virtual void init();
70 
73  virtual void processRunHeader( lcio::LCRunHeader* run ) ;
74 
77  virtual void processEvent( lcio::LCEvent * evt ) ;
78 
79  virtual void check( lcio::LCEvent * evt ) ;
80 
83  virtual void end() ;
84 
85  protected:
86 
88  struct StcPedestal
89  {
91  float Mean;
93  float Width;
94  };
95 
97 
100  typedef std::vector<StcPedestal*> PedestalVector_t;
101 
104  {
110  FloatVec* Data;
118  };
119 
120 
122 
128  typedef std::map< std::pair<int, int>, ChannelPedestal* > PedestalMap_t;
129 
130 
133 
135  std::pair<int, int> _ChannelPair;
136 
137 
139 
144  StcPedestal* calcPedestal(FloatVec* Data);
145 
146 
148 
151  virtual void calcAverage(ChannelPedestal* thisChannelPedestal);
152 
155  thisChannelPedestalCollection);
156 
158  virtual void printPedestal(PedestalMap_t*
159  thisChannelPedestalCollection);
160 
162  virtual void printPedestalShort(PedestalMap_t*
163  thisChannelPedestalCollection);
164 
165  virtual void printPedestal(LCCollection* thisCollection);
166 
168  virtual void makeLCCDData();
169 
170 
171  // Member variables for the processor parameters.
173  std::string _inputColName;
175  std::string _pedestalColName;
177  std::string _simpleFileName;
179  std::string _dbFolder;
181  std::string _dbInitString;
183  std::string _conditionsTag;
187  std::string _validFrom;
189  std::string _validTill;
197  double _precision;
202 
203  // count the number of events
204  int _NRun ;
205  int _NEvt ;
206  lcio::long64 _validFromInt;
207  lcio::long64 _validTillInt;
208  lcio::long64 _lastSinceTime;
209  lcio::long64 _lastEventTime;
210 
211  private:
212 
213  void writePedestals();
214  bool _doTagging;
215  int _runNumber;
216  int _writingIteration;
217  std::string _detectorName;
218  std::string _folderName;
219  IMPL::LCCollectionVec* _outputCollection;
220  };
221 }
222 #endif
std::string _simpleFileName
Name of the simple file where the pedestal collection should be stored (optional) ...
Definition: PedestalCalculator.h:177
virtual void processEvent(lcio::LCEvent *evt)
Called for every event - the working horse.
Definition: PedestalCalculator.cc:162
virtual void processRunHeader(lcio::LCRunHeader *run)
Called for every run.
Definition: PedestalCalculator.cc:136
int ReadoutGroup
Hardware readout Group ID.
Definition: PedestalCalculator.h:108
int ChannelID
Hardware channel ID.
Definition: PedestalCalculator.h:106
PedestalMap_t * _PedestalMap
Map to store the pedestals internally during the calculation.
Definition: PedestalCalculator.h:132
virtual void calcAverage(ChannelPedestal *thisChannelPedestal)
Calculates average of pedestals of different events of a channel.
Definition: PedestalCalculator.cc:355
PedestalVector_t * PedestalCol
Vector to store calculated pedestal information in StcPedestal structs (contains value and width)...
Definition: PedestalCalculator.h:113
int _writeEveryNEvents
Calculate and write the calculated pedestals after this number of events.
Definition: PedestalCalculator.h:185
float _initCalcWidth
Start value for the pedestal width for the calculation.
Definition: PedestalCalculator.h:195
virtual void CreatePedestalCollection(PedestalMap_t *thisChannelPedestalCollection)
Creates an LCCollectionVector of Pedestals and fills it with the calculated pedestals.
Definition: PedestalCalculator.cc:409
std::pair< int, int > _ChannelPair
Channel identifier, pair of two integers (first one for the pad and second one for the readout group)...
Definition: PedestalCalculator.h:135
virtual void printPedestalShort(PedestalMap_t *thisChannelPedestalCollection)
Writes a summery of the pedestals to the std output.
Definition: PedestalCalculator.cc:481
StcPedestal * Average
Average of the PedestalCol vector.
Definition: PedestalCalculator.h:115
double _signalThreshold
Data time slice is considered a signal during calculation iteration, if is bigger than signalThreshol...
Definition: PedestalCalculator.h:199
virtual void printPedestal(PedestalMap_t *thisChannelPedestalCollection)
Write the pedestal to the std output.
Definition: PedestalCalculator.cc:456
Calculates the pedestals out of raw data.
Definition: PedestalCalculator.h:53
int _calculationIterations
How many times the calculation iterates over the raw data vector.
Definition: PedestalCalculator.h:191
std::map< std::pair< int, int >, ChannelPedestal * > PedestalMap_t
Typedef: Map to store the pedestal data during calculation.
Definition: PedestalCalculator.h:128
std::string _pedestalColName
Name of the pedestal collection.
Definition: PedestalCalculator.h:175
StcPedestal * AverageError
Average error of the PedestalCol vector.
Definition: PedestalCalculator.h:117
float Mean
Pedestal Value.
Definition: PedestalCalculator.h:91
float Width
Pedestal Width.
Definition: PedestalCalculator.h:93
bool _makeRunNumberFolder
parameter if sub-folder named by run number should be automatically added to the database folder ...
Definition: PedestalCalculator.h:201
virtual void makeLCCDData()
Converts the pedestal information to Pedestal objects and stores them into an LCCollection Vector...
Definition: PedestalCalculator.cc:429
std::string _validFrom
Time from when the calculated pedestals will be valid (is stored in the database).
Definition: PedestalCalculator.h:187
double _precision
Precision of pedestal calculation.
Definition: PedestalCalculator.h:197
virtual void init()
Called at the begin of the job before anything is read.
Definition: PedestalCalculator.cc:118
Structure to store the pedestal of a channel and other needed informations during internal calculatio...
Definition: PedestalCalculator.h:103
int _ignoreSurrounding
time slices before and after the currend slice must not be a signal.
Definition: PedestalCalculator.h:193
std::string _validTill
Time till when the calculated pedestals will be valid (is stored in the database).
Definition: PedestalCalculator.h:189
std::string _conditionsTag
Tag of the conditions data that should be stored.
Definition: PedestalCalculator.h:183
StcPedestal * calcPedestal(FloatVec *Data)
Claculates the pedestal mean and width from raw data.
Definition: PedestalCalculator.cc:261
std::string _dbFolder
Name of the folder, where the pedestal collection should be stored in the database (optional) ...
Definition: PedestalCalculator.h:179
std::string _dbInitString
DBInit String (optional, can also be provided by evironment varibale)
Definition: PedestalCalculator.h:181
std::string _inputColName
Name of the input collection.
Definition: PedestalCalculator.h:173
FloatVec * Data
Vector of raw ADC data.
Definition: PedestalCalculator.h:110
Structure to store pedestal value and width.
Definition: PedestalCalculator.h:88
std::vector< StcPedestal * > PedestalVector_t
Typedef: vector to store pedestal data.
Definition: PedestalCalculator.h:100
virtual void end()
Called after data processing for clean up.
Definition: PedestalCalculator.cc:250