CMS 3D CMS Logo

Public Member Functions | Private Attributes

CastorSimpleReconstructor Class Reference

#include <CastorSimpleReconstructor.h>

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

List of all members.

Public Member Functions

virtual void beginRun (edm::Run &r, edm::EventSetup const &es)
 CastorSimpleReconstructor (const edm::ParameterSet &ps)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~CastorSimpleReconstructor ()

Private Attributes

DetId::Detector det_
int firstSample_
edm::InputTag inputLabel_
CastorRecoParamsparamTS_
CastorSimpleRecAlgo reco_
int samplesToAdd_
int subdet_
bool tsFromDB_

Detailed Description

Definition at line 14 of file CastorSimpleReconstructor.h.


Constructor & Destructor Documentation

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

Definition at line 24 of file CastorSimpleReconstructor.cc.

References DetId::Calo, det_, edm::ParameterSet::getParameter(), subdet_, and HcalCastorDetId::SubdetectorId.

                                                                               :
  reco_(conf.getParameter<int>("firstSample"),conf.getParameter<int>("samplesToAdd"),conf.getParameter<bool>("correctForTimeslew"),
        conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
  det_(DetId::Hcal),
  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
  firstSample_(conf.getParameter<int>("firstSample")),
  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
  tsFromDB_(conf.getUntrackedParameter<bool>("tsFromDB",true))
{
  std::string subd=conf.getParameter<std::string>("Subdetector");
  if (!strcasecmp(subd.c_str(),"CASTOR")) {
    det_=DetId::Calo;
    subdet_=HcalCastorDetId::SubdetectorId;
    produces<CastorRecHitCollection>();
  } else {
    edm::LogWarning("CastorSimpleReconstructor") << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
  }       
  
}
CastorSimpleReconstructor::~CastorSimpleReconstructor ( ) [virtual]

Definition at line 44 of file CastorSimpleReconstructor.cc.

                                                      {
}

Member Function Documentation

void CastorSimpleReconstructor::beginRun ( edm::Run r,
edm::EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 47 of file CastorSimpleReconstructor.cc.

References edm::EventSetup::get(), edm::ESHandleBase::isValid(), AlCaHLTBitMon_ParallelJobs::p, paramTS_, edm::ESHandle< T >::product(), and tsFromDB_.

                                                                          {

  if (tsFromDB_) {
        edm::ESHandle<CastorRecoParams> p;
        es.get<CastorRecoParamsRcd>().get(p);
        if (!p.isValid()) { 
                tsFromDB_ = false;
                edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorRecoParamsRcd correctly, using parameters from cfg file. These parameters could be wrong for this run... please check" << std::endl;
        } else {
                paramTS_ = new CastorRecoParams(*p.product());
        }
  }
  
}
void CastorSimpleReconstructor::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 61 of file CastorSimpleReconstructor.cc.

References DetId::Calo, det_, CastorRecoParam::firstSample(), edm::EventSetup::get(), CastorCondObjectContainer< Item >::getAllChannels(), edm::Event::getByLabel(), CastorChannelStatus::getValue(), CastorCondObjectContainer< Item >::getValues(), i, inputLabel_, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, paramTS_, edm::ESHandle< T >::product(), edm::Event::put(), DetId::rawId(), reco_, CastorSimpleRecAlgo::reconstruct(), CastorSimpleRecAlgo::resetTimeSamples(), CastorRecoParam::samplesToAdd(), subdet_, HcalCastorDetId::SubdetectorId, and tsFromDB_.

{
  // get conditions
  edm::ESHandle<CastorDbService> conditions;
  eventSetup.get<CastorDbRecord>().get(conditions);
  const CastorQIEShape* shape = conditions->getCastorShape (); // this one is generic
  
  CastorCalibrations calibrations;
  
   edm::ESHandle<CastorChannelQuality> p;
   eventSetup.get<CastorChannelQualityRcd>().get(p);
   CastorChannelQuality* myqual = new CastorChannelQuality(*p.product());
  
  
//  if (det_==DetId::Hcal) {
     if (det_==DetId::Calo && subdet_==HcalCastorDetId::SubdetectorId) {
    edm::Handle<CastorDigiCollection> digi;
    e.getByLabel(inputLabel_,digi);
    
    // create empty output
    std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
    // run the algorithm
    CastorDigiCollection::const_iterator i;
    for (i=digi->begin(); i!=digi->end(); i++) {
      HcalCastorDetId cell = i->id();
      DetId detcell=(DetId)cell;          
 const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);

        // now check the channelquality of this rechit
        bool ok = true;
        std::vector<DetId> channels = myqual->getAllChannels();
        for (std::vector<DetId>::iterator channel = channels.begin();channel !=  channels.end();channel++) {    
                if (channel->rawId() == detcell.rawId()) {
                        const CastorChannelStatus* mydigistatus=myqual->getValues(*channel);
                        if (mydigistatus->getValue() == 2989) ok = false; // 2989 = BAD
                }
        }

//conditions->makeCastorCalibration (cell, &calibrations);
      
      if (tsFromDB_) {
          const CastorRecoParam* param_ts = paramTS_->getValues(detcell.rawId());
          reco_.resetTimeSamples(param_ts->firstSample(),param_ts->samplesToAdd());
          //std::cout << "using CastorRecoParam from DB, reco_ parameters are reset to: firstSample_ = " << param_ts->firstSample() << " samplesToAdd_ = " << 
          //param_ts->samplesToAdd() << std::endl;
      }          
      const CastorQIECoder* channelCoder = conditions->getCastorCoder (cell);
      CastorCoderDb coder (*channelCoder, *shape);
      if (ok) rec->push_back(reco_.reconstruct(*i,coder,calibrations));
    }
    // return result
    e.put(rec);     
//     }
  }
}

Member Data Documentation

Definition at line 22 of file CastorSimpleReconstructor.h.

Referenced by CastorSimpleReconstructor(), and produce().

Definition at line 27 of file CastorSimpleReconstructor.h.

Definition at line 25 of file CastorSimpleReconstructor.h.

Referenced by produce().

Definition at line 30 of file CastorSimpleReconstructor.h.

Referenced by beginRun(), and produce().

Definition at line 21 of file CastorSimpleReconstructor.h.

Referenced by produce().

Definition at line 28 of file CastorSimpleReconstructor.h.

Definition at line 23 of file CastorSimpleReconstructor.h.

Referenced by CastorSimpleReconstructor(), and produce().

Definition at line 29 of file CastorSimpleReconstructor.h.

Referenced by beginRun(), and produce().