File indexing completed on 2025-01-30 10:30:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef FLATHCALDEBUGTREEMAKERPROCESSOR_H
0012 #define FLATHCALDEBUGTREEMAKERPROCESSOR_H
0013
0014
0015 #include <cmath>
0016 #include <limits>
0017 #include <vector>
0018 #include <string>
0019 #include <cstdlib>
0020
0021 #include <TTree.h>
0022 #include <TFile.h>
0023 #include <TDirectory.h>
0024
0025 #include <JANA/JEventProcessor.h>
0026 #include <JANA/JEventProcessorSequentialRoot.h>
0027
0028 #include <edm4eic/Cluster.h>
0029 #include <edm4eic/TrackerHit.h>
0030 #include <edm4eic/ProtoCluster.h>
0031 #include <edm4eic/RawTrackerHit.h>
0032 #include <edm4eic/CalorimeterHit.h>
0033 #include <edm4eic/ReconstructedParticle.h>
0034 #include <edm4eic/MCRecoClusterParticleAssociation.h>
0035 #include <edm4hep/MCParticle.h>
0036 #include <edm4hep/SimCalorimeterHit.h>
0037
0038 #include <spdlog/spdlog.h>
0039 #include <services/log/Log_service.h>
0040 #include <services/rootfile/RootFile_service.h>
0041 #include <services/geometry/dd4hep/DD4hep_service.h>
0042
0043 #include "DD4hep/Objects.h"
0044 #include "DD4hep/Detector.h"
0045 #include "DD4hep/DetElement.h"
0046 #include "DD4hep/IDDescriptor.h"
0047 #include "DDG4/Geant4Data.h"
0048 #include "DDRec/Surface.h"
0049 #include "DDRec/SurfaceManager.h"
0050 #include "DDRec/CellIDPositionConverter.h"
0051
0052
0053
0054 class FlatHCalDebugTreeMakerProcessor: public JEventProcessorSequentialRoot {
0055
0056
0057 struct Config {
0058 std::string sPlugin;
0059 std::string sMCPars;
0060 std::string sGenPars;
0061 std::string sSimHits;
0062 std::string sRecHits;
0063 std::string sClusters;
0064 std::vector<std::string> sFields;
0065 } m_config = {
0066 "FlatHCalDebugTreeMaker",
0067 "MCParticles",
0068 "GeneratedParticles",
0069 "HcalBarrelHits",
0070 "HcalBarrelRecHits",
0071 "HcalBarrelClusters",
0072 {"eta", "phi"}
0073 };
0074
0075
0076 struct Const {
0077 size_t nFieldMax;
0078 } m_const = {6};
0079
0080 public:
0081
0082
0083 FlatHCalDebugTreeMakerProcessor() { SetTypeName(NAME_OF_THIS); }
0084
0085
0086 void InitWithGlobalRootLock() override;
0087 void ProcessSequential(const std::shared_ptr<const JEvent>& event) override;
0088 void FinishWithGlobalRootLock() override;
0089
0090 private:
0091
0092
0093 void InitializeDecoder();
0094 void InitializeTree();
0095 void ResetVariables();
0096 void FillMCVariables(const edm4hep::MCParticle* mc);
0097 void FillGenVariables(const edm4eic::ReconstructedParticle* gen);
0098 void FillCellVariables(const edm4eic::CalorimeterHit* cell);
0099 void FillClusterVariables(const edm4eic::Cluster* clust, const int64_t iClust);
0100 void GetCellIndices(const int64_t cellID, std::vector<short>& indices);
0101 double GetTime(const double tIn);
0102 double GetEta(const double theta);
0103
0104
0105 PrefetchT<edm4hep::MCParticle> m_mcPars = {this, m_config.sMCPars.data()};
0106 PrefetchT<edm4eic::ReconstructedParticle> m_genPars = {this, m_config.sGenPars.data()};
0107 PrefetchT<edm4hep::SimCalorimeterHit> m_simHits = {this, m_config.sSimHits.data()};
0108 PrefetchT<edm4eic::CalorimeterHit> m_recHits = {this, m_config.sRecHits.data()};
0109 PrefetchT<edm4eic::Cluster> m_clusters = {this, m_config.sClusters.data()};
0110
0111
0112 dd4hep::BitFieldCoder* m_decoder;
0113
0114
0115 TTree* m_outTree;
0116 TDirectory* m_pluginDir;
0117
0118
0119 uint64_t m_evtIndex;
0120 uint64_t m_nGen;
0121 uint64_t m_nMC;
0122 uint64_t m_nCells;
0123 uint64_t m_nClust;
0124
0125
0126 std::vector<int32_t> m_genType;
0127 std::vector<int32_t> m_genPDG;
0128 std::vector<float> m_genEne;
0129 std::vector<float> m_genPhi;
0130 std::vector<float> m_genEta;
0131 std::vector<float> m_genMass;
0132
0133
0134 std::vector<int32_t> m_mcGenStat;
0135 std::vector<int32_t> m_mcSimStat;
0136 std::vector<int32_t> m_mcPDG;
0137 std::vector<float> m_mcEne;
0138 std::vector<float> m_mcPhi;
0139 std::vector<float> m_mcEta;
0140 std::vector<float> m_mcMass;
0141 std::vector<float> m_mcStartVX;
0142 std::vector<float> m_mcStartVY;
0143 std::vector<float> m_mcStartVZ;
0144 std::vector<float> m_mcStopVX;
0145 std::vector<float> m_mcStopVY;
0146 std::vector<float> m_mcStopVZ;
0147 std::vector<float> m_mcTime;
0148
0149
0150 std::vector<uint64_t> m_cellID;
0151 std::vector<float> m_cellEne;
0152 std::vector<float> m_cellRX;
0153 std::vector<float> m_cellRY;
0154 std::vector<float> m_cellRZ;
0155 std::vector<float> m_cellTime;
0156 std::vector<short> m_cellIndexA;
0157 std::vector<short> m_cellIndexB;
0158 std::vector<short> m_cellIndexC;
0159 std::vector<short> m_cellIndexE;
0160 std::vector<short> m_cellIndexF;
0161 std::vector<short> m_cellIndexG;
0162
0163
0164 std::vector<uint64_t> m_clustIndex;
0165 std::vector<uint64_t> m_clustNCells;
0166 std::vector<float> m_clustEne;
0167 std::vector<float> m_clustEta;
0168 std::vector<float> m_clustPhi;
0169 std::vector<float> m_clustRX;
0170 std::vector<float> m_clustRY;
0171 std::vector<float> m_clustRZ;
0172 std::vector<float> m_clustTime;
0173
0174 };
0175
0176 #endif
0177
0178