Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • display/DelphesBranchElement.cc

    r341014c r273735d  
    1818
    1919#include "display/DelphesBranchElement.h"
    20 #include "TEveArrow.h"
     20#include "classes/DelphesClasses.h"
    2121#include "TEveJetCone.h"
    2222#include "TEveTrack.h"
    2323#include "TEveTrackPropagator.h"
     24#include "TEveArrow.h"
    2425#include "TEveVector.h"
    25 #include "classes/DelphesClasses.h"
    2626#include <iostream>
    2727
    2828// special case for calo towers
    29 template <>
    30 DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
    31   DelphesBranchBase(name, branch, color, maxPt)
    32 {
    33   data_ = new DelphesCaloData(2);
    34   data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
    35   data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
    36   data_->IncDenyDestroy();
    37 }
    38 template <>
    39 void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
    40 template <>
    41 void DelphesBranchElement<DelphesCaloData>::ReadBranch()
    42 {
    43   if(TString(GetType()) == "Tower")
    44   {
     29template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
     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}
     35template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
     36template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() {
     37  if(TString(GetType())=="Tower") {
    4538    // Loop over all towers
    4639    TIter itTower(branch_);
    4740    Tower *tower;
    48     while((tower = (Tower *)itTower.Next()))
    49     {
     41    while((tower = (Tower *) itTower.Next())) {
    5042      data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
    5143      data_->FillSlice(0, tower->Eem);
     
    5547  }
    5648}
    57 template <>
    58 std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors()
    59 {
     49template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() {
    6050  std::vector<TLorentzVector> output;
    61   if(TString(GetType()) == "Tower")
    62   {
     51  if(TString(GetType())=="Tower") {
    6352    TIter itTower(branch_);
    6453    Tower *tower;
    65     while((tower = (Tower *)itTower.Next()))
    66     {
     54    while((tower = (Tower *) itTower.Next())) {
    6755      TLorentzVector v;
    68       v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2., 0.);
     56      v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.);
    6957      output.push_back(v);
    7058    }
     
    7462
    7563// special case for element lists
    76 template <>
    77 DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
    78   DelphesBranchBase(name, branch, color, maxPt)
    79 {
    80   data_ = new TEveElementList(name);
    81   data_->SetMainColor(color_);
    82 }
    83 template <>
    84 void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
    85 template <>
    86 void DelphesBranchElement<TEveElementList>::ReadBranch()
    87 {
    88   if(TString(GetType()) == "Jet")
    89   {
     64template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
     65    data_ = new TEveElementList(name);
     66    data_->SetMainColor(color_);
     67}
     68template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
     69template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
     70  if(TString(GetType())=="Jet") {
    9071    TIter itJet(branch_);
    9172    Jet *jet;
     
    9374    // Loop over all jets
    9475    Int_t counter = 0;
    95     while((jet = (Jet *)itJet.Next()))
    96     {
     76    while((jet = (Jet *) itJet.Next())) {
    9777      eveJetCone = new TEveJetCone();
    98       eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter, jet->PT, jet->Eta, jet->Phi, jet->Mass));
     78      eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
    9979      eveJetCone->SetName(Form("jet [%d]", counter++));
    10080      eveJetCone->SetMainTransparency(60);
     
    10686      data_->AddElement(eveJetCone);
    10787    }
    108   }
    109   else if(TString(GetType()) == "MissingET")
    110   {
     88  } else if(TString(GetType())=="MissingET") {
    11189    // MissingET as invisible track (like a photon)
    11290    MissingET *MET;
     
    11694    trkProp->SetMaxR(tkRadius_);
    11795    trkProp->SetMaxZ(tkHalfLength_);
    118     if(branch_->GetEntriesFast() > 0)
    119     {
    120       MET = (MissingET *)branch_->At(0);
     96    if(branch_->GetEntriesFast() > 0) {
     97      MET = (MissingET*) branch_->At(0);
    12198      TParticle pb(13, 1, 0, 0, 0, 0,
    122         (tkRadius_ * MET->MET / maxPt_) * cos(MET->Phi),
    123         (tkRadius_ * MET->MET / maxPt_) * sin(MET->Phi),
    124         0., MET->MET, 0.0, 0.0, 0.0, 0.0);
     99                   (tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi),
     100                   (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi),
     101                   0., MET->MET, 0.0, 0.0, 0.0, 0.0);
    125102      eveMet = new TEveTrack(&pb, 0, trkProp);
    126103      eveMet->SetName("Missing Et");
     
    138115  }
    139116}
    140 template <>
    141 std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors()
    142 {
     117template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() {
    143118  std::vector<TLorentzVector> output;
    144   if(TString(GetType()) == "Jet")
    145   {
     119  if(TString(GetType())=="Jet") {
    146120    TIter itJet(branch_);
    147121    Jet *jet;
    148122    // Loop over all jets
    149     while((jet = (Jet *)itJet.Next()))
    150     {
     123    while((jet = (Jet *) itJet.Next())) {
    151124      TLorentzVector v;
    152125      v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
    153126      output.push_back(v);
    154127    }
    155   }
    156   else if(TString(GetType()) == "MissingET")
    157   {
     128  } else if(TString(GetType())=="MissingET") {
    158129    TIter itMet(branch_);
    159130    MissingET *MET;
    160131    // Missing Et
    161     while((MET = (MissingET *)itMet.Next()))
    162     {
     132    while((MET = (MissingET*) itMet.Next())) {
    163133      TLorentzVector v;
    164       v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi, 0.);
     134      v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.);
    165135      output.push_back(v);
    166136    }
     
    170140
    171141// special case for track lists
    172 template <>
    173 DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
    174   DelphesBranchBase(name, branch, color, maxPt)
    175 {
     142template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
    176143  data_ = new TEveTrackList(name);
    177144  data_->SetMainColor(color_);
     
    180147  data_->SetMarkerSize(0.5);
    181148}
    182 template <>
    183 void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz)
    184 {
    185   tkRadius_ = r;
     149template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
     150  tkRadius_ = r;
    186151  tkHalfLength_ = l;
    187152  tk_Bz_ = Bz;
     
    191156  trkProp->SetMaxZ(tkHalfLength_);
    192157}
    193 template <>
    194 void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
    195 template <>
    196 void DelphesBranchElement<TEveTrackList>::ReadBranch()
    197 {
     158template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
     159template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
    198160  TString type = GetType();
    199161  TIter itTrack(branch_);
     
    205167  trkProp->SetMaxZ(tkHalfLength_);
    206168  GenParticle *particle;
    207   if(type == "Track")
    208   { // CASE 1: TRACKS
     169  if(type=="Track") { // CASE 1: TRACKS
    209170    Track *track;
    210     while((track = (Track *)itTrack.Next()))
    211     {
     171    while((track = (Track *) itTrack.Next())) {
    212172      TParticle pb(track->PID, 1, 0, 0, 0, 0,
    213         track->P4().Px(), track->P4().Py(),
    214         track->P4().Pz(), track->P4().E(),
    215         track->X / 10.0, track->Y / 10.0, track->Z / 10.0, track->T / 10.0);
    216       eveTrack = new TEveTrack(&pb, counter, trkProp);
    217       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    218       eveTrack->SetStdTitle();
    219       eveTrack->SetAttLineAttMarker(data_);
    220       data_->AddElement(eveTrack);
    221       eveTrack->SetLineColor(GetColor());
    222       eveTrack->MakeTrack();
    223     }
    224   }
    225   else if(type == "Electron")
    226   { // CASE 2: ELECTRONS
     173                   track->P4().Px(), track->P4().Py(),
     174                   track->P4().Pz(), track->P4().E(),
     175                   track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0);
     176      eveTrack = new TEveTrack(&pb, counter, trkProp);
     177      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     178      eveTrack->SetStdTitle();
     179      eveTrack->SetAttLineAttMarker(data_);
     180      data_->AddElement(eveTrack);
     181      eveTrack->SetLineColor(GetColor());
     182      eveTrack->MakeTrack();
     183    }
     184  } else if(type=="Electron") { // CASE 2: ELECTRONS
    227185    Electron *electron;
    228     while((electron = (Electron *)itTrack.Next()))
    229     {
    230       particle = (GenParticle *)electron->Particle.GetObject();
    231       TParticle pb(electron->Charge < 0 ? 11 : -11, 1, 0, 0, 0, 0,
    232         electron->P4().Px(), electron->P4().Py(),
    233         electron->P4().Pz(), electron->P4().E(),
    234         particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
    235       eveTrack = new TEveTrack(&pb, counter, trkProp);
    236       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    237       eveTrack->SetStdTitle();
    238       eveTrack->SetAttLineAttMarker(data_);
    239       data_->AddElement(eveTrack);
    240       eveTrack->SetLineColor(GetColor());
    241       eveTrack->MakeTrack();
    242     }
    243   }
    244   else if(type == "Muon")
    245   { // CASE 3: MUONS
     186    while((electron = (Electron *) itTrack.Next())) {
     187      particle = (GenParticle*) electron->Particle.GetObject();
     188      TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
     189                   electron->P4().Px(), electron->P4().Py(),
     190                   electron->P4().Pz(), electron->P4().E(),
     191                   particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
     192      eveTrack = new TEveTrack(&pb, counter, trkProp);
     193      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     194      eveTrack->SetStdTitle();
     195      eveTrack->SetAttLineAttMarker(data_);
     196      data_->AddElement(eveTrack);
     197      eveTrack->SetLineColor(GetColor());
     198      eveTrack->MakeTrack();
     199    }
     200  } else if(type=="Muon") { // CASE 3: MUONS
    246201    Muon *muon;
    247     while((muon = (Muon *)itTrack.Next()))
    248     {
    249       particle = (GenParticle *)muon->Particle.GetObject();
    250       TParticle pb(muon->Charge < 0 ? 13 : -13, 1, 0, 0, 0, 0,
    251         muon->P4().Px(), muon->P4().Py(),
    252         muon->P4().Pz(), muon->P4().E(),
    253         particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
    254       eveTrack = new TEveTrack(&pb, counter, trkProp);
    255       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    256       eveTrack->SetStdTitle();
    257       eveTrack->SetAttLineAttMarker(data_);
    258       data_->AddElement(eveTrack);
    259       eveTrack->SetLineColor(GetColor());
    260       eveTrack->MakeTrack();
    261     }
    262   }
    263   else if(type == "Photon")
    264   { // CASE 4: PHOTONS
     202    while((muon = (Muon *) itTrack.Next())) {
     203      particle = (GenParticle*) muon->Particle.GetObject();
     204      TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
     205                   muon->P4().Px(), muon->P4().Py(),
     206                   muon->P4().Pz(), muon->P4().E(),
     207                   particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
     208      eveTrack = new TEveTrack(&pb, counter, trkProp);
     209      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     210      eveTrack->SetStdTitle();
     211      eveTrack->SetAttLineAttMarker(data_);
     212      data_->AddElement(eveTrack);
     213      eveTrack->SetLineColor(GetColor());
     214      eveTrack->MakeTrack();
     215    }
     216  } else if(type=="Photon") { // CASE 4: PHOTONS
    265217    Photon *photon;
    266     while((photon = (Photon *)itTrack.Next()))
    267     {
     218    while((photon = (Photon *) itTrack.Next())) {
    268219      TParticle pb(22, 1, 0, 0, 0, 0,
    269         photon->P4().Px(), photon->P4().Py(),
    270         photon->P4().Pz(), photon->P4().E(),
    271         0.0, 0.0, 0.0, 0.0);
     220                   photon->P4().Px(), photon->P4().Py(),
     221                   photon->P4().Pz(), photon->P4().E(),
     222                   0.0, 0.0, 0.0, 0.0);
    272223      eveTrack = new TEveTrack(&pb, counter, trkProp);
    273224      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     
    279230      eveTrack->MakeTrack();
    280231    }
    281   }
    282   else if(type == "GenParticle")
    283   { // CASE 5: GENPARTICLES
     232  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
    284233    GenParticle *particle;
    285     while((particle = (GenParticle *)itTrack.Next()))
    286     {
     234    while((particle = (GenParticle *) itTrack.Next())) {
    287235      if(particle->Status != 1) continue;
    288236      TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
    289         particle->P4().Px(), particle->P4().Py(),
    290         particle->P4().Pz(), particle->P4().E(),
    291         particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
    292       eveTrack = new TEveTrack(&pb, counter, trkProp);
    293       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    294       eveTrack->SetStdTitle();
    295       eveTrack->SetAttLineAttMarker(data_);
    296       data_->AddElement(eveTrack);
    297       eveTrack->SetLineColor(GetColor());
    298       if(particle->Charge == 0) eveTrack->SetLineStyle(7);
    299       eveTrack->MakeTrack();
    300     }
    301   }
    302 }
    303 template <>
    304 std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors()
    305 {
     237                   particle->P4().Px(), particle->P4().Py(),
     238                   particle->P4().Pz(), particle->P4().E(),
     239                   particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
     240      eveTrack = new TEveTrack(&pb, counter, trkProp);
     241      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     242      eveTrack->SetStdTitle();
     243      eveTrack->SetAttLineAttMarker(data_);
     244      data_->AddElement(eveTrack);
     245      eveTrack->SetLineColor(GetColor());
     246      if(particle->Charge==0) eveTrack->SetLineStyle(7);
     247      eveTrack->MakeTrack();
     248    }
     249  }
     250}
     251template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
    306252  std::vector<TLorentzVector> output;
    307253  TString type = GetType();
    308254  TIter itTrack(branch_);
    309   if(type == "Track")
    310   { // CASE 1: TRACKS
     255  if(type=="Track") { // CASE 1: TRACKS
    311256    Track *track;
    312     while((track = (Track *)itTrack.Next()))
    313     {
     257    while((track = (Track *) itTrack.Next())) {
    314258      output.push_back(track->P4());
    315259    }
    316   }
    317   else if(type == "Electron")
    318   { // CASE 2: ELECTRONS
     260  } else if(type=="Electron") { // CASE 2: ELECTRONS
    319261    Electron *electron;
    320     while((electron = (Electron *)itTrack.Next()))
    321     {
     262    while((electron = (Electron *) itTrack.Next())) {
    322263      output.push_back(electron->P4());
    323264    }
    324   }
    325   else if(type == "Muon")
    326   { // CASE 3: MUONS
     265  } else if(type=="Muon") { // CASE 3: MUONS
    327266    Muon *muon;
    328     while((muon = (Muon *)itTrack.Next()))
    329     {
     267    while((muon = (Muon *) itTrack.Next())) {
    330268      output.push_back(muon->P4());
    331269    }
    332   }
    333   else if(type == "Photon")
    334   { // CASE 4: PHOTONS
     270  } else if(type=="Photon") { // CASE 4: PHOTONS
    335271    Photon *photon;
    336     while((photon = (Photon *)itTrack.Next()))
    337     {
     272    while((photon = (Photon *) itTrack.Next())) {
    338273      output.push_back(photon->P4());
    339274    }
    340   }
    341   else if(type == "GenParticle")
    342   { // CASE 5: GENPARTICLES
     275  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
    343276    GenParticle *particle;
    344     while((particle = (GenParticle *)itTrack.Next()))
    345     {
     277    while((particle = (GenParticle *) itTrack.Next())) {
    346278      if(particle->Status != 1) continue;
    347       output.push_back(particle->P4());
     279        output.push_back(particle->P4());
    348280    }
    349281  }
Note: See TracChangeset for help on using the changeset viewer.