CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Attributes

CaloHitResponse Class Reference

Creates electronics signals from hits. More...

#include <CaloHitResponse.h>

Inheritance diagram for CaloHitResponse:
HcalSiPMHitResponse

List of all members.

Public Types

enum  { BUNCHSPACE = 25 }
typedef std::map< DetId,
CaloSamples
AnalogSignalMap

Public Member Functions

virtual void add (const PCaloHit &hit)
 process a single SimHit
void add (const CaloSamples &signal)
 add a signal, in units of pe
void addHit (const PCaloHit *hit, CaloSamples &frame) const
 adds the amplitude for a single hit to the frame
double analogSignalAmplitude (const DetId &id, float energy, const CaloSimParameters &parameters) const
 CaloHitResponse (const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes)
 CaloHitResponse (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape)
void clear ()
 frees up memory
virtual void finalizeHits ()
 Finalize hits.
CaloSamplesfindSignal (const DetId &detId)
 users can look for the signal for a given cell
void initHBHEScale ()
virtual void initializeHits ()
 Initialize hits.
virtual bool keepBlank () const
virtual CaloSamples makeAnalogSignal (const PCaloHit &inputHit) const
 creates the signal corresponding to this hit
CaloSamples makeBlankSignal (const DetId &detId) const
 creates an empty signal for this DetId
int nSignals () const
 number of signals in the current cache
virtual void run (MixCollection< PCaloHit > &hits)
 Complete cell digitization.
void setBunchRange (int minBunch, int maxBunch)
 tells it which pileup bunches to do
void setGeometry (const CaloGeometry *geometry)
 geometry needed for time-of-flight
void setHBHEScale (std::string &)
void setHitCorrection (const CaloVHitCorrection *hitCorrection)
 If you want to correct hits, for attenuation or delay, set this.
void setHitFilter (const CaloVHitFilter *filter)
 if you want to reject hits, for example, from a certain subdetector, set this
void setPECorrection (const CaloVPECorrection *peCorrection)
 if you want to correct the photoelectrons
void setPhaseShift (const double &thePhaseShift)
 setting the phase shift for asynchronous trigger (e.g. test beams)
virtual void setRandomEngine (CLHEP::HepRandomEngine &engine)
double timeOfFlight (const DetId &detId) const
bool withinBunchRange (int bunchCrossing) const
 check if crossing is within bunch range:
virtual ~CaloHitResponse ()
 doesn't delete the pointers passed in

Protected Attributes

bool changeScale
float hcal_en_scale [100][72][4]
AnalogSignalMap theAnalogSignalMap
const CaloGeometrytheGeometry
const CaloVHitCorrectiontheHitCorrection
const CaloVHitFiltertheHitFilter
int theMaxBunch
int theMinBunch
const CaloVSimParameterMaptheParameterMap
const CaloVPECorrectionthePECorrection
double thePhaseShift_
CLHEP::RandPoissonQ * theRandPoisson
const CaloVShapetheShape
const CaloShapestheShapes

Detailed Description

Creates electronics signals from hits.

Definition at line 31 of file CaloHitResponse.h.


Member Typedef Documentation

Definition at line 34 of file CaloHitResponse.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
BUNCHSPACE 

Definition at line 36 of file CaloHitResponse.h.

{BUNCHSPACE=25};

Constructor & Destructor Documentation

CaloHitResponse::CaloHitResponse ( const CaloVSimParameterMap parameterMap,
const CaloVShape shape 
)
CaloHitResponse::CaloHitResponse ( const CaloVSimParameterMap parameterMap,
const CaloShapes shapes 
)

Definition at line 41 of file CaloHitResponse.cc.

CaloHitResponse::~CaloHitResponse ( ) [virtual]

doesn't delete the pointers passed in

Definition at line 57 of file CaloHitResponse.cc.

References theRandPoisson.

                                  {
  delete theRandPoisson;
}

Member Function Documentation

void CaloHitResponse::add ( const PCaloHit hit) [virtual]

