[5d2481f] | 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 |
|
---|
| 20 | /** \class PhotonConversions
|
---|
| 21 | *
|
---|
| 22 | *
|
---|
| 23 | * Converts photons into e+ e- pairs according to mass ditribution in the detector.
|
---|
| 24 | *
|
---|
| 25 | * \author M. Selvaggi - UCL, Louvain-la-Neuve
|
---|
| 26 | *
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | #include "modules/PhotonConversions.h"
|
---|
| 30 |
|
---|
| 31 | #include "classes/DelphesClasses.h"
|
---|
| 32 | #include "classes/DelphesFactory.h"
|
---|
| 33 | #include "classes/DelphesCylindricalFormula.h"
|
---|
| 34 |
|
---|
| 35 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
| 36 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 37 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
| 38 |
|
---|
| 39 | #include "TMath.h"
|
---|
| 40 | #include "TF1.h"
|
---|
| 41 | #include "TString.h"
|
---|
| 42 | #include "TFormula.h"
|
---|
| 43 | #include "TRandom3.h"
|
---|
| 44 | #include "TObjArray.h"
|
---|
| 45 | #include "TDatabasePDG.h"
|
---|
| 46 | #include "TLorentzVector.h"
|
---|
| 47 | #include "TVector3.h"
|
---|
| 48 |
|
---|
| 49 | #include <algorithm>
|
---|
| 50 | #include <stdexcept>
|
---|
| 51 | #include <iostream>
|
---|
| 52 | #include <sstream>
|
---|
| 53 |
|
---|
| 54 | using namespace std;
|
---|
| 55 |
|
---|
| 56 | //------------------------------------------------------------------------------
|
---|
| 57 |
|
---|
| 58 | PhotonConversions::PhotonConversions() :
|
---|
| 59 | fDecayXsec(0), fConversionMap(0), fItInputArray(0)
|
---|
| 60 | {
|
---|
| 61 | fDecayXsec = new TF1;
|
---|
| 62 | fConversionMap = new DelphesCylindricalFormula;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | //------------------------------------------------------------------------------
|
---|
| 66 |
|
---|
| 67 | PhotonConversions::~PhotonConversions()
|
---|
| 68 | {
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | //------------------------------------------------------------------------------
|
---|
| 72 |
|
---|
| 73 | void PhotonConversions::Init()
|
---|
| 74 | {
|
---|
| 75 | fRadius = GetDouble("Radius", 1.0);
|
---|
| 76 | fRadius2 = fRadius*fRadius;
|
---|
| 77 |
|
---|
| 78 | fHalfLength = GetDouble("HalfLength", 3.0);
|
---|
| 79 |
|
---|
| 80 | fEtaMax = GetDouble("EtaMax", 5.0);
|
---|
| 81 | fEtaMin = GetDouble("EtaMin", 2.0);
|
---|
| 82 |
|
---|
| 83 | fStep = GetDouble("Step", 0.1); // in meters
|
---|
| 84 |
|
---|
| 85 | fConversionMap->Compile(GetString("ConversionMap", "0."));
|
---|
| 86 |
|
---|
| 87 | fDecayXsec->Compile("1 - 4/3*x*(1-x)");
|
---|
| 88 | fDecayXsec->SetRange(0.0,1.0);
|
---|
| 89 |
|
---|
| 90 | // import array with output from filter/classifier module
|
---|
| 91 |
|
---|
| 92 | fInputArray = ImportArray(GetString("InputArray", "Delphes/stableParticles"));
|
---|
| 93 | fItInputArray = fInputArray->MakeIterator();
|
---|
| 94 |
|
---|
| 95 | // create output arrays
|
---|
| 96 |
|
---|
| 97 | fOutputArray = ExportArray(GetString("OutputArray", "stableParticles"));
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | //------------------------------------------------------------------------------
|
---|
| 101 |
|
---|
| 102 | void PhotonConversions::Finish()
|
---|
| 103 | {
|
---|
| 104 | if(fItInputArray) delete fItInputArray;
|
---|
| 105 | if(fDecayXsec) delete fDecayXsec;
|
---|
| 106 | if(fConversionMap) delete fConversionMap;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | //------------------------------------------------------------------------------
|
---|
| 110 |
|
---|
| 111 | void PhotonConversions::Process()
|
---|
| 112 | {
|
---|
| 113 | Candidate *candidate, *mother, *ep, *em;
|
---|
| 114 | TLorentzVector candidatePosition, candidateMomentum;
|
---|
| 115 | TVector3 pos_i;
|
---|
| 116 | Double_t px, py, pz, pt, pt2, e, eta, phi, q;
|
---|
| 117 | Double_t x, y, z, t;
|
---|
| 118 | Double_t x_t, y_t, z_t, r_t;
|
---|
| 119 | Double_t x_i, y_i, z_i, r_i, phi_i;
|
---|
| 120 | Double_t dt, t1, t2, t3, t4;
|
---|
| 121 | Double_t tmp, discr, discr2;
|
---|
| 122 | Int_t nsteps, i;
|
---|
| 123 | Double_t rate, p_conv, x1, x2;
|
---|
| 124 | Bool_t converted;
|
---|
| 125 |
|
---|
| 126 | const Double_t c_light = 2.99792458E8;
|
---|
| 127 |
|
---|
| 128 | fItInputArray->Reset();
|
---|
| 129 | while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
|
---|
| 130 | {
|
---|
| 131 |
|
---|
| 132 | if(candidate->PID != 22) fOutputArray->Add(candidate);
|
---|
| 133 | else
|
---|
| 134 | {
|
---|
| 135 | candidatePosition = candidate->Position;
|
---|
| 136 | candidateMomentum = candidate->Momentum;
|
---|
| 137 | x = candidatePosition.X()*1.0E-3;
|
---|
| 138 | y = candidatePosition.Y()*1.0E-3;
|
---|
| 139 | z = candidatePosition.Z()*1.0E-3;
|
---|
| 140 | q = candidate->Charge;
|
---|
| 141 |
|
---|
| 142 | // check that particle position is inside the cylinder
|
---|
| 143 | if(TMath::Hypot(x, y) > fRadius || TMath::Abs(z) > fHalfLength)
|
---|
| 144 | {
|
---|
| 145 | continue;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | px = candidateMomentum.Px();
|
---|
| 149 | py = candidateMomentum.Py();
|
---|
| 150 | pz = candidateMomentum.Pz();
|
---|
| 151 | pt = candidateMomentum.Pt();
|
---|
| 152 | pt2 = candidateMomentum.Perp2();
|
---|
| 153 | eta = candidateMomentum.Eta();
|
---|
| 154 | phi = candidateMomentum.Phi();
|
---|
| 155 | e = candidateMomentum.E();
|
---|
| 156 |
|
---|
| 157 | if(eta < fEtaMin || eta > fEtaMax) continue;
|
---|
| 158 |
|
---|
| 159 | // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
|
---|
| 160 | tmp = px*y - py*x;
|
---|
| 161 | discr2 = pt2*fRadius2 - tmp*tmp;
|
---|
| 162 |
|
---|
| 163 | if(discr2 < 0.0)
|
---|
| 164 | {
|
---|
| 165 | // no solutions
|
---|
| 166 | continue;
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | tmp = px*x + py*y;
|
---|
| 170 | discr = TMath::Sqrt(discr2);
|
---|
| 171 | t1 = (-tmp + discr)/pt2;
|
---|
| 172 | t2 = (-tmp - discr)/pt2;
|
---|
| 173 | t = (t1 < 0.0) ? t2 : t1;
|
---|
| 174 |
|
---|
| 175 | z_t = z + pz*t;
|
---|
| 176 | if(TMath::Abs(z_t) > fHalfLength)
|
---|
| 177 | {
|
---|
| 178 | t3 = (+fHalfLength - z) / pz;
|
---|
| 179 | t4 = (-fHalfLength - z) / pz;
|
---|
| 180 | t = (t3 < 0.0) ? t4 : t3;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | // final position
|
---|
| 184 |
|
---|
| 185 | x_t = x + px*t;
|
---|
| 186 | y_t = y + py*t;
|
---|
| 187 | z_t = z + pz*t;
|
---|
| 188 |
|
---|
| 189 | r_t = TMath::Sqrt(x_t*x_t + y_t*y_t + z_t*z_t);
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 | // here starts conversion code
|
---|
| 193 | nsteps = Int_t(r_t/fStep);
|
---|
| 194 |
|
---|
| 195 | x_i = x;
|
---|
| 196 | y_i = y;
|
---|
| 197 | z_i = z;
|
---|
| 198 |
|
---|
| 199 | dt = t/nsteps;
|
---|
| 200 |
|
---|
| 201 | converted = false;
|
---|
| 202 |
|
---|
| 203 | for(i=0; i<nsteps; ++i)
|
---|
| 204 | {
|
---|
| 205 |
|
---|
| 206 | x_i += px*dt;
|
---|
| 207 | y_i += py*dt;
|
---|
| 208 | z_i += pz*dt;
|
---|
| 209 | pos_i.SetXYZ(x_i,y_i,z_i);
|
---|
| 210 |
|
---|
| 211 | //convert photon position into cylindrical coordinates, cylindrical r,phi,z !!
|
---|
| 212 |
|
---|
| 213 | r_i = TMath::Sqrt(x_i*x_i + y_i*y_i);
|
---|
| 214 | phi_i = pos_i.Phi();
|
---|
| 215 |
|
---|
| 216 | // read conversion rate/meter from card
|
---|
| 217 | rate = fConversionMap->Eval(r_i, phi_i, z_i);
|
---|
| 218 |
|
---|
| 219 | // convert into conversion probability
|
---|
| 220 | p_conv = 1 - TMath::Exp(-7.0/9.0*fStep*rate);
|
---|
| 221 |
|
---|
| 222 |
|
---|
| 223 | //case conversion occurs
|
---|
| 224 | if(gRandom->Uniform() < p_conv)
|
---|
| 225 | {
|
---|
| 226 | converted = true;
|
---|
| 227 |
|
---|
| 228 | // generate x1 and x2, the fraction of the photon energy taken resp. by e+ and e-
|
---|
| 229 | x1 = fDecayXsec->GetRandom();
|
---|
| 230 | x2 = 1 - x1;
|
---|
| 231 |
|
---|
| 232 | mother = candidate;
|
---|
| 233 | ep = static_cast<Candidate*>(candidate->Clone());
|
---|
| 234 | em = static_cast<Candidate*>(candidate->Clone());
|
---|
| 235 |
|
---|
| 236 | ep->Position.SetXYZT(x_i*1.0E3, y_i*1.0E3, z_i*1.0E3, candidatePosition.T() + nsteps*dt*e*1.0E3);
|
---|
| 237 | em->Position.SetXYZT(x_i*1.0E3, y_i*1.0E3, z_i*1.0E3, candidatePosition.T() + nsteps*dt*e*1.0E3);
|
---|
| 238 |
|
---|
| 239 | ep->Momentum.SetPtEtaPhiE(x1*pt, eta, phi, x1*e);
|
---|
| 240 | em->Momentum.SetPtEtaPhiE(x2*pt, eta, phi, x2*e);
|
---|
| 241 |
|
---|
| 242 | ep->PID = -11;
|
---|
| 243 | em->PID = 11;
|
---|
| 244 |
|
---|
| 245 | ep->Charge = 1.0;
|
---|
| 246 | em->Charge = -1.0;
|
---|
| 247 |
|
---|
| 248 | ep->IsFromConversion = 1;
|
---|
| 249 | em->IsFromConversion = 1;
|
---|
| 250 |
|
---|
| 251 | fOutputArray->Add(em);
|
---|
| 252 | fOutputArray->Add(ep);
|
---|
| 253 |
|
---|
| 254 | break;
|
---|
| 255 |
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | if(!converted) fOutputArray->Add(candidate);
|
---|
| 261 |
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | //------------------------------------------------------------------------------
|
---|
| 267 |
|
---|