CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

HBHETimingShapedFlagSetter Class Reference

#include <HBHETimingShapedFlag.h>

List of all members.

Public Member Functions

void Clear ()
void dumpInfo ()
 HBHETimingShapedFlagSetter ()
 HBHETimingShapedFlagSetter (const std::vector< double > &tfilterEnvelope)
 HBHETimingShapedFlagSetter (const std::vector< double > &tfilterEnvelope, bool ignorelowest, bool ignorehighest, double win_offset, double win_gain)
void SetTimingShapedFlags (HBHERecHit &hbhe)
int timingStatus (const HBHERecHit &hbhe)
 ~HBHETimingShapedFlagSetter ()

Private Types

typedef std::map< int,
std::pair< double, double > > 
TfilterEnvelope_t

Private Member Functions

void makeTfilterEnvelope (std::vector< double > v_userEnvelope)

Private Attributes

bool ignorehighest_
bool ignorelowest_
TfilterEnvelope_t tfilterEnvelope_
double win_gain_
double win_offset_

Detailed Description

Definition at line 9 of file HBHETimingShapedFlag.h.


Member Typedef Documentation

typedef std::map<int,std::pair<double,double> > HBHETimingShapedFlagSetter::TfilterEnvelope_t [private]

Definition at line 37 of file HBHETimingShapedFlag.h.


Constructor & Destructor Documentation

HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( )

Definition at line 13 of file HBHETimingShapedFlag.cc.

{
}
HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( const std::vector< double > &  tfilterEnvelope)
HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( const std::vector< double > &  tfilterEnvelope,
bool  ignorelowest,
bool  ignorehighest,
double  win_offset,
double  win_gain 
)

Definition at line 27 of file HBHETimingShapedFlag.cc.

References ignorehighest_, ignorelowest_, makeTfilterEnvelope(), win_gain_, and win_offset_.

{
  makeTfilterEnvelope(v_userEnvelope);

  ignorelowest_  = ignorelowest;  // can ignore flagging hits below lowest energy threshold
  ignorehighest_ = ignorehighest; // can ignore flagging hits above highest energy threshold
  win_offset_    = win_offset;    // timing offset
  win_gain_      = win_gain;      // time gain
}
HBHETimingShapedFlagSetter::~HBHETimingShapedFlagSetter ( )

Member Function Documentation

void HBHETimingShapedFlagSetter::Clear ( )
void HBHETimingShapedFlagSetter::dumpInfo ( )

Definition at line 62 of file HBHETimingShapedFlag.cc.

References gather_cfg::cout, ignorehighest_, ignorelowest_, tfilterEnvelope_, win_gain_, and win_offset_.

{  
  std::cout <<"Timing Energy/Time parameters are:"<<std::endl;
  TfilterEnvelope_t::const_iterator it;
  for (it=tfilterEnvelope_.begin();it!=tfilterEnvelope_.end();++it)
    std::cout <<"\t"<<it->first<<" GeV\t"<<it->second.first<<" ns\t"<<it->second.second<<" ns"<<std::endl;

  std::cout <<"ignorelowest  = "<<ignorelowest_<<std::endl;
  std::cout <<"ignorehighest = "<<ignorehighest_<<std::endl;
  std::cout <<"win_offset    = "<<win_offset_<<std::endl;
  std::cout <<"win_gain      = "<<win_gain_<<std::endl;
}
void HBHETimingShapedFlagSetter::makeTfilterEnvelope ( std::vector< double >  v_userEnvelope) [private]

Definition at line 40 of file HBHETimingShapedFlag.cc.

References Exception, i, and tfilterEnvelope_.

Referenced by HBHETimingShapedFlagSetter().

{
  // Transform vector of doubles into a map of <energy,lowtime,hitime> triplets
  // Add extra protection in case vector of doubles is not a multiple of 3
  if (v_userEnvelope.size()%3)
    throw cms::Exception("Invalid tfilterEnvelope definition") <<
      "Must be one energy and two times per point";

  for (unsigned int i=0;i<v_userEnvelope.size();i+=3) {
    int intGeV = (int)(v_userEnvelope[i]+0.5);
    std::pair<double,double> pairOfTimes = std::make_pair(v_userEnvelope[i+1],
                                                          v_userEnvelope[i+2]);
    if ((pairOfTimes.first  > 0) ||
        (pairOfTimes.second < 0) )
      throw cms::Exception("Invalid tfilterEnvelope definition") <<
        "Min and max time values must straddle t=0; use win_offset to shift";

    tfilterEnvelope_[intGeV] = pairOfTimes;
  }
}
void HBHETimingShapedFlagSetter::SetTimingShapedFlags ( HBHERecHit hbhe)

Definition at line 157 of file HBHETimingShapedFlag.cc.

References HcalCaloFlagLabels::HBHETimingShapedCutsBits, CaloRecHit::setFlagField(), ntuplemaker::status, and timingStatus().

Referenced by HcalHitReconstructor::produce().

{
  int status = timingStatus(hbhe);

  // Though we're only using a single bit right now, 3 bits are reserved for these cuts
  hbhe.setFlagField(status,HcalCaloFlagLabels::HBHETimingShapedCutsBits,3);

  return;
}
int HBHETimingShapedFlagSetter::timingStatus ( const HBHERecHit hbhe)

Definition at line 76 of file HBHETimingShapedFlag.cc.

References CaloRecHit::energy(), relval_parameters_module::energy, ignorehighest_, ignorelowest_, ntuplemaker::status, tfilterEnvelope_, CaloRecHit::time(), win_gain_, and win_offset_.

Referenced by SetTimingShapedFlags().

{
  int status=0;  // 3 bits reserved;status can range from 0-7

  // tfilterEnvelope stores triples of energy and high/low time limits; 
  // make sure we're checking over an even number of values
  // energies are guaranteed by std::map to appear in increasing order

  // need at least two values to make comparison, and must
  // always have energy, time pair; otherwise, assume "in time" and don't set bits
  if (tfilterEnvelope_.size()==0)
    return 0;

  double twinmin, twinmax;  // min, max 'good' time; values outside this range have flag set
  double rhtime=hbhe.time();
  double energy=hbhe.energy();

  if (energy< (double)tfilterEnvelope_.begin()->first) // less than lowest energy threshold
    {
      // Can skip timing test on cells below lowest threshold if so desired
      if (ignorelowest_) 
        return 0;
      else {
        twinmin=tfilterEnvelope_.begin()->second.first;
        twinmax=tfilterEnvelope_.begin()->second.second;
      }
    }
  else
    {
      // Loop over energies in tfilterEnvelope
      TfilterEnvelope_t::const_iterator it;
      for (it=tfilterEnvelope_.begin();it!=tfilterEnvelope_.end();++it)
        {
          // Identify tfilterEnvelope index for this rechit energy
          if (energy < (double)it->first)
            break;
        }

      if (it==tfilterEnvelope_.end())
        {
          // Skip timing test on cells above highest threshold if so desired
          if (ignorehighest_)
            return 0;
          else {
            twinmin=tfilterEnvelope_.rbegin()->second.first;
            twinmax=tfilterEnvelope_.rbegin()->second.second;
          }
        }
      else
        {
          // Perform linear interpolation between energy boundaries

          std::map<int,std::pair<double,double> >::const_iterator prev = it; prev--;

          // twinmax interpolation
          double energy1  = prev->first;
          double lim1     = prev->second.second;
          double energy2  = it->first;
          double lim2     = it->second.second;
        
          twinmax=lim1+((lim2-lim1)*(energy-energy1)/(energy2-energy1));

          // twinmin interpolation
          lim1     = prev->second.first;
          lim2     = it->second.first;
        
          twinmin=lim1+((lim2-lim1)*(energy-energy1)/(energy2-energy1));
        }
    }

  // Apply offset, gain
  twinmin=win_offset_+twinmin*win_gain_;
  twinmax=win_offset_+twinmax*win_gain_;  

  // Set status high if time outside expected range
  if (rhtime<=twinmin || rhtime >= twinmax)
    status=1; // set status to 1

  return status;
}

Member Data Documentation

Definition at line 43 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().

Definition at line 42 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().

Definition at line 38 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), makeTfilterEnvelope(), and timingStatus().

Definition at line 45 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().

Definition at line 44 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().