00001 #include "RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.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/EScales.h"
00006
00007
00008 const std::vector<double>&
00009 CaloTowersCreator::getGridValues()
00010 {
00011 static std::vector<double> retval;
00012
00013 if (retval.size() == 0)
00014 {
00015 retval.push_back(0.);
00016 retval.push_back(10.);
00017 retval.push_back(20.);
00018 retval.push_back(30.);
00019 retval.push_back(40.);
00020 retval.push_back(50.);
00021 retval.push_back(100.);
00022 retval.push_back(1000.);
00023 }
00024
00025 return retval;
00026 }
00027
00028
00029 CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) :
00030 algo_(conf.getParameter<double>("EBThreshold"),
00031 conf.getParameter<double>("EEThreshold"),
00032 conf.getParameter<double>("HcalThreshold"),
00033 conf.getParameter<double>("HBThreshold"),
00034 conf.getParameter<double>("HESThreshold"),
00035 conf.getParameter<double>("HEDThreshold"),
00036 conf.getParameter<double>("HOThreshold"),
00037 conf.getParameter<double>("HF1Threshold"),
00038 conf.getParameter<double>("HF2Threshold"),
00039 conf.getUntrackedParameter<std::vector<double> >("EBGrid",getGridValues() ),
00040 conf.getUntrackedParameter<std::vector<double> >("EBWeights",std::vector<double>(getGridValues().size(),1.) ),
00041 conf.getUntrackedParameter<std::vector<double> >("EEGrid",getGridValues() ),
00042 conf.getUntrackedParameter<std::vector<double> >("EEWeights",std::vector<double>(getGridValues().size(),1.) ),
00043 conf.getUntrackedParameter<std::vector<double> >("HBGrid",getGridValues() ),
00044 conf.getUntrackedParameter<std::vector<double> >("HBWeights",std::vector<double>(getGridValues().size(),1.) ),
00045 conf.getUntrackedParameter<std::vector<double> >("HESGrid",getGridValues() ),
00046 conf.getUntrackedParameter<std::vector<double> >("HESWeights",std::vector<double>(getGridValues().size(),1.) ),
00047 conf.getUntrackedParameter<std::vector<double> >("HEDGrid",getGridValues() ),
00048 conf.getUntrackedParameter<std::vector<double> >("HEDWeights",std::vector<double>(getGridValues().size(),1.) ),
00049 conf.getUntrackedParameter<std::vector<double> >("HOGrid",getGridValues() ),
00050 conf.getUntrackedParameter<std::vector<double> >("HOWeights",std::vector<double>(getGridValues().size(),1.) ),
00051 conf.getUntrackedParameter<std::vector<double> >("HF1Grid",getGridValues() ),
00052 conf.getUntrackedParameter<std::vector<double> >("HF1Weights",std::vector<double>(getGridValues().size(),1.) ),
00053 conf.getUntrackedParameter<std::vector<double> >("HF2Grid",getGridValues() ),
00054 conf.getUntrackedParameter<std::vector<double> >("HF2Weights",std::vector<double>(getGridValues().size(),1.) ),
00055 conf.getParameter<double>("EBWeight"),
00056 conf.getParameter<double>("EEWeight"),
00057 conf.getParameter<double>("HBWeight"),
00058 conf.getParameter<double>("HESWeight"),
00059 conf.getParameter<double>("HEDWeight"),
00060 conf.getParameter<double>("HOWeight"),
00061 conf.getParameter<double>("HF1Weight"),
00062 conf.getParameter<double>("HF2Weight"),
00063 conf.getParameter<double>("EcutTower"),
00064 conf.getParameter<double>("EBSumThreshold"),
00065 conf.getParameter<double>("EESumThreshold"),
00066 conf.getParameter<bool>("UseHO"),
00067
00068 conf.getParameter<int>("MomConstrMethod"),
00069 conf.getParameter<double>("MomEmDepth"),
00070 conf.getParameter<double>("MomHadDepth"),
00071 conf.getParameter<double>("MomTotDepth")
00072 ),
00073
00074 hbheLabel_(conf.getParameter<edm::InputTag>("hbheInput")),
00075 hoLabel_(conf.getParameter<edm::InputTag>("hoInput")),
00076 hfLabel_(conf.getParameter<edm::InputTag>("hfInput")),
00077 ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
00078 allowMissingInputs_(conf.getUntrackedParameter<bool>("AllowMissingInputs",false))
00079 {
00080 EBEScale=EScales.EBScale;
00081 EEEScale=EScales.EEScale;
00082 HBEScale=EScales.HBScale;
00083 HESEScale=EScales.HESScale;
00084 HEDEScale=EScales.HEDScale;
00085 HOEScale=EScales.HOScale;
00086 HF1EScale=EScales.HF1Scale;
00087 HF2EScale=EScales.HF2Scale;
00088 if (EScales.instanceLabel=="") produces<CaloTowerCollection>();
00089 else produces<CaloTowerCollection>(EScales.instanceLabel);
00090 }
00091
00092 void CaloTowersCreator::produce(edm::Event& e, const edm::EventSetup& c) {
00093
00094 edm::ESHandle<CaloGeometry> pG;
00095 edm::ESHandle<HcalTopology> htopo;
00096 edm::ESHandle<CaloTowerConstituentsMap> cttopo;
00097 c.get<CaloGeometryRecord>().get(pG);
00098 c.get<IdealGeometryRecord>().get(htopo);
00099 c.get<IdealGeometryRecord>().get(cttopo);
00100
00101 algo_.setEBEScale(EBEScale);
00102 algo_.setEEEScale(EEEScale);
00103 algo_.setHBEScale(HBEScale);
00104 algo_.setHESEScale(HESEScale);
00105 algo_.setHEDEScale(HEDEScale);
00106 algo_.setHOEScale(HOEScale);
00107 algo_.setHF1EScale(HF1EScale);
00108 algo_.setHF2EScale(HF2EScale);
00109 algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
00110
00111 algo_.begin();
00112
00113 bool present;
00114
00115
00116 edm::Handle<HBHERecHitCollection> hbhe;
00117 present=e.getByLabel(hbheLabel_,hbhe);
00118 if (present || !allowMissingInputs_) algo_.process(*hbhe);
00119
00120 edm::Handle<HORecHitCollection> ho;
00121 present=e.getByLabel(hoLabel_,ho);
00122 if (present || !allowMissingInputs_) algo_.process(*ho);
00123
00124 edm::Handle<HFRecHitCollection> hf;
00125 present=e.getByLabel(hfLabel_,hf);
00126 if (present || !allowMissingInputs_) algo_.process(*hf);
00127
00128 std::vector<edm::InputTag>::const_iterator i;
00129 for (i=ecalLabels_.begin(); i!=ecalLabels_.end(); i++) {
00130 edm::Handle<EcalRecHitCollection> ec;
00131 present=e.getByLabel(*i,ec);
00132 if (present || !allowMissingInputs_) algo_.process(*ec);
00133 }
00134
00135
00136 std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
00137
00138
00139 algo_.finish(*prod);
00140
00141
00142 if (EScales.instanceLabel=="") e.put(prod);
00143 else e.put(prod,EScales.instanceLabel);
00144 }
00145