Go to the documentation of this file.00001 using namespace std;
00002 #include "ZdcSimpleReconstructor.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
00015 #include <iostream>
00016
00017
00018 ZdcSimpleReconstructor::ZdcSimpleReconstructor(edm::ParameterSet const& conf):
00019 reco_(conf.getParameter<int>("firstSample"),conf.getParameter<int>("samplesToAdd"),conf.getParameter<bool>("correctForTimeslew"),
00020 conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS"),
00021 conf.getParameter<int>("recoMethod")),
00022 det_(DetId::Hcal),
00023 inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00024 dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed"))
00025 {
00026 std::string subd=conf.getParameter<std::string>("Subdetector");
00027 if (!strcasecmp(subd.c_str(),"ZDC")) {
00028 det_=DetId::Calo;
00029 subdet_=HcalZDCDetId::SubdetectorId;
00030 produces<ZDCRecHitCollection>();
00031 } else if (!strcasecmp(subd.c_str(),"CALIB")) {
00032 subdet_=HcalOther;
00033 subdetOther_=HcalCalibration;
00034 produces<HcalCalibRecHitCollection>();
00035 } else {
00036 std::cout << "ZdcSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
00037 }
00038
00039 }
00040
00041 ZdcSimpleReconstructor::~ZdcSimpleReconstructor() {
00042 }
00043
00044 void ZdcSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00045 {
00046
00047 edm::ESHandle<HcalDbService> conditions;
00048 eventSetup.get<HcalDbRecord>().get(conditions);
00049 const HcalQIEShape* shape = conditions->getHcalShape ();
00050
00051 if (det_==DetId::Calo && subdet_==HcalZDCDetId::SubdetectorId) {
00052 edm::Handle<ZDCDigiCollection> digi;
00053 e.getByLabel(inputLabel_,digi);
00054
00055
00056 std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00057 rec->reserve(digi->size());
00058
00059 ZDCDigiCollection::const_iterator i;
00060 for (i=digi->begin(); i!=digi->end(); i++) {
00061 HcalZDCDetId cell = i->id();
00062
00063 if (dropZSmarkedPassed_)
00064 if (i->zsMarkAndPass()) continue;
00065
00066 const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00067 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00068 HcalCoderDb coder (*channelCoder, *shape);
00069 rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00070 }
00071
00072 e.put(rec);
00073 }
00074 }