Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-15 22:46:06

0001 #ifndef SimG4CMS_CaloTrkProcessing_H
0002 #define SimG4CMS_CaloTrkProcessing_H
0003 
0004 #include "SimG4Core/Notification/interface/Observer.h"
0005 #include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h"
0006 
0007 #include "CondFormats/GeometryObjects/interface/CaloSimulationParameters.h"
0008 
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include "G4VTouchable.hh"
0014 #include "G4Track.hh"
0015 #include "DataFormats/Math/interface/LorentzVector.h"
0016 
0017 #include <map>
0018 #include <vector>
0019 #include <string>
0020 #include <iostream>
0021 
0022 class BeginOfEvent;
0023 class G4LogicalVolume;
0024 class G4Step;
0025 class SimTrackManager;
0026 
0027 class CaloTrkProcessing : public SensitiveCaloDetector,
0028                           public Observer<const BeginOfEvent*>,
0029                           public Observer<const G4Step*> {
0030 public:
0031   CaloTrkProcessing(const std::string& aSDname,
0032                     const CaloSimulationParameters& csps,
0033                     const SensitiveDetectorCatalog& clg,
0034                     bool testBeam,
0035                     double eMin,
0036                     bool putHistory,
0037                     bool doFineCalo,
0038                     double eMinFine,
0039                     int addlevel,
0040                     const std::vector<std::string>& fineNames,
0041                     const std::vector<int>& fineLevels,
0042                     const std::vector<int>& useFines,
0043                     const SimTrackManager*);
0044   ~CaloTrkProcessing() override;
0045   void Initialize(G4HCofThisEvent*) override {}
0046   void clearHits() override {}
0047   bool ProcessHits(G4Step*, G4TouchableHistory*) override { return true; }
0048   uint32_t setDetUnitId(const G4Step* step) override { return 0; }
0049   void EndOfEvent(G4HCofThisEvent*) override {}
0050   void fillHits(edm::PCaloHitContainer&, const std::string&) override {}
0051 
0052 private:
0053   struct Detector {
0054     Detector() {}
0055     std::string name;
0056     G4LogicalVolume* lv;
0057     int level;
0058     std::vector<std::string> fromDets;
0059     std::vector<G4LogicalVolume*> fromDetL;
0060     std::vector<int> fromLevels;
0061   };
0062 
0063   void update(const BeginOfEvent* evt) override;
0064   void update(const G4Step*) override;
0065   int isItCalo(const G4VTouchable*, const std::vector<Detector>&);
0066   int isItInside(const G4VTouchable*, int, int);
0067 
0068   // Utilities to get detector levels during a step
0069   int detLevels(const G4VTouchable*) const;
0070   G4LogicalVolume* detLV(const G4VTouchable*, int) const;
0071   void detectorLevel(const G4VTouchable*, int&, int*, G4String*) const;
0072 
0073   const bool testBeam_;
0074   const double eMin_;
0075   const bool putHistory_;
0076   bool doFineCalo_;
0077   const double eMinFine_;
0078   const int addlevel_;
0079   int lastTrackID_;
0080   std::vector<Detector> detectors_, fineDetectors_;
0081 };
0082 
0083 #endif