Go to the documentation of this file.00001 #include "HcalSimpleReconstructor.h"
00002 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00003 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00004 #include "DataFormats/Common/interface/EDCollection.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00009 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00010 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00011 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00012 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00013
00014 #include <iostream>
00015
00016 HcalSimpleReconstructor::HcalSimpleReconstructor(edm::ParameterSet const& conf):
00017 reco_(conf.getParameter<bool>("correctForTimeslew"),
00018 conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
00019 det_(DetId::Hcal),
00020 inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00021 dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
00022 firstSample_(conf.getParameter<int>("firstSample")),
00023 samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
00024 tsFromDB_(conf.getParameter<bool>("tsFromDB")),
00025 paramTS(0),
00026 theTopology(0)
00027 {
00028
00029 std::string subd=conf.getParameter<std::string>("Subdetector");
00030 if (!strcasecmp(subd.c_str(),"HBHE")) {
00031 subdet_=HcalBarrel;
00032 produces<HBHERecHitCollection>();
00033 } else if (!strcasecmp(subd.c_str(),"HO")) {
00034 subdet_=HcalOuter;
00035 produces<HORecHitCollection>();
00036 } else if (!strcasecmp(subd.c_str(),"HF")) {
00037 subdet_=HcalForward;
00038 produces<HFRecHitCollection>();
00039 } else {
00040 std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
00041 }
00042
00043 }
00044
00045 HcalSimpleReconstructor::~HcalSimpleReconstructor() {
00046 delete paramTS;
00047 delete theTopology;
00048 }
00049
00050 void HcalSimpleReconstructor::beginRun(edm::Run&r, edm::EventSetup const & es){
00051 if(tsFromDB_) {
00052 edm::ESHandle<HcalRecoParams> p;
00053 es.get<HcalRecoParamsRcd>().get(p);
00054 paramTS = new HcalRecoParams(*p.product());
00055
00056 edm::ESHandle<HcalTopology> htopo;
00057 es.get<IdealGeometryRecord>().get(htopo);
00058 theTopology=new HcalTopology(*htopo);
00059 paramTS->setTopo(theTopology);
00060
00061 }
00062 reco_.beginRun(es);
00063 }
00064
00065 void HcalSimpleReconstructor::endRun(edm::Run&r, edm::EventSetup const & es){
00066 if(tsFromDB_ && paramTS) {
00067 delete paramTS;
00068 paramTS = 0;
00069 reco_.endRun();
00070 }
00071 }
00072
00073
00074 template<class DIGICOLL, class RECHITCOLL>
00075 void HcalSimpleReconstructor::process(edm::Event& e, const edm::EventSetup& eventSetup)
00076 {
00077
00078 edm::ESHandle<HcalDbService> conditions;
00079 eventSetup.get<HcalDbRecord>().get(conditions);
00080
00081
00082 if(e.isRealData()) reco_.setForData();
00083
00084 edm::Handle<DIGICOLL> digi;
00085
00086 e.getByLabel(inputLabel_,digi);
00087
00088
00089 std::auto_ptr<RECHITCOLL> rec(new RECHITCOLL);
00090 rec->reserve(digi->size());
00091
00092 int first = firstSample_;
00093 int toadd = samplesToAdd_;
00094 typename DIGICOLL::const_iterator i;
00095 for (i=digi->begin(); i!=digi->end(); i++) {
00096 HcalDetId cell = i->id();
00097 DetId detcell=(DetId)cell;
00098
00099 if (dropZSmarkedPassed_)
00100 if (i->zsMarkAndPass()) continue;
00101
00102 const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00103 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00104 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
00105 HcalCoderDb coder (*channelCoder, *shape);
00106
00107
00108 if(tsFromDB_) {
00109 const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
00110 first = param_ts->firstSample();
00111 toadd = param_ts->samplesToAdd();
00112 }
00113 rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
00114
00115 }
00116
00117 e.put(rec);
00118 }
00119
00120
00121 void HcalSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00122 {
00123
00124 if(e.isRealData()) reco_.setForData();
00125
00126
00127 if (det_==DetId::Hcal) {
00128 if (subdet_==HcalBarrel || subdet_==HcalEndcap) {
00129 process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup);
00130 } else if (subdet_==HcalForward) {
00131 process<HFDigiCollection, HFRecHitCollection>(e, eventSetup);
00132 } else if (subdet_==HcalOuter) {
00133 process<HODigiCollection, HORecHitCollection>(e, eventSetup);
00134 } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
00135 process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup);
00136 }
00137 }
00138 }