er  dev
ERTelescopePID.h
1 /********************************************************************************
2  * Copyright (C) Joint Institute for Nuclear Research *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef ERTelescopePID_H
10 #define ERTelescopePID_H
11 
12 #include <limits>
13 #include <map>
14 #include <list>
15 
16 #include "TClonesArray.h"
17 #include "TString.h"
18 #include "TVector3.h"
19 
20 #include "ERTask.h"
21 #include "ERDigi.h"
22 #include "ERTelescopeTrack.h"
23 #include "ERTelescopeParticle.h"
24 #include "ERTelescopeSetup.h"
25 
26 class G4ParticleDefinition;
27 
34 class ERTelescopePID : public ERTask {
35  using PDG = Int_t;
36 public:
37  enum EdepAccountingStrategy {EdepFromXChannel, EdepFromYChannel, AverageEdep, SummarizedEdep};
39  const PDG fPDG = -1;
40  const TString fDeStation;
41  const std::list<TString> fEStations;
42  const Double_t fNormalizedThickness = 0.002;
43  const std::vector<TString> stations_to_use_em_calculator_for_de_e_;
44  const std::vector<TString> stations_to_use_em_calculator_for_kinetic_energy_;
45  ParticleDescription() = default;
46  ParticleDescription(PDG pdg, const TString& deStation,
47  const std::list<TString>& eStations, Double_t normalizedThickness,
48  const std::vector<TString>& stations_to_use_em_calculator_for_de_e,
49  const std::vector<TString>& stations_to_use_em_calculator_for_kinetic_energy)
50  : fPDG(pdg), fDeStation(deStation), fEStations(eStations),
51  fNormalizedThickness(normalizedThickness),
52  stations_to_use_em_calculator_for_de_e_(stations_to_use_em_calculator_for_de_e),
53  stations_to_use_em_calculator_for_kinetic_energy_(stations_to_use_em_calculator_for_kinetic_energy) {}
54  };
55  struct DigiOnTrack {
56  const TString fBranch;
57  ERDigi* fDigi = nullptr;
58  const Double_t fSensetiveThickness = 0.;
59  DigiOnTrack() = default;
60  DigiOnTrack(const TString& branch, ERDigi* digi, Double_t sensetiveThickness) :
61  fBranch(branch), fDigi(digi), fSensetiveThickness(sensetiveThickness) {}
62  bool IsFound() const { return fDigi != nullptr; }
63  };
64 
70  ERTelescopePID(Int_t verbose);
72  ~ERTelescopePID() = default;
73  /* Modifiers */
74  void SetParticle(const TString& trackBranchName, const PDG pdg,
75  const TString& deStation = "", const TString& eStation = "",
76  Double_t deNormalizedThickness = 0.002,
77  const std::vector<TString>& stations_to_use_em_calculator_for_de_e = {},
78  const std::vector<TString>& stations_to_use_em_calculator_for_kinetic_energy = {});
79  void SetParticle(const TString& trackBranchName, const PDG pdg,
80  const TString& deStation = "", const std::list<TString>& eStations = {},
81  Double_t deNormalizedThickness = 0.002,
82  const std::vector<TString>& stations_to_use_em_calculator_for_de_e = {},
83  const std::vector<TString>& stations_to_use_em_calculator_for_kinetic_energy = {});
84  void SetEdepAccountingStrategy(
85  const TString& station, EdepAccountingStrategy strategy) {
86  fEdepAccountingStrategies[station] = strategy;
87  }
88 public:
92  virtual InitStatus Init();
96  virtual void Exec(Option_t* opt);
98  virtual void Reset();
99 protected:
100  //Paramaters
102  std::map<TString, std::list<ParticleDescription>> fParticleDescriptions;
103  std::map<TString, EdepAccountingStrategy> fEdepAccountingStrategies;
104  //Input arrays
105  std::map<TString, TClonesArray*> fQTelescopeDigi;
106  std::map<TString, TClonesArray*> fQTelescopeTrack;
107  //Output arrays
108  std::map<TString, std::map<PDG, TClonesArray*> > fQTelescopeParticle;
109 protected:
110  TVector3 FindBackPropagationStartPoint(const ERTelescopeTrack& track);
111  std::pair<Double_t, Double_t> CalcEnergyDeposites (
112  const ERTelescopeTrack& track, const TVector3& startPoint,
113  const G4ParticleDefinition& particle, std::list<DigiOnTrack>& digisOnTrack,
114  const std::vector<TString>& stations_to_use_em_calculator_for_de_e,
115  const std::vector<TString>& stations_to_use_em_calculator_for_kinetic_energy);
116  std::map<TString, ERDigi*> FindDigisByNode(const TGeoNode& node, const TString& nodePath);
117  void FindEnergiesForDeEAnalysis(const TString& trackBranch,
118  const std::list<DigiOnTrack>& digisOnTrack,
119  const std::list<TString>& eStations,
120  const TString& deStation,
121  const Double_t normalizedThickness,
122  Double_t& edepInThickStation, Double_t& edepInThinStation,
123  Double_t& edepInThickStationCorrected, Double_t& edepInThinStationCorrected,
124  ERChannel& channelOfThinStation, ERChannel& channelOfThickStation);
125  Double_t ApplyEdepAccountingStrategy(const std::map<TString, ERDigi*>& digisByBranchName);
126  Double_t ApplyEdepAccountingStrategy(const std::list<DigiOnTrack>& digisOnTrack);
128  ERTelescopeParticle* AddParticle(const TLorentzVector& lvInteraction, Double_t kineticEnergy,
129  Double_t deadEloss, Double_t edepInThickStation, Double_t edepInThinStation,
130  Double_t edepInThickStationCorrected, Double_t edepInThinStationCorrected,
131  ERChannel channelOfThinStaion, ERChannel channelOfThickStation,
132  TClonesArray& col);
133  ClassDef(ERTelescopePID, 1)
134 };
135 #endif
Definition: ERDigi.h:15
virtual void Exec(Option_t *opt)
Defines the transformation actions for all input data (Digi) to output data (Track) for each event...
virtual void Reset()
Resets all output data.
ERTelescopeSetup * fQTelescopeSetup
access to ERTelescopeSetup class instance
virtual InitStatus Init()
Defines all input and output object colletions participates in track finding.
ERTelescopePID()
Default constructor.
ERTelescopeParticle * AddParticle(const TLorentzVector &lvInteraction, Double_t kineticEnergy, Double_t deadEloss, Double_t edepInThickStation, Double_t edepInThinStation, Double_t edepInThickStationCorrected, Double_t edepInThinStationCorrected, ERChannel channelOfThinStaion, ERChannel channelOfThickStation, TClonesArray &col)
Adds a ERTelescopeParticles to the output Collection.
~ERTelescopePID()=default
Destructor.
Base abstract class for all tasks in er.
Definition: ERTask.h:27