14 |
|
using namespace Pythia8; |
15 |
|
|
16 |
|
#include "UltraFastSim.h" |
17 |
< |
#include "Analysis.h" |
17 |
> |
#include "UFSDataStore.h" |
18 |
> |
|
19 |
> |
int poisson(double mean, Rndm *rndmPtr) { |
20 |
> |
static double oldMean = -1; |
21 |
> |
static double g; |
22 |
> |
if(mean != oldMean) { |
23 |
> |
oldMean = mean; |
24 |
> |
if(mean == 0) { |
25 |
> |
g = 0; |
26 |
> |
} |
27 |
> |
else { |
28 |
> |
g = exp(-mean); |
29 |
> |
} |
30 |
> |
} |
31 |
> |
double em = -1; |
32 |
> |
double t = 1; |
33 |
> |
do { |
34 |
> |
em++; |
35 |
> |
t *= rndmPtr->flat(); |
36 |
> |
} while(t > g); |
37 |
> |
return em; |
38 |
> |
} |
39 |
|
|
40 |
|
int main(int argc, char **argv) { |
41 |
|
// Generator. Process selection. LHC initialization. Histogram. |
47 |
|
{ |
48 |
|
cerr << "Command syntax: " << argv[0] << " ZHmmbb[...]" << " <nEvents> [RandomSeed] [meanPileupEventCount]" << endl; |
49 |
|
cerr << "or " << argv[0] << " ZHeebb[...]" << " <nEvents> [RandomSeed] [meanPileupEventCount]" << endl; |
50 |
+ |
cerr << "or " << argv[0] << " ZZmmbb[...]" << " <nEvents> [RandomSeed] [meanPileupEventCount]" << endl; |
51 |
|
cerr << "or " << argv[0] << " BBHmh[...] " << " <nEvents> [RandomSeed] [meanPileupEventCount]" << endl; |
52 |
|
cerr << "or " << argv[0] << " BBAmh[...] " << " <nEvents> [RandomSeed] [meanPileupEventCount]" << endl; |
53 |
|
cerr << "or " << argv[0] << " Zee[...] " << " <nEvents> [RandomSeed] [meanPileupEventCount]" << endl; |
176 |
|
pythia.readString("15:onIfAny = 13"); |
177 |
|
} |
178 |
|
} |
179 |
+ |
else if(strncmp(argv[1], "ZZmmbb", 6) == 0) |
180 |
+ |
{ |
181 |
+ |
pythia.readString("WeakDoubleBoson:ffbar2gmZgmZ = on"); |
182 |
+ |
pythia.readString("23:onMode = 0"); |
183 |
+ |
pythia.readString("23:onIfAny = 5 13"); // Let the Z decay to bQuarks or muons |
184 |
+ |
} |
185 |
|
else |
186 |
|
{ |
187 |
|
cerr << "Unknown process type " << argv[1] << " - aborting" << endl; |
205 |
|
|
206 |
|
// Ultra Fast Simulator |
207 |
|
|
208 |
< |
UltraFastSim ufs(rndmPtr); |
209 |
< |
Analysis analysis(argv[1], &ufs); |
208 |
> |
UltraFastSim ufs; |
209 |
> |
char jobName[256]; |
210 |
> |
sprintf(jobName, "%s-PU%3.3d-%4.4d", argv[1], meanPileupEventCount, runNumber); |
211 |
> |
UFSDataStore dataStore(jobName, &ufs); |
212 |
|
|
213 |
|
// Begin event loop |
214 |
|
for (int iEvent = 0; iEvent < nEvents; ) { |
221 |
|
// Add pileup |
222 |
|
|
223 |
|
int pileupEventCount = 0; |
224 |
< |
if(meanPileupEventCount > 0) pileupEventCount = meanPileupEventCount; // * rmdmPtr->pois(); (not available yet) |
224 |
> |
if(meanPileupEventCount > 0) pileupEventCount = poisson(meanPileupEventCount, rndmPtr); |
225 |
|
for (int puEvent = 0; puEvent < pileupEventCount; ) { |
226 |
|
if(!pileupPythia.next()) continue; |
227 |
+ |
double vx = rndmPtr->gauss()*2.; // Mean beam spread is 2 mm in x-y and 75 mm in z |
228 |
+ |
double vy = rndmPtr->gauss()*2.; |
229 |
+ |
double vz = rndmPtr->gauss()*75.; |
230 |
|
for(int i = 0; i < pileupPythia.event.size(); i++) { |
231 |
|
Particle& particle = pileupPythia.event[i]; |
232 |
+ |
particle.xProd(vx+particle.xProd()); |
233 |
+ |
particle.yProd(vy+particle.yProd()); |
234 |
+ |
particle.zProd(vz+particle.zProd()); |
235 |
|
if(particle.status() > 0) { |
236 |
|
if(particle.isVisible()) { |
237 |
|
if(particle.pT() > 0.5) { |
245 |
|
|
246 |
|
// Ultra fast simulation |
247 |
|
|
248 |
< |
if(!ufs.run(pythia.event)) |
248 |
> |
if(!ufs.run(pythia.event, rndmPtr)) |
249 |
|
{ |
250 |
|
cerr << "Ultra fast simulation failed - aborting" << endl; |
251 |
|
exit(1); |
252 |
|
} |
253 |
|
|
254 |
< |
cout << "Number of Gen Chrgd = " << ufs.chargedHadronList().size() << endl; |
219 |
< |
cout << "Number of Gen Neutr = " << ufs.neutralHadronList().size() << endl; |
220 |
< |
cout << "Number of Gen Phtns = " << ufs.photonList().size() << endl; |
221 |
< |
cout << "Number of Gen Elcns = " << ufs.electronList().size() << endl; |
222 |
< |
cout << "Number of Gen Muons = " << ufs.muonList().size() << endl; |
223 |
< |
cout << "Number of Gen Taus = " << ufs.genTauList().size() << endl; |
224 |
< |
cout << "Number of taus = " << ufs.tauList().size() << endl; |
225 |
< |
cout << "Number of c Quarks = " << ufs.cQuarkList().size() << endl; |
226 |
< |
cout << "Number of b Quarks = " << ufs.bQuarkList().size() << endl; |
227 |
< |
cout << "Number of Jets = " << ufs.jetList().size() << endl; |
228 |
< |
cout << "Number of bJets = " << ufs.bJetList().size() << endl; |
229 |
< |
cout << endl; |
230 |
< |
|
231 |
< |
// Run analysis |
254 |
> |
// Store data |
255 |
|
|
256 |
< |
if(!analysis.run()) |
256 |
> |
if(!dataStore.run()) |
257 |
|
{ |
258 |
< |
cerr << "Analysis failed - aborting" << endl; |
259 |
< |
exit(2); |
258 |
> |
cerr << "Failed to store data" << endl; |
259 |
> |
exit(3); |
260 |
|
} |
261 |
|
|
262 |
|
// End of event loop. Statistics. Histogram. Done. |