CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DataFormats/EcalDigi/interface/EcalMatacqDigi.h

Go to the documentation of this file.
00001 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 8; -*-
00002 //$Id: EcalMatacqDigi.h,v 1.5 2009/02/25 14:49:51 pgras Exp $
00003 
00004 #ifndef ECALMATACQDIGI_H
00005 #define ECALMATACQDIGI_H 1
00006 
00007 #include <ostream>
00008 #include <vector>
00009 #include <algorithm>
00010 #include "Rtypes.h"
00011 
00012 #define ECAL_MATACQ_DIGI_VERS 2
00013 
00017 class EcalMatacqDigi {
00018 public:
00021   static const double lsb_;
00022 
00025   static const int MAXSAMPLES = 2560;
00026 
00027 public:
00028   typedef int key_type; //matacq channel id used as key for edm::SortedCollection
00029 
00030 public:
00033   EcalMatacqDigi(): chId_(-1), ts_(0.), tTrigS_(999.), version_(-1){
00034     init();
00035   }
00036   
00044   EcalMatacqDigi(const std::vector<Short_t>& samples, const int& chId, const double& ts,
00045                  const short& version=-1, const double& tTrig=999.)
00046     : chId_(chId), data_(samples), ts_(ts), tTrigS_(tTrig),
00047       version_(version){
00048     init();
00049   };
00050   
00051   
00055   const float adcCount(const int& i) const { return data_[i]; }
00056 
00060   const float amplitudeV(const int& i) const { return data_[i]*lsb_;}
00061 
00064   int chId() const{ return chId_;}
00065 
00069   int id() const { return chId_;}
00070 
00071 //   /** Sets Matacq electronics channel id
00072 //    */
00073 //   void chId(int newChId){ chId_ = newChId;}
00074   
00077   int size() const { return data_.size();}
00078   
00083   void swap(std::vector<short>& samples){ std::swap(data_, samples);}
00084 
00085   void swap(EcalMatacqDigi& a);
00086   
00087 //   /** Gets time of sample i. i between 0 and size()-1.
00088 //    */
00089 //   float t(int i) const { return ts()*i;}
00090   
00093   float ts() const { return ts_;}
00094 
00095 //   /** Sets sampling time period
00096 //    * @param ts sampling time period in seconds
00097 //    */
00098 //   void ts(double newTs){
00099 //     ts_ = newTs;
00100 //   }
00101 
00107   float tTrig() const { return tTrigS_;}
00108 
00109 //   /** Sets trigger time position
00110 //    * @param tTrigS (t_trig-t_0) in seconds, with t_trig the time of MATACQ
00111 //    * trigger and t_0 the time of the first sample of each MATACQ channel.
00112 //    */
00113 //   void tTrig(double tTrigS){
00114 //     tTrigS_ = tTrigS;
00115 //   }
00116 
00120   short version() const {return version_;}
00121 
00122 //   /** Sets the raw data format, the digi is issued from.
00123 //    * @param version internal matacq raw data format version
00124 //    */
00125 //   void version(short version){
00126 //     version_ = version;
00127 //   }
00128 
00129 #if (ECAL_MATACQ_DIGI_VERS>=2)
00130 
00133   int bxId() const { return bxId_; }
00134 
00138   void bxId(int value) { bxId_ = value; }
00139 
00143   int l1a() const { return l1a_; }
00144   
00148   void l1a(int value) { l1a_ = value; }
00149   
00153   int triggerType() const { return triggerType_; }
00154 
00158   void triggerType(int value) { triggerType_ = value; }
00159 
00165   timeval timeStamp() const { return timeStamp_; }
00166 
00170   void timeStamp(timeval value) { timeStamp_ = value; }
00171   
00176   UInt_t orbitId() const { return orbitId_; }
00177 
00181   void orbitId(UInt_t value) { orbitId_ = value; }
00182   
00187   int trigRec() const { return trigRec_; }
00188   
00192   void trigRec(int value) { trigRec_ = value; }
00193 
00197   int postTrig() const { return postTrig_; }
00198 
00202   void postTrig(int value) { postTrig_ = value; }
00203 
00207   std::vector<int> vernier() const { return vernier_; }
00208   
00212   void vernier(const std::vector<int>& value) { vernier_ = value; }
00213 
00214   
00218   int delayA() const { return delayA_; }
00219 
00223   void delayA(int value) { delayA_ = value; }
00224 
00228   int emtcDelay() const { return emtcDelay_; }
00229   
00233   void emtcDelay(int value) { emtcDelay_ = value; }
00234   
00238   int emtcPhase() const { return emtcPhase_; }
00239   
00243   void emtcPhase(int value) { emtcPhase_ = value; }
00244 
00249   int attenuation_dB() const { return attenuation_dB_; }
00250 
00255   void attenuation_dB(int value) { attenuation_dB_ = value; }
00256   
00261   int laserPower() const { return laserPower_; }
00262   
00267   void laserPower(int value) { laserPower_ = value; }
00268 
00269   void init(){
00270 #if (ECAL_MATACQ_DIGI_VERS>=2)
00271     bxId_ = -1;
00272     l1a_ = -1;
00273     triggerType_ = -1;
00274     orbitId_ = -1;
00275     trigRec_ = -1;
00276     postTrig_ = -1;
00277     vernier_ = std::vector<Int_t>(4,-1);
00278     delayA_ = -1;
00279     emtcDelay_ = -1;
00280     emtcPhase_ = -1;
00281     attenuation_dB_ = -1;
00282     laserPower_ = -1;
00283 #endif
00284   }
00285 
00286 #endif
00287 
00288 private:
00291   int chId_;
00292   
00295   std::vector<Short_t> data_;
00296 
00299   int freq;
00300   
00303   double ts_;
00304 
00307   double tTrigS_;
00308 
00311   short version_;
00312 
00313 #if (ECAL_MATACQ_DIGI_VERS>=2)
00314 
00317   char triggerType_;
00318 
00322   char attenuation_dB_;
00323 
00326   Short_t bxId_;
00327 
00330   Int_t l1a_;
00331   
00332   /* LHC orbit ID
00333    */
00334   Int_t orbitId_;
00335   
00338   Short_t trigRec_;
00339   
00342   Short_t postTrig_;
00343 
00346   std::vector<Int_t> vernier_;
00347 
00350   Int_t delayA_;
00351 
00354   Int_t emtcDelay_;
00355 
00358   Int_t emtcPhase_;
00359 
00362   Int_t laserPower_;
00363 
00366   timeval timeStamp_;
00367 #endif
00368   
00369 };
00370 
00371 
00372 std::ostream& operator<<(std::ostream& s, const EcalMatacqDigi& digi);
00373 
00374 #endif