00001 #include "RecoLocalCalo/CaloTowersCreator/src/CaloTowersReCreator.h"
00002 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00003 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "RecoLocalCalo/CaloTowersCreator/interface/ctEScales.h"
00006
00007 CaloTowersReCreator::CaloTowersReCreator(const edm::ParameterSet& conf) :
00008 algo_(0.,0.,0.,0.,0.,0.,0.,0.,0.,
00009 conf.getUntrackedParameter<std::vector<double> >("EBGrid",std::vector<double>(10,0.)),
00010 conf.getUntrackedParameter<std::vector<double> >("EBWeights",std::vector<double>(10,0.)),
00011 conf.getUntrackedParameter<std::vector<double> >("EEGrid",std::vector<double>(10,0.)),
00012 conf.getUntrackedParameter<std::vector<double> >("EEWeights",std::vector<double>(10,0.)),
00013 conf.getUntrackedParameter<std::vector<double> >("HBGrid",std::vector<double>(10,0.)),
00014 conf.getUntrackedParameter<std::vector<double> >("HBWeights",std::vector<double>(10,0.)),
00015 conf.getUntrackedParameter<std::vector<double> >("HESGrid",std::vector<double>(10,0.)),
00016 conf.getUntrackedParameter<std::vector<double> >("HESWeights",std::vector<double>(10,0.)),
00017 conf.getUntrackedParameter<std::vector<double> >("HEDGrid",std::vector<double>(10,0.)),
00018 conf.getUntrackedParameter<std::vector<double> >("HEDWeights",std::vector<double>(10,0.)),
00019 conf.getUntrackedParameter<std::vector<double> >("HOGrid",std::vector<double>(10,0.)),
00020 conf.getUntrackedParameter<std::vector<double> >("HOWeights",std::vector<double>(10,0.)),
00021 conf.getUntrackedParameter<std::vector<double> >("HF1Grid",std::vector<double>(10,0.)),
00022 conf.getUntrackedParameter<std::vector<double> >("HF1Weights",std::vector<double>(10,0.)),
00023 conf.getUntrackedParameter<std::vector<double> >("HF2Grid",std::vector<double>(10,0.)),
00024 conf.getUntrackedParameter<std::vector<double> >("HF2Weights",std::vector<double>(10,0.)),
00025 conf.getParameter<double>("EBWeight"),
00026 conf.getParameter<double>("EEWeight"),
00027 conf.getParameter<double>("HBWeight"),
00028 conf.getParameter<double>("HESWeight"),
00029 conf.getParameter<double>("HEDWeight"),
00030 conf.getParameter<double>("HOWeight"),
00031 conf.getParameter<double>("HF1Weight"),
00032 conf.getParameter<double>("HF2Weight"),
00033 0.,0.,0.,
00034 conf.getParameter<bool>("UseHO"),
00035
00036 conf.getParameter<int>("MomConstrMethod"),
00037 conf.getParameter<double>("MomEmDepth"),
00038 conf.getParameter<double>("MomHadDepth"),
00039 conf.getParameter<double>("MomTotDepth")
00040 ),
00041 caloLabel_(conf.getParameter<edm::InputTag>("caloLabel")),
00042 allowMissingInputs_(false)
00043 {
00044 EBEScale=conf.getUntrackedParameter<double>("EBEScale",50.);
00045 EEEScale=conf.getUntrackedParameter<double>("EEEScale",50.);
00046 HBEScale=conf.getUntrackedParameter<double>("HBEScale",50.);
00047 HESEScale=conf.getUntrackedParameter<double>("HESEScale",50.);
00048 HEDEScale=conf.getUntrackedParameter<double>("HEDEScale",50.);
00049 HOEScale=conf.getUntrackedParameter<double>("HOEScale",50.);
00050 HF1EScale=conf.getUntrackedParameter<double>("HF1EScale",50.);
00051 HF2EScale=conf.getUntrackedParameter<double>("HF2EScale",50.);
00052 if (ctEScales.instanceLabel=="") produces<CaloTowerCollection>();
00053 else produces<CaloTowerCollection>(ctEScales.instanceLabel);
00054
00055
00056
00057 }
00058
00059 void CaloTowersReCreator::produce(edm::Event& e, const edm::EventSetup& c) {
00060
00061 edm::ESHandle<CaloGeometry> pG;
00062 edm::ESHandle<HcalTopology> htopo;
00063 edm::ESHandle<CaloTowerConstituentsMap> cttopo;
00064 c.get<CaloGeometryRecord>().get(pG);
00065 c.get<IdealGeometryRecord>().get(htopo);
00066 c.get<IdealGeometryRecord>().get(cttopo);
00067
00068 algo_.setEBEScale(EBEScale);
00069 algo_.setEEEScale(EEEScale);
00070 algo_.setHBEScale(HBEScale);
00071 algo_.setHESEScale(HESEScale);
00072 algo_.setHEDEScale(HEDEScale);
00073 algo_.setHOEScale(HOEScale);
00074 algo_.setHF1EScale(HF1EScale);
00075 algo_.setHF2EScale(HF2EScale);
00076 algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
00077
00078 algo_.begin();
00079
00080
00081 edm::Handle<CaloTowerCollection> calt;
00082 e.getByLabel(caloLabel_,calt);
00083
00084 if (!calt.isValid()) {
00085
00086 if (!allowMissingInputs_) {
00087 *calt;
00088 }
00089 } else {
00090 algo_.process(*calt);
00091 }
00092
00093
00094 std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
00095
00096
00097 algo_.finish(*prod);
00098
00099
00100 if (ctEScales.instanceLabel=="") e.put(prod);
00101 else e.put(prod,ctEScales.instanceLabel);
00102 }
00103