Changeset 2d494a6 in git for modules/PileUpMergerPythia8.cc
- Timestamp:
- Jan 26, 2015, 3:13:02 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 3db5282
- Parents:
- b62c2da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/PileUpMergerPythia8.cc
rb62c2da r2d494a6 29 29 #include "classes/DelphesClasses.h" 30 30 #include "classes/DelphesFactory.h" 31 #include "classes/Delphes Formula.h"31 #include "classes/DelphesTF2.h" 32 32 #include "classes/DelphesPileUpReader.h" 33 33 … … 56 56 57 57 PileUpMergerPythia8::PileUpMergerPythia8() : 58 fPythia(0), fItInputArray(0) 59 { 58 fFunction(0), fPythia(0), fItInputArray(0) 59 { 60 fFunction = new DelphesTF2; 60 61 } 61 62 … … 64 65 PileUpMergerPythia8::~PileUpMergerPythia8() 65 66 { 67 delete fFunction; 66 68 } 67 69 … … 72 74 const char *fileName; 73 75 76 fPileUpDistribution = GetInt("PileUpDistribution", 0); 77 74 78 fMeanPileUp = GetDouble("MeanPileUp", 10); 75 fZVertexSpread = GetDouble("ZVertexSpread", 0.05)*1.0E3; 79 80 fZVertexSpread = GetDouble("ZVertexSpread", 0.15); 81 fTVertexSpread = GetDouble("TVertexSpread", 1.5E-09); 82 83 fInputBeamSpotX = GetDouble("InputBeamSpotX", 0.0); 84 fInputBeamSpotY = GetDouble("InputBeamSpotY", 0.0); 85 fOutputBeamSpotX = GetDouble("OutputBeamSpotX", 0.0); 86 fOutputBeamSpotY = GetDouble("OutputBeamSpotY", 0.0); 76 87 77 88 fPTMin = GetDouble("PTMin", 0.0); 89 90 fFunction->Compile(GetString("VertexDistributionFormula", "0.0")); 91 fFunction->SetRange(-fZVertexSpread, -fTVertexSpread, fZVertexSpread, fTVertexSpread); 78 92 79 93 fileName = GetString("ConfigFile", "MinBias.cmnd"); … … 86 100 87 101 // create output arrays 88 fOutputArray = ExportArray(GetString("OutputArray", "stableParticles")); 102 fParticleOutputArray = ExportArray(GetString("ParticleOutputArray", "stableParticles")); 103 fVertexOutputArray = ExportArray(GetString("VertexOutputArray", "vertices")); 89 104 } 90 105 … … 103 118 TParticlePDG *pdgParticle; 104 119 Int_t pid, status; 105 Float_t x, y, z, t ;120 Float_t x, y, z, t, vx, vy; 106 121 Float_t px, py, pz, e; 107 Double_t dz, dphi ;108 Int_t poisson, event, i;109 Candidate *candidate ;122 Double_t dz, dphi, dt; 123 Int_t numberOfEvents, event, numberOfParticles, i; 124 Candidate *candidate, *vertex; 110 125 DelphesFactory *factory; 111 126 127 const Double_t c_light = 2.99792458E8; 128 112 129 fItInputArray->Reset(); 130 131 // --- Deal with primary vertex first ------ 132 133 fFunction->GetRandom2(dz, dt); 134 135 dt *= c_light*1.0E3; // necessary in order to make t in mm/c 136 dz *= 1.0E3; // necessary in order to make z in mm 137 vx = 0.0; 138 vy = 0.0; 139 numberOfParticles = fInputArray->GetEntriesFast(); 113 140 while((candidate = static_cast<Candidate*>(fItInputArray->Next()))) 114 141 { 115 fOutputArray->Add(candidate); 142 vx += candidate->Position.X(); 143 vy += candidate->Position.Y(); 144 z = candidate->Position.Z(); 145 t = candidate->Position.T(); 146 candidate->Position.SetZ(z + dz); 147 candidate->Position.SetT(t + dt); 148 fParticleOutputArray->Add(candidate); 149 } 150 151 if(numberOfParticles > 0) 152 { 153 vx /= numberOfParticles; 154 vy /= numberOfParticles; 116 155 } 117 156 118 157 factory = GetFactory(); 119 158 120 poisson = gRandom->Poisson(fMeanPileUp); 121 122 for(event = 0; event < poisson; ++event) 159 vertex = factory->NewCandidate(); 160 vertex->Position.SetXYZT(vx, vy, dz, dt); 161 fVertexOutputArray->Add(vertex); 162 163 // --- Then with pile-up vertices ------ 164 165 switch(fPileUpDistribution) 166 { 167 case 0: 168 numberOfEvents = gRandom->Poisson(fMeanPileUp); 169 break; 170 case 1: 171 numberOfEvents = gRandom->Integer(2*fMeanPileUp + 1); 172 break; 173 default: 174 numberOfEvents = gRandom->Poisson(fMeanPileUp); 175 break; 176 } 177 178 for(event = 0; event < numberOfEvents; ++event) 123 179 { 124 180 while(!fPythia->next()); 125 181 126 dz = gRandom->Gaus(0.0, fZVertexSpread); 182 // --- Pile-up vertex smearing 183 184 fFunction->GetRandom2(dz, dt); 185 186 dt *= c_light*1.0E3; // necessary in order to make t in mm/c 187 dz *= 1.0E3; // necessary in order to make z in mm 188 127 189 dphi = gRandom->Uniform(-TMath::Pi(), TMath::Pi()); 128 190 129 for(i = 1; i < fPythia->event.size(); ++i) 191 vx = 0.0; 192 vy = 0.0; 193 numberOfParticles = fPythia->event.size(); 194 for(i = 1; i < numberOfParticles; ++i) 130 195 { 131 196 Pythia8::Particle &particle = fPythia->event[i]; … … 143 208 candidate->PID = pid; 144 209 145 candidate->Status = status;210 candidate->Status = 1; 146 211 147 212 pdgParticle = pdg->GetParticle(pid); … … 154 219 candidate->Momentum.RotateZ(dphi); 155 220 156 candidate->Position.SetXYZT(x, y, z + dz, t); 221 x -= fInputBeamSpotX; 222 y -= fInputBeamSpotY; 223 candidate->Position.SetXYZT(x, y, z + dz, t + dt); 157 224 candidate->Position.RotateZ(dphi); 158 159 fOutputArray->Add(candidate); 225 candidate->Position += TLorentzVector(fOutputBeamSpotX, fOutputBeamSpotY, 0.0, 0.0); 226 227 vx += candidate->Position.X(); 228 vy += candidate->Position.Y(); 229 230 fParticleOutputArray->Add(candidate); 160 231 } 161 } 162 } 163 164 //------------------------------------------------------------------------------ 165 232 233 if(numberOfParticles > 0) 234 { 235 vx /= numberOfParticles; 236 vy /= numberOfParticles; 237 } 238 239 vertex = factory->NewCandidate(); 240 vertex->Position.SetXYZT(vx, vy, dz, dt); 241 vertex->IsPU = 1; 242 243 fVertexOutputArray->Add(vertex); 244 } 245 } 246 247 //------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.