CMS 3D CMS Logo

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

HcalTBDigiProducer Class Reference

#include <HcalTBDigiProducer.h>

Inheritance diagram for HcalTBDigiProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 HcalTBDigiProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~HcalTBDigiProducer ()

Private Types

typedef CaloTDigitizer
< HBHEDigitizerTraits
HBHEDigitizer
typedef CaloTDigitizer
< HODigitizerTraits
HODigitizer

Private Member Functions

void checkGeometry (const edm::EventSetup &eventSetup)
void setPhaseShift (const DetId &detId)
void sortHits (const edm::PCaloHitContainer &hits)
 fills the vectors for each subdetector
void updateGeometry ()

Private Attributes

bool doPhaseShift
std::string ecalTBInfoLabel
std::vector< DetIdhbheCells
std::vector< DetIdhoCells
HcalAmplifiertheAmplifier
HcalCoderFactorytheCoderFactory
HcalElectronicsSimtheElectronicsSim
const CaloGeometrytheGeometry
HBHEDigitizertheHBHEDigitizer
HBHEHitFilter theHBHEHitFilter
std::vector< PCaloHittheHBHEHits
CaloHitResponsetheHBHEResponse
CaloVShapetheHcalIntegratedShape
CaloVShapetheHcalShape
HcalHitCorrectiontheHitCorrection
HODigitizertheHODigitizer
HOHitFilter theHOHitFilter
std::vector< PCaloHittheHOHits
CaloHitResponsetheHOResponse
HcalTBSimParameterMaptheParameterMap
double thisPhaseShift
double tunePhaseShift

Detailed Description

Definition at line 24 of file HcalTBDigiProducer.h.


Member Typedef Documentation

Reconstruction algorithm

Definition at line 48 of file HcalTBDigiProducer.h.

Definition at line 49 of file HcalTBDigiProducer.h.


Constructor & Destructor Documentation

HcalTBDigiProducer::HcalTBDigiProducer ( const edm::ParameterSet ps) [explicit]

Definition at line 19 of file HcalTBDigiProducer.cc.

References HcalCoderFactory::DB, doPhaseShift, ecalTBInfoLabel, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), DetId::Hcal, CaloHitResponse::setHitCorrection(), CaloHitResponse::setHitFilter(), HcalTBSimParameterMap::simParameters(), theAmplifier, theCoderFactory, theElectronicsSim, theHBHEDigitizer, theHBHEHitFilter, theHBHEResponse, theHitCorrection, theHODigitizer, theHOHitFilter, theHOResponse, theParameterMap, and tunePhaseShift.

                                                                :
  theParameterMap(new HcalTBSimParameterMap(ps)), 
  theHcalShape(new HcalShape()),
  theHcalIntegratedShape(new CaloShapeIntegrator(theHcalShape)),
  theHBHEResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
  theHOResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
  theAmplifier(0), theCoderFactory(0), theElectronicsSim(0), 
  theHitCorrection(0), theHBHEDigitizer(0), theHODigitizer(0), theHBHEHits(),
  theHOHits(), thisPhaseShift(0) {
  
  produces<HBHEDigiCollection>();
  produces<HODigiCollection>();

  DetId detId(DetId::Hcal, 1);
  bool syncPhase = (theParameterMap->simParameters(detId)).syncPhase();
  doPhaseShift   = !syncPhase;

  theHBHEResponse->setHitFilter(&theHBHEHitFilter);
  theHOResponse->setHitFilter(&theHOHitFilter);

  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
  if(doTimeSlew) {
    // no time slewing for HF
    theHitCorrection = new HcalHitCorrection(theParameterMap);
    theHBHEResponse->setHitCorrection(theHitCorrection);
    theHOResponse->setHitCorrection(theHitCorrection);
  }

  bool doNoise = ps.getParameter<bool>("doNoise");
  theAmplifier = new HcalAmplifier(theParameterMap, doNoise);
  theCoderFactory = new HcalCoderFactory(HcalCoderFactory::DB);
  theElectronicsSim = new HcalElectronicsSim(theAmplifier, theCoderFactory);

  theHBHEDigitizer = new HBHEDigitizer(theHBHEResponse, theElectronicsSim, doNoise);
  theHODigitizer = new HODigitizer(theHOResponse, theElectronicsSim, doNoise);

  tunePhaseShift =  ps.getUntrackedParameter<double>("tunePhaseShiftTB", 1.);
  ecalTBInfoLabel = ps.getUntrackedParameter<std::string>("EcalTBInfoLabel","SimEcalTBG4Object");
  edm::LogInfo("HcalSim") << "HcalTBDigiProducer initialized with doNoise = "
                          << doNoise << ", doTimeSlew = " << doTimeSlew
                          << " and doPhaseShift = " << doPhaseShift
                          << " tunePhasShift = " << tunePhaseShift;

}
HcalTBDigiProducer::~HcalTBDigiProducer ( ) [virtual]

