ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/Validation/src/GenRelValMod.cc
(Generate patch)

Comparing UserCode/MitAna/Validation/src/GenRelValMod.cc (file contents):
Revision 1.4 by loizides, Fri Jul 25 12:41:41 2008 UTC vs.
Revision 1.5 by loizides, Fri Nov 21 20:12:26 2008 UTC

# Line 11 | Line 11 | ClassImp(mithep::GenRelValMod)
11   GenRelValMod::GenRelValMod(const char *name, const char *title) :
12    BaseMod(name,title),
13    fMCPartName(Names::gkMCPartBrn),
14 +  fFileName("macro_output.txt"),
15 +  fPrint(1),
16 +  fWrite(0),
17    fParticles(0),
18    ofile(0)
19   {
# Line 26 | Line 29 | void GenRelValMod::SlaveBegin()
29  
30    ReqBranch(fMCPartName,fParticles);
31  
32 <  ofile = new std::ofstream("macro_output.txt");
33 <  if (ofile->bad()) {
34 <    SendError(kAbortAnalysis, "SlaveBegin", "Can not open output file.");
32 >  if (fWrite) {
33 >    ofile = new std::ofstream(fFileName);
34 >    if (ofile->bad()) {
35 >      SendError(kAbortAnalysis, "SlaveBegin", "Can not open output file.");
36 >    }
37    }
38   }
39  
# Line 41 | Line 46 | void GenRelValMod::Process()
46  
47    for (UInt_t i=0; i<fParticles->GetEntries(); ++i) {
48      const MCParticle *p = fParticles->At(i);
49 +    if (!p->IsGenerated()) continue;
50 +
51      int I     = i+1;                                         // Particle index (starts at 1)
52      int KF    = p->PdgId();                                  // Pdg code
53      double p_x = p->Px(); if (fabs(p_x)<0.0005) p_x = 0.;    // Momenta.  We only compare the
# Line 52 | Line 59 | void GenRelValMod::Process()
59        const MCParticle *mother = p->Mother();
60        if(mother) {
61          for (UInt_t j=0; j<fParticles->GetEntries(); ++j) {
62 <          const  MCParticle *test = fParticles->At(j);
62 >          const MCParticle *test = fParticles->At(j);
63            if(test==mother) {
64              mind=j+1;
65              // hack to overcome ambiguity
# Line 64 | Line 71 | void GenRelValMod::Process()
71      }
72      char buf[1024];
73      sprintf(buf,"%5i%5i%5i%9.3f%9.3f%9.3f%9.3f\n",I,KF,mind,p_x,p_y,p_z,E);
74 <    *ofile<<buf;
74 >    if (fPrint) {
75 >      std::cout << buf;
76 >    }
77 >    if (fWrite)
78 >      *ofile<<buf;
79    }
80   }
81  
# Line 74 | Line 85 | void GenRelValMod::SlaveTerminate()
85    // Run finishing code on the computer (slave) that did the analysis. For this module, we close
86    // the text file.
87  
88 <  ofile->close();
89 <  delete ofile;
90 <  ofile=0;
88 >  if (fWrite) {
89 >    ofile->close();
90 >    delete ofile;
91 >    ofile=0;
92 >  }
93   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines