Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/PileUpMerger.cc

    r3e2bb2b r2d494a6  
    115115  TDatabasePDG *pdg = TDatabasePDG::Instance();
    116116  TParticlePDG *pdgParticle;
    117   Int_t pid, nch, nvtx = -1;
     117  Int_t pid;
    118118  Float_t x, y, z, t, vx, vy;
    119   Float_t px, py, pz, e, pt;
    120   Double_t dz, dphi, dt, sumpt2, dz0, dt0;
     119  Float_t px, py, pz, e;
     120  Double_t dz, dphi, dt;
    121121  Int_t numberOfEvents, event, numberOfParticles;
    122122  Long64_t allEntries, entry;
     
    132132  fFunction->GetRandom2(dz, dt);
    133133
    134   dz0 = -1.0e6;
    135   dt0 = -1.0e6;
    136 
    137134  dt *= c_light*1.0E3; // necessary in order to make t in mm/c
    138135  dz *= 1.0E3; // necessary in order to make z in mm
    139 
    140   //cout<<dz<<","<<dt<<endl;
    141 
    142136  vx = 0.0;
    143137  vy = 0.0;
    144 
    145138  numberOfParticles = fInputArray->GetEntriesFast();
    146   nch = 0;
    147   sumpt2 = 0.0;
    148 
    149   factory = GetFactory();
    150   vertex = factory->NewCandidate();
    151 
    152139  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    153140  {
     
    156143    z = candidate->Position.Z();
    157144    t = candidate->Position.T();
    158     pt = candidate->Momentum.Pt();
    159 
    160     // take postion and time from first stable particle
    161     if (dz0 < -999999.0)
    162       dz0 = z;
    163     if (dt0 < -999999.0)
    164       dt0 = t;
    165 
    166     // cancel any possible offset in position and time the input file
    167     candidate->Position.SetZ(z - dz0 + dz);
    168     candidate->Position.SetT(t - dt0 + dt);
    169 
    170     candidate->IsPU = 0;
    171 
     145    candidate->Position.SetZ(z + dz);
     146    candidate->Position.SetT(t + dt);
    172147    fParticleOutputArray->Add(candidate);
    173 
    174     if(TMath::Abs(candidate->Charge) >  1.0E-9)
    175     {
    176       nch++;
    177       sumpt2 += pt*pt;
    178       vertex->AddCandidate(candidate);
    179     }
    180148  }
    181149
    182150  if(numberOfParticles > 0)
    183151  {
    184     vx /= sumpt2;
    185     vy /= sumpt2;
    186   }
    187 
    188   nvtx++;
     152    vx /= numberOfParticles;
     153    vy /= numberOfParticles;
     154  }
     155
     156  factory = GetFactory();
     157
     158  vertex = factory->NewCandidate();
    189159  vertex->Position.SetXYZT(vx, vy, dz, dt);
    190   vertex->ClusterIndex = nvtx;
    191   vertex->ClusterNDF = nch;
    192   vertex->SumPT2 = sumpt2;
    193   vertex->GenSumPT2 = sumpt2;
    194160  fVertexOutputArray->Add(vertex);
    195161
     
    204170      numberOfEvents = gRandom->Integer(2*fMeanPileUp + 1);
    205171      break;
    206     case 2:
    207       numberOfEvents = fMeanPileUp;
    208       break;
    209172    default:
    210173      numberOfEvents = gRandom->Poisson(fMeanPileUp);
     
    213176
    214177  allEntries = fReader->GetEntries();
    215 
    216178
    217179  for(event = 0; event < numberOfEvents; ++event)
     
    236198    vx = 0.0;
    237199    vy = 0.0;
    238 
    239200    numberOfParticles = 0;
    240     sumpt2 = 0.0;
    241 
    242     //factory = GetFactory();
    243     vertex = factory->NewCandidate();
    244 
    245201    while(fReader->ReadParticle(pid, x, y, z, t, px, py, pz, e))
    246202    {
     
    259215      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    260216      candidate->Momentum.RotateZ(dphi);
    261       pt = candidate->Momentum.Pt();
    262217
    263218      x -= fInputBeamSpotX;
     
    269224      vx += candidate->Position.X();
    270225      vy += candidate->Position.Y();
    271 
    272226      ++numberOfParticles;
    273       if(TMath::Abs(candidate->Charge) >  1.0E-9)
    274       {
    275         nch++;
    276         sumpt2 += pt*pt;
    277         vertex->AddCandidate(candidate);
    278       }
    279227
    280228      fParticleOutputArray->Add(candidate);
     
    287235    }
    288236
    289     nvtx++;
    290 
     237    vertex = factory->NewCandidate();
    291238    vertex->Position.SetXYZT(vx, vy, dz, dt);
    292 
    293     vertex->ClusterIndex = nvtx;
    294     vertex->ClusterNDF = nch;
    295     vertex->SumPT2 = sumpt2;
    296     vertex->GenSumPT2 = sumpt2;
    297 
    298239    vertex->IsPU = 1;
    299240
    300241    fVertexOutputArray->Add(vertex);
    301 
    302   }
    303 }
    304 
    305 //------------------------------------------------------------------------------
     242  }
     243}
     244
     245//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.