Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:06

0001 #include <memory>
0002 #include <iostream>
0003 #include <vector>
0004 
0005 #include <TTree.h>
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/ServiceRegistry/interface/Service.h"
0014 #include "FWCore/Common/interface/TriggerNames.h"
0015 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0016 
0017 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0018 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0019 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0020 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0021 #include "SimDataFormats/Track/interface/SimTrack.h"
0022 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0023 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0024 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0025 
0026 #include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h"
0027 #include "Calibration/IsolatedParticles/interface/eECALMatrix.h"
0028 #include "Calibration/IsolatedParticles/interface/eHCALMatrix.h"
0029 
0030 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0031 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0032 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0033 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0034 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0035 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0036 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0037 #include "Geometry/HcalCommonData/interface/HcalHitRelabeller.h"
0038 #include "MagneticField/Engine/interface/MagneticField.h"
0039 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0040 
0041 //#define EDM_ML_DEBUG
0042 
0043 class HcalHBHEMuonSimAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
0044 public:
0045   explicit HcalHBHEMuonSimAnalyzer(const edm::ParameterSet&);
0046   ~HcalHBHEMuonSimAnalyzer() override {}
0047 
0048   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0049 
0050 private:
0051   void beginJob() override;
0052   void analyze(edm::Event const&, edm::EventSetup const&) override;
0053   void beginRun(edm::Run const&, edm::EventSetup const&) override;
0054   void endRun(edm::Run const&, edm::EventSetup const&) override {}
0055   virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {}
0056   virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {}
0057   void clearVectors();
0058   unsigned int matchId(const HcalDetId&, const HcalDetId&);
0059   double activeLength(const DetId&);
0060 
0061   const std::string g4Label_, ebLabel_, eeLabel_, hcLabel_;
0062   const int verbosity_, maxDepth_;
0063   const double etaMax_, tMinE_, tMaxE_, tMinH_, tMaxH_;
0064   const edm::EDGetTokenT<edm::SimTrackContainer> tok_SimTk_;
0065   const edm::EDGetTokenT<edm::SimVertexContainer> tok_SimVtx_;
0066   const edm::EDGetTokenT<edm::PCaloHitContainer> tok_caloEB_, tok_caloEE_;
0067   const edm::EDGetTokenT<edm::PCaloHitContainer> tok_caloHH_;
0068 
0069   const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_ddrec_;
0070   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
0071   const edm::ESGetToken<CaloTopology, CaloTopologyRecord> tok_caloTopology_;
0072   const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> tok_topo_;
0073   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tok_magField_;
0074 
0075   std::vector<HcalDDDRecConstants::HcalActiveLength> actHB_, actHE_;
0076 
0077   const HcalDDDRecConstants* hcons_;
0078 
0079   static const int depthMax_ = 7;
0080   const int idMuon_ = 13;
0081   TTree* tree_;
0082   unsigned int runNumber_, eventNumber_, lumiNumber_, bxNumber_;
0083   double ptGlob_, etaGlob_, phiGlob_, pMuon_;
0084   double ecal3x3Energy_, hcal1x1Energy_;
0085   unsigned int ecalDetId_, hcalDetId_, hcalHot_;
0086   double matchedId_;
0087   double hcalDepthEnergy_[depthMax_];
0088   double hcalDepthActiveLength_[depthMax_];
0089   double hcalDepthEnergyHot_[depthMax_];
0090   double hcalDepthActiveLengthHot_[depthMax_];
0091   double hcalActiveLength_, hcalActiveLengthHot_;
0092 };
0093 
0094 HcalHBHEMuonSimAnalyzer::HcalHBHEMuonSimAnalyzer(const edm::ParameterSet& iConfig)
0095     : g4Label_(iConfig.getParameter<std::string>("ModuleLabel")),
0096       ebLabel_(iConfig.getParameter<std::string>("EBCollection")),
0097       eeLabel_(iConfig.getParameter<std::string>("EECollection")),
0098       hcLabel_(iConfig.getParameter<std::string>("HCCollection")),
0099       verbosity_(iConfig.getUntrackedParameter<int>("Verbosity", 0)),
0100       maxDepth_(iConfig.getUntrackedParameter<int>("MaxDepth", 7)),
0101       etaMax_(iConfig.getUntrackedParameter<double>("EtaMax", 3.0)),
0102       tMinE_(iConfig.getUntrackedParameter<double>("TimeMinCutECAL", -500.)),
0103       tMaxE_(iConfig.getUntrackedParameter<double>("TimeMaxCutECAL", 500.)),
0104       tMinH_(iConfig.getUntrackedParameter<double>("TimeMinCutHCAL", -500.)),
0105       tMaxH_(iConfig.getUntrackedParameter<double>("TimeMaxCutHCAL", 500.)),
0106       tok_SimTk_(consumes<edm::SimTrackContainer>(edm::InputTag(g4Label_))),
0107       tok_SimVtx_(consumes<edm::SimVertexContainer>(edm::InputTag(g4Label_))),
0108       tok_caloEB_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, ebLabel_))),
0109       tok_caloEE_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, eeLabel_))),
0110       tok_caloHH_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hcLabel_))),
0111       tok_ddrec_(esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>()),
0112       tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
0113       tok_caloTopology_(esConsumes<CaloTopology, CaloTopologyRecord>()),
0114       tok_topo_(esConsumes<HcalTopology, HcalRecNumberingRecord>()),
0115       tok_magField_(esConsumes<MagneticField, IdealMagneticFieldRecord>()) {
0116   //now do what ever initialization is needed
0117   usesResource(TFileService::kSharedResource);
0118 
0119   edm::LogVerbatim("HBHEMuon") << "Labels: " << g4Label_ << ":" << ebLabel_ << ":" << eeLabel_ << ":" << hcLabel_
0120                                << "\nVerbosity " << verbosity_ << " MaxDepth " << maxDepth_ << " Maximum Eta "
0121                                << etaMax_ << " tMin|tMax " << tMinE_ << ":" << tMaxE_ << ":" << tMinH_ << ":" << tMaxH_;
0122 }
0123 
0124 void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0125   clearVectors();
0126   bool debug(false);
0127 #ifdef EDM_ML_DEBUG
0128   debug = ((verbosity_ / 10) > 0);
0129 #endif
0130 
0131   runNumber_ = iEvent.id().run();
0132   eventNumber_ = iEvent.id().event();
0133   lumiNumber_ = iEvent.id().luminosityBlock();
0134   bxNumber_ = iEvent.bunchCrossing();
0135 
0136   //get Handles to SimTracks and SimHits
0137   edm::Handle<edm::SimTrackContainer> SimTk = iEvent.getHandle(tok_SimTk_);
0138   edm::Handle<edm::SimVertexContainer> SimVtx = iEvent.getHandle(tok_SimVtx_);
0139 
0140   //get Handles to PCaloHitContainers of eb/ee/hbhe
0141   edm::Handle<edm::PCaloHitContainer> pcaloeb = iEvent.getHandle(tok_caloEB_);
0142   edm::Handle<edm::PCaloHitContainer> pcaloee = iEvent.getHandle(tok_caloEE_);
0143   edm::Handle<edm::PCaloHitContainer> pcalohh = iEvent.getHandle(tok_caloHH_);
0144   std::vector<PCaloHit> calohh;
0145   bool testN(false);
0146   for (unsigned int k = 1; k < pcalohh->size(); ++k) {
0147     // if it is a standard DetId bits 28..31 will carry the det #
0148     // for HCAL det # is 4 and if there is at least one hit in the collection
0149     // have det # which is not 4 this collection is created using TestNumbering
0150     int det = ((((*pcalohh)[k].id()) >> 28) & 0xF);
0151     if (det != 4) {
0152       testN = true;
0153       break;
0154     }
0155   }
0156   if (testN) {
0157     for (auto hit : (*(pcalohh.product()))) {
0158       DetId newid = HcalHitRelabeller::relabel(hit.id(), hcons_);
0159 #ifdef EDM_ML_DEBUG
0160       edm::LogVerbatim("HBHEMuon") << "Old ID " << std::hex << hit.id() << std::dec << " New " << HcalDetId(newid);
0161 #endif
0162       hit.setID(newid.rawId());
0163       calohh.push_back(hit);
0164     }
0165   } else {
0166     calohh.insert(calohh.end(), pcalohh->begin(), pcalohh->end());
0167   }
0168 
0169   // get handles to calogeometry and calotopology
0170   const CaloGeometry* geo = &iSetup.getData(tok_geom_);
0171   const MagneticField* bField = &iSetup.getData(tok_magField_);
0172   const CaloTopology* caloTopology = &iSetup.getData(tok_caloTopology_);
0173   const HcalTopology* theHBHETopology = &iSetup.getData(tok_topo_);
0174 
0175   std::vector<double> ptGlob, etaGlob, phiGlob, pMuon;
0176   std::vector<double> ecal3x3Energy, hcal1x1Energy;
0177   std::vector<unsigned int> ecalDetId, hcalDetId, hcalHot;
0178   std::vector<double> matchedId;
0179   std::vector<double> hcalDepthEnergy[depthMax_];
0180   std::vector<double> hcalDepthActiveLength[depthMax_];
0181   std::vector<double> hcalDepthEnergyHot[depthMax_];
0182   std::vector<double> hcalDepthActiveLengthHot[depthMax_];
0183   std::vector<double> hcalActiveLength, hcalActiveLengthHot;
0184 
0185   // Loop over all SimTracks
0186   for (const auto& simTrkItr : (*(SimTk.product()))) {
0187     if ((std::abs(simTrkItr.type()) == idMuon_) && (simTrkItr.vertIndex() == 0) &&
0188         (std::abs(simTrkItr.momentum().eta()) < etaMax_)) {
0189       unsigned int thisTrk = simTrkItr.trackId();
0190       spr::propagatedTrackDirection trkD = spr::propagateCALO(thisTrk, SimTk, SimVtx, geo, bField, debug);
0191 
0192       double eEcal(0), eHcal(0), activeLengthHotTot(0);
0193       double eHcalDepth[depthMax_], eHcalDepthHot[depthMax_];
0194       double activeL[depthMax_], activeHotL[depthMax_];
0195       unsigned int isHot(0);
0196       bool tmpmatch(false);
0197       for (int i = 0; i < depthMax_; ++i)
0198         eHcalDepth[i] = eHcalDepthHot[i] = activeL[i] = activeHotL[i] = -10000;
0199 
0200 #ifdef EDM_ML_DEBUG
0201       if ((verbosity_ % 10) > 0)
0202         edm::LogVerbatim("HBHEMuon") << "Track Type " << simTrkItr.type() << " Vertex " << simTrkItr.vertIndex()
0203                                      << " Charge " << simTrkItr.charge() << " Momentum " << simTrkItr.momentum().P()
0204                                      << ":" << simTrkItr.momentum().eta() << ":" << simTrkItr.momentum().phi()
0205                                      << " ECAL|HCAL " << trkD.okECAL << ":" << trkD.okHCAL << " Point "
0206                                      << trkD.pointECAL << ":" << trkD.pointHCAL << " Direction "
0207                                      << trkD.directionECAL.eta() << ":" << trkD.directionECAL.phi() << " | "
0208                                      << trkD.directionHCAL.eta() << ":" << trkD.directionHCAL.phi();
0209 #endif
0210       bool propageback(false);
0211       spr::propagatedTrackDirection trkD_back = spr::propagateHCALBack(thisTrk, SimTk, SimVtx, geo, bField, debug);
0212       HcalDetId closestCell_back;
0213       if (trkD_back.okHCAL) {
0214         closestCell_back = (HcalDetId)(trkD_back.detIdHCAL);
0215         propageback = true;
0216       }
0217       if (trkD.okHCAL) {
0218         // Muon properties
0219         spr::trackAtOrigin tkvx = spr::simTrackAtOrigin(thisTrk, SimTk, SimVtx, debug);
0220         ptGlob.push_back(tkvx.momentum.perp());
0221         etaGlob.push_back(tkvx.momentum.eta());
0222         phiGlob.push_back(tkvx.momentum.phi());
0223         pMuon.push_back(tkvx.momentum.mag());
0224 #ifdef EDM_ML_DEBUG
0225         if ((verbosity_ % 10) > 0)
0226           edm::LogVerbatim("HBHEMuon") << "Track at vertex " << tkvx.ok << " position " << tkvx.position << " Momentum "
0227                                        << tkvx.momentum.mag() << ":" << tkvx.momentum.eta() << ":"
0228                                        << tkvx.momentum.phi() << " Charge " << tkvx.charge;
0229 #endif
0230         // Energy in ECAL
0231         DetId isoCell;
0232         if (trkD.okECAL) {
0233           isoCell = trkD.detIdECAL;
0234           eEcal = spr::eECALmatrix(
0235               isoCell, pcaloeb, pcaloee, geo, caloTopology, 1, 1, -100.0, -100.0, tMinE_, tMaxE_, debug);
0236         }
0237 
0238         // Energy in  Hcal
0239         const DetId closestCell(trkD.detIdHCAL);
0240         if ((propageback) && (HcalDetId(closestCell).ieta() == HcalDetId(closestCell_back).ieta()) &&
0241             (HcalDetId(closestCell).iphi() == HcalDetId(closestCell_back).iphi()))
0242           tmpmatch = true;
0243 
0244         eHcal = spr::eHCALmatrix(
0245             theHBHETopology, closestCell, calohh, 0, 0, false, -100.0, -100.0, -100.0, -100.0, tMinH_, tMaxH_, debug);
0246 #ifdef EDM_ML_DEBUG
0247         if ((verbosity_ % 10) > 0)
0248           edm::LogVerbatim("HBHEMuon") << "eEcal " << trkD.okECAL << ":" << eEcal << " eHcal " << eHcal;
0249 #endif
0250         HcalSubdetector subdet = HcalDetId(closestCell).subdet();
0251         int ieta = HcalDetId(closestCell).ieta();
0252         int iphi = HcalDetId(closestCell).iphi();
0253         int zside = HcalDetId(closestCell).zside();
0254         bool hbhe = (std::abs(ieta) == 16);
0255         int depthHE = hcons_->getMinDepth(1, 16, iphi, zside);
0256         std::vector<std::pair<double, int> > ehdepth;
0257         spr::energyHCALCell((HcalDetId)closestCell,
0258                             calohh,
0259                             ehdepth,
0260                             maxDepth_,
0261                             -100.0,
0262                             -100.0,
0263                             -100.0,
0264                             -100.0,
0265                             -500.0,
0266                             500.0,
0267                             depthHE,
0268                             debug);
0269         for (unsigned int i = 0; i < ehdepth.size(); ++i) {
0270           eHcalDepth[ehdepth[i].second - 1] = ehdepth[i].first;
0271           HcalSubdetector subdet0 = (hbhe) ? ((ehdepth[i].second >= depthHE) ? HcalEndcap : HcalBarrel) : subdet;
0272           HcalDetId hcid0(subdet0, ieta, iphi, ehdepth[i].second);
0273           double actL = activeLength(DetId(hcid0));
0274           activeL[ehdepth[i].second - 1] = actL;
0275 #ifdef EDM_ML_DEBUG
0276           if ((verbosity_ % 10) > 0)
0277             edm::LogVerbatim("HBHEMuon") << hcid0 << " E " << ehdepth[i].first << " L " << actL;
0278 #endif
0279         }
0280 
0281         HcalDetId hotCell;
0282         double h3x3 = spr::eHCALmatrix(geo, theHBHETopology, closestCell, calohh, 1, 1, hotCell, debug);
0283         isHot = matchId(closestCell, hotCell);
0284         if ((verbosity_ % 10) > 0)
0285           edm::LogVerbatim("HBHEMuon") << "hcal 3X3  < " << h3x3 << "> ClosestCell <" << (HcalDetId)(closestCell)
0286                                        << "> hotCell id < " << hotCell << "> isHot" << isHot;
0287         if (hotCell != HcalDetId()) {
0288           subdet = HcalDetId(hotCell).subdet();
0289           ieta = HcalDetId(hotCell).ieta();
0290           iphi = HcalDetId(hotCell).iphi();
0291           zside = HcalDetId(hotCell).zside();
0292           hbhe = (std::abs(ieta) == 16);
0293           depthHE = hcons_->getMinDepth(1, 16, iphi, zside);
0294           std::vector<std::pair<double, int> > ehdepth;
0295           spr::energyHCALCell(
0296               hotCell, calohh, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, tMinH_, tMaxH_, depthHE, debug);
0297           for (unsigned int i = 0; i < ehdepth.size(); ++i) {
0298             eHcalDepthHot[ehdepth[i].second - 1] = ehdepth[i].first;
0299             HcalSubdetector subdet0 = (hbhe) ? ((ehdepth[i].second >= depthHE) ? HcalEndcap : HcalBarrel) : subdet;
0300             HcalDetId hcid0(subdet0, ieta, iphi, ehdepth[i].second);
0301             double actL = activeLength(DetId(hcid0));
0302             activeHotL[ehdepth[i].second - 1] = actL;
0303             activeLengthHotTot += actL;
0304 #ifdef EDM_ML_DEBUG
0305             if ((verbosity_ % 10) > 0)
0306               edm::LogVerbatim("HBHEMuon") << hcid0 << " E " << ehdepth[i].first << " L " << actL;
0307 #endif
0308           }
0309         }
0310 #ifdef EDM_ML_DEBUG
0311         if ((verbosity_ % 10) > 0) {
0312           for (int k = 0; k < depthMax_; ++k)
0313             edm::LogVerbatim("HBHEMuon") << "Depth " << k << " E " << eHcalDepth[k] << ":" << eHcalDepthHot[k];
0314         }
0315 #endif
0316         matchedId.push_back(tmpmatch);
0317         ecal3x3Energy.push_back(eEcal);
0318         ecalDetId.push_back(isoCell.rawId());
0319         hcal1x1Energy.push_back(eHcal);
0320         hcalDetId.push_back(closestCell.rawId());
0321         for (int k = 0; k < depthMax_; ++k) {
0322           hcalDepthEnergy[k].push_back(eHcalDepth[k]);
0323           hcalDepthActiveLength[k].push_back(activeL[k]);
0324           hcalDepthEnergyHot[k].push_back(eHcalDepthHot[k]);
0325           hcalDepthActiveLengthHot[k].push_back(activeHotL[k]);
0326         }
0327         hcalHot.push_back(isHot);
0328         hcalActiveLengthHot.push_back(activeLengthHotTot);
0329       }
0330     }
0331   }
0332   for (unsigned int k = 0; k < hcalHot.size(); ++k) {
0333     ptGlob_ = ptGlob[k];
0334     etaGlob_ = etaGlob[k];
0335     phiGlob_ = phiGlob[k];
0336     pMuon_ = pMuon[k];
0337     ecal3x3Energy_ = ecal3x3Energy[k];
0338     hcal1x1Energy_ = hcal1x1Energy[k];
0339     ecalDetId_ = ecalDetId[k];
0340     hcalDetId_ = hcalDetId[k];
0341     hcalHot_ = hcalHot[k];
0342     matchedId_ = matchedId[k];
0343     for (int i = 0; i < depthMax_; ++i) {
0344       hcalDepthEnergy_[i] = hcalDepthEnergy[k][i];
0345       hcalDepthActiveLength_[i] = hcalDepthActiveLength[k][i];
0346       hcalDepthEnergyHot_[i] = hcalDepthEnergyHot[k][i];
0347       hcalDepthActiveLengthHot_[i] = hcalDepthActiveLengthHot[k][i];
0348     }
0349     hcalActiveLength_ = hcalActiveLength[k];
0350     hcalActiveLengthHot_ = hcalActiveLengthHot[k];
0351     tree_->Fill();
0352   }
0353 }
0354 
0355 void HcalHBHEMuonSimAnalyzer::beginJob() {
0356   edm::Service<TFileService> fs;
0357   tree_ = fs->make<TTree>("TREE", "TREE");
0358   tree_->Branch("Run_No", &runNumber_);
0359   tree_->Branch("Event_No", &eventNumber_);
0360   tree_->Branch("LumiNumber", &lumiNumber_);
0361   tree_->Branch("BXNumber", &bxNumber_);
0362   tree_->Branch("pt_of_muon", &ptGlob_);
0363   tree_->Branch("eta_of_muon", &etaGlob_);
0364   tree_->Branch("phi_of_muon", &phiGlob_);
0365   tree_->Branch("p_of_muon", &pMuon_);
0366   tree_->Branch("matchedId", &matchedId_);
0367 
0368   tree_->Branch("ecal_3x3", &ecal3x3Energy_);
0369   tree_->Branch("ecal_detID", &ecalDetId_);
0370   tree_->Branch("hcal_1x1", &hcal1x1Energy_);
0371   tree_->Branch("hcal_detID", &hcalDetId_);
0372   tree_->Branch("hcal_cellHot", &hcalHot_);
0373   tree_->Branch("activeLength", &hcalActiveLength_);
0374   tree_->Branch("activeLengthHot", &hcalActiveLengthHot_);
0375   char name[100];
0376   for (int k = 0; k < maxDepth_; ++k) {
0377     sprintf(name, "hcal_edepth%d", (k + 1));
0378     tree_->Branch(name, &hcalDepthEnergy_[k]);
0379     sprintf(name, "hcal_activeL%d", (k + 1));
0380     tree_->Branch(name, &hcalDepthActiveLength_[k]);
0381     sprintf(name, "hcal_edepthHot%d", (k + 1));
0382     tree_->Branch(name, &hcalDepthEnergyHot_[k]);
0383     sprintf(name, "hcal_activeHotL%d", (k + 1));
0384     tree_->Branch(name, &hcalDepthActiveLength_[k]);
0385   }
0386 }
0387 
0388 void HcalHBHEMuonSimAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
0389   hcons_ = &iSetup.getData(tok_ddrec_);
0390   actHB_.clear();
0391   actHE_.clear();
0392   actHB_ = hcons_->getThickActive(0);
0393   actHE_ = hcons_->getThickActive(1);
0394 }
0395 
0396 void HcalHBHEMuonSimAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0397   edm::ParameterSetDescription desc;
0398   desc.add<std::string>("ModuleLabel", "g4SimHits");
0399   desc.add<std::string>("EBCollection", "EcalHitsEB");
0400   desc.add<std::string>("EECollection", "EcalHitsEE");
0401   desc.add<std::string>("HCCollection", "HcalHits");
0402   desc.addUntracked<int>("Verbosity", 0);
0403   desc.addUntracked<int>("MaxDepth", 7);
0404   desc.addUntracked<double>("EtaMax", 3.0);
0405   desc.addUntracked<double>("TimeMinCutECAL", -500.);
0406   desc.addUntracked<double>("TimeMaxCutECAL", 500.);
0407   desc.addUntracked<double>("TimeMinCutHCAL", -500.);
0408   desc.addUntracked<double>("TimeMaxCutHCAL", 500.);
0409   descriptions.add("hcalHBHEMuonSim", desc);
0410 }
0411 
0412 void HcalHBHEMuonSimAnalyzer::clearVectors() {
0413   ///clearing vectots
0414   runNumber_ = -99999;
0415   eventNumber_ = -99999;
0416   lumiNumber_ = -99999;
0417   bxNumber_ = -99999;
0418 }
0419 
0420 unsigned int HcalHBHEMuonSimAnalyzer::matchId(const HcalDetId& id1, const HcalDetId& id2) {
0421   HcalDetId kd1(id1.subdet(), id1.ieta(), id1.iphi(), 1);
0422   HcalDetId kd2(id2.subdet(), id2.ieta(), id2.iphi(), 1);
0423   unsigned int match = ((kd1 == kd2) ? 1 : 0);
0424   return match;
0425 }
0426 
0427 double HcalHBHEMuonSimAnalyzer::activeLength(const DetId& id_) {
0428   HcalDetId id(id_);
0429   int ieta = id.ietaAbs();
0430   int depth = id.depth();
0431   double lx(0);
0432   if (id.subdet() == HcalBarrel) {
0433     for (unsigned int i = 0; i < actHB_.size(); ++i) {
0434       if (ieta == actHB_[i].ieta && depth == actHB_[i].depth) {
0435         lx = actHB_[i].thick;
0436         break;
0437       }
0438     }
0439   } else {
0440     for (unsigned int i = 0; i < actHE_.size(); ++i) {
0441       if (ieta == actHE_[i].ieta && depth == actHE_[i].depth) {
0442         lx = actHE_[i].thick;
0443         break;
0444       }
0445     }
0446   }
0447   return lx;
0448 }
0449 
0450 //define this as a plug-in
0451 DEFINE_FWK_MODULE(HcalHBHEMuonSimAnalyzer);