Fork me on GitHub

Changes between Version 24 and Version 25 of WorkBook/LibraryInterface


Ignore:
Timestamp:
Nov 13, 2012, 5:36:14 PM (12 years ago)
Author:
Pavel Demin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WorkBook/LibraryInterface

    v24 v25  
    99  setup ROOT environment variables
    1010
    11   wget --no-check-certificate https://server06.fynu.ucl.ac.be/projects/delphes/raw-attachment/wiki/LibraryInterface/ModularDelphes.tar.gz
     11  wget --no-check-certificate https://cp3.irmp.ucl.ac.be/projects/delphes/raw-attachment/wiki/LibraryInterface/ModularDelphes.tar.gz
    1212  tar -zxf ModularDelphes.tar.gz
    1313
     
    4444
    4545#include "TObjArray.h"
     46#include "TDatabasePDG.h"
     47#include "TParticlePDG.h"
    4648#include "TLorentzVector.h"
    4749
    48 #include "ExRootAnalysis/ExRootFactory.h"
    49 #include "ExRootAnalysis/ExRootAnalysis.h"
    50 #include "ExRootAnalysis/ExRootCandidate.h"
     50#include "modules/Delphes.h"
     51#include "classes/DelphesClasses.h"
     52#include "classes/DelphesFactory.h"
    5153
    5254using namespace std;
    5355
    54 void ConvertInput(ExRootFactory *factory, TObjArray *particleOutputArray, TObjArray *partonOutputArray);
     56void ConvertInput(DelphesFactory *factory, TObjArray *particleOutputArray, TObjArray *candidateOutputArray, TObjArray *partonOutputArray);
    5557
    56 void ConvertOutput(ExRootAnalysis *modularDelphes);
     58void ConvertOutput(Delphes *modularDelphes);
    5759
    5860bool ReadEvent() { return true; }
     
    6466  // Declaration of variables
    6567  ExRootConfReader *confReader;
    66   ExRootAnalysis *modularDelphes;
    67   ExRootFactory *factory;
     68  Delphes *modularDelphes;
     69  DelphesFactory *factory;
    6870  TObjArray *particleOutputArray;
     71  TObjArray *candidateOutputArray;
    6972  TObjArray *partonOutputArray;
    7073
     
    8285    confReader->ReadFile("etc/delphes_card_CMS.tcl");
    8386
    84     modularDelphes = new ExRootAnalysis("Delphes");
     87    modularDelphes = new Delphes("Delphes");
    8588    modularDelphes->SetConfReader(confReader);
    8689   
    8790    factory = modularDelphes->GetFactory();
     91
    8892    particleOutputArray = modularDelphes->ExportArray("particles");
     93    candidateOutputArray = modularDelphes->ExportArray("candidates");
    8994    partonOutputArray = modularDelphes->ExportArray("partons");
    9095
     
    95100    {
    96101      modularDelphes->Clear();
    97       ConvertInput(factory, particleOutputArray, partonOutputArray);
     102      ConvertInput(factory, particleOutputArray, candidateOutputArray, partonOutputArray);
    98103      modularDelphes->ProcessTask();
    99104      ConvertOutput(modularDelphes);
     
    113118}
    114119
    115 void ConvertInput(ExRootFactory *factory, TObjArray *particleOutputArray, TObjArray *partonOutputArray)
     120void ConvertInput(DelphesFactory *factory, TObjArray *particleOutputArray, TObjArray *candidateOutputArray, TObjArray *partonOutputArray)
    116121{
    117   ExRootCandidate *candidate;
    118   TLorentzVector candidateMomentum, candidatePosition;
     122  Candidate *candidate;
     123  TDatabasePDG *pdg;
     124  TParticlePDG *pdgParticle;
    119125  Int_t pid, status;
    120   Double_t px, py, pz, e, m;
     126  Double_t px, py, pz, e;
    121127  Double_t x, y, z, t; 
    122128
     129  pdg = TDatabasePDG::Instance()
     130 
    123131  while(ReadParticle())
    124132  {
     
    127135      candidate = factory->NewCandidate();
    128136
    129       candidate->SetType(pid);
     137      candidate->PID = pid;
    130138
    131       candidateMomentum.SetPxPyPzE(px, py, pz, e);
    132       candidate->SetMomentum(candidateMomentum);
     139      candidate->Status = status;
    133140
    134       candidatePosition.SetXYZT(x, y, z, t);
    135       candidate->SetPosition(candidatePosition);
     141     
     142      pdgParticle = pdg->GetParticle(fPID);
     143      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     144      candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
     145 
     146      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
     147
     148      candidate->Position.SetXYZT(x, y, z, t);
     149
     150      particleOutputArray->Add(candidate);
     151
     152      if(!pdgParticle) return;
    136153
    137154      if(status == 1)
    138155      {
    139         particleOutputArray->Add(candidate);
     156        candidateOutputArray->Add(candidate);
    140157      }
    141158      else if(status == 2)
     
    147164}
    148165
    149 void ConvertOutput(ExRootAnalysis *modularDelphes)
     166void ConvertOutput(Delphes *modularDelphes)
    150167{
    151168  const TObjArray *arrayJets = modularDelphes->ImportArray("FastJetFinder/jets");
    152169  TIter iteratorJets(arrayJets);
    153   ExRootCandidate *candidate;
     170  Candidate *candidate;
    154171
    155172  iteratorJets.Reset();
    156   while((candidate = static_cast<ExRootCandidate*>(iteratorJets.Next())))
     173  while((candidate = static_cast<Candidate*>(iteratorJets.Next())))
    157174  {
    158175    const TLorentzVector &momentum = candidate->GetMomentum();