Go to the documentation of this file.00001 #include "ZdcHitReconstructor.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 "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00013 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00014 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00015
00016 #include <iostream>
00017
00018
00019
00020 ZdcHitReconstructor::ZdcHitReconstructor(edm::ParameterSet const& conf):
00021 reco_(conf.getParameter<bool>("correctForTimeslew"),
00022 conf.getParameter<bool>("correctForPhaseContainment"),
00023 conf.getParameter<double>("correctionPhaseNS"),
00024 conf.getParameter<int>("recoMethod"),
00025 conf.getParameter<int>("lowGainOffset"),
00026 conf.getParameter<double>("lowGainFrac")),
00027 det_(DetId::Hcal),
00028 inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00029 correctTiming_(conf.getParameter<bool>("correctTiming")),
00030 setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
00031 setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
00032 setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
00033 setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
00034 dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
00035 AuxTSvec_(conf.getParameter<std::vector<int> >("AuxTSvec")),
00036 myobject(0),
00037 theTopology(0)
00038
00039 {
00040 std::sort(AuxTSvec_.begin(),AuxTSvec_.end());
00041 std::string subd=conf.getParameter<std::string>("Subdetector");
00042
00043 if (setSaturationFlags_)
00044 {
00045 const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
00046 saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
00047 }
00048 if (!strcasecmp(subd.c_str(),"ZDC")) {
00049 det_=DetId::Calo;
00050 subdet_=HcalZDCDetId::SubdetectorId;
00051 produces<ZDCRecHitCollection>();
00052 } else if (!strcasecmp(subd.c_str(),"CALIB")) {
00053 subdet_=HcalOther;
00054 subdetOther_=HcalCalibration;
00055 produces<HcalCalibRecHitCollection>();
00056 } else {
00057 std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
00058 }
00059
00060 }
00061
00062 ZdcHitReconstructor::~ZdcHitReconstructor() {;
00063 }
00064 void ZdcHitReconstructor::beginRun(edm::Run const&r, edm::EventSetup const & es){
00065
00066 edm::ESHandle<HcalLongRecoParams> p;
00067 es.get<HcalLongRecoParamsRcd>().get(p);
00068 myobject = new HcalLongRecoParams(*p.product());
00069
00070 edm::ESHandle<HcalTopology> htopo;
00071 es.get<IdealGeometryRecord>().get(htopo);
00072 theTopology=new HcalTopology(*htopo);
00073 myobject->setTopo(theTopology);
00074
00075 }
00076
00077 void ZdcHitReconstructor::endRun(edm::Run const&r, edm::EventSetup const & es){
00078 delete myobject; myobject=0;
00079 delete theTopology; theTopology=0;
00080 }
00081 void ZdcHitReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00082 {
00083
00084 edm::ESHandle<HcalDbService> conditions;
00085 eventSetup.get<HcalDbRecord>().get(conditions);
00086
00087 edm::ESHandle<HcalChannelQuality> p;
00088 eventSetup.get<HcalChannelQualityRcd>().get(p);
00089 HcalChannelQuality* myqual = new HcalChannelQuality(*p.product());
00090
00091 edm::ESHandle<HcalSeverityLevelComputer> mycomputer;
00092 eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
00093 const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
00094
00095
00096 std::vector<unsigned int> mySignalTS;
00097 std::vector<unsigned int> myNoiseTS;
00098
00099 if (det_==DetId::Calo && subdet_==HcalZDCDetId::SubdetectorId) {
00100 edm::Handle<ZDCDigiCollection> digi;
00101 e.getByLabel(inputLabel_,digi);
00102
00103
00104 std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00105 rec->reserve(digi->size());
00106
00107 ZDCDigiCollection::const_iterator i;
00108 for (i=digi->begin(); i!=digi->end(); i++) {
00109 HcalZDCDetId cell = i->id();
00110 DetId detcell=(DetId)cell;
00111
00112 const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
00113 if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
00114 if (dropZSmarkedPassed_)
00115 if (i->zsMarkAndPass()) continue;
00116 const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00117 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00118 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
00119 HcalCoderDb coder (*channelCoder, *shape);
00120
00121
00122 const HcalLongRecoParam* myParams = myobject->getValues(detcell);
00123 mySignalTS.clear();
00124 myNoiseTS.clear();
00125 mySignalTS = myParams->signalTS();
00126 myNoiseTS = myParams->noiseTS();
00127
00128 rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
00129 (rec->back()).setFlags(0);
00130 if (setSaturationFlags_)
00131 saturationFlagSetter_->setSaturationFlag(rec->back(),*i);
00132
00133
00134
00135 int auxflag=0;
00136 for (unsigned int xx=0; xx<AuxTSvec_.size() && xx<4;++xx)
00137 {
00138 if (AuxTSvec_[xx]<0 || AuxTSvec_[xx]>9) continue;
00139 auxflag+=(i->sample(AuxTSvec_[xx]).adc())<<(7*xx);
00140 }
00141
00142 if (AuxTSvec_.size()>0)
00143 auxflag+=((i->sample(AuxTSvec_[0]).capid())<<28);
00144 (rec->back()).setAux(auxflag);
00145 }
00146
00147 e.put(rec);
00148 }
00149
00150 delete myqual;
00151 }