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. |
182 |
|
pythia.readString("23:onMode = 0"); |
183 |
|
pythia.readString("23:onIfAny = 5 13"); // Let the Z decay to bQuarks or muons |
184 |
|
} |
185 |
+ |
else if(strncmp(argv[1], "ZZmmnn", 6) == 0) |
186 |
+ |
{ |
187 |
+ |
pythia.readString("WeakDoubleBoson:ffbar2gmZgmZ = on"); |
188 |
+ |
pythia.readString("23:onMode = 0"); |
189 |
+ |
pythia.readString("23:onIfAny = 13 12 14 16"); // Let the Z decay to muons or neutrinos |
190 |
+ |
} |
191 |
+ |
else if(strncmp(argv[1], "ZHmmXX", 6) == 0) |
192 |
+ |
{ |
193 |
+ |
pythia.readString("HiggsSM:ffbar2HZ = on"); |
194 |
+ |
pythia.readString("25:m0 = 120"); |
195 |
+ |
pythia.readString("25:mayDecay = false"); // Higgs does not decay -- becomes invisible |
196 |
+ |
pythia.readString("25:isVisible = false"); |
197 |
+ |
pythia.readString("23:onMode = 0"); // Z decays to mu+,mu- only (for trigger) |
198 |
+ |
pythia.readString("23:onIfAny = 13"); |
199 |
+ |
} |
200 |
|
else |
201 |
|
{ |
202 |
|
cerr << "Unknown process type " << argv[1] << " - aborting" << endl; |
204 |
|
} |
205 |
|
} |
206 |
|
|
177 |
– |
string name(argv[1]); |
178 |
– |
name += ".root"; |
179 |
– |
TFile *outFile = TFile::Open(name.c_str(), "recreate"); |
180 |
– |
|
207 |
|
// Initialize pythia |
208 |
|
|
209 |
|
pythia.init( 2212, 2212, 14000.); |
220 |
|
|
221 |
|
// Ultra Fast Simulator |
222 |
|
|
223 |
< |
UltraFastSim ufs(rndmPtr); |
224 |
< |
bbHAnalysis bbH(outFile, &pythia, &ufs, true); |
225 |
< |
//ZHAnalysis ZH; // outFile, &pythia, &ufs, true); |
226 |
< |
//ZH.BookTree(); |
223 |
> |
UltraFastSim ufs; |
224 |
> |
char jobName[256]; |
225 |
> |
sprintf(jobName, "%s-PU%3.3d-%4.4d", argv[1], meanPileupEventCount, runNumber); |
226 |
> |
UFSDataStore dataStore(jobName, &ufs); |
227 |
|
|
228 |
|
// Begin event loop |
229 |
|
for (int iEvent = 0; iEvent < nEvents; ) { |
236 |
|
// Add pileup |
237 |
|
|
238 |
|
int pileupEventCount = 0; |
239 |
< |
if(meanPileupEventCount > 0) pileupEventCount = meanPileupEventCount; // * rmdmPtr->pois(); (not available yet) |
239 |
> |
if(meanPileupEventCount > 0) pileupEventCount = poisson(meanPileupEventCount, rndmPtr); |
240 |
|
for (int puEvent = 0; puEvent < pileupEventCount; ) { |
241 |
|
if(!pileupPythia.next()) continue; |
242 |
|
double vx = rndmPtr->gauss()*2.; // Mean beam spread is 2 mm in x-y and 75 mm in z |
260 |
|
|
261 |
|
// Ultra fast simulation |
262 |
|
|
263 |
< |
if(!ufs.run(pythia.event)) |
263 |
> |
if(!ufs.run(pythia.event, rndmPtr)) |
264 |
|
{ |
265 |
|
cerr << "Ultra fast simulation failed - aborting" << endl; |
266 |
|
exit(1); |
267 |
|
} |
268 |
|
|
269 |
< |
// Run bbHAnalysis |
269 |
> |
// Store data |
270 |
|
|
271 |
< |
if(!bbH.run()) |
271 |
> |
if(!dataStore.run()) |
272 |
|
{ |
273 |
< |
cerr << "bbH Analysis failed - aborting" << endl; |
248 |
< |
exit(2); |
249 |
< |
} |
250 |
< |
|
251 |
< |
// Run ZHAnalysis |
252 |
< |
|
253 |
< |
/* if(!ZH.Run(&ufs)) |
254 |
< |
{ |
255 |
< |
cerr << "ZH Analysis failed - aborting" << endl; |
273 |
> |
cerr << "Failed to store data" << endl; |
274 |
|
exit(3); |
275 |
|
} |
276 |
< |
*/ |
276 |
> |
|
277 |
|
// End of event loop. Statistics. Histogram. Done. |
278 |
|
|
279 |
|
if(!(iEvent % 100)) cout << "Processed event " << iEvent << endl; |
286 |
|
pythia.statistics(); |
287 |
|
pileupPythia.statistics(); |
288 |
|
|
271 |
– |
bbH.end(); |
272 |
– |
|
273 |
– |
outFile->cd(); |
274 |
– |
outFile->Write(); |
275 |
– |
outFile->Close(); |
276 |
– |
|
289 |
|
return 0; |
290 |
|
|
291 |
|
} |