CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoLocalCalo/HcalRecProducers/src/HcalSimpleReconstructor.cc

Go to the documentation of this file.
00001 using namespace std;
00002 #include "HcalSimpleReconstructor.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 HcalSimpleReconstructor::HcalSimpleReconstructor(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   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(),"HBHE")) {
00027     subdet_=HcalBarrel;
00028     produces<HBHERecHitCollection>();
00029   } else if (!strcasecmp(subd.c_str(),"HO")) {
00030     subdet_=HcalOuter;
00031     produces<HORecHitCollection>();
00032   } else if (!strcasecmp(subd.c_str(),"HF")) {
00033     subdet_=HcalForward;
00034     produces<HFRecHitCollection>();
00035   } else {
00036     std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
00037   }       
00038   
00039 }
00040 
00041 HcalSimpleReconstructor::~HcalSimpleReconstructor() {
00042 }
00043 
00044 void HcalSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00045 {
00046   // get conditions
00047   edm::ESHandle<HcalDbService> conditions;
00048   eventSetup.get<HcalDbRecord>().get(conditions);
00049   const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
00050   
00051   
00052   if (det_==DetId::Hcal) {
00053     if (subdet_==HcalBarrel || subdet_==HcalEndcap) {
00054       edm::Handle<HBHEDigiCollection> digi;
00055       
00056       e.getByLabel(inputLabel_,digi);
00057       
00058       // create empty output
00059       std::auto_ptr<HBHERecHitCollection> rec(new HBHERecHitCollection);
00060       rec->reserve(digi->size());
00061       // run the algorithm
00062       HBHEDigiCollection::const_iterator i;
00063       for (i=digi->begin(); i!=digi->end(); i++) {
00064         HcalDetId cell = i->id();
00065         // rof 27.03.09: drop ZS marked and passed digis:
00066         if (dropZSmarkedPassed_)
00067           if (i->zsMarkAndPass()) continue;
00068 
00069         const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00070         const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00071         HcalCoderDb coder (*channelCoder, *shape);
00072         rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00073       }
00074       // return result
00075       e.put(rec);
00076     } else if (subdet_==HcalOuter) {
00077       edm::Handle<HODigiCollection> digi;
00078       e.getByLabel(inputLabel_,digi);
00079       
00080       // create empty output
00081       std::auto_ptr<HORecHitCollection> rec(new HORecHitCollection);
00082       rec->reserve(digi->size());
00083       // run the algorithm
00084       HODigiCollection::const_iterator i;
00085       for (i=digi->begin(); i!=digi->end(); i++) {
00086         HcalDetId cell = i->id();
00087         // rof 27.03.09: drop ZS marked and passed digis:
00088         if (dropZSmarkedPassed_)
00089           if (i->zsMarkAndPass()) continue;
00090 
00091         const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00092         const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00093         HcalCoderDb coder (*channelCoder, *shape);
00094         rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00095       }
00096       // return result
00097       e.put(rec);    
00098     } else if (subdet_==HcalForward) {
00099       edm::Handle<HFDigiCollection> digi;
00100       e.getByLabel(inputLabel_,digi);
00101       
00102       // create empty output
00103       std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
00104       rec->reserve(digi->size());
00105       // run the algorithm
00106       HFDigiCollection::const_iterator i;
00107       for (i=digi->begin(); i!=digi->end(); i++) {
00108         HcalDetId cell = i->id();        
00109         // rof 27.03.09: drop ZS marked and passed digis:
00110         if (dropZSmarkedPassed_)
00111           if (i->zsMarkAndPass()) continue;
00112  
00113         const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00114         const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00115         HcalCoderDb coder (*channelCoder, *shape);
00116         rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00117       }
00118       // return result
00119       e.put(rec);     
00120     } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
00121       edm::Handle<HcalCalibDigiCollection> digi;
00122       e.getByLabel(inputLabel_,digi);
00123       
00124       // create empty output
00125       std::auto_ptr<HcalCalibRecHitCollection> rec(new HcalCalibRecHitCollection);
00126       rec->reserve(digi->size());
00127       // run the algorithm
00128       HcalCalibDigiCollection::const_iterator i;
00129       for (i=digi->begin(); i!=digi->end(); i++) {
00130         HcalCalibDetId cell = i->id();    
00131         // rof 27.03.09: drop ZS marked and passed digis:
00132         if (dropZSmarkedPassed_)
00133           if (i->zsMarkAndPass()) continue;
00134 
00135         const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00136         const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00137         HcalCoderDb coder (*channelCoder, *shape);
00138         rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00139       }
00140       // return result
00141       e.put(rec);     
00142     }
00143   } 
00144 }