ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/dasu/UltraFastSim/generateData.cc
(Generate patch)

Comparing UserCode/dasu/UltraFastSim/generateData.cc (file contents):
Revision 1.10 by dasu, Fri Feb 18 05:06:02 2011 UTC vs.
Revision 1.16 by dasu, Wed Mar 2 21:57:09 2011 UTC

# Line 13 | Line 13 | using namespace std;
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"
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.
# Line 172 | Line 189 | int main(int argc, char **argv) {
189        }
190    }
191  
175  string name(argv[1]);
176  name += ".root";
177  TFile *outFile = TFile::Open(name.c_str(), "recreate");
178
192    // Initialize pythia
193  
194    pythia.init( 2212, 2212, 14000.);
# Line 192 | Line 205 | int main(int argc, char **argv) {
205  
206    // Ultra Fast Simulator
207  
208 <  UltraFastSim ufs(rndmPtr);
209 <  bbHAnalysis bbH(outFile, &pythia, &ufs, true);
210 <  ZHAnalysis ZH(outFile, &pythia, &ufs, true);
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; ) {
# Line 207 | Line 221 | int main(int argc, char **argv) {
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) {
# Line 225 | Line 245 | int main(int argc, char **argv) {
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
254 >    // Store data
255  
256 <    if(!bbH.run())
256 >    if(!dataStore.run())
257        {
258 <        cerr << "bbH Analysis failed - aborting" << endl;
239 <        exit(2);
240 <      }
241 <
242 <    // Run ZHAnalysis
243 <
244 <    if(!ZH.run())
245 <      {
246 <        cerr << "ZH Analysis failed - aborting" << endl;
258 >        cerr << "Failed to store data" << endl;
259          exit(3);
260        }
261  
# Line 259 | Line 271 | int main(int argc, char **argv) {
271    pythia.statistics();
272    pileupPythia.statistics();
273  
262  bbH.end();
263  ZH.end();
264
265  outFile->cd();
266  outFile->Write();
267  outFile->Close();
268
274    return 0;
275  
276   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines