13 |
|
#include "Pythia.h" |
14 |
|
using namespace Pythia8; |
15 |
|
|
16 |
– |
#include "TROOT.h" |
17 |
– |
#include "TFile.h" |
18 |
– |
|
16 |
|
#include "UltraFastSim.h" |
17 |
< |
#include "bbHAnalysis.h" |
18 |
< |
//#include "ZHAnalysis.h" |
19 |
< |
#include "bbHAnalysis.cc" |
20 |
< |
//#include "ZHAnalysis.cc" |
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. |
189 |
|
} |
190 |
|
} |
191 |
|
|
177 |
– |
string name(argv[1]); |
178 |
– |
name += ".root"; |
179 |
– |
TFile *outFile = TFile::Open(name.c_str(), "recreate"); |
180 |
– |
|
192 |
|
// Initialize pythia |
193 |
|
|
194 |
|
pythia.init( 2212, 2212, 14000.); |
205 |
|
|
206 |
|
// Ultra Fast Simulator |
207 |
|
|
208 |
< |
UltraFastSim ufs(rndmPtr); |
209 |
< |
bbHAnalysis bbH(outFile, &pythia, &ufs, true); |
210 |
< |
//ZHAnalysis ZH; // outFile, &pythia, &ufs, true); |
211 |
< |
//ZH.BookTree(); |
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 |
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 |
< |
// Run bbHAnalysis |
244 |
< |
|
245 |
< |
if(!bbH.run()) |
246 |
< |
{ |
247 |
< |
cerr << "bbH Analysis failed - aborting" << endl; |
248 |
< |
exit(2); |
249 |
< |
} |
250 |
< |
|
251 |
< |
// Run ZHAnalysis |
254 |
> |
// Store data |
255 |
|
|
256 |
< |
/* if(!ZH.Run(&ufs)) |
256 |
> |
if(!dataStore.run()) |
257 |
|
{ |
258 |
< |
cerr << "ZH Analysis failed - aborting" << endl; |
258 |
> |
cerr << "Failed to store data" << endl; |
259 |
|
exit(3); |
260 |
|
} |
261 |
< |
*/ |
261 |
> |
|
262 |
|
// End of event loop. Statistics. Histogram. Done. |
263 |
|
|
264 |
|
if(!(iEvent % 100)) cout << "Processed event " << iEvent << endl; |
271 |
|
pythia.statistics(); |
272 |
|
pileupPythia.statistics(); |
273 |
|
|
271 |
– |
bbH.end(); |
272 |
– |
|
273 |
– |
outFile->cd(); |
274 |
– |
outFile->Write(); |
275 |
– |
outFile->Close(); |
276 |
– |
|
274 |
|
return 0; |
275 |
|
|
276 |
|
} |