Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:38

0001 #ifndef DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
0002 #define DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
0003 
0004 #include <utility>
0005 
0006 #include "DataFormats/HcalRecHit/interface/HFQIE10Info.h"
0007 
0008 /** \class HFPreRecHit
0009 *
0010 * Class to contain the info needed to perform HF reconstruction
0011 * using QIE10 chips and dual-anode readout. Groups the information
0012 * provided by a single PMT.
0013 */
0014 class HFPreRecHit {
0015 public:
0016   typedef HcalDetId key_type;
0017 
0018   constexpr HFPreRecHit() : hasInfo_{false, false} {}
0019 
0020   // In the constructor below, either "first" or "second"
0021   // pointer can be nullptr
0022   constexpr HFPreRecHit(const HcalDetId& id, const HFQIE10Info* first, const HFQIE10Info* second)
0023       : id_(id), hasInfo_{false, false} {
0024     if (first) {
0025       hfQIE10Info_[0] = *first;
0026       hasInfo_[0] = true;
0027     }
0028     if (second) {
0029       hfQIE10Info_[1] = *second;
0030       hasInfo_[1] = true;
0031     }
0032   }
0033 
0034   constexpr HcalDetId id() const { return id_; }
0035 
0036   // Get a pointer to the QIE10 info. nullptr will be returned
0037   // if the info with the given index does not exist or if the
0038   // index is out of range.
0039   constexpr HFQIE10Info const* getHFQIE10Info(unsigned index) const {
0040     if (index < 2 && hasInfo_[index])
0041       return &hfQIE10Info_[index];
0042     else
0043       return nullptr;
0044   }
0045 
0046   // Quantities simply added from both anodes
0047   constexpr float charge() const {
0048     float q = 0.f;
0049     for (unsigned i = 0; i < 2; ++i)
0050       if (hasInfo_[i])
0051         q += hfQIE10Info_[i].charge();
0052     return q;
0053   }
0054   constexpr float energy() const {
0055     float e = 0.f;
0056     for (unsigned i = 0; i < 2; ++i)
0057       if (hasInfo_[i])
0058         e += hfQIE10Info_[i].energy();
0059     return e;
0060   }
0061 
0062   // The following function returns a pair.
0063   // The first element of the pair is the charge asymmetry,
0064   // if calculated. The second element of the pair indicates
0065   // whether the asymmetry is actually calculated. "true"
0066   // means yes, it is. The asymmetry is calculated if all
0067   // of the following conditions are satisfied:
0068   //
0069   //   1) The data is available for both PMT anodes.
0070   //   2) The sum of the charges is positive.
0071   //   3) The sum of the charges is at least "chargeThreshold".
0072   //
0073   // If the asymmetry is not calculated, the first element of
0074   // the pair is set to 0 and the second to "false".
0075   //
0076   std::pair<float, bool> chargeAsymmetry(float chargeThreshold) const;
0077 
0078   // Similar function for the energy asymmetry
0079   std::pair<float, bool> energyAsymmetry(float energyThreshold) const;
0080 
0081 private:
0082   HcalDetId id_;
0083 
0084   HFQIE10Info hfQIE10Info_[2];
0085   bool hasInfo_[2];
0086 };
0087 
0088 #endif  // DATAFORMATS_HCALRECHIT_HFPRERECHIT_H