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