CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoLocalCalo/HcalRecProducers/src/ZdcSimpleReconstructor.cc

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/Selector.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00010 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00011 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00012 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00013 
00014 #include <iostream>
00015 
00016     
00017 ZdcSimpleReconstructor::ZdcSimpleReconstructor(edm::ParameterSet const& conf):
00018   reco_(conf.getParameter<bool>("correctForTimeslew"),
00019         conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS"),
00020         conf.getParameter<int>("recoMethod")),
00021   det_(DetId::Hcal),
00022   inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00023   dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed"))
00024 {
00025   std::string subd=conf.getParameter<std::string>("Subdetector");
00026   if (!strcasecmp(subd.c_str(),"ZDC")) {
00027     det_=DetId::Calo;
00028     subdet_=HcalZDCDetId::SubdetectorId;
00029     produces<ZDCRecHitCollection>();
00030   } else if (!strcasecmp(subd.c_str(),"CALIB")) {
00031     subdet_=HcalOther;
00032     subdetOther_=HcalCalibration;
00033     produces<HcalCalibRecHitCollection>();
00034   } else {
00035     std::cout << "ZdcSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
00036   }       
00037   
00038 }
00039 
00040 ZdcSimpleReconstructor::~ZdcSimpleReconstructor() {
00041 }
00042 void ZdcSimpleReconstructor::beginRun(edm::Run&r, edm::EventSetup const & es){
00043 
00044    edm::ESHandle<HcalLongRecoParams> p;
00045    es.get<HcalLongRecoParamsRcd>().get(p);
00046    myobject = new HcalLongRecoParams(*p.product());
00047 }
00048 
00049 void ZdcSimpleReconstructor::endRun(edm::Run&r, edm::EventSetup const & es){
00050   if (myobject) delete myobject;
00051 }
00052 void ZdcSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00053 {
00054   // get conditions
00055   edm::ESHandle<HcalDbService> conditions;
00056   eventSetup.get<HcalDbRecord>().get(conditions);
00057   const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
00058   // define vectors to pass noiseTS and signalTS
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     // create empty output
00067     std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00068     rec->reserve(digi->size());
00069     // run the algorithm
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         // rof 27.03.09: drop ZS marked and passed digis:
00077         if (dropZSmarkedPassed_)
00078           if (i->zsMarkAndPass()) continue;
00079 
00080 // get db values for signalTSs and noiseTSs
00081       const HcalLongRecoParam* myParams = myobject->getValues(detcell);
00082       mySignalTS.clear();
00083       myNoiseTS.clear();
00084       mySignalTS = myParams->signalTS();
00085       myNoiseTS = myParams->noiseTS(); 
00086 // warning: the PulseCorrection is not used by ZDC. If it gets a non-contingious set of 
00087 // signal TS, it may not work properly. Assume contiguous here....
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       HcalCoderDb coder (*channelCoder, *shape);
00096       rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
00097     }
00098     // return result
00099     e.put(rec);     
00100   }
00101 }