Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:09

0001 #ifndef DATAFORMATS_FTLRECHIT_H
0002 #define DATAFORMATS_FTLRECHIT_H 1
0003 
0004 #include "DataFormats/ForwardDetId/interface/MTDDetId.h"
0005 #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
0006 #include <vector>
0007 
0008 /** \class FTLRecHit
0009  *  
0010  * based on EcalRecHit
0011  *
0012  * \author Lindsey Gray
0013  */
0014 
0015 class FTLRecHit {
0016 public:
0017   typedef DetId key_type;
0018 
0019   // FTLEE recHit flags
0020   enum Flags {
0021     kGood = 0,  // channel ok, the energy and time measurement are reliable
0022     kKilled,    // MC only flag: the channel is killed in the real detector
0023     kUnknown    // to ease the interface with functions returning flags.
0024   };
0025 
0026   /** bit structure of CaloRecHit::flags_ used in FTLRecHit:
0027    *
0028    *  | 32 | 31...25 | 24...12 | 11...5 | 4...1 |
0029    *     |      |         |         |       |
0030    *     |      |         |         |       +--> reco flags       ( 4 bits)
0031    *     |      |         |         +--> chi2 for in time events  ( 7 bits)
0032    *     |      |         +--> energy for out-of-time events      (13 bits)
0033    *     |      +--> chi2 for out-of-time events                  ( 7 bits)
0034    *     +--> spare                                               ( 1 bit )
0035    */
0036 
0037   FTLRecHit();
0038   // by default a recHit is greated with no flag
0039   FTLRecHit(const DetId& id,
0040             uint8_t row,
0041             uint8_t column,
0042             float energy,
0043             float time,
0044             float timeError,
0045             float position,
0046             float positionError,
0047             uint32_t flagBits = 0);
0048 
0049   FTLRecHit(const DetId& id,
0050             float energy,
0051             float time,
0052             float timeError,
0053             float position,
0054             float positionError,
0055             uint32_t flagBits = 0);
0056 
0057   /// get the id
0058 
0059   float energy() const { return energy_; }
0060   void setEnergy(float energy) { energy_ = energy; }
0061 
0062   const DetId& id() const { return id_; }
0063   const DetId& detid() const { return id(); }
0064 
0065   const MTDDetId mtdId() const { return MTDDetId(id_); }
0066 
0067   int row() const { return row_; }
0068   int column() const { return column_; }
0069 
0070   float time() const { return time_; }
0071   void setTime(float time) { time_ = time; }
0072 
0073   float position() const { return position_; }
0074   void setPosition(float position) { position_ = position; }
0075 
0076   bool isTimeValid() const;
0077   bool isTimeErrorValid() const;
0078 
0079   float timeError() const { return timeError_; }
0080   void setTimeError(float err) { timeError_ = err; }
0081 
0082   float positionError() const { return positionError_; }
0083   void setPositionError(float poserr) { positionError_ = poserr; }
0084 
0085   /// set the flags (from Flags or ESFlags)
0086   void setFlag(int flag) { flagBits_ |= (0x1 << flag); }
0087   void unsetFlag(int flag) { flagBits_ &= ~(0x1 << flag); }
0088 
0089   /// check if the flag is true
0090   bool checkFlag(int flag) const { return flagBits_ & (0x1 << flag); }
0091 
0092   /// check if one of the flags in a set is true
0093   bool checkFlags(const std::vector<int>& flagsvec) const;
0094 
0095 private:
0096   DetId id_;
0097   float energy_;
0098   float time_;
0099   float timeError_;
0100   /// position is the distance from the center of the bar to hit
0101   float position_;
0102   float positionError_;
0103   uint8_t row_;
0104   uint8_t column_;
0105 
0106   /// store rechit condition (see Flags enum) in a bit-wise way
0107   unsigned char flagBits_;
0108 };
0109 
0110 std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit);
0111 
0112 #endif