Fork me on GitHub

Changeset 4d999a57 in git


Ignore:
Timestamp:
Oct 15, 2014, 2:27:37 PM (10 years ago)
Author:
Christophe Delaere <christophe.delaere@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
cfc3160
Parents:
b3c42d3
Message:

Still broken, but better.

debugging may require to transfer chuncks of the code to compiled code.
I have in mind the geometry and the code that prepares the GUI.
Right now I got a segfault + funny cint errors.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • display/DelphesBranchElement.cc

    rb3c42d3 r4d999a57  
     1/*
     2 *  Delphes: a framework for fast simulation of a generic collider experiment
     3 *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
     4 * 
     5 *  This program is free software: you can redistribute it and/or modify
     6 *  it under the terms of the GNU General Public License as published by
     7 *  the Free Software Foundation, either version 3 of the License, or
     8 *  (at your option) any later version.
     9 * 
     10 *  This program is distributed in the hope that it will be useful,
     11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 *  GNU General Public License for more details.
     14 * 
     15 *  You should have received a copy of the GNU General Public License
     16 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 */
     18
     19#include "display/DelphesBranchElement.h"
     20
     21// special case for calo towers
     22template<> 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    }
     32template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
     33
     34// special case for element lists
     35template<> 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    }
     43template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
     44
     45// special case for track lists
     46template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
     47      if(TString(type)=="track") {
     48        data_ = new TEveTrackList(name);
     49        data_->SetMainColor(color_);
     50        data_->SetMarkerColor(color_);
     51        data_->SetMarkerStyle(kCircle);
     52        data_->SetMarkerSize(0.5);
     53      } else if(TString(type)=="photon") {
     54        data_ = new TEveTrackList(name);
     55        data_->SetMainColor(color_);
     56        data_->SetMarkerColor(color_);
     57        data_->SetMarkerStyle(kCircle);
     58        data_->SetMarkerSize(0.5);
     59      } else {
     60        throw std::exception();
     61      }
     62    }
     63template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
     64
  • display/DelphesBranchElement.h

    rb3c42d3 r4d999a57  
    3131{
    3232  public:
    33     DelphesBranchBase():color_(kBlack) {}
    34     DelphesBranchBase(const char* name, const char*type, const enum EColor color):name_(name),type_(type),color_(color) {}
     33    DelphesBranchBase(const char* name="", const char*type="", const enum EColor color=kBlack):name_(name),type_(type),color_(color) {}
    3534    virtual ~DelphesBranchBase() {};
    3635    const char* GetName() const { return (const char*)name_; }
     
    5150  public:
    5251    // constructor
    53     DelphesBranchElement():DelphesBranchBase() {}
    54     DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {}
     52    DelphesBranchElement(const char* name="", const char*type="", const enum EColor color=kBlack):DelphesBranchBase(name, type, color) {
     53      throw std::exception();
     54    }
    5555
    5656    // destructor
     
    6161
    6262    // resets the collection (before moving to the next event)
    63     virtual void Reset() = 0;
     63    virtual void Reset() {};
    6464
    6565    // template class name
     
    7070};
    7171
     72#if !defined(__CINT__) && !defined(__CLING__)
     73
    7274// special case for calo towers
    73 template<> class DelphesBranchElement<DelphesCaloData>: public DelphesBranchBase
    74 {
    75   public:
    76     // constructor
    77     DelphesBranchElement():DelphesBranchBase() {}
    78     DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
    79       if(TString(type)=="tower") {
    80         data_ = new DelphesCaloData(2);
    81         data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
    82         data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
    83         data_->IncDenyDestroy();
    84       } else {
    85         throw std::exception();
    86       }
    87     }
    88 
    89     // destructor
    90     virtual ~DelphesBranchElement() { delete data_; }
    91 
    92     // get the container (ElementList, TrackList, or CaloData)
    93     DelphesCaloData* GetContainer() { return data_; }
    94 
    95     // resets the collection (before moving to the next event)
    96     virtual void Reset() { data_->ClearTowers(); }
    97 
    98     // template class name
    99     virtual const char* GetClassName() { return data_->ClassName(); }
    100 
    101   private:
    102     DelphesCaloData* data_;
    103 };
    104 //template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
    105 //template<> void DelphesBranchElement<DelphesCaloData>::Reset();
     75template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
     76template<> void DelphesBranchElement<DelphesCaloData>::Reset();
    10677
    10778// special case for element lists
    108 template<> class DelphesBranchElement<TEveElementList>: public DelphesBranchBase
    109 {
    110   public:
    111     // constructor
    112     DelphesBranchElement():DelphesBranchBase() {}
    113     DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
    114       if(TString(type)=="vector" || TString(type)=="jet") {
    115         data_ = new TEveElementList(name);
    116         data_->SetMainColor(color_);
    117       } else {
    118         throw std::exception();
    119       }
    120     }
    121 
    122     // destructor
    123     virtual ~DelphesBranchElement() { delete data_; }
    124 
    125     // get the container (ElementList, TrackList, or CaloData)
    126     TEveElementList* GetContainer() { return data_; }
    127 
    128     // resets the collection (before moving to the next event)
    129     virtual void Reset() { data_->DestroyElements(); }
    130 
    131     // template class name
    132     virtual const char* GetClassName() { return data_->ClassName(); }
    133 
    134   private:
    135     TEveElementList* data_;
    136 };
    137 //template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
    138 //template<> void DelphesBranchElement<TEveElementList>::Reset();
     79template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
     80template<> void DelphesBranchElement<TEveElementList>::Reset();
    13981
    14082// special case for track lists
    141 template<> class DelphesBranchElement<TEveTrackList>: public DelphesBranchBase
    142 {
    143   public:
    144     // constructor
    145     DelphesBranchElement():DelphesBranchBase() {}
    146     DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
    147       if(TString(type)=="track") {
    148         data_ = new TEveTrackList(name);
    149         data_->SetMainColor(color_);
    150         data_->SetMarkerColor(color_);
    151         data_->SetMarkerStyle(kCircle);
    152         data_->SetMarkerSize(0.5);
    153       } else if(TString(type)=="photon") {
    154         data_ = new TEveTrackList(name);
    155         data_->SetMainColor(color_);
    156         data_->SetMarkerColor(color_);
    157         data_->SetMarkerStyle(kCircle);
    158         data_->SetMarkerSize(0.5);
    159       } else {
    160         throw std::exception();
    161       }
    162     }
     83template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
     84template<> void DelphesBranchElement<TEveTrackList>::Reset();
    16385
    164     // destructor
    165     virtual ~DelphesBranchElement() { delete data_; }
    166 
    167     // get the container (ElementList, TrackList, or CaloData)
    168     TEveTrackList* GetContainer() { return data_; }
    169 
    170     // resets the collection (before moving to the next event)
    171     virtual void Reset() { data_->DestroyElements(); }
    172 
    173     // template class name
    174     virtual const char* GetClassName() { return data_->ClassName(); }
    175 
    176   private:
    177     TEveTrackList* data_;
    178 };
    179 //template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);
    180 //template<> void DelphesBranchElement<TEveTrackList>::Reset();
     86#endif // CINT, CLING
    18187
    18288#endif //DelphesBranchElement_h
  • display/DisplayLinkDef.h

    rb3c42d3 r4d999a57  
    4242#pragma link C++ class DelphesDisplay+;
    4343#pragma link C++ class DelphesCaloData+;
    44 #pragma link C++ class DelphesBranchElement<DelphesCaloData>;
    45 #pragma link C++ class DelphesBranchElement<TEveElementList>;
    46 #pragma link C++ class DelphesBranchElement<TEveTrackList>;
     44#pragma link C++ class DelphesBranchElement<DelphesCaloData>-!;
     45#pragma link C++ class DelphesBranchElement<TEveElementList>-!;
     46#pragma link C++ class DelphesBranchElement<TEveTrackList>-!;
    4747
    4848#endif
  • examples/geometry.C

    rb3c42d3 r4d999a57  
    1919//#include "display/DelphesCaloData.h"
    2020//#include "display/DelphesDisplay.h"
    21 //#include "display/DelphesBranchElement.h"
     21#include "../display/DelphesBranchElement.h"
    2222//#include "classes/DelphesClasses.h"
    2323#include "TF2.h"
     
    6262void load_event();
    6363void delphes_read();
     64void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element);
     65void delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element);
     66void delphes_read_jets(TClonesArray* data, DelphesBranchBase* element);
     67void delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element);
    6468void readConfig(const char *configFile, const Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays);
    6569
     
    496500   DelphesBranchElement<TEveTrackList>* tlist;
    497501   DelphesBranchElement<DelphesCaloData>* clist;
    498    DelphesBranchElement<TEveTrackList>* elist;
     502   DelphesBranchElement<TEveElementList>* elist;
    499503   for(Int_t b = 0; b<nBranches; ++b) {
    500504     TString input = branches[b*3].GetString();
     
    503507     if(className=="Track") {
    504508       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    505        elist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue);
    506        elements.push_back(elist);
    507        TEveTrackPropagator *trkProp = elist->GetContainer()->GetPropagator();
     509       tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue);
     510       elements.push_back(tlist);
     511       TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    508512       trkProp->SetMagField(0., 0., -tk_Bz);
    509513       trkProp->SetMaxR(tk_radius);
     
    622626   gDelphesDisplay->ImportGeomRhoZ(geometry);
    623627   // find the first calo data and use that to initialize the calo display
    624    for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++Data) {
     628   for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
    625629     if(TString((*data)->GetType())=="tower") {
    626        TEveCalo3D *calo3d = new TEveCalo3D((*data)->GetContainer());
     630//TODO: why do I have to split this in two lines??? seems a cint bug?
     631       DelphesBranchElement<DelphesCaloData>* data_tmp = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(*data);
     632       DelphesCaloData* container =  data_tmp->GetContainer();
     633//       DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
     634       assert(container);
     635       TEveCalo3D *calo3d = new TEveCalo3D(container);
    627636       calo3d->SetBarrelRadius(gRadius);
    628637       calo3d->SetEndCapPos(gHalfLength);
     
    630639       gDelphesDisplay->ImportCaloRPhi(calo3d);
    631640       gDelphesDisplay->ImportCaloRhoZ(calo3d);
    632        TEveCaloLego *lego = new TEveCaloLego((*data)->GetContainer());
     641       TEveCaloLego *lego = new TEveCaloLego(container);
    633642       lego->InitMainTrans();
    634643       lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
     
    653662   // clear the previous event
    654663   gEve->GetViewers()->DeleteAnnotations();
    655    for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++Data) {
    656      (*data)->Reset()
     664   for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
     665     (*data)->Reset();
    657666   }
    658667
     
    691700    TString type = (*element)->GetType();
    692701    // keep the most generic track collection for the end
    693     if(type=="track" && (*element)->GetClassName()=="Track" && nTracks=0) {
     702    if(type=="track" && TString((*element)->GetClassName())=="Track" && nTracks==0) {
    694703      data_tracks = data;
    695704      element_tracks = element;
     
    698707    }
    699708    // branch on the element type
    700     // TODO : I understand that we will have to cast the elements.
    701709    if(type=="tower") delphes_read_towers(*data,*element);
    702710    else if(type=="track" || type=="photon") delphes_read_tracks(*data,*element);
     
    705713  }
    706714  // finish whith what we consider to be the main track collection
    707   if(nTracks>0) delphes_read_tracks(*data,(*element)->GetContainer());
    708 }
    709 
    710 void delphes_read_towers(TClonesArray* data, DelphesBranchElement<TEveElementList>* element) {
    711   DelphesCaloData* container = element->GetContainer();
     715  if(nTracks>0) delphes_read_tracks(*data,*element);
     716}
     717
     718void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element) {
     719  DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(element)->GetContainer();
     720  assert(container);
    712721  // Loop over all towers
    713722  TIter itTower(data);
     
    722731}
    723732
    724 void delphes_read_tracks(TClonesArray* data, DelphesBranchElement<TEveTrackList>* element) {
    725   TEveTrackList* container = element->GetContainer();
     733void delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element) {
     734  TEveTrackList* container = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(element)->GetContainer();
     735  assert(container);
    726736  TString className = element->GetClassName();
    727737  TIter itTrack(data);
     
    741751      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    742752      eveTrack->SetStdTitle();
    743       eveTrack->SetAttLineAttMarker(gTrackList);
     753      eveTrack->SetAttLineAttMarker(container);
    744754      container->AddElement(eveTrack);
    745755      eveTrack->SetLineColor(element->GetColor());
     
    749759    // Loop over all electrons
    750760    Electron *electron;
    751     while((electron = (Electron *) itElectron.Next())) {
     761    while((electron = (Electron *) itTrack.Next())) {
    752762      TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
    753763                   electron->P4().Px(), electron->P4().Py(),
     
    758768      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    759769      eveTrack->SetStdTitle();
    760       eveTrack->SetAttLineAttMarker(gElectronList);
     770      eveTrack->SetAttLineAttMarker(container);
    761771      container->AddElement(eveTrack);
    762772      eveTrack->SetLineColor(element->GetColor());
     
    766776    // Loop over all muons
    767777    Muon *muon;
    768     while((muon = (Muon *) itMuon.Next())) {
     778    while((muon = (Muon *) itTrack.Next())) {
    769779      TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
    770780                   muon->P4().Px(), muon->P4().Py(),
     
    775785      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    776786      eveTrack->SetStdTitle();
    777       eveTrack->SetAttLineAttMarker(gMuonList);
     787      eveTrack->SetAttLineAttMarker(container);
    778788      container->AddElement(eveTrack);
    779789      eveTrack->SetLineColor(element->GetColor());
     
    783793    // Loop over all photons
    784794    Photon *photon;
    785     while((photon = (Photon *) itPhoton.Next())) {
     795    while((photon = (Photon *) itTrack.Next())) {
    786796      TParticle pb(22, 1, 0, 0, 0, 0,
    787797                   photon->P4().Px(), photon->P4().Py(),
     
    792802      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    793803      eveTrack->SetStdTitle();
    794       eveTrack->SetAttLineAttMarker(gPhotonList);
     804      eveTrack->SetAttLineAttMarker(container);
    795805      container->AddElement(eveTrack);
    796806      eveTrack->SetLineColor(element->GetColor());
     
    800810}
    801811
    802 void delphes_read_jets(TClonesArray* data, DelphesBranchElement<TEveElementList>* element) {
    803   TEveElementList* container = element->GetContainer();
     812void delphes_read_jets(TClonesArray* data, DelphesBranchBase* element) {
     813  TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();
     814  assert(container);
    804815  TIter itJet(data);
    805816  Jet *jet;
     
    822833}
    823834
    824 void delphes_read_vectors(TClonesArray* data, DelphesBranchElement<TEveElementList>* element) {
    825   TEveElementList* container = element->GetContainer();
     835void delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element) {
     836  TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();
     837  assert(container);
    826838  TIter itMet(data);
    827839  MissingET *MET;
Note: See TracChangeset for help on using the changeset viewer.