CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoLocalCalo/HcalRecProducers/src/ZdcHitReconstructor.cc

Go to the documentation of this file.
00001 using namespace std;
00002 #include "ZdcHitReconstructor.h"
00003 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00004 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00005 #include "DataFormats/Common/interface/EDCollection.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/Framework/interface/Selector.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00011 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00012 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00013 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00014 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00015 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00016 
00017 #include <iostream>
00018 
00019 /*  Zdc Hit reconstructor allows for CaloRecHits with status words */
00020 
00021 ZdcHitReconstructor::ZdcHitReconstructor(edm::ParameterSet const& conf):
00022   reco_(conf.getParameter<int>("firstSample"),
00023         conf.getParameter<int>("samplesToAdd"),
00024         conf.getParameter<bool>("correctForTimeslew"),
00025         conf.getParameter<bool>("correctForPhaseContainment"),
00026         conf.getParameter<double>("correctionPhaseNS"),
00027         conf.getParameter<int>("recoMethod")),
00028   det_(DetId::Hcal),
00029   inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00030   correctTiming_(conf.getParameter<bool>("correctTiming")),
00031   setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
00032   setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
00033   setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
00034   setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
00035   dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed"))
00036   
00037 {  std::string subd=conf.getParameter<std::string>("Subdetector");
00038  
00039  if (setSaturationFlags_)
00040     {
00041       const edm::ParameterSet& pssat      = conf.getParameter<edm::ParameterSet>("saturationParameters");
00042       saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
00043     }
00044 
00045   if (!strcasecmp(subd.c_str(),"ZDC")) {
00046     det_=DetId::Calo;
00047     subdet_=HcalZDCDetId::SubdetectorId;
00048     produces<ZDCRecHitCollection>();
00049   } else if (!strcasecmp(subd.c_str(),"CALIB")) {
00050     subdet_=HcalOther;
00051     subdetOther_=HcalCalibration;
00052     produces<HcalCalibRecHitCollection>();
00053   } else {
00054     std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
00055   }       
00056   
00057 }
00058 
00059 ZdcHitReconstructor::~ZdcHitReconstructor() {;
00060 }
00061 
00062 void ZdcHitReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00063 {
00064   // get conditions
00065   edm::ESHandle<HcalDbService> conditions;
00066   eventSetup.get<HcalDbRecord>().get(conditions);
00067   const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
00068   
00069   edm::ESHandle<HcalChannelQuality> p;
00070   eventSetup.get<HcalChannelQualityRcd>().get(p);
00071   HcalChannelQuality* myqual = new HcalChannelQuality(*p.product());
00072 
00073   edm::ESHandle<HcalSeverityLevelComputer> mycomputer;
00074   eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
00075   const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
00076   
00077    if (det_==DetId::Calo && subdet_==HcalZDCDetId::SubdetectorId) {
00078      edm::Handle<ZDCDigiCollection> digi;
00079      e.getByLabel(inputLabel_,digi);
00080      
00081      // create empty output
00082      std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00083      rec->reserve(digi->size());
00084      // run the algorithm
00085      ZDCDigiCollection::const_iterator i;
00086      for (i=digi->begin(); i!=digi->end(); i++) {
00087        HcalZDCDetId cell = i->id();
00088       DetId detcell=(DetId)cell;
00089       // check on cells to be ignored and dropped: (rof,20.Feb.09)
00090       const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
00091       if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
00092         if (dropZSmarkedPassed_)
00093           if (i->zsMarkAndPass()) continue;
00094         const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00095         const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00096         HcalCoderDb coder (*channelCoder, *shape);
00097         rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00098         (rec->back()).setFlags(0);
00099         if (setSaturationFlags_)
00100           saturationFlagSetter_->setSaturationFlag(rec->back(),*i);     
00101      }
00102      // return result
00103      e.put(rec);     
00104    } // else if (det_==DetId::Calo...)
00105 
00106    delete myqual;
00107 } // void HcalHitReconstructor::produce(...)