Go to the documentation of this file.00001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalShapes.h"
00002 #include "FWCore/Framework/interface/ESHandle.h"
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "SimCalorimetry/CaloSimAlgos/interface/CaloCachedShapeIntegrator.h"
00005 #include "CondFormats/HcalObjects/interface/HcalMCParam.h"
00006 #include "CondFormats/HcalObjects/interface/HcalMCParams.h"
00007 #include "CondFormats/DataRecord/interface/HcalMCParamsRcd.h"
00008 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010
00011 HcalShapes::HcalShapes()
00012 : theMCParams(0),
00013 theShapes(),
00014 theZDCShape(),
00015 theHcalShape101(),
00016 theHcalShape102(),
00017 theHcalShape103(),
00018 theHcalShape104(),
00019 theHcalShape105(),
00020 theHcalShape123(),
00021 theHcalShape124(),
00022 theHcalShape125(),
00023 theHcalShape201(),
00024 theHcalShape202(),
00025 theHcalShape301(),
00026 theHcalShape401()
00027 {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 theHcalShape101.setShape(101);
00047 theShapes[101] = new CaloCachedShapeIntegrator(&theHcalShape101);
00048 theHcalShape102.setShape(102);
00049 theShapes[102] = new CaloCachedShapeIntegrator(&theHcalShape102);
00050 theHcalShape103.setShape(103);
00051 theShapes[103] = new CaloCachedShapeIntegrator(&theHcalShape103);
00052 theHcalShape104.setShape(104);
00053 theShapes[104] = new CaloCachedShapeIntegrator(&theHcalShape104);
00054 theHcalShape104.setShape(105);
00055 theShapes[105] = new CaloCachedShapeIntegrator(&theHcalShape105);
00056 theHcalShape123.setShape(123);
00057 theShapes[123] = new CaloCachedShapeIntegrator(&theHcalShape123);
00058 theHcalShape124.setShape(124);
00059 theShapes[124] = new CaloCachedShapeIntegrator(&theHcalShape124);
00060 theHcalShape125.setShape(125);
00061 theShapes[125] = new CaloCachedShapeIntegrator(&theHcalShape125);
00062 theHcalShape201.setShape(201);
00063 theShapes[201] = new CaloCachedShapeIntegrator(&theHcalShape201);
00064 theHcalShape202.setShape(202);
00065 theShapes[202] = new CaloCachedShapeIntegrator(&theHcalShape202);
00066 theHcalShape301.setShape(301);
00067 theShapes[301] = new CaloCachedShapeIntegrator(&theHcalShape301);
00068
00069
00070
00071 theShapes[ZDC] = new CaloCachedShapeIntegrator(&theZDCShape);
00072
00073
00074
00075
00076
00077 theShapes[0] = theShapes[HPD];
00078
00079 theShapes[1] = theShapes[LONG];
00080 theShapes[2] = theShapes[ZECOTEK];
00081 theShapes[3] = theShapes[HF];
00082 theShapes[4] = theShapes[ZDC];
00083
00084 }
00085
00086
00087 HcalShapes::~HcalShapes()
00088 {
00089 for(ShapeMap::const_iterator shapeItr = theShapes.begin();
00090 shapeItr != theShapes.end(); ++shapeItr)
00091 {
00092 delete shapeItr->second;
00093 }
00094 theShapes.clear();
00095 delete theMCParams;
00096 }
00097
00098
00099 void HcalShapes::beginRun(edm::EventSetup const & es)
00100 {
00101 edm::ESHandle<HcalMCParams> p;
00102 es.get<HcalMCParamsRcd>().get(p);
00103 theMCParams = new HcalMCParams(*p.product());
00104 }
00105
00106
00107 void HcalShapes::endRun()
00108 {
00109 delete theMCParams;
00110 theMCParams = 0;
00111 }
00112
00113
00114 const CaloVShape * HcalShapes::shape(const DetId & detId) const
00115 {
00116 if(!theMCParams) {
00117 return defaultShape(detId);
00118 }
00119 int shapeType = theMCParams->getValues(detId)->signalShape();
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 ShapeMap::const_iterator shapeMapItr = theShapes.find(shapeType);
00134 if(shapeMapItr == theShapes.end()) {
00135 edm::LogWarning("HcalShapes") << "HcalShapes::shape - shapeType ? = "
00136 << shapeType << std::endl;
00137 return defaultShape(detId);
00138 } else {
00139 return shapeMapItr->second;
00140 }
00141 }
00142
00143 const CaloVShape * HcalShapes::defaultShape(const DetId & detId) const
00144 {
00145
00146 const CaloVShape * result;
00147 HcalGenericDetId::HcalGenericSubdetector subdet
00148 = HcalGenericDetId(detId).genericSubdet();
00149 if(subdet == HcalGenericDetId::HcalGenBarrel
00150 || subdet == HcalGenericDetId::HcalGenEndcap) result = theShapes.find(0)->second;
00151 else if(subdet == HcalGenericDetId::HcalGenOuter) result = theShapes.find(2)->second;
00152 else if(subdet == HcalGenericDetId::HcalGenForward) result = theShapes.find(3)->second;
00153 else if(subdet == HcalGenericDetId::HcalGenZDC) result = theShapes.find(3)->second;
00154 else result = 0;
00155
00156 edm::LogWarning("HcalShapes") << "Cannot find HCAL MC Params, so the defalut one is taken for subdet " << subdet;
00157
00158 return result;
00159 }