CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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         conf.getParameter<int>("lowGainOffset"),
00022         conf.getParameter<double>("lowGainFrac")),
00023   det_(DetId::Hcal),
00024   inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00025   dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed"))
00026 {
00027   std::string subd=conf.getParameter<std::string>("Subdetector");
00028   if (!strcasecmp(subd.c_str(),"ZDC")) {
00029     det_=DetId::Calo;
00030     subdet_=HcalZDCDetId::SubdetectorId;
00031     produces<ZDCRecHitCollection>();
00032   } else if (!strcasecmp(subd.c_str(),"CALIB")) {
00033     subdet_=HcalOther;
00034     subdetOther_=HcalCalibration;
00035     produces<HcalCalibRecHitCollection>();
00036   } else {
00037     std::cout << "ZdcSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
00038   }       
00039   
00040 }
00041 
00042 ZdcSimpleReconstructor::~ZdcSimpleReconstructor() {
00043 }
00044 void ZdcSimpleReconstructor::beginRun(edm::Run&r, edm::EventSetup const & es){
00045 
00046    edm::ESHandle<HcalLongRecoParams> p;
00047    es.get<HcalLongRecoParamsRcd>().get(p);
00048    myobject = new HcalLongRecoParams(*p.product());
00049 }
00050 
00051 void ZdcSimpleReconstructor::endRun(edm::Run&r, edm::EventSetup const & es){
00052   if (myobject) delete myobject;
00053 }
00054 void ZdcSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00055 {
00056   // get conditions
00057   edm::ESHandle<HcalDbService> conditions;
00058   eventSetup.get<HcalDbRecord>().get(conditions);
00059   const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
00060   // define vectors to pass noiseTS and signalTS
00061   std::vector<unsigned int> mySignalTS;
00062   std::vector<unsigned int> myNoiseTS;
00063   
00064   if (det_==DetId::Calo && subdet_==HcalZDCDetId::SubdetectorId) {
00065     edm::Handle<ZDCDigiCollection> digi;
00066     e.getByLabel(inputLabel_,digi);
00067     
00068     // create empty output
00069     std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00070     rec->reserve(digi->size());
00071     // run the algorithm
00072     unsigned int toaddMem = 0;
00073     
00074     ZDCDigiCollection::const_iterator i;
00075     for (i=digi->begin(); i!=digi->end(); i++) {
00076       HcalZDCDetId cell = i->id();        
00077       DetId detcell=(DetId)cell;
00078         // rof 27.03.09: drop ZS marked and passed digis:
00079         if (dropZSmarkedPassed_)
00080           if (i->zsMarkAndPass()) continue;
00081 
00082 // get db values for signalTSs and noiseTSs
00083       const HcalLongRecoParam* myParams = myobject->getValues(detcell);
00084       mySignalTS.clear();
00085       myNoiseTS.clear();
00086       mySignalTS = myParams->signalTS();
00087       myNoiseTS = myParams->noiseTS(); 
00088 // warning: the PulseCorrection is not used by ZDC. If it gets a non-contingious set of 
00089 // signal TS, it may not work properly. Assume contiguous here....
00090         unsigned int toadd = mySignalTS.size();    
00091         if(toaddMem != toadd) {
00092           reco_.initPulseCorr(toadd);
00093           toaddMem = toadd;
00094         }   
00095       const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00096       const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00097       HcalCoderDb coder (*channelCoder, *shape);
00098       rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
00099     }
00100     // return result
00101     e.put(rec);     
00102   }
00103 }