Member Function Documentation

void HcalTBDigiProducer::checkGeometry ( const edm::EventSetup eventSetup) [private]

make sure the digitizer has the correct list of all cells that exist in the geometry

Definition at line 154 of file HcalTBDigiProducer.cc.

References geometry, edm::EventSetup::get(), theGeometry, and updateGeometry().

Referenced by produce().

                                                                       {

  // TODO find a way to avoid doing this every event
  edm::ESHandle<CaloGeometry> geometry;
  eventSetup.get<CaloGeometryRecord>().get(geometry);
 
  const CaloGeometry * pGeometry = &*geometry;

  // see if we need to update
  if(pGeometry != theGeometry) {
    theGeometry = pGeometry;
    updateGeometry();
  }
}
void HcalTBDigiProducer::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Produces the EDM products,

Implements edm::EDProducer.

Definition at line 80 of file HcalTBDigiProducer.cc.

References checkGeometry(), doPhaseShift, ecalTBInfoLabel, HcalHitCorrection::fillChargeSums(), edm::EventSetup::get(), edm::Event::getByLabel(), DetId::Hcal, LogDebug, edm::ESHandle< T >::product(), edm::Handle< T >::product(), edm::Event::put(), CaloTDigitizer< Traits >::run(), HcalCoderFactory::setDbService(), HcalAmplifier::setDbService(), setPhaseShift(), theAmplifier, theCoderFactory, theHBHEDigitizer, theHBHEHits, theHitCorrection, theHODigitizer, theHOHits, and thisPhaseShift.

                                                                             {

  // get the appropriate gains, noises, & widths for this event
  edm::ESHandle<HcalDbService> conditions;
  eventSetup.get<HcalDbRecord>().get(conditions);
  theAmplifier->setDbService(conditions.product());
  theCoderFactory->setDbService(conditions.product());

  // get the correct geometry
  checkGeometry(eventSetup);

  theHBHEHits.clear();
  theHOHits.clear();

  // Step A: Get Inputs
  edm::Handle<CrossingFrame<PCaloHit> > cf;
  // e.getByType(cf);

  LogDebug("HcalSim") << "HcalTBDigiProducer::produce trying to ger SimHit";
  // test access to SimHits
  const std::string subdet("HcalHits");
  // std::auto_ptr<MixCollection<PCaloHit> > col(new MixCollection<PCaloHit>(cf.product(), subdet));
  e.getByLabel("mix", subdet, cf);
  std::auto_ptr<MixCollection<PCaloHit> > col(new MixCollection<PCaloHit>(cf.product() ));

  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Collection of SimHit found";
  if(theHitCorrection != 0) {
    theHitCorrection->fillChargeSums(*col);
  }
  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Hits corrected";

  // Step B: Create empty output
  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Empty collection created";
  if (doPhaseShift) {
    
    edm::Handle<PEcalTBInfo> theEcalTBInfo;
    e.getByLabel(ecalTBInfoLabel,theEcalTBInfo);
    thisPhaseShift = theEcalTBInfo->phaseShift();

    DetId detIdHB(DetId::Hcal, 1);
    setPhaseShift(detIdHB);
    DetId detIdHO(DetId::Hcal, 3);
    setPhaseShift(detIdHO);
  }

  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
  theHBHEDigitizer->run(*col, *hbheResult);
  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HBHE digis : " << hbheResult->size();
  theHODigitizer->run(*col, *hoResult);
  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HO digis   : " << hoResult->size();

  // Step D: Put outputs into event
  e.put(hbheResult);
  e.put(hoResult);

}
void HcalTBDigiProducer::setPhaseShift ( const DetId detId) [private]
void HcalTBDigiProducer::sortHits ( const edm::PCaloHitContainer hits) [private]

