Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • readers/DelphesCMSFWLite.cpp

    r2886328 r77e9ae1  
    1818
    1919#include <algorithm>
     20#include <iostream>
     21#include <memory>
     22#include <sstream>
    2023#include <stdexcept>
    21 #include <iostream>
    22 #include <sstream>
    23 #include <memory>
    2424
    2525#include <map>
    2626#include <vector>
    2727
    28 #include <stdlib.h>
    2928#include <signal.h>
    3029#include <stdio.h>
    31 
     30#include <stdlib.h>
     31
     32#include "TApplication.h"
    3233#include "TROOT.h"
    33 #include "TApplication.h"
    34 
     34
     35#include "TDatabasePDG.h"
    3536#include "TFile.h"
     37#include "TLorentzVector.h"
    3638#include "TObjArray.h"
     39#include "TParticlePDG.h"
    3740#include "TStopwatch.h"
    38 #include "TDatabasePDG.h"
    39 #include "TParticlePDG.h"
    40 #include "TLorentzVector.h"
    41 
    42 #include "modules/Delphes.h"
    43 #include "classes/DelphesStream.h"
     41
    4442#include "classes/DelphesClasses.h"
    4543#include "classes/DelphesFactory.h"
    46 
     44#include "classes/DelphesStream.h"
     45#include "modules/Delphes.h"
     46
     47#include "ExRootAnalysis/ExRootProgressBar.h"
     48#include "ExRootAnalysis/ExRootTreeBranch.h"
    4749#include "ExRootAnalysis/ExRootTreeWriter.h"
    48 #include "ExRootAnalysis/ExRootTreeBranch.h"
    49 #include "ExRootAnalysis/ExRootProgressBar.h"
    50 
    51 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
     50
    5251#include "DataFormats/FWLite/interface/Event.h"
    5352#include "DataFormats/FWLite/interface/Handle.h"
    5453#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
    5554#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
     55#include "FWCore/FWLite/interface/FWLiteEnabler.h"
     56#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
    5657#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
    57 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
    5858#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
    5959#include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"
     
    6969{
    7070
    71   fwlite::Handle< GenEventInfoProduct > handleGenEventInfo;
    72   fwlite::Handle< LHEEventProduct > handleLHEEvent;
    73   fwlite::Handle< vector< reco::GenParticle > > handleParticle;
    74   fwlite::Handle< vector< pat::PackedGenParticle > > handlePackedParticle;
    75 
    76   vector< reco::GenParticle >::const_iterator itParticle;
    77   vector< pat::PackedGenParticle >::const_iterator itPackedParticle;
    78 
    79   vector< const reco::Candidate * > vectorCandidate;
    80   vector< const reco::Candidate * >::iterator itCandidate;
     71  fwlite::Handle<GenEventInfoProduct> handleGenEventInfo;
     72  fwlite::Handle<LHEEventProduct> handleLHEEvent;
     73  fwlite::Handle<vector<reco::GenParticle> > handleParticle;
     74  fwlite::Handle<vector<pat::PackedGenParticle> > handlePackedParticle;
     75
     76  vector<reco::GenParticle>::const_iterator itParticle;
     77  vector<pat::PackedGenParticle>::const_iterator itPackedParticle;
     78
     79  vector<const reco::Candidate *> vectorCandidate;
     80  vector<const reco::Candidate *>::iterator itCandidate;
    8181
    8282  handleGenEventInfo.getByLabel(event, "generator");
     
    9999    handleParticle.getByLabel(event, "genParticles");
    100100  }
    101   else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event,"prunedGenParticles")).empty()))
     101  else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty()))
    102102  {
    103103    handleParticle.getByLabel(event, "prunedGenParticles");
     
    106106  else
    107107  {
    108     std::cout<<"Wrong GenParticle Label! Please, check the input file."<<std::endl;
     108    std::cout << "Wrong GenParticle Label! Please, check the input file." << std::endl;
    109109    exit(-1);
    110110  }
    111111
    112112  Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty());
    113   Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) ;
     113  Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty());
    114114
    115115  HepMCEvent *element;
     
    148148  if(foundLHE)
    149149  {
    150     const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights();
    151     vector< gen::WeightsInfo >::const_iterator itWeightsInfo;
     150    const vector<gen::WeightsInfo> &vectorWeightsInfo = handleLHEEvent->weights();
     151    vector<gen::WeightsInfo>::const_iterator itWeightsInfo;
    152152
    153153    for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
     
    173173    status = particle.status();
    174174    if(isMiniAOD && particle.status() == 1) continue;
    175     px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    176     x = particle.vx(); y = particle.vy(); z = particle.vz();
     175    px = particle.px();
     176    py = particle.py();
     177    pz = particle.pz();
     178    e = particle.energy();
     179    mass = particle.mass();
     180    x = particle.vx();
     181    y = particle.vy();
     182    z = particle.vz();
    177183
    178184    candidate = factory->NewCandidate();
     
    196202
    197203    pdgParticle = pdg->GetParticle(pid);
    198     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     204    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    199205    candidate->Mass = mass;
    200206
    201207    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    202208
    203     candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
     209    candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
    204210
    205211    allParticleOutputArray->Add(candidate);
     
    232238    pid = particle.pdgId();
    233239    status = particle.status();
    234     px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    235     x = particle.vx(); y = particle.vy(); z = particle.vz();
     240    px = particle.px();
     241    py = particle.py();
     242    pz = particle.pz();
     243    e = particle.energy();
     244    mass = particle.mass();
     245    x = particle.vx();
     246    y = particle.vy();
     247    z = particle.vz();
    236248
    237249    candidate = factory->NewCandidate();
     
    255267
    256268    pdgParticle = pdg->GetParticle(pid);
    257     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     269    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    258270    candidate->Mass = mass;
    259271
    260272    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    261273
    262     candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
     274    candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
    263275
    264276    allParticleOutputArray->Add(candidate);
     
    303315  if(argc < 4)
    304316  {
    305     cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
     317    cout << " Usage: " << appName << " config_file"
     318         << " output_file"
     319         << " input_file(s)" << endl;
    306320    cout << " config_file - configuration file in Tcl format," << endl;
    307321    cout << " output_file - output file in ROOT format," << endl;
Note: See TracChangeset for help on using the changeset viewer.