CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoLocalCalo/CaloTowersCreator/src/CaloTowersReCreator.cc

Go to the documentation of this file.
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., false, false, false, false, 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0., // thresholds cannot be reapplied
00009         conf.getParameter<std::vector<double> >("EBGrid"),
00010         conf.getParameter<std::vector<double> >("EBWeights"),
00011         conf.getParameter<std::vector<double> >("EEGrid"),
00012         conf.getParameter<std::vector<double> >("EEWeights"),
00013         conf.getParameter<std::vector<double> >("HBGrid"),
00014         conf.getParameter<std::vector<double> >("HBWeights"),
00015         conf.getParameter<std::vector<double> >("HESGrid"),
00016         conf.getParameter<std::vector<double> >("HESWeights"),
00017         conf.getParameter<std::vector<double> >("HEDGrid"),
00018         conf.getParameter<std::vector<double> >("HEDWeights"),
00019         conf.getParameter<std::vector<double> >("HOGrid"),
00020         conf.getParameter<std::vector<double> >("HOWeights"),
00021         conf.getParameter<std::vector<double> >("HF1Grid"),
00022         conf.getParameter<std::vector<double> >("HF1Weights"),
00023         conf.getParameter<std::vector<double> >("HF2Grid"),
00024         conf.getParameter<std::vector<double> >("HF2Weights"),
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         // (these have no effect on recreation: here for compatibility)
00036         conf.getParameter<int>("MomConstrMethod"),
00037         conf.getParameter<double>("MomHBDepth"),
00038         conf.getParameter<double>("MomHEDepth"),
00039         conf.getParameter<double>("MomEBDepth"),
00040         conf.getParameter<double>("MomEEDepth")
00041 
00042         ),
00043   caloLabel_(conf.getParameter<edm::InputTag>("caloLabel")),
00044   allowMissingInputs_(false)
00045 {
00046   EBEScale=conf.getParameter<double>("EBEScale");
00047   EEEScale=conf.getParameter<double>("EEEScale");
00048   HBEScale=conf.getParameter<double>("HBEScale");
00049   HESEScale=conf.getParameter<double>("HESEScale");
00050   HEDEScale=conf.getParameter<double>("HEDEScale");
00051   HOEScale=conf.getParameter<double>("HOEScale");
00052   HF1EScale=conf.getParameter<double>("HF1EScale");
00053   HF2EScale=conf.getParameter<double>("HF2EScale");
00054   if (ctEScales.instanceLabel=="") produces<CaloTowerCollection>();
00055   else produces<CaloTowerCollection>(ctEScales.instanceLabel);
00056   //  two notes:
00057   //  1) all this could go in a pset
00058   //  2) not clear the instanceLabel thing
00059 }
00060 
00061 void CaloTowersReCreator::produce(edm::Event& e, const edm::EventSetup& c) {
00062   // get the necessary event setup objects...
00063   edm::ESHandle<CaloGeometry> pG;
00064   edm::ESHandle<HcalTopology> htopo;
00065   edm::ESHandle<CaloTowerConstituentsMap> cttopo;
00066   c.get<CaloGeometryRecord>().get(pG);
00067   c.get<IdealGeometryRecord>().get(htopo);
00068   c.get<IdealGeometryRecord>().get(cttopo);
00069  
00070   algo_.setEBEScale(EBEScale);
00071   algo_.setEEEScale(EEEScale);
00072   algo_.setHBEScale(HBEScale);
00073   algo_.setHESEScale(HESEScale);
00074   algo_.setHEDEScale(HEDEScale);
00075   algo_.setHOEScale(HOEScale);
00076   algo_.setHF1EScale(HF1EScale);
00077   algo_.setHF2EScale(HF2EScale);
00078   algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
00079 
00080   algo_.begin(); // clear the internal buffer
00081   
00082   // Step A/C: Get Inputs and process (repeatedly)
00083   edm::Handle<CaloTowerCollection> calt;
00084   e.getByLabel(caloLabel_,calt);
00085 
00086 /*
00087   if (!calt.isValid()) {
00088     // can't find it!
00089     if (!allowMissingInputs_) {
00090       *calt;  // will throw the proper exception
00091     }
00092   } else {
00093     algo_.process(*calt);
00094   }
00095 
00096   // Step B: Create empty output
00097   std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
00098 
00099   // Step C: Process
00100   algo_.finish(*prod);
00101 
00102   // Step D: Put into the event
00103   if (ctEScales.instanceLabel=="") e.put(prod);
00104   else e.put(prod,ctEScales.instanceLabel);
00105 */
00106 
00107   // modified to rescale the CaloTowers directly
00108   // without going through metatowers
00109   // required for the algorithms that make use of individual
00110   // crystal information
00111 
00112   if (!calt.isValid()) {
00113     // can't find it!
00114     if (!allowMissingInputs_) {
00115       *calt;  // will throw the proper exception
00116     }
00117   } else {
00118     // Step B: Create empty output
00119     std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
00120 
00121     // step C: rescale (without going threough metataowers)
00122     algo_.rescaleTowers(*calt, *prod);
00123 
00124     // Step D: Put into the event
00125     if (ctEScales.instanceLabel=="") e.put(prod);
00126     else e.put(prod,ctEScales.instanceLabel);
00127   }
00128 
00129 }
00130