Go to the documentation of this file.00001 #include "ZdcSimpleReconstructor.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
00013 #include <iostream>
00014
00015
00016 ZdcSimpleReconstructor::ZdcSimpleReconstructor(edm::ParameterSet const& conf):
00017 reco_(conf.getParameter<bool>("correctForTimeslew"),
00018 conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS"),
00019 conf.getParameter<int>("recoMethod"),
00020 conf.getParameter<int>("lowGainOffset"),
00021 conf.getParameter<double>("lowGainFrac")),
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 void ZdcSimpleReconstructor::beginRun(edm::Run const&r, edm::EventSetup const & es){
00044
00045 edm::ESHandle<HcalLongRecoParams> p;
00046 es.get<HcalLongRecoParamsRcd>().get(p);
00047 myobject = new HcalLongRecoParams(*p.product());
00048 }
00049
00050 void ZdcSimpleReconstructor::endRun(edm::Run const&r, edm::EventSetup const & es){
00051 delete myobject; myobject = 0;
00052 }
00053 void ZdcSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00054 {
00055
00056 edm::ESHandle<HcalDbService> conditions;
00057 eventSetup.get<HcalDbRecord>().get(conditions);
00058
00059 std::vector<unsigned int> mySignalTS;
00060 std::vector<unsigned int> myNoiseTS;
00061
00062 if (det_==DetId::Calo && subdet_==HcalZDCDetId::SubdetectorId) {
00063 edm::Handle<ZDCDigiCollection> digi;
00064 e.getByLabel(inputLabel_,digi);
00065
00066
00067 std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00068 rec->reserve(digi->size());
00069
00070 unsigned int toaddMem = 0;
00071
00072 ZDCDigiCollection::const_iterator i;
00073 for (i=digi->begin(); i!=digi->end(); i++) {
00074 HcalZDCDetId cell = i->id();
00075 DetId detcell=(DetId)cell;
00076
00077 if (dropZSmarkedPassed_)
00078 if (i->zsMarkAndPass()) continue;
00079
00080
00081 const HcalLongRecoParam* myParams = myobject->getValues(detcell);
00082 mySignalTS.clear();
00083 myNoiseTS.clear();
00084 mySignalTS = myParams->signalTS();
00085 myNoiseTS = myParams->noiseTS();
00086
00087
00088 unsigned int toadd = mySignalTS.size();
00089 if(toaddMem != toadd) {
00090 reco_.initPulseCorr(toadd);
00091 toaddMem = toadd;
00092 }
00093 const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00094 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00095 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
00096 HcalCoderDb coder (*channelCoder, *shape);
00097 rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
00098 }
00099
00100 e.put(rec);
00101 }
00102 }