CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/SimCalorimetry/HcalSimAlgos/src/HcalShapes.cc

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          00 - not used (reserved)
00030         101 - regular HPD  HB/HE/HO shape
00031         102 - "special" HB HPD#14 long shape
00032         201 - SiPMs Zecotec shape   (HO)
00033         202 - SiPMs Hamamatsu shape (HO)
00034         301 - regular HF PMT shape
00035         401 - regular ZDC shape
00036   */
00037 
00038 /*  
00039   theShapes[HPD] = new CaloCachedShapeIntegrator(&theHcalShape);
00040   theShapes[LONG] = theShapes[HPD];
00041   theShapes[ZECOTEK] = new CaloCachedShapeIntegrator(&theSiPMShape);
00042   theShapes[HAMAMATSU] = theShapes[ZECOTEK];
00043   theShapes[HF] = new CaloCachedShapeIntegrator(&theHFShape);
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); // HPD new 
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   //    ZDC not yet defined in CalibCalorimetry/HcalAlgos/src/HcalPulseShapes.cc
00069   // theHcalShape401(401);
00070   // theShapes[401] = new CaloCachedShapeIntegrator(&theHcalShape401);
00071   theShapes[ZDC] = new CaloCachedShapeIntegrator(&theZDCShape);
00072 
00073 
00074 
00075   // backward-compatibility with old scheme
00076 
00077   theShapes[0] = theShapes[HPD];
00078   //FIXME "special" HB
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           HcalDetId cell(detId);
00122           int sub     = cell.subdet();
00123           int depth   = cell.depth();
00124           int inteta  = cell.ieta();
00125           int intphi  = cell.iphi();
00126           
00127           std::cout << "(SIM)HcalShapes::shape  cell:" 
00128                     << " sub, ieta, iphi, depth = " 
00129                     << sub << "  " << inteta << "  " << intphi 
00130                     << "  " << depth  << " => ShapeId "<<  shapeType 
00131                     << std::endl;
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   // try to figure the appropriate shape
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 }