Fork me on GitHub

source: git/modules/EICPIDDetector.cc@ f4900ab

Last change on this file since f4900ab was f4900ab, checked in by Stephen Sekula <sekula@…>, 4 years ago

Implement EIC dualRICH code

  • Property mode set to 100644
File size: 7.8 KB
Line 
1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/** \class EICPIDDetector
20 *
21 * Applies complex photon Id. Reconstructed photon candidtes are first separated into matched and non-matched to gen particles.
22 * Non-matched pass the "fake" efficiency. Matched photons get further splitted into isolated and non-isolated (user can choose criterion for isolation)
23 * Isolated photons pass the "prompt" efficiency while the non-isolated pass the "non-prompt" efficiency
24 *
25 * \author M. Selvaggi CERN
26 *
27 */
28
29#include "modules/EICPIDDetector.h"
30
31#include "classes/DelphesClasses.h"
32#include "classes/DelphesFactory.h"
33#include "classes/DelphesFormula.h"
34
35#include "ExRootAnalysis/ExRootClassifier.h"
36#include "ExRootAnalysis/ExRootFilter.h"
37#include "ExRootAnalysis/ExRootResult.h"
38
39#include "TDatabasePDG.h"
40#include "TFormula.h"
41#include "TLorentzVector.h"
42#include "TMath.h"
43#include "TObjArray.h"
44#include "TRandom3.h"
45#include "TString.h"
46#include "Math/PdfFuncMathCore.h"
47#include "Math/ProbFuncMathCore.h"
48
49#include "pid/barrelDIRC/src/barrelDirc.h"
50#include "pid/quintRICH/src/CF4rich.h"
51#include "pid/mRICH/src/mRICH.h"
52#include "pid/tofBarrel/src/tofBarrel.h"
53#include "pid/dRICH/dualRICH.h"
54
55#include <algorithm>
56#include <iostream>
57#include <sstream>
58#include <stdexcept>
59
60using namespace std;
61
62//------------------------------------------------------------------------------
63
64EICPIDDetector::EICPIDDetector() :
65 fItInputArray(0)
66{
67}
68
69//------------------------------------------------------------------------------
70
71EICPIDDetector::~EICPIDDetector()
72{
73}
74
75//------------------------------------------------------------------------------
76
77void EICPIDDetector::Init()
78{
79
80 // import input arrays
81 fInputArray = ImportArray(GetString("InputArray", "ParticlePropagator/stableParticles"));
82 fItInputArray = fInputArray->MakeIterator();
83
84 // PID Pair to be assessed
85 ExRootConfParam param;
86 Int_t size;
87 param = GetParam("Hypotheses");
88 size = param.GetSize();
89
90 fHypo = static_cast<PID::type>(0);
91 if (size == 2) {
92 fPDG1 = abs(param[0].GetInt());
93 fPDG2 = abs(param[1].GetInt());
94
95 if (fPDG1 == 321) {
96 if (fPDG2 == 211) {
97 fHypo = PID::pi_k;
98 } else if (fPDG2 == 2212) {
99 fHypo = PID::k_p;
100 }
101 }
102
103 } else {
104 // Bad parameter - do something intelligent here.
105 std::cout << "Unable to retrieve Particle ID hypothesis pair." << std::endl;
106 }
107
108
109 fDetectorName = std::string(GetString("DetectorName", "barrelDirc"));
110
111 // Common PID Detector parameters
112 fTrackResolution = GetDouble("TrackResolution", 0.5); // mrad
113 fTimeResolution = GetDouble("TimeResolution", 0.1); //ns
114 fDetectorLength = GetDouble("DetectorLength", 1500); // mm
115 fetaLow = GetDouble("EtaLow", -8.0);
116 fetaHigh = GetDouble("EtaHigh", 8.0);
117
118 // Barrel DIRC Parameters
119 fQE = GetDouble("QuantumEfficiency", 0.0); // 0 = 27% for barrelDirc, 1 = 22% for barrelDirc
120
121 // mRICH Parameters
122 fPixelSize = GetDouble("PixelSize", 1.0); // 1.0 mm
123
124 // CF4RICH Parameters
125
126
127 // Build the detector object
128 if (fDetectorName == "barrelDirc") {
129 fPIDDetector = new barrelDirc(fTrackResolution,fTimeResolution,fQE,fetaLow,fetaHigh);
130 }
131 else if (fDetectorName == "mRICH") {
132 fPIDDetector = new mRICH(fTrackResolution,fTimeResolution, fPixelSize, fetaLow, fetaHigh);
133 //fPIDDetector = new mRICH(0.00175, 1, 3);
134 }
135 else if (fDetectorName == "CF4rich") {
136 fPIDDetector = new CF4rich(fDetectorLength/10, fetaLow, fetaHigh, fPixelSize, fTrackResolution);
137 }
138 else if (fDetectorName == "tofBarrel") {
139 fPIDDetector = new tofBarrel(100, fetaLow, fetaHigh, 10);
140 }
141 else if (fDetectorName == "dualRICH_aerogel") {
142 fPIDDetector = new dualRICH_aerogel();
143 }
144 else if (fDetectorName == "dualRICH_C2F6") {
145 fPIDDetector = new dualRICH_C2F6();
146 } else {
147 std::cout << "No valid EIC PID Detector technology was specified!" << std::endl;
148 assert(1==0);
149 }
150
151 fPIDDetector->description();
152
153 // create output array
154 fOutputArray = ExportArray(GetString("OutputArray", "tracks"));
155}
156
157//------------------------------------------------------------------------------
158
159void EICPIDDetector::Finish()
160{
161 if(fItInputArray) delete fItInputArray;
162 if(fPIDDetector) delete fPIDDetector;
163}
164
165//------------------------------------------------------------------------------
166
167void EICPIDDetector::Process()
168{
169 Candidate *candidate, *mother;
170 Double_t pt, eta;
171 Int_t true_id;
172
173 fItInputArray->Reset();
174 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
175 {
176
177 mother = candidate;
178 candidate = static_cast<Candidate *>(candidate->Clone());
179 candidate->AddCandidate(mother);
180
181 const TLorentzVector &candidateMomentum = candidate->Momentum;
182 eta = candidateMomentum.Eta();
183 pt = candidateMomentum.Pt();
184 true_id = candidate->PID;
185
186 Float_t p = pt * TMath::CosH(eta);
187
188 // Obtain the number of sigma separation for a given hypothesis pair for this track
189 Bool_t valid = fPIDDetector->valid(eta, p);
190
191 Double_t nsigma = -1.0;
192
193 if (valid) {
194 nsigma = fPIDDetector->numSigma(eta, p, fHypo);
195
196 // Assume that Nsigma_Hypo1 = N_sigma_Hypo2, so that Nsigma_HypoX = Nsigma/Sqrt(2).
197 nsigma = nsigma/TMath::Sqrt(2.0);
198 //std::cout << std::scientific << "EICDetector nsigma = " << nsigma << std::fixed << std::endl;
199 }
200
201
202
203 int pid_reco = 0;
204 int pid_true = TMath::Abs(candidate->PID);
205 if (!valid || TMath::IsNaN(nsigma) || !TMath::Finite(nsigma)) {
206 pid_reco = 0;
207 } else {
208
209
210 // Use accept/reject to assign a PID-detector identity to this track
211 Double_t probability = 0.0;
212 if (TMath::Abs(true_id) == fPDG1) {
213 // We are selecting FOR this hypothesis, so use the core of a Gaussian as the probability
214 probability = 1.0 - ROOT::Math::gaussian_pdf(nsigma);
215 } else if (TMath::Abs(true_id) == fPDG2) {
216 // We are trying to reject these using this detector, so the one-sided tail of the Gaussian probability applies
217 probability = 1.0 - ROOT::Math::normal_cdf(nsigma);
218 }
219
220 // std::cout << "True ID = " << true_id << ", |eta| = " << TMath::Abs(eta) << ", p = " << pt*TMath::CosH(eta)
221 // <<", nsigma = " << std::scientific << nsigma << ", probability = " << std::fixed
222 // << std::scientific << probability << std::fixed << std::endl;
223
224 // Create a PID value that is the concatenation of two 16-bit numbers.
225 // The lowest 16 bits are the reconstructed PID
226 // The highest 16 bits are the truth PID
227 // Bitmasking and shifting can be used to get these separately.
228 // For example, do the following to get the ... :
229 //
230 // * True PID: (Track.PID & 0xffff0000) >> 16) (Mask-select the highest 16 bits and shift right by 16 bits.
231 // * Reco PID: (Track.PID & 0xffff) (Mask-select the lowest 16 bits)
232 if (gRandom->Uniform(0, 1) < probability) {
233 candidate = static_cast<Candidate *>(candidate->Clone());
234 pid_reco = TMath::Abs(fPDG1);
235 pid_true = TMath::Abs(candidate->PID);
236 } else {
237 pid_reco = TMath::Abs(fPDG2);
238 pid_true = TMath::Abs(candidate->PID);
239 }
240 }
241 int pid_all = pid_reco + (pid_true << 16);
242 candidate->PID = pid_all;
243 fOutputArray->Add(candidate);
244 }
245}
Note: See TracBrowser for help on using the repository browser.