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(5), 00014 theHcalShape(), 00015 theHFShape(), 00016 theZDCShape(), 00017 theSiPMShape() 00018 { 00019 theShapes[0] = new CaloCachedShapeIntegrator(&theHcalShape); 00020 theShapes[1] = new CaloCachedShapeIntegrator(&theHcalShape); 00021 theShapes[2] = new CaloCachedShapeIntegrator(&theSiPMShape); 00022 theShapes[3] = new CaloCachedShapeIntegrator(&theHFShape); 00023 theShapes[4] = new CaloCachedShapeIntegrator(&theZDCShape); 00024 } 00025 00026 00027 HcalShapes::~HcalShapes() 00028 { 00029 for(std::vector<const CaloVShape *>::const_iterator shapeItr = theShapes.begin(); 00030 shapeItr != theShapes.end(); ++shapeItr) 00031 { 00032 delete *shapeItr; 00033 } 00034 theShapes.clear(); 00035 delete theMCParams; 00036 } 00037 00038 00039 void HcalShapes::beginRun(edm::EventSetup const & es) 00040 { 00041 edm::ESHandle<HcalMCParams> p; 00042 es.get<HcalMCParamsRcd>().get(p); 00043 theMCParams = new HcalMCParams(*p.product()); 00044 } 00045 00046 00047 void HcalShapes::endRun() 00048 { 00049 delete theMCParams; 00050 theMCParams = 0; 00051 } 00052 00053 00054 const CaloVShape * HcalShapes::shape(const DetId & detId) const 00055 { 00056 if(!theMCParams) { 00057 edm::LogWarning("HcalShapes") << "Cannot find HCAL MC Params "; 00058 // try to figure the appropriate shape 00059 HcalGenericDetId::HcalGenericSubdetector subdet = HcalGenericDetId(detId).genericSubdet(); 00060 if(subdet == HcalGenericDetId::HcalGenBarrel || subdet == HcalGenericDetId::HcalGenEndcap) return theShapes[0]; 00061 else if(subdet == HcalGenericDetId::HcalGenOuter) return theShapes[2]; 00062 else if(subdet == HcalGenericDetId::HcalGenForward) return theShapes[3]; 00063 else if(subdet == HcalGenericDetId::HcalGenZDC) return theShapes[4]; 00064 else return 0; 00065 } 00066 int shapeType = theMCParams->getValues(detId)->signalShape(); 00067 return theShapes.at(shapeType); 00068 } 00069