fills the vectors for each subdetector

Definition at line 139 of file HcalTBDigiProducer.cc.

References HcalBarrel, HcalEndcap, HcalOuter, theHBHEHits, and theHOHits.

                                                                   {

  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
       hitItr != hits.end(); ++hitItr) {
    HcalSubdetector subdet = HcalDetId(hitItr->id()).subdet();
    if(subdet == HcalBarrel || subdet == HcalEndcap) {
      theHBHEHits.push_back(*hitItr);
    } else if(subdet == HcalOuter) {
      theHOHits.push_back(*hitItr);
    } else {
      edm::LogError("HcalSim") << "Bad HcalHit subdetector " << subdet;
    }
  }
}
void HcalTBDigiProducer::updateGeometry ( ) [private]

Definition at line 169 of file HcalTBDigiProducer.cc.

References CaloGeometry::getValidDetIds(), hbheCells, DetId::Hcal, HcalBarrel, HcalEndcap, HcalOuter, hoCells, LogDebug, CaloTDigitizer< Traits >::setDetIds(), CaloHitResponse::setGeometry(), theGeometry, theHBHEDigitizer, theHBHEResponse, theHODigitizer, and theHOResponse.

Referenced by checkGeometry().

                                        {

  theHBHEResponse->setGeometry(theGeometry);
  theHOResponse->setGeometry(theGeometry);

  // Get cells for HB and HE
  hbheCells.clear();
  hbheCells = theGeometry->getValidDetIds(DetId::Hcal, HcalBarrel);
  std::vector<DetId> heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
  // combine HB & HE
  hbheCells.insert(hbheCells.end(), heCells.begin(), heCells.end());

  // Get cells for HO
  hoCells.clear();
  hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter);

  edm::LogInfo("HcalSim") << "HcalTBDigiProducer update Geometry with "
                          << hbheCells.size() << " cells in HB/HE and "
                          << hoCells.size() << " cells in HO";

  theHBHEDigitizer->setDetIds(hbheCells);
  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HB/HE";
  theHODigitizer->setDetIds(hoCells);
  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HO";
}

Member Data Documentation

Definition at line 79 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), and produce().

std::string HcalTBDigiProducer::ecalTBInfoLabel [private]

Definition at line 76 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), and produce().

std::vector<DetId> HcalTBDigiProducer::hbheCells [private]

Definition at line 71 of file HcalTBDigiProducer.h.

Referenced by updateGeometry().

std::vector<DetId> HcalTBDigiProducer::hoCells [private]

Definition at line 72 of file HcalTBDigiProducer.h.

Referenced by updateGeometry().

Definition at line 58 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), produce(), and ~HcalTBDigiProducer().

Definition at line 59 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), produce(), and ~HcalTBDigiProducer().

Definition at line 60 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), and ~HcalTBDigiProducer().

Definition at line 70 of file HcalTBDigiProducer.h.

Referenced by checkGeometry(), and updateGeometry().

Definition at line 62 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer().

std::vector<PCaloHit> HcalTBDigiProducer::theHBHEHits [private]

Definition at line 74 of file HcalTBDigiProducer.h.

Referenced by produce(), and sortHits().

Definition at line 53 of file HcalTBDigiProducer.h.

Referenced by ~HcalTBDigiProducer().

Definition at line 52 of file HcalTBDigiProducer.h.

Referenced by ~HcalTBDigiProducer().

Definition at line 65 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), produce(), and ~HcalTBDigiProducer().

Definition at line 63 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer().

std::vector<PCaloHit> HcalTBDigiProducer::theHOHits [private]

Definition at line 74 of file HcalTBDigiProducer.h.

Referenced by produce(), and sortHits().

Definition at line 51 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), setPhaseShift(), and ~HcalTBDigiProducer().

Definition at line 77 of file HcalTBDigiProducer.h.

Referenced by produce(), and setPhaseShift().

Definition at line 80 of file HcalTBDigiProducer.h.

Referenced by HcalTBDigiProducer(), and setPhaseShift().