process a single SimHit

Reimplemented in HcalSiPMHitResponse.

Definition at line 116 of file CaloHitResponse.cc.

References CaloVHitFilter::accepts(), i, edm::isNotFinite(), keep, keepBlank(), LogDebug, makeAnalogSignal(), findQualityFiles::size, CaloSamples::size(), theHitFilter, and PCaloHit::time().

Referenced by CaloTDigitizer< Traits >::add(), CaloTDigitizer< Traits >::addNoiseHits(), CaloTDigitizer< Traits >::addNoiseSignals(), and run().

                                               {
  // check the hit time makes sense
  if ( edm::isNotFinite(hit.time()) ) { return; }

  // maybe it's not from this subdetector
  if(theHitFilter == 0 || theHitFilter->accepts(hit)) {
    LogDebug("CaloHitResponse") << hit;
    CaloSamples signal( makeAnalogSignal( hit ) ) ;

    bool keep ( keepBlank() ) ;  // here we  check for blank signal if not keeping them
    if( !keep )
    {
       const unsigned int size ( signal.size() ) ;
       if( 0 != size )
       {
          for( unsigned int i ( 0 ) ; i != size ; ++i )
          {
             keep = keep || signal[i] > 1.e-7 ;
          }
       }
    }
    LogDebug("CaloHitResponse") << signal;
    if( keep ) add(signal);
  }
}
void CaloHitResponse::add ( const CaloSamples signal)

add a signal, in units of pe

Definition at line 143 of file CaloHitResponse.cc.

References findSignal(), i, CaloSamples::id(), CaloSamples::presamples(), CaloSamples::size(), and theAnalogSignalMap.

{
  DetId id(signal.id());
  CaloSamples * oldSignal = findSignal(id);
  if (oldSignal == 0) {
    theAnalogSignalMap[id] = signal;
  } else  {
    // need a "+=" to CaloSamples
    int sampleSize =  oldSignal->size();
    assert(sampleSize == signal.size());
    assert(signal.presamples() == oldSignal->presamples());

    for(int i = 0; i < sampleSize; ++i) {
      (*oldSignal)[i] += signal[i];
    }
  }
}
void CaloHitResponse::addHit ( const PCaloHit hit,
CaloSamples frame 
) const

adds the amplitude for a single hit to the frame

double CaloHitResponse::analogSignalAmplitude ( const DetId id,
float  energy,
const CaloSimParameters parameters 
) const

finds the amplitude contribution from this hit, applying photostatistics, if needed. Results are in photoelectrons

Definition at line 197 of file CaloHitResponse.cc.

References changeScale, CaloVPECorrection::correctPE(), HcalDetId::depth(), DetId::det(), CaloSimParameters::doPhotostatistics(), Exception, DetId::Hcal, hcal_en_scale, HcalBarrel, HcalEndcap, HcalDetId::ieta(), HcalDetId::iphi(), edm::Service< T >::isAvailable(), LogDebug, CaloSimParameters::simHitToPhotoelectrons(), HcalDetId::subdet(), thePECorrection, and theRandPoisson.

Referenced by makeAnalogSignal(), and HcalSiPMHitResponse::makeSiPMSignal().

                                                                                                                           {

  if(!theRandPoisson)
    {
      edm::Service<edm::RandomNumberGenerator> rng;
      if ( ! rng.isAvailable()) {
        throw cms::Exception("Configuration")
          << "CaloHitResponse requires the RandomNumberGeneratorService\n"
          "which is not present in the configuration file.  You must add the service\n"
          "in the configuration file or remove the modules that require it.";
      }
      theRandPoisson = new CLHEP::RandPoissonQ(rng->getEngine());
    }
  
  // OK, the "energy" in the hit could be a real energy, deposited energy,
  // or pe count.  This factor converts to photoelectrons
  //GMA Smeared in photon production it self  
  double scl =1.0;
#ifdef ChangeHcalEnergyScale
  if (changeScale) {
    if (detId.det()==DetId::Hcal ) { 
      HcalDetId dId = HcalDetId(detId); 
      if (dId.subdet()==HcalBarrel || dId.subdet()==HcalEndcap) { 
        int ieta = dId.ieta()+50;
        int iphi = dId.iphi()-1;
        int idep = dId.depth()-1;
        scl = hcal_en_scale[ieta][iphi][idep];
        LogDebug("CaloHitResponse") << " ID " << dId << " Scale " << scl;
      }
    }
  } 
#endif
  double npe = scl * energy * parameters.simHitToPhotoelectrons(detId);
  // do we need to doPoisson statistics for the photoelectrons?
  if(parameters.doPhotostatistics()) {
    npe = theRandPoisson->fire(npe);
  }
  if(thePECorrection) npe = thePECorrection->correctPE(detId, npe);
  return npe;
}
void CaloHitResponse::clear ( void  ) [inline]

frees up memory

Definition at line 89 of file CaloHitResponse.h.

References theAnalogSignalMap.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi(), and CaloTDigitizer< Traits >::run().

{theAnalogSignalMap.clear();}
virtual void CaloHitResponse::finalizeHits ( ) [inline, virtual]

Finalize hits.

Reimplemented in HcalSiPMHitResponse.

Definition at line 60 of file CaloHitResponse.h.

Referenced by CaloTDigitizer< Traits >::run().

{}
CaloSamples * CaloHitResponse::findSignal ( const DetId detId)

users can look for the signal for a given cell

Definition at line 239 of file CaloHitResponse.cc.

References query::result, and theAnalogSignalMap.

Referenced by add(), EcalMixingModuleValidation::computeSDBunchDigi(), and CaloTDigitizer< Traits >::run().

                                                             {
  CaloSamples * result = 0;
  AnalogSignalMap::iterator signalItr = theAnalogSignalMap.find(detId);
  if(signalItr == theAnalogSignalMap.end()) {
    result = 0;
  } else {
    result = &(signalItr->second);
  }
  return result;
}
void CaloHitResponse::initHBHEScale ( )

Definition at line 61 of file CaloHitResponse.cc.

References hcal_en_scale.

Referenced by HcalDigitizer::HcalDigitizer().

                                    {
#ifdef ChangeHcalEnergyScale
  for (int ij=0; ij<100; ij++) {
    for (int jk=0; jk<72; jk++) {       
      for (int kl=0; kl<4; kl++) {
        hcal_en_scale[ij][jk][kl] = 1.0;
      }
    }
  }
#endif
}
virtual void CaloHitResponse::initializeHits ( ) [inline, virtual]

Initialize hits.

Reimplemented in HcalSiPMHitResponse.

Definition at line 57 of file CaloHitResponse.h.

Referenced by CaloTDigitizer< Traits >::initializeHits().

{}
virtual bool CaloHitResponse::keepBlank ( ) const [inline, virtual]

Definition at line 54 of file CaloHitResponse.h.

References funct::true.

Referenced by add().

{ return true ; }
CaloSamples CaloHitResponse::makeAnalogSignal ( const PCaloHit inputHit) const [virtual]

creates the signal corresponding to this hit

Definition at line 162 of file CaloHitResponse.cc.

References analogSignalAmplitude(), newFWLiteAna::bin, BUNCHSPACE, CaloVHitCorrection::delay(), PCaloHit::energy(), PCaloHit::id(), makeBlankSignal(), Parameters::parameters, query::result, CaloShapes::shape(), CaloVSimParameterMap::simParameters(), CaloSamples::size(), theHitCorrection, theParameterMap, thePhaseShift_, theShape, theShapes, cond::rpcobgas::time, PCaloHit::time(), timeOfFlight(), CaloVShape::timeToRise(), and tzero.

Referenced by add().

                                                                        {

  DetId detId(hit.id());
  const CaloSimParameters & parameters = theParameterMap->simParameters(detId);
  
  double signal = analogSignalAmplitude(detId, hit.energy(), parameters);

  double time = hit.time();
  if(theHitCorrection != 0) {
    time += theHitCorrection->delay(hit);
  }
  double jitter = hit.time() - timeOfFlight(detId);

  const CaloVShape * shape = theShape;
  if(!shape) {
    shape = theShapes->shape(detId);
  }
  // assume bins count from zero, go for center of bin
  const double tzero = ( shape->timeToRise()
                         + parameters.timePhase() 
                         - jitter 
                         - BUNCHSPACE*( parameters.binOfMaximum()
                                        - thePhaseShift_          ) ) ;
  double binTime = tzero;

  CaloSamples result(makeBlankSignal(detId));

  for(int bin = 0; bin < result.size(); bin++) {
    result[bin] += (*shape)(binTime)* signal;
    binTime += BUNCHSPACE;
  }
  return result;
} 
CaloSamples CaloHitResponse::makeBlankSignal ( const DetId detId) const
int CaloHitResponse::nSignals ( ) const [inline]

number of signals in the current cache

Definition at line 105 of file CaloHitResponse.h.

References theAnalogSignalMap.

Referenced by CaloTDigitizer< Traits >::run().

{return theAnalogSignalMap.size();}
void CaloHitResponse::run ( MixCollection< PCaloHit > &  hits) [virtual]

Complete cell digitization.

Reimplemented in HcalSiPMHitResponse.

Definition at line 106 of file CaloHitResponse.cc.

References add(), MixCollection< T >::begin(), MixCollection< T >::end(), and withinBunchRange().

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

                                                        {

  for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
      hitItr != hits.end(); ++hitItr) {
    if(withinBunchRange(hitItr.bunch())) {
      add(*hitItr);
    } // loop over hits
  }
}
void CaloHitResponse::setBunchRange ( int  minBunch,
int  maxBunch 
)

tells it which pileup bunches to do

Definition at line 95 of file CaloHitResponse.cc.

References theMaxBunch, and theMinBunch.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

                                                              {
  theMinBunch = minBunch;
  theMaxBunch = maxBunch;
}
void CaloHitResponse::setGeometry ( const CaloGeometry geometry) [inline]
void CaloHitResponse::setHBHEScale ( std::string &  fileIn)

Definition at line 73 of file CaloHitResponse.cc.

References changeScale, eta(), hcal_en_scale, EdgesToViz::infile, LogDebug, and phi.

Referenced by HcalDigitizer::HcalDigitizer().

                                                     {
  
  ifstream infile(fileIn.c_str());
  LogDebug("CaloHitResponse") << "Reading from " << fileIn;
#ifdef ChangeHcalEnergyScale
  if (!infile.is_open()) {
    edm::LogError("CaloHitResponse") << "** ERROR: Can't open '" << fileIn << "' for the input file";
  } else {
    int     eta, phi, depth;
    double  cFactor;
    while(1) {
      infile >> eta >> phi >> depth >> cFactor;
      if (!infile.good()) break;
      hcal_en_scale[eta][phi][depth] = cFactor;
      //      LogDebug("CaloHitResponse") << "hcal_en_scale[" << eta << "][" << phi << "][" << depth << "] = " << hcal_en_scale[eta][phi][depth];
    }
    infile.close();
  }
  changeScale = true;
#endif
}
void CaloHitResponse::setHitCorrection ( const CaloVHitCorrection hitCorrection) [inline]

If you want to correct hits, for attenuation or delay, set this.

Definition at line 77 of file CaloHitResponse.h.

References theHitCorrection.

Referenced by CastorDigiProducer::CastorDigiProducer(), and HcalTBDigiProducer::HcalTBDigiProducer().

                                                                  {
    theHitCorrection = hitCorrection;
  }
void CaloHitResponse::setHitFilter ( const CaloVHitFilter filter) [inline]

if you want to reject hits, for example, from a certain subdetector, set this

Definition at line 72 of file CaloHitResponse.h.

References alcazmumu_cfi::filter, and theHitFilter.

Referenced by CastorDigiProducer::CastorDigiProducer(), HcalDigitizer::HcalDigitizer(), and HcalTBDigiProducer::HcalTBDigiProducer().

void CaloHitResponse::setPECorrection ( const CaloVPECorrection peCorrection) [inline]

if you want to correct the photoelectrons

Definition at line 82 of file CaloHitResponse.h.

References thePECorrection.

Referenced by HcalDigitizer::HcalDigitizer().

                                                               {
    thePECorrection = peCorrection;
  }
void CaloHitResponse::setPhaseShift ( const double &  thePhaseShift) [inline]

setting the phase shift for asynchronous trigger (e.g. test beams)

Definition at line 116 of file CaloHitResponse.h.

References thePhaseShift_.

Referenced by HcalTBDigiProducer::setPhaseShift().

{ thePhaseShift_ = thePhaseShift; }
void CaloHitResponse::setRandomEngine ( CLHEP::HepRandomEngine &  engine) [virtual]

Reimplemented in HcalSiPMHitResponse.

Definition at line 101 of file CaloHitResponse.cc.

References theRandPoisson.

Referenced by CaloTDigitizer< Traits >::setRandomEngine().

                                                                   {
  theRandPoisson = new CLHEP::RandPoissonQ(engine);
}
double CaloHitResponse::timeOfFlight ( const DetId detId) const

time-of-flight, in ns, to get to this cell returns 0 if no geometry has been set

Definition at line 259 of file CaloHitResponse.cc.

References CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), PV3DBase< T, PVType, FrameType >::mag(), DetId::rawId(), query::result, and theGeometry.

Referenced by makeAnalogSignal(), and HcalSiPMHitResponse::makeSiPMSignal().

                                                              {
  // not going to assume there's one of these per subdetector.
  // Take the whole CaloGeometry and find the right subdet
  double result = 0.;
  if(theGeometry == 0) {
    edm::LogWarning("CaloHitResponse") << "No Calo Geometry set, so no time of flight correction";
  } 
  else {
    const CaloCellGeometry* cellGeometry = theGeometry->getSubdetectorGeometry(detId)->getGeometry(detId);
    if(cellGeometry == 0) {
       edm::LogWarning("CaloHitResponse") << "No Calo cell found for ID"
         << detId.rawId() << " so no time-of-flight subtraction will be done";
    }
    else {
      double distance = cellGeometry->getPosition().mag();
      result =  distance * cm / c_light; // Units of c_light: mm/ns
    }
  }
  return result;
}
bool CaloHitResponse::withinBunchRange ( int  bunchCrossing) const [inline]

check if crossing is within bunch range:

Definition at line 120 of file CaloHitResponse.h.

References theMaxBunch, and theMinBunch.

Referenced by CaloTDigitizer< Traits >::add(), and run().

                                                 {
    return(bunchCrossing >= theMinBunch && bunchCrossing <= theMaxBunch);
  }

Member Data Documentation

bool CaloHitResponse::changeScale [protected]

Definition at line 145 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), and setHBHEScale().

float CaloHitResponse::hcal_en_scale[100][72][4] [protected]

Definition at line 147 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), initHBHEScale(), and setHBHEScale().

Definition at line 126 of file CaloHitResponse.h.

Referenced by add(), clear(), findSignal(), and nSignals().

Definition at line 135 of file CaloHitResponse.h.

Referenced by setGeometry(), and timeOfFlight().

Definition at line 140 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::run(), setBunchRange(), and withinBunchRange().

Definition at line 139 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::run(), setBunchRange(), and withinBunchRange().

Definition at line 132 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

double CaloHitResponse::thePhaseShift_ [protected]
CLHEP::RandPoissonQ* CaloHitResponse::theRandPoisson [mutable, protected]

Definition at line 137 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), setRandomEngine(), and ~CaloHitResponse().

Definition at line 130 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().

Definition at line 129 of file CaloHitResponse.h.

Referenced by makeAnalogSignal(), and HcalSiPMHitResponse::makeSiPMSignal().