Fork me on GitHub

Changeset 4fd37d4 in git


Ignore:
Timestamp:
Oct 18, 2014, 12:27:15 PM (10 years ago)
Author:
Christophe Delaere <christophe.delaere@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
5fbcfe8
Parents:
400597a
Message:

Code reorganization

Moved the methods that read branches to the correponding BranchElements.

Location:
display
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • display/DelphesBranchElement.cc

    r400597a r4fd37d4  
    1818
    1919#include "display/DelphesBranchElement.h"
     20#include "classes/DelphesClasses.h"
     21#include "TEveJetCone.h"
     22#include "TEveTrack.h"
     23#include "TEveTrackPropagator.h"
     24#include "TEveArrow.h"
     25#include "TEveVector.h"
     26#include <iostream>
    2027
    2128// special case for calo towers
    22 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
    23       if(TString(type)=="tower") {
    24         data_ = new DelphesCaloData(2);
    25         data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
    26         data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
    27         data_->IncDenyDestroy();
    28       } else {
    29         throw std::exception();
    30       }
    31     }
     29template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color):DelphesBranchBase(name, branch, color) {
     30    data_ = new DelphesCaloData(2);
     31    data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
     32    data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
     33    data_->IncDenyDestroy();
     34}
    3235template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
     36template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() {
     37  if(TString(GetType())=="Tower") {
     38    // Loop over all towers
     39    TIter itTower(branch_);
     40    Tower *tower;
     41    while((tower = (Tower *) itTower.Next())) {
     42      data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
     43      data_->FillSlice(0, tower->Eem);
     44      data_->FillSlice(1, tower->Ehad);
     45    }
     46    data_->DataChanged();
     47  }
     48}
    3349
    3450// special case for element lists
    35 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
    36       if(TString(type)=="vector" || TString(type)=="jet") {
    37         data_ = new TEveElementList(name);
    38         data_->SetMainColor(color_);
    39       } else {
    40         throw std::exception();
    41       }
    42     }
     51template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color):DelphesBranchBase(name, branch, color) {
     52    data_ = new TEveElementList(name);
     53    data_->SetMainColor(color_);
     54}
    4355template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
     56template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
     57  if(TString(GetType())=="Jet") {
     58    TIter itJet(branch_);
     59    Jet *jet;
     60    TEveJetCone *eveJetCone;
     61    // Loop over all jets
     62    Int_t counter = 0;
     63    while((jet = (Jet *) itJet.Next())) {
     64      eveJetCone = new TEveJetCone();
     65      eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
     66      eveJetCone->SetName(Form("jet [%d]", counter++));
     67      eveJetCone->SetMainTransparency(60);
     68      eveJetCone->SetLineColor(GetColor());
     69      eveJetCone->SetFillColor(GetColor());
     70      eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);
     71      eveJetCone->SetPickable(kTRUE);
     72      eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
     73      data_->AddElement(eveJetCone);
     74    }
     75  } else if(TString(GetType())=="MissingET") {
     76    TIter itMet(branch_);
     77    MissingET *MET;
     78    TEveArrow *eveMet;
     79    // Missing Et
     80    Double_t maxPt = 50.;
     81    // TODO to be changed as we don't have access to maxPt anymore. MET scale could be a general parameter set in GUI
     82    while((MET = (MissingET*) itMet.Next())) {
     83      eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.);
     84      eveMet->SetMainColor(GetColor());
     85      eveMet->SetTubeR(0.04);
     86      eveMet->SetConeR(0.08);
     87      eveMet->SetConeL(0.10);
     88      eveMet->SetPickable(kTRUE);
     89      eveMet->SetName("Missing Et");
     90      eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
     91      data_->AddElement(eveMet);
     92    }
     93  }
     94}
    4495
    4596// special case for track lists
    46 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
    47         data_ = new TEveTrackList(name);
    48         data_->SetMainColor(color_);
    49         data_->SetMarkerColor(color_);
    50         data_->SetMarkerStyle(kCircle);
    51         data_->SetMarkerSize(0.5);
    52     }
     97template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color):DelphesBranchBase(name, branch, color) {
     98  data_ = new TEveTrackList(name);
     99  data_->SetMainColor(color_);
     100  data_->SetMarkerColor(color_);
     101  data_->SetMarkerStyle(kCircle);
     102  data_->SetMarkerSize(0.5);
     103}
     104template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
     105  tkRadius_ = r;
     106  tkHalfLength_ = l;
     107  tk_Bz_ = Bz;
     108  TEveTrackPropagator *trkProp = data_->GetPropagator();
     109  trkProp->SetMagField(0., 0., -tk_Bz_);
     110  trkProp->SetMaxR(tkRadius_);
     111  trkProp->SetMaxZ(tkHalfLength_);
     112}
    53113template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
    54 
     114template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
     115  TString type = GetType();
     116  TIter itTrack(branch_);
     117  Int_t counter = 0;
     118  TEveTrack *eveTrack;
     119  TEveTrackPropagator *trkProp = data_->GetPropagator();
     120  trkProp->SetMagField(0., 0., -tk_Bz_);
     121  trkProp->SetMaxR(tkRadius_);
     122  trkProp->SetMaxZ(tkHalfLength_);
     123  if(type=="Track") { // CASE 1: TRACKS
     124    Track *track;
     125    while((track = (Track *) itTrack.Next())) {
     126      TParticle pb(track->PID, 1, 0, 0, 0, 0,
     127                   track->P4().Px(), track->P4().Py(),
     128                   track->P4().Pz(), track->P4().E(),
     129                   track->X, track->Y, track->Z, 0.0);
     130      eveTrack = new TEveTrack(&pb, counter, trkProp);
     131      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     132      eveTrack->SetStdTitle();
     133      eveTrack->SetAttLineAttMarker(data_);
     134      data_->AddElement(eveTrack);
     135      eveTrack->SetLineColor(GetColor());
     136      eveTrack->MakeTrack();
     137    }
     138  } else if(type=="Electron") { // CASE 2: ELECTRONS
     139    Electron *electron;
     140    while((electron = (Electron *) itTrack.Next())) {
     141      TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
     142                   electron->P4().Px(), electron->P4().Py(),
     143                   electron->P4().Pz(), electron->P4().E(),
     144                   0., 0., 0., 0.);
     145      eveTrack = new TEveTrack(&pb, counter, trkProp);
     146      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     147      eveTrack->SetStdTitle();
     148      eveTrack->SetAttLineAttMarker(data_);
     149      data_->AddElement(eveTrack);
     150      eveTrack->SetLineColor(GetColor());
     151      eveTrack->MakeTrack();
     152    }
     153  } else if(type=="Muon") { // CASE 3: MUONS
     154    Muon *muon;
     155    while((muon = (Muon *) itTrack.Next())) {
     156      TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
     157                   muon->P4().Px(), muon->P4().Py(),
     158                   muon->P4().Pz(), muon->P4().E(),
     159                   0., 0., 0., 0.);
     160      eveTrack = new TEveTrack(&pb, counter, trkProp);
     161      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     162      eveTrack->SetStdTitle();
     163      eveTrack->SetAttLineAttMarker(data_);
     164      data_->AddElement(eveTrack);
     165      eveTrack->SetLineColor(GetColor());
     166      eveTrack->MakeTrack();
     167    }
     168  } else if(type=="Photon") { // CASE 4: PHOTONS
     169    Photon *photon;
     170    while((photon = (Photon *) itTrack.Next())) {
     171      TParticle pb(22, 1, 0, 0, 0, 0,
     172                   photon->P4().Px(), photon->P4().Py(),
     173                   photon->P4().Pz(), photon->P4().E(),
     174                   0., 0., 0., 0.);
     175      eveTrack = new TEveTrack(&pb, counter, trkProp);
     176      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     177      eveTrack->SetStdTitle();
     178      eveTrack->SetAttLineAttMarker(data_);
     179      eveTrack->SetLineStyle(7);
     180      data_->AddElement(eveTrack);
     181      eveTrack->SetLineColor(GetColor());
     182      eveTrack->MakeTrack();
     183    }
     184  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
     185    GenParticle *particle;
     186    while((particle = (GenParticle *) itTrack.Next())) {
     187      TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
     188                   particle->P4().Px(), particle->P4().Py(),
     189                   particle->P4().Pz(), particle->P4().E(),
     190                   particle->X, particle->Y, particle->Z, particle->T);
     191      eveTrack = new TEveTrack(&pb, counter, trkProp);
     192      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     193      eveTrack->SetStdTitle();
     194      eveTrack->SetAttLineAttMarker(data_);
     195      data_->AddElement(eveTrack);
     196      eveTrack->SetLineColor(GetColor());
     197      if(particle->Charge==0) eveTrack->SetLineStyle(7);
     198      eveTrack->MakeTrack();
     199    }
     200  }
     201}
  • display/DelphesBranchElement.h

    r400597a r4fd37d4  
    2222#include "TColor.h"
    2323#include "TString.h"
     24#include "TClonesArray.h"
     25#include "TClass.h"
    2426#include <exception>
     27#include <iostream>
    2528#include "display/DelphesCaloData.h"
    2629#include "TEveElement.h"
     
    3134{
    3235  public:
    33     DelphesBranchBase(const char* name="", const char*type="", const enum EColor color=kBlack):name_(name),type_(type),color_(color) {}
    34     virtual ~DelphesBranchBase() {};
     36    DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack):name_(name),branch_(branch),color_(color) {}
     37    virtual ~DelphesBranchBase() {}
    3538    const char* GetName() const { return (const char*)name_; }
    36     const char* GetType() const { return (const char*)type_; }
     39    const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
     40    virtual const char* GetClassName() = 0;
    3741    enum EColor GetColor() const { return color_; }
    38     virtual const char* GetClassName() = 0;
    3942    virtual void Reset() = 0;
     43    virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
     44    virtual void ReadBranch() = 0;
    4045
    4146  protected:
    4247    TString name_;
    43     TString type_; // needed for parsing the branch later on
     48    TClonesArray* branch_;
    4449    const enum EColor color_;
     50    Float_t tkRadius_,tkHalfLength_, tk_Bz_;
    4551};
    4652
     
    5056  public:
    5157    // constructor
    52     DelphesBranchElement(const char* name="", const char*type="", const enum EColor color=kBlack):DelphesBranchBase(name, type, color) {
     58    DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack):DelphesBranchBase(name, branch, color) {
    5359      throw std::exception();
    5460    }
     
    6066    EveContainer* GetContainer() { return data_; }
    6167
     68    // tracking volume
     69    virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
     70
    6271    // resets the collection (before moving to the next event)
    6372    virtual void Reset() {};
     
    6574    // template class name
    6675    virtual const char* GetClassName() { return data_->ClassName(); }
     76
     77    // read the branch and fill elements for display
     78    virtual void ReadBranch() {}
    6779
    6880  private:
     
    7385
    7486// special case for calo towers
    75 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
     87template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color);
    7688template<> void DelphesBranchElement<DelphesCaloData>::Reset();
     89template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch();
    7790
    7891// special case for element lists
    79 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
     92template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color);
    8093template<> void DelphesBranchElement<TEveElementList>::Reset();
     94template<> void DelphesBranchElement<TEveElementList>::ReadBranch();
    8195
    8296// special case for track lists
    83 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
     97template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color);
     98template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
    8499template<> void DelphesBranchElement<TEveTrackList>::Reset();
     100template<> void DelphesBranchElement<TEveTrackList>::ReadBranch();
    85101
    86102#endif // CINT, CLING
  • display/DelphesEventDisplay.cc

    r400597a r4fd37d4  
    5353   totRadius_ = 2.0;
    5454   tkHalfLength_ = 3.0;
     55   muHalfLength_ = 6.0;
    5556   bz_ = 3.8;
    5657   chain_ = new TChain("Delphes");
    5758   treeReader_ = 0;
    5859   delphesDisplay_ = 0;
     60   etaAxis_ = 0;
     61   phiAxis_ = 0;
    5962}
    6063
     
    8386   totRadius_ = det3D.getDetectorRadius();
    8487   tkHalfLength_ = det3D.getTrackerHalfLength();
     88   muHalfLength_ = det3D.getDetectorHalfLength();
    8589   bz_ = det3D.getBField();
     90   etaAxis_ = det3D.getCaloAxes().first;
     91   phiAxis_ = det3D.getCaloAxes().second;
    8692   TGeoVolume* top = det3D.getDetector(false);
    8793   geom->SetTopVolume(top);
     
    105111
    106112   // prepare data collections
    107    readConfig(configFile, det3D, elements_, arrays_);
     113   readConfig(configFile, elements_);
    108114   for(std::vector<DelphesBranchBase*>::iterator element = elements_.begin(); element<elements_.end(); ++element) {
    109115     DelphesBranchElement<TEveTrackList>*   item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element);
     
    120126   // find the first calo data and use that to initialize the calo display
    121127   for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
    122      if(TString((*data)->GetType())=="tower") { // we could also use GetClassName()=="DelphesCaloData"
     128     if(TString((*data)->GetType())=="Tower") { // we could also use GetClassName()=="DelphesCaloData"
    123129       DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
    124130       assert(container);
     
    146152
    147153// function that parses the config to extract the branches of interest and prepare containers
    148 void DelphesEventDisplay::readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays) {
     154void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements) {
    149155   ExRootConfReader *confReader = new ExRootConfReader;
    150156   confReader->ReadFile(configFile);
    151    Double_t tk_radius = det3D.getTrackerRadius();
    152    Double_t tk_length = det3D.getTrackerHalfLength();
    153    Double_t tk_Bz     = det3D.getBField();
    154    Double_t mu_radius = det3D.getDetectorRadius();
    155    Double_t mu_length = det3D.getDetectorHalfLength();
    156    TAxis*   etaAxis   = det3D.getCaloAxes().first;
    157    TAxis*   phiAxis   = det3D.getCaloAxes().second;
    158157   ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
    159158   Int_t nBranches = branches.GetSize()/3;
     
    168167     if(className=="Tower") {
    169168       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    170        clist = new DelphesBranchElement<DelphesCaloData>(name,"tower",kBlack);
    171        clist->GetContainer()->SetEtaBins(etaAxis);
    172        clist->GetContainer()->SetPhiBins(phiAxis);
     169       clist = new DelphesBranchElement<DelphesCaloData>(name,treeReader_->UseBranch(name),kBlack);
     170       clist->GetContainer()->SetEtaBins(etaAxis_);
     171       clist->GetContainer()->SetPhiBins(phiAxis_);
    173172       elements.push_back(clist);
    174173     } else if(className=="Jet") {
    175174       if(input.Contains("GenJetFinder")) {
    176          elist = new DelphesBranchElement<TEveElementList>(name,"jet",kCyan);
     175         elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kCyan);
    177176         elist->GetContainer()->SetRnrSelf(false);
    178177         elist->GetContainer()->SetRnrChildren(false);
     178         elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    179179         elements.push_back(elist);
    180180       } else {
    181          elements.push_back(new DelphesBranchElement<TEveElementList>(name,"jet",kYellow));
     181         elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kYellow);
     182         elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     183         elements.push_back(elist);
    182184       }
    183185     } else if(className=="Electron") {
    184        tlist = new DelphesBranchElement<TEveTrackList>(name,"electron",kRed);
    185        elements.push_back(tlist);
    186        TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    187        trkProp->SetMagField(0., 0., -tk_Bz);
    188        trkProp->SetMaxR(tk_radius);
    189        trkProp->SetMaxZ(tk_length);
     186       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kRed);
     187       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     188       elements.push_back(tlist);
    190189     } else if(className=="Photon") {
    191        tlist = new DelphesBranchElement<TEveTrackList>(name,"photon",kYellow);
    192        elements.push_back(tlist);
    193        TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    194        trkProp->SetMagField(0., 0., 0.);
    195        trkProp->SetMaxR(tk_radius);
    196        trkProp->SetMaxZ(tk_length);
     190       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kYellow);
     191       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     192       elements.push_back(tlist);
    197193     } else if(className=="Muon") {
    198        tlist = new DelphesBranchElement<TEveTrackList>(name,"muon",kGreen);
    199        elements.push_back(tlist);
    200        TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    201        trkProp->SetMagField(0., 0., -tk_Bz);
    202        trkProp->SetMaxR(mu_radius);
    203        trkProp->SetMaxZ(mu_length);
     194       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kGreen);
     195       tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_);
     196       elements.push_back(tlist);
    204197     } else if(className=="MissingET") {
    205        elements.push_back(new DelphesBranchElement<TEveElementList>(name,"vector",kViolet));
     198       elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kViolet);
     199       elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     200       elements.push_back(elist);
    206201     } else if(className=="GenParticle") {
    207        tlist = new DelphesBranchElement<TEveTrackList>(name,"genparticle",kCyan);
    208        elements.push_back(tlist);
     202       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kCyan);
     203       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    209204       tlist->GetContainer()->SetRnrSelf(false);
    210205       tlist->GetContainer()->SetRnrChildren(false);
    211        TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    212        trkProp->SetMagField(0., 0., -tk_Bz);
    213        trkProp->SetMaxR(tk_radius);
    214        trkProp->SetMaxZ(tk_length);
     206       elements.push_back(tlist);
    215207     } else {
    216208       continue;
    217209     }
    218      arrays.push_back(treeReader_->UseBranch(name));
    219210   }
    220211   // second loop for tracks
     
    225216     if(className=="Track") {
    226217       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    227        tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue);
    228        elements.push_back(tlist);
    229        TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    230        trkProp->SetMagField(0., 0., -tk_Bz);
    231        trkProp->SetMaxR(tk_radius);
    232        trkProp->SetMaxZ(tk_length);
    233        arrays.push_back(treeReader_->UseBranch(name));
     218       tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kBlue);
     219       tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     220       elements.push_back(tlist);
    234221     }
    235222   }
     
    255242   // Load selected branches with data from specified event
    256243   treeReader_->ReadEntry(event_id_);
    257 
    258    // loop over selected branches, and apply the proper recipe to fill the collections.
    259    // this is basically to loop on arrays_ to fill elements_.
    260    std::vector<TClonesArray*>::iterator data = arrays_.begin();
    261    std::vector<DelphesBranchBase*>::iterator element = elements_.begin();
    262    for(; data<arrays_.end() && element<elements_.end(); ++data, ++element) {
    263      TString type = (*element)->GetType();
    264      // branch on the element type
    265      if(type=="tower") delphes_read_towers(*data,*element);
    266      else if(type=="track" || type=="photon" || type=="electron" || type=="muon" || type=="genparticle") delphes_read_tracks(*data,*element);
    267      else if(type=="jet") delphes_read_jets(*data,*element);
    268      else if(type=="vector") delphes_read_vectors(*data,*element);
     244   for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
     245     (*data)->ReadBranch();
    269246   }
    270247
     
    278255
    279256   gEve->Redraw3D(kFALSE, kTRUE);
    280 }
    281 
    282 void DelphesEventDisplay::delphes_read_towers(TClonesArray* data, DelphesBranchBase* element) {
    283   DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(element)->GetContainer();
    284   assert(container);
    285   // Loop over all towers
    286   TIter itTower(data);
    287   Tower *tower;
    288   while((tower = (Tower *) itTower.Next()))
    289   {
    290     container->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
    291     container->FillSlice(0, tower->Eem);
    292     container->FillSlice(1, tower->Ehad);
    293   }
    294   container->DataChanged();
    295 }
    296 
    297 void DelphesEventDisplay::delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element) {
    298   TEveTrackList* container = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(element)->GetContainer();
    299   assert(container);
    300   TString type = element->GetType();
    301   TIter itTrack(data);
    302   Int_t counter = 0;
    303   TEveTrack *eveTrack;
    304   TEveTrackPropagator *trkProp = container->GetPropagator();
    305   if(type=="track") {
    306     // Loop over all tracks
    307     Track *track;
    308     while((track = (Track *) itTrack.Next())) {
    309       TParticle pb(track->PID, 1, 0, 0, 0, 0,
    310                    track->P4().Px(), track->P4().Py(),
    311                    track->P4().Pz(), track->P4().E(),
    312                    track->X, track->Y, track->Z, 0.0);
    313       eveTrack = new TEveTrack(&pb, counter, trkProp);
    314       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    315       eveTrack->SetStdTitle();
    316       eveTrack->SetAttLineAttMarker(container);
    317       container->AddElement(eveTrack);
    318       eveTrack->SetLineColor(element->GetColor());
    319       eveTrack->MakeTrack();
    320     }
    321   } else if(type=="electron") {
    322     // Loop over all electrons
    323     Electron *electron;
    324     while((electron = (Electron *) itTrack.Next())) {
    325       TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
    326                    electron->P4().Px(), electron->P4().Py(),
    327                    electron->P4().Pz(), electron->P4().E(),
    328                    0., 0., 0., 0.);
    329 
    330       eveTrack = new TEveTrack(&pb, counter, trkProp);
    331       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    332       eveTrack->SetStdTitle();
    333       eveTrack->SetAttLineAttMarker(container);
    334       container->AddElement(eveTrack);
    335       eveTrack->SetLineColor(element->GetColor());
    336       eveTrack->MakeTrack();
    337     }
    338   } else if(type=="muon") {
    339     // Loop over all muons
    340     Muon *muon;
    341     while((muon = (Muon *) itTrack.Next())) {
    342       TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
    343                    muon->P4().Px(), muon->P4().Py(),
    344                    muon->P4().Pz(), muon->P4().E(),
    345                    0., 0., 0., 0.);
    346 
    347       eveTrack = new TEveTrack(&pb, counter, trkProp);
    348       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    349       eveTrack->SetStdTitle();
    350       eveTrack->SetAttLineAttMarker(container);
    351       container->AddElement(eveTrack);
    352       eveTrack->SetLineColor(element->GetColor());
    353       eveTrack->MakeTrack();
    354     }
    355   } else if(type=="photon") {
    356     // Loop over all photons
    357     Photon *photon;
    358     while((photon = (Photon *) itTrack.Next())) {
    359       TParticle pb(22, 1, 0, 0, 0, 0,
    360                    photon->P4().Px(), photon->P4().Py(),
    361                    photon->P4().Pz(), photon->P4().E(),
    362                    0., 0., 0., 0.);
    363       eveTrack = new TEveTrack(&pb, counter, trkProp);
    364       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    365       eveTrack->SetStdTitle();
    366       eveTrack->SetAttLineAttMarker(container);
    367       eveTrack->SetLineStyle(7);
    368       container->AddElement(eveTrack);
    369       eveTrack->SetLineColor(element->GetColor());
    370       eveTrack->MakeTrack();
    371     }
    372   } else if(type=="genparticle") {
    373     // Loop over all particles
    374     GenParticle *particle;
    375     while((particle = (GenParticle *) itTrack.Next())) {
    376       TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
    377                    particle->P4().Px(), particle->P4().Py(),
    378                    particle->P4().Pz(), particle->P4().E(),
    379                    particle->X, particle->Y, particle->Z, particle->T);
    380       eveTrack = new TEveTrack(&pb, counter, trkProp);
    381       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    382       eveTrack->SetStdTitle();
    383       eveTrack->SetAttLineAttMarker(container);
    384       container->AddElement(eveTrack);
    385       eveTrack->SetLineColor(element->GetColor());
    386       if(particle->Charge==0) eveTrack->SetLineStyle(7);
    387       eveTrack->MakeTrack();
    388     }
    389   }
    390 }
    391 
    392 void DelphesEventDisplay::delphes_read_jets(TClonesArray* data, DelphesBranchBase* element) {
    393   TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();
    394   assert(container);
    395   TIter itJet(data);
    396   Jet *jet;
    397   TEveJetCone *eveJetCone;
    398   // Loop over all jets
    399   Int_t counter = 0;
    400   while((jet = (Jet *) itJet.Next()))
    401   {
    402     eveJetCone = new TEveJetCone();
    403     eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
    404     eveJetCone->SetName(Form("jet [%d]", counter++));
    405     eveJetCone->SetMainTransparency(60);
    406     eveJetCone->SetLineColor(element->GetColor());
    407     eveJetCone->SetFillColor(element->GetColor());
    408     eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);
    409     eveJetCone->SetPickable(kTRUE);
    410     eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
    411     container->AddElement(eveJetCone);
    412   }
    413 }
    414 
    415 void DelphesEventDisplay::delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element) {
    416   TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();
    417   assert(container);
    418   TIter itMet(data);
    419   MissingET *MET;
    420   TEveArrow *eveMet;
    421   // Missing Et
    422   Double_t maxPt = 50.;
    423   // TODO to be changed as we don't have access to maxPt anymore. MET scale could be a general parameter set in GUI
    424   while((MET = (MissingET*) itMet.Next())) {
    425     eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.);
    426     eveMet->SetMainColor(element->GetColor());
    427     eveMet->SetTubeR(0.04);
    428     eveMet->SetConeR(0.08);
    429     eveMet->SetConeL(0.10);
    430     eveMet->SetPickable(kTRUE);
    431     eveMet->SetName("Missing Et");
    432     eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
    433     container->AddElement(eveMet);
    434   }
    435257}
    436258
  • display/DelphesEventDisplay.h

    r400597a r4fd37d4  
    2626#include "display/Delphes3DGeometry.h"
    2727#include "TChain.h"
     28#include "TAxis.h"
    2829#include "TClonesArray.h"
    2930
     
    4546    void make_gui();
    4647    void load_event();
    47     void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element);
    48     void delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element);
    49     void delphes_read_jets(TClonesArray* data, DelphesBranchBase* element);
    50     void delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element);
    51     void readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays);
     48    void readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements);
    5249
    5350    // Configuration and global variables.
    5451    Int_t event_id_;
    5552    ExRootTreeReader *treeReader_;
    56     Double_t tkRadius_, totRadius_, tkHalfLength_, bz_;
     53    Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_;
     54    TAxis *etaAxis_, *phiAxis_;
    5755    TChain* chain_;
    5856    std::vector<DelphesBranchBase*> elements_;
    59     std::vector<TClonesArray*> arrays_;
    6057    DelphesDisplay *delphesDisplay_;
    6158
Note: See TracChangeset for help on using the changeset viewer.