00001 #include "SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h"
00002 #include "SimCalorimetry/HcalSimProducers/src/HcalTestHitGenerator.h"
00003 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00004 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h"
00005 #include "SimCalorimetry/HcalSimAlgos/interface/HcalShape.h"
00006 #include "SimCalorimetry/HcalSimAlgos/interface/HFShape.h"
00007 #include "SimCalorimetry/HcalSimAlgos/interface/ZDCShape.h"
00008 #include "SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h"
00009 #include "SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h"
00010 #include "SimCalorimetry/HcalSimAlgos/interface/HcalAmplifier.h"
00011 #include "SimCalorimetry/HcalSimAlgos/interface/HcalCoderFactory.h"
00012 #include "SimCalorimetry/HcalSimAlgos/interface/HcalHitCorrection.h"
00013 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h"
00014 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSiPMShape.h"
00015 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSiPMHitResponse.h"
00016 #include "SimCalorimetry/HcalSimAlgos/interface/HPDIonFeedbackSim.h"
00017 #include "DataFormats/Common/interface/Handle.h"
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "FWCore/Framework/interface/EventSetup.h"
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00023 #include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h"
00024 #include "SimCalorimetry/CaloSimAlgos/interface/CaloShapeIntegrator.h"
00025 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00026 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00027 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00028 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00029 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00030 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00031 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00032 #include "FWCore/ServiceRegistry/interface/Service.h"
00033 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
00034 #include "SimCalorimetry/HcalSimAlgos/interface/HPDNoiseGenerator.h"
00035 #include <boost/foreach.hpp>
00036 using namespace std;
00037
00038 namespace HcalDigitizerImpl {
00039
00040 template<typename SIPMDIGITIZER>
00041 void fillSiPMCells(const vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
00042 {
00043 std::vector<DetId> siPMDetIds;
00044 siPMDetIds.reserve(siPMCells.size());
00045 for(std::vector<int>::const_iterator idItr = siPMCells.begin();
00046 idItr != siPMCells.end(); ++idItr)
00047 {
00048 siPMDetIds.push_back(DetId(*idItr));
00049 }
00050 siPMDigitizer->setDetIds(siPMDetIds);
00051 }
00052
00053
00054
00055 template<typename HPDDIGITIZER, typename SIPMDIGITIZER>
00056 void fillCells(const vector<DetId>& allCells,
00057 HPDDIGITIZER * hpdDigitizer,
00058 SIPMDIGITIZER * siPMDigitizer)
00059 {
00060
00061 if(siPMDigitizer && hpdDigitizer)
00062 {
00063 std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
00064 std::sort(siPMDetIds.begin(), siPMDetIds.end());
00065 std::vector<DetId> sortedCells = allCells;
00066 std::sort(sortedCells.begin(), sortedCells.end());
00067 std::vector<DetId> hpdCells;
00068 std::set_difference(sortedCells.begin(), sortedCells.end(),
00069 siPMDetIds.begin(), siPMDetIds.end(),
00070 std::back_inserter(hpdCells) );
00071 hpdDigitizer->setDetIds(hpdCells);
00072 }
00073 else
00074 {
00075 if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
00076 if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
00077 }
00078 }
00079 }
00080
00081
00082 HcalDigitizer::HcalDigitizer(const edm::ParameterSet& ps)
00083 : theGeometry(0),
00084 theParameterMap(new HcalSimParameterMap(ps)),
00085 theHcalShape(0),
00086 theSiPMShape(0),
00087 theHFShape(new HFShape()),
00088 theZDCShape(new ZDCShape()),
00089 theHcalIntegratedShape(0),
00090 theSiPMIntegratedShape(0),
00091 theHFIntegratedShape(new CaloShapeIntegrator(theHFShape)),
00092 theZDCIntegratedShape(new CaloShapeIntegrator(theZDCShape)),
00093 theHBHEResponse(0),
00094 theHBHESiPMResponse(0),
00095 theHOResponse(0),
00096 theHOSiPMResponse(0),
00097 theHFResponse(new CaloHitResponse(theParameterMap, theHFIntegratedShape)),
00098 theZDCResponse(new CaloHitResponse(theParameterMap, theZDCIntegratedShape)),
00099 theHBHEAmplifier(0),
00100 theHFAmplifier(0),
00101 theHOAmplifier(0),
00102 theZDCAmplifier(0),
00103 theIonFeedback(0),
00104 theCoderFactory(0),
00105 theHBHEElectronicsSim(0),
00106 theHFElectronicsSim(0),
00107 theHOElectronicsSim(0),
00108 theZDCElectronicsSim(0),
00109 theHBHEHitFilter(),
00110 theHFHitFilter(ps.getParameter<bool>("doHFWindow")),
00111 theHOHitFilter(),
00112 theHOSiPMHitFilter(HcalOuter),
00113 theZDCHitFilter(),
00114 theHitCorrection(0),
00115 theNoiseGenerator(0),
00116 theNoiseHitGenerator(0),
00117 theHBHEDigitizer(0),
00118 theHBHESiPMDigitizer(0),
00119 theHODigitizer(0),
00120 theHOSiPMDigitizer(0),
00121 theHFDigitizer(0),
00122 theZDCDigitizer(0),
00123 theHBHEDetIds(),
00124 theHOHPDDetIds(),
00125 theHOSiPMDetIds(),
00126 isZDC(true),
00127 isHCAL(true),
00128 zdcgeo(true),
00129 hbhegeo(true),
00130 hogeo(true),
00131 hfgeo(true),
00132 theHOSiPMCode(ps.getParameter<edm::ParameterSet>("ho").getParameter<int>("siPMCode"))
00133 {
00134 bool doNoise = ps.getParameter<bool>("doNoise");
00135 bool useOldNoiseHB = ps.getParameter<bool>("useOldHB");
00136 bool useOldNoiseHE = ps.getParameter<bool>("useOldHE");
00137 bool useOldNoiseHF = ps.getParameter<bool>("useOldHF");
00138 bool useOldNoiseHO = ps.getParameter<bool>("useOldHO");
00139 bool doEmpty = ps.getParameter<bool>("doEmpty");
00140 double HBtp = ps.getParameter<double>("HBTuningParameter");
00141 double HEtp = ps.getParameter<double>("HETuningParameter");
00142 double HFtp = ps.getParameter<double>("HFTuningParameter");
00143 double HOtp = ps.getParameter<double>("HOTuningParameter");
00144
00145
00146 theHBHEAmplifier = new HcalAmplifier(theParameterMap, doNoise);
00147 theHFAmplifier = new HcalAmplifier(theParameterMap, doNoise);
00148 theHOAmplifier = new HcalAmplifier(theParameterMap, doNoise);
00149 theZDCAmplifier = new HcalAmplifier(theParameterMap, doNoise);
00150 theHBHEAmplifier->setHBtuningParameter(HBtp);
00151 theHBHEAmplifier->setHEtuningParameter(HEtp);
00152 theHFAmplifier->setHFtuningParameter(HFtp);
00153 theHOAmplifier->setHOtuningParameter(HOtp);
00154 theHBHEAmplifier->setUseOldHB(useOldNoiseHB);
00155 theHBHEAmplifier->setUseOldHE(useOldNoiseHE);
00156 theHFAmplifier->setUseOldHF(useOldNoiseHF);
00157 theHOAmplifier->setUseOldHO(useOldNoiseHO);
00158
00159 theCoderFactory = new HcalCoderFactory(HcalCoderFactory::DB);
00160 theHBHEElectronicsSim = new HcalElectronicsSim(theHBHEAmplifier, theCoderFactory);
00161 theHFElectronicsSim = new HcalElectronicsSim(theHFAmplifier, theCoderFactory);
00162 theHOElectronicsSim = new HcalElectronicsSim(theHOAmplifier, theCoderFactory);
00163 theZDCElectronicsSim = new HcalElectronicsSim(theZDCAmplifier, theCoderFactory);
00164
00165
00166 std::vector<int> hbSiPMCells(ps.getParameter<edm::ParameterSet>("hb").getParameter<std::vector<int> >("siPMCells"));
00167
00168
00169
00170 bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
00171 bool doHOHPD = (theHOSiPMCode != 1);
00172 bool doHBHESiPM = !hbSiPMCells.empty();
00173 bool doHOSiPM = (theHOSiPMCode != 0);
00174
00175 if(doHBHEHPD || doHOHPD )
00176 {
00177 theHcalShape = new HcalShape();
00178 theHcalIntegratedShape = new CaloShapeIntegrator(theHcalShape);
00179 }
00180 if(doHBHESiPM || doHOSiPM )
00181 {
00182 theSiPMShape = new HcalSiPMShape();
00183 theSiPMIntegratedShape = new CaloShapeIntegrator(theSiPMShape);
00184 }
00185
00186 if(doHBHEHPD)
00187 {
00188 theHBHEResponse = new CaloHitResponse(theParameterMap, theHcalIntegratedShape);
00189 theHBHEResponse->setHitFilter(&theHBHEHitFilter);
00190 theHBHEDigitizer = new HBHEDigitizer(theHBHEResponse, theHBHEElectronicsSim, doEmpty);
00191 }
00192 if(doHOHPD)
00193 {
00194 theHOResponse = new CaloHitResponse(theParameterMap, theHcalIntegratedShape);
00195 theHOResponse->setHitFilter(&theHOHitFilter);
00196 theHODigitizer = new HODigitizer(theHOResponse, theHOElectronicsSim, doEmpty);
00197 }
00198
00199 if(doHBHESiPM)
00200 {
00201 theHBHESiPMResponse = new HcalSiPMHitResponse(theParameterMap, theSiPMIntegratedShape);
00202 theHBHESiPMResponse->setHitFilter(&theHBHEHitFilter);
00203 theHBHESiPMDigitizer = new HBHEDigitizer(theHBHESiPMResponse, theHBHEElectronicsSim, doEmpty);
00204 }
00205 if(doHOSiPM)
00206 {
00207 theHOSiPMResponse = new HcalSiPMHitResponse(theParameterMap, theSiPMIntegratedShape);
00208 theHOSiPMResponse->setHitFilter(&theHOSiPMHitFilter);
00209 theHOSiPMDigitizer = new HODigitizer(theHOSiPMResponse, theHOElectronicsSim, doEmpty);
00210 }
00211
00212
00213 if(doHBHEHPD && doHBHESiPM)
00214 {
00215 HcalDigitizerImpl::fillSiPMCells(hbSiPMCells, theHBHESiPMDigitizer);
00216 }
00217
00218
00219 theHFResponse->setHitFilter(&theHFHitFilter);
00220 theZDCResponse->setHitFilter(&theZDCHitFilter);
00221
00222 bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
00223 if(doTimeSlew) {
00224
00225 theHitCorrection = new HcalHitCorrection(theParameterMap);
00226 if(theHBHEResponse) theHBHEResponse->setHitCorrection(theHitCorrection);
00227 if(theHBHESiPMResponse) theHBHESiPMResponse->setHitCorrection(theHitCorrection);
00228 if(theHOResponse) theHOResponse->setHitCorrection(theHitCorrection);
00229 if(theHOSiPMResponse) theHOSiPMResponse->setHitCorrection(theHitCorrection);
00230 theZDCResponse->setHitCorrection(theHitCorrection);
00231 }
00232
00233 theHFDigitizer = new HFDigitizer(theHFResponse, theHFElectronicsSim, doEmpty);
00234 theZDCDigitizer = new ZDCDigitizer(theZDCResponse, theZDCElectronicsSim, doEmpty);
00235
00236 bool doHPDNoise = ps.getParameter<bool>("doHPDNoise");
00237 if(doHPDNoise) {
00238
00239 theNoiseGenerator = new HPDNoiseGenerator(ps);
00240 if(theHBHEDigitizer) theHBHEDigitizer->setNoiseSignalGenerator(theNoiseGenerator);
00241 if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->setNoiseSignalGenerator(theNoiseGenerator);
00242 }
00243
00244 if(ps.getParameter<bool>("doIonFeedback") && theHBHEResponse)
00245 {
00246 theIonFeedback = new HPDIonFeedbackSim(ps);
00247 theHBHEResponse->setPECorrection(theIonFeedback);
00248 if(ps.getParameter<bool>("doThermalNoise"))
00249 {
00250 theHBHEAmplifier->setIonFeedbackSim(theIonFeedback);
00251 theIonFeedback->setShape(theHcalIntegratedShape);
00252 }
00253 }
00254
00255 if(ps.getParameter<bool>("injectTestHits") ){
00256 theNoiseHitGenerator = new HcalTestHitGenerator(ps);
00257 if(theHBHEDigitizer) theHBHEDigitizer->setNoiseHitGenerator(theNoiseHitGenerator);
00258 if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->setNoiseHitGenerator(theNoiseHitGenerator);
00259 if(theHODigitizer) theHODigitizer->setNoiseHitGenerator(theNoiseHitGenerator);
00260 if(theHOSiPMDigitizer) theHOSiPMDigitizer->setNoiseHitGenerator(theNoiseHitGenerator);
00261 theHFDigitizer->setNoiseHitGenerator(theNoiseHitGenerator);
00262 theZDCDigitizer->setNoiseHitGenerator(theNoiseHitGenerator);
00263 }
00264
00265 edm::Service<edm::RandomNumberGenerator> rng;
00266 if ( ! rng.isAvailable()) {
00267 throw cms::Exception("Configuration")
00268 << "HcalDigitizer requires the RandomNumberGeneratorService\n"
00269 "which is not present in the configuration file. You must add the service\n"
00270 "in the configuration file or remove the modules that require it.";
00271 }
00272
00273 CLHEP::HepRandomEngine& engine = rng->getEngine();
00274 if(theHBHEDigitizer) theHBHEDigitizer->setRandomEngine(engine);
00275 if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->setRandomEngine(engine);
00276 if(theHODigitizer) theHODigitizer->setRandomEngine(engine);
00277 if(theHOSiPMDigitizer) theHOSiPMDigitizer->setRandomEngine(engine);
00278 if(theIonFeedback) theIonFeedback->setRandomEngine(engine);
00279 theHFDigitizer->setRandomEngine(engine);
00280 theZDCDigitizer->setRandomEngine(engine);
00281
00282 if (theHitCorrection!=0) theHitCorrection->setRandomEngine(engine);
00283
00284 hitsProducer_ = ps.getParameter<std::string>("hitsProducer");
00285
00286 }
00287
00288
00289 HcalDigitizer::~HcalDigitizer() {
00290 delete theHBHEDigitizer;
00291 delete theHBHESiPMDigitizer;
00292 delete theHODigitizer;
00293 delete theHOSiPMDigitizer;
00294 delete theHFDigitizer;
00295 delete theZDCDigitizer;
00296 delete theParameterMap;
00297 delete theHcalShape;
00298 delete theSiPMShape;
00299 delete theHFShape;
00300 delete theZDCShape;
00301 delete theHcalIntegratedShape;
00302 delete theSiPMIntegratedShape;
00303 delete theHFIntegratedShape;
00304 delete theZDCIntegratedShape;
00305 delete theHBHEResponse;
00306 delete theHBHESiPMResponse;
00307 delete theHOResponse;
00308 delete theHOSiPMResponse;
00309 delete theHFResponse;
00310 delete theZDCResponse;
00311 delete theHBHEElectronicsSim;
00312 delete theHFElectronicsSim;
00313 delete theHOElectronicsSim;
00314 delete theZDCElectronicsSim;
00315 delete theHBHEAmplifier;
00316 delete theHFAmplifier;
00317 delete theHOAmplifier;
00318 delete theZDCAmplifier;
00319 delete theCoderFactory;
00320 delete theHitCorrection;
00321 delete theNoiseGenerator;
00322 }
00323
00324
00325 void HcalDigitizer::setHBHENoiseSignalGenerator(HcalBaseSignalGenerator * noiseGenerator)
00326 {
00327 noiseGenerator->setParameterMap(theParameterMap);
00328 noiseGenerator->setElectronicsSim(theHBHEElectronicsSim);
00329 theHBHEDigitizer->setNoiseSignalGenerator(noiseGenerator);
00330 theHBHEAmplifier->setNoiseSignalGenerator(noiseGenerator);
00331 }
00332
00333 void HcalDigitizer::setHFNoiseSignalGenerator(HcalBaseSignalGenerator * noiseGenerator)
00334 {
00335 noiseGenerator->setParameterMap(theParameterMap);
00336 noiseGenerator->setElectronicsSim(theHFElectronicsSim);
00337 theHFDigitizer->setNoiseSignalGenerator(noiseGenerator);
00338 theHFAmplifier->setNoiseSignalGenerator(noiseGenerator);
00339 }
00340
00341 void HcalDigitizer::setHONoiseSignalGenerator(HcalBaseSignalGenerator * noiseGenerator)
00342 {
00343 noiseGenerator->setParameterMap(theParameterMap);
00344 noiseGenerator->setElectronicsSim(theHOElectronicsSim);
00345 theHODigitizer->setNoiseSignalGenerator(noiseGenerator);
00346 theHOAmplifier->setNoiseSignalGenerator(noiseGenerator);
00347 }
00348
00349 void HcalDigitizer::setZDCNoiseSignalGenerator(HcalBaseSignalGenerator * noiseGenerator)
00350 {
00351 noiseGenerator->setParameterMap(theParameterMap);
00352 noiseGenerator->setElectronicsSim(theZDCElectronicsSim);
00353 theZDCDigitizer->setNoiseSignalGenerator(noiseGenerator);
00354 theZDCAmplifier->setNoiseSignalGenerator(noiseGenerator);
00355 }
00356
00357
00358 void HcalDigitizer::produce(edm::Event& e, const edm::EventSetup& eventSetup) {
00359
00360 edm::ESHandle<HcalDbService> conditions;
00361 eventSetup.get<HcalDbRecord>().get(conditions);
00362 theHBHEAmplifier->setDbService(conditions.product());
00363 theHFAmplifier->setDbService(conditions.product());
00364 theHOAmplifier->setDbService(conditions.product());
00365 theZDCAmplifier->setDbService(conditions.product());
00366
00367 theCoderFactory->setDbService(conditions.product());
00368 theParameterMap->setDbService(conditions.product());
00369
00370 edm::ESHandle<HcalCholeskyMatrices> refCholesky;
00371 eventSetup.get<HcalCholeskyMatricesRcd>().get(refCholesky);
00372 const HcalCholeskyMatrices * myCholesky = refCholesky.product();
00373
00374 edm::ESHandle<HcalPedestals> pedshandle;
00375 eventSetup.get<HcalPedestalsRcd>().get(pedshandle);
00376 const HcalPedestals * myADCPedestals = pedshandle.product();
00377
00378 theHBHEAmplifier->setCholesky(myCholesky);
00379 theHFAmplifier->setCholesky(myCholesky);
00380 theHOAmplifier->setCholesky(myCholesky);
00381
00382 theHBHEAmplifier->setADCPeds(myADCPedestals);
00383 theHFAmplifier->setADCPeds(myADCPedestals);
00384 theHOAmplifier->setADCPeds(myADCPedestals);
00385
00386
00387
00388 checkGeometry(eventSetup);
00389
00390
00391 edm::Handle<CrossingFrame<PCaloHit> > cf, zdccf;
00392
00393
00394 const std::string zdcHitsName(hitsProducer_+"ZDCHITS");
00395 e.getByLabel("mix", zdcHitsName , zdccf);
00396 MixCollection<PCaloHit> * colzdc = 0 ;
00397 if(zdccf.isValid()){
00398 colzdc = new MixCollection<PCaloHit>(zdccf.product());
00399 }else{
00400 edm::LogInfo("HcalDigitizer") << "We don't have ZDC hit collection available ";
00401 isZDC = false;
00402 }
00403
00404 const std::string hcalHitsName(hitsProducer_+"HcalHits");
00405 e.getByLabel("mix", hcalHitsName ,cf);
00406 MixCollection<PCaloHit> * col = 0 ;
00407 if(cf.isValid()){
00408 col = new MixCollection<PCaloHit>(cf.product());
00409 }else{
00410 edm::LogInfo("HcalDigitizer") << "We don't have HCAL hit collection available ";
00411 isHCAL = false;
00412 }
00413
00414 if(theHitCorrection != 0)
00415 {
00416 theHitCorrection->clear();
00417 if(isHCAL)
00418 theHitCorrection->fillChargeSums(*col);
00419 }
00420
00421
00422 std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
00423 std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
00424 std::auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection());
00425 std::auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection());
00426
00427
00428 if(isHCAL&&hbhegeo)
00429 {
00430 if(theHBHEDigitizer) theHBHEDigitizer->run(*col, *hbheResult);
00431 if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->run(*col, *hbheResult);
00432 }
00433 if(isHCAL&&hogeo)
00434 {
00435 if(theHODigitizer) theHODigitizer->run(*col, *hoResult);
00436 if(theHOSiPMDigitizer) theHOSiPMDigitizer->run(*col, *hoResult);
00437 }
00438 if(isHCAL&&hfgeo)
00439 theHFDigitizer->run(*col, *hfResult);
00440 if(isZDC&&zdcgeo)
00441 theZDCDigitizer->run(*colzdc, *zdcResult);
00442
00443 edm::LogInfo("HcalDigitizer") << "HCAL HBHE digis : " << hbheResult->size();
00444 edm::LogInfo("HcalDigitizer") << "HCAL HO digis : " << hoResult->size();
00445 edm::LogInfo("HcalDigitizer") << "HCAL HF digis : " << hfResult->size();
00446 edm::LogInfo("HcalDigitizer") << "HCAL ZDC digis : " << zdcResult->size();
00447
00448
00449 e.put(hbheResult);
00450 e.put(hoResult);
00451 e.put(hfResult);
00452 e.put(zdcResult);
00453 }
00454
00455
00456 void HcalDigitizer::checkGeometry(const edm::EventSetup & eventSetup) {
00457
00458 edm::ESHandle<CaloGeometry> geometry;
00459 eventSetup.get<CaloGeometryRecord>().get(geometry);
00460
00461 if(&*geometry != theGeometry)
00462 {
00463 theGeometry = &*geometry;
00464 updateGeometry();
00465 }
00466 }
00467
00468
00469 void HcalDigitizer::updateGeometry()
00470 {
00471 if(theHBHEResponse) theHBHEResponse->setGeometry(theGeometry);
00472 if(theHBHESiPMResponse) theHBHESiPMResponse->setGeometry(theGeometry);
00473 if(theHOResponse) theHOResponse->setGeometry(theGeometry);
00474 if(theHOSiPMResponse) theHOSiPMResponse->setGeometry(theGeometry);
00475 theHFResponse->setGeometry(theGeometry);
00476 theZDCResponse->setGeometry(theGeometry);
00477
00478 const vector<DetId>& hbCells = theGeometry->getValidDetIds(DetId::Hcal, HcalBarrel);
00479 const vector<DetId>& heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
00480 const vector<DetId>& hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter);
00481 const vector<DetId>& hfCells = theGeometry->getValidDetIds(DetId::Hcal, HcalForward);
00482 const vector<DetId>& zdcCells = theGeometry->getValidDetIds(DetId::Calo, HcalZDCDetId::SubdetectorId);
00483
00484
00485
00486 if(zdcCells.empty()) zdcgeo = false;
00487 if(hbCells.empty() && heCells.empty()) hbhegeo = false;
00488 if(hoCells.empty()) hogeo = false;
00489 if(hfCells.empty()) hfgeo = false;
00490
00491
00492
00493 theHBHEDetIds = hbCells;
00494 theHBHEDetIds.insert(theHBHEDetIds.end(), heCells.begin(), heCells.end());
00495
00496 HcalDigitizerImpl::fillCells(theHBHEDetIds, theHBHEDigitizer, theHBHESiPMDigitizer);
00497
00498 buildHOSiPMCells(hoCells);
00499 theHFDigitizer->setDetIds(hfCells);
00500 theZDCDigitizer->setDetIds(zdcCells);
00501 }
00502
00503
00504 void HcalDigitizer::buildHOSiPMCells(const std::vector<DetId>& allCells)
00505 {
00506
00507 if(theHOSiPMCode == 0)
00508 {
00509 theHODigitizer->setDetIds(allCells);
00510 }
00511 else if(theHOSiPMCode == 1)
00512 {
00513 theHOSiPMDigitizer->setDetIds(allCells);
00514
00515 }
00516 else if(theHOSiPMCode == 2)
00517 {
00518 std::vector<HcalDetId> zecotekDetIds;
00519 std::vector<HcalDetId> hamamatsuDetIds;
00520 for(std::vector<DetId>::const_iterator detItr = allCells.begin();
00521 detItr != allCells.end(); ++detItr)
00522 {
00523 HcalDetId hcalId(*detItr);
00524 int ieta = hcalId.ieta();
00525 int iphi = hcalId.iphi();
00526 if ((ieta>=5 && ieta <= 10 ) && (iphi >=47 && iphi <=52))
00527 {
00528 zecotekDetIds.push_back(hcalId);
00529 theHOSiPMDetIds.push_back(*detItr);
00530 }
00531 else if(((ieta>=5 && ieta <= 10 ) && (iphi >=53 && iphi <=58))
00532 || ((ieta>=11 && ieta <= 15 ) && (iphi >=59 && iphi <=70))){
00533 hamamatsuDetIds.push_back(hcalId);
00534 theHOSiPMDetIds.push_back(*detItr);
00535 }
00536 else {
00537 theHOHPDDetIds.push_back(*detItr);
00538 }
00539 }
00540 assert(theHODigitizer);
00541 assert(theHOSiPMDigitizer);
00542 theHODigitizer->setDetIds(theHOHPDDetIds);
00543 theHOSiPMDigitizer->setDetIds(theHOSiPMDetIds);
00544 theHOSiPMHitFilter.setDetIds(theHOSiPMDetIds);
00545
00546 theParameterMap->setHOZecotekDetIds(zecotekDetIds);
00547 theParameterMap->setHOHamamatsuDetIds(hamamatsuDetIds);
00548
00549
00550 theHOSiPMCode = -2;
00551 }
00552 }
00553
00554
00555
00556