Fork me on GitHub

Changeset a3b2495 in git for display


Ignore:
Timestamp:
Oct 16, 2014, 10:52:47 AM (10 years ago)
Author:
Christophe Delaere <christophe.delaere@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
fafc433
Parents:
84dd1c8
Message:

Display of automatically selected elements working

The original features are back, but with a much more flexible code that
selects automatically the list of branches from the tcl file. The main
issue left is the GUI (handler not found), and then some more
cleaning. One idea is to further exploit templating to avoid ifs when
leading events.

Location:
display
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • display/DelphesBranchElement.cc

    r84dd1c8 ra3b2495  
    4343template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
    4444
     45//TODO: does the type really make sense?
    4546// special case for track lists
    4647template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) {
     
    5859        data_->SetMarkerSize(0.5);
    5960      } else {
    60         throw std::exception();
     61        data_ = new TEveTrackList(name);
     62        data_->SetMainColor(color_);
     63        data_->SetMarkerColor(color_);
     64        data_->SetMarkerStyle(kCircle);
     65        data_->SetMarkerSize(0.5);
     66        //throw std::exception();
    6167      }
    6268    }
  • display/DelphesEventDisplay.cc

    r84dd1c8 ra3b2495  
    109109   for(std::vector<DelphesBranchBase*>::iterator element = gElements.begin(); element<gElements.end(); ++element) {
    110110     DelphesBranchElement<TEveTrackList>*   item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element);
    111      DelphesBranchElement<DelphesCaloData>* item_v2 = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(*element);
    112      DelphesBranchElement<TEveElementList>* item_v3 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element);
     111     DelphesBranchElement<TEveElementList>* item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element);
    113112     if(item_v1) gEve->AddElement(item_v1->GetContainer());
    114113     if(item_v2) gEve->AddElement(item_v2->GetContainer());
    115      if(item_v3) gEve->AddElement(item_v3->GetContainer());
    116114   }
    117115
     
    123121   // find the first calo data and use that to initialize the calo display
    124122   for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
    125      if(TString((*data)->GetType())=="tower") {
     123     if(TString((*data)->GetType())=="tower") { // we could also use GetClassName()=="DelphesCaloData"
    126124       DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
    127125       assert(container);
     
    142140   }
    143141
    144    //make_gui();
    145    //load_event();
     142   //make_gui(); //TODO put back!
     143   //load_event(); //TODO put back!
    146144   gEve->Redraw3D(kTRUE);   
    147145
     
    163161   DelphesBranchElement<DelphesCaloData>* clist;
    164162   DelphesBranchElement<TEveElementList>* elist;
     163   // first loop with all but tracks
    165164   for(Int_t b = 0; b<nBranches; ++b) {
    166165     TString input = branches[b*3].GetString();
    167166     TString name = branches[b*3+1].GetString();
    168167     TString className = branches[b*3+2].GetString();
    169      if(className=="Track") {
    170        if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    171        tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue);
    172        elements.push_back(tlist);
    173        TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
    174        trkProp->SetMagField(0., 0., -tk_Bz);
    175        trkProp->SetMaxR(tk_radius);
    176        trkProp->SetMaxZ(tk_length);
    177      } else if(className=="Tower") {
     168     if(className=="Tower") {
    178169       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    179170       clist = new DelphesBranchElement<DelphesCaloData>(name,"tower",kBlack);
     
    191182       }
    192183     } else if(className=="Electron") {
    193        tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kRed);
     184       tlist = new DelphesBranchElement<TEveTrackList>(name,"electron",kRed);
    194185       elements.push_back(tlist);
    195186       TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
     
    205196       trkProp->SetMaxZ(tk_length);
    206197     } else if(className=="Muon") {
    207        tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kGreen);
     198       tlist = new DelphesBranchElement<TEveTrackList>(name,"muon",kGreen);
    208199       elements.push_back(tlist);
    209200       TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
     
    214205       elements.push_back(new DelphesBranchElement<TEveElementList>(name,"vector",kViolet));
    215206     } else if(className=="GenParticle") {
    216        tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kCyan);
     207       tlist = new DelphesBranchElement<TEveTrackList>(name,"genparticle",kCyan);
    217208       elements.push_back(tlist);
    218209       tlist->GetContainer()->SetRnrSelf(false);
     
    222213       trkProp->SetMaxR(tk_radius);
    223214       trkProp->SetMaxZ(tk_length);
     215     } else {
     216       continue;
    224217     }
    225218//TODO one possible simplification could be to add the array to the element class.
    226219     arrays.push_back(gTreeReader->UseBranch(name));
     220   }
     221   // second loop for tracks
     222   for(Int_t b = 0; b<nBranches; ++b) {
     223     TString input = branches[b*3].GetString();
     224     TString name = branches[b*3+1].GetString();
     225     TString className = branches[b*3+2].GetString();
     226     if(className=="Track") {
     227       if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
     228       tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue);
     229       elements.push_back(tlist);
     230       TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
     231       trkProp->SetMagField(0., 0., -tk_Bz);
     232       trkProp->SetMaxR(tk_radius);
     233       trkProp->SetMaxZ(tk_length);
     234       arrays.push_back(gTreeReader->UseBranch(name));
     235     }
    227236   }
    228237}
     
    248257   delphes_read();
    249258
    250 //TODO: it blocks somewhere below....
    251 //TODO: also the event content has one weird entry "TEveCalData" -> corruption????
    252 //other observation: projections appear in the 3D view ! -> seems to indicate that we have a common problem there.
    253 //should check the content of the elements vector when filling them
    254259   // update display
    255260   TEveElement* top = (TEveElement*)gEve->GetCurrentEvent();
     
    277282  std::vector<TClonesArray*>::iterator data = gArrays.begin();
    278283  std::vector<DelphesBranchBase*>::iterator element = gElements.begin();
    279   std::vector<TClonesArray*>::iterator data_tracks = gArrays.begin();
    280   std::vector<DelphesBranchBase*>::iterator element_tracks = gElements.begin();
    281   Int_t nTracks = 0;
    282284  for(; data<gArrays.end() && element<gElements.end(); ++data, ++element) {
    283285    TString type = (*element)->GetType();
    284     // keep the most generic track collection for the end
    285     if(type=="track" && TString((*element)->GetClassName())=="Track" && nTracks==0) {
    286       data_tracks = data;
    287       element_tracks = element;
    288       nTracks = (*data_tracks)->GetEntries();
    289       continue;
    290     }
    291286    // branch on the element type
    292287    if(type=="tower") delphes_read_towers(*data,*element);
    293     else if(type=="track" || type=="photon") delphes_read_tracks(*data,*element);
     288    else if(type=="track" || type=="photon" || type=="electron" || type=="muon" || type=="genparticle") delphes_read_tracks(*data,*element);
    294289    else if(type=="jet") delphes_read_jets(*data,*element);
    295290    else if(type=="vector") delphes_read_vectors(*data,*element);
    296291  }
    297   // finish whith what we consider to be the main track collection
    298   if(nTracks>0) delphes_read_tracks(*data,*element);
    299292}
    300293
     
    317310  TEveTrackList* container = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(element)->GetContainer();
    318311  assert(container);
    319   TString className = element->GetClassName();
     312  TString type = element->GetType();
    320313  TIter itTrack(data);
    321314  Int_t counter = 0;
    322315  TEveTrack *eveTrack;
    323316  TEveTrackPropagator *trkProp = container->GetPropagator();
    324   if(className=="Track") {
     317  if(type=="track") {
    325318    // Loop over all tracks
    326319    Track *track;
     
    330323                   track->P4().Pz(), track->P4().E(),
    331324                   track->X, track->Y, track->Z, 0.0);
    332 
    333325      eveTrack = new TEveTrack(&pb, counter, trkProp);
    334326      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     
    339331      eveTrack->MakeTrack();
    340332    }
    341   } else if(className=="Electron") {
     333  } else if(type=="electron") {
    342334    // Loop over all electrons
    343335    Electron *electron;
     
    346338                   electron->P4().Px(), electron->P4().Py(),
    347339                   electron->P4().Pz(), electron->P4().E(),
    348                    0., 0., 0., 0.);
    349 
    350       eveTrack = new TEveTrack(&pb, counter, trkProp);
    351       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    352       eveTrack->SetStdTitle();
    353       eveTrack->SetAttLineAttMarker(container);
    354       container->AddElement(eveTrack);
    355       eveTrack->SetLineColor(element->GetColor());
    356       eveTrack->MakeTrack();
    357   }
    358   } else if(className=="Muon") {
    359     // Loop over all muons
    360     Muon *muon;
    361     while((muon = (Muon *) itTrack.Next())) {
    362       TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
    363                    muon->P4().Px(), muon->P4().Py(),
    364                    muon->P4().Pz(), muon->P4().E(),
    365340                   0., 0., 0., 0.);
    366341
     
    373348      eveTrack->MakeTrack();
    374349    }
    375   } else if(className=="Photon") {
     350  } else if(type=="muon") {
     351    // Loop over all muons
     352    Muon *muon;
     353    while((muon = (Muon *) itTrack.Next())) {
     354      TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
     355                   muon->P4().Px(), muon->P4().Py(),
     356                   muon->P4().Pz(), muon->P4().E(),
     357                   0., 0., 0., 0.);
     358
     359      eveTrack = new TEveTrack(&pb, counter, trkProp);
     360      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     361      eveTrack->SetStdTitle();
     362      eveTrack->SetAttLineAttMarker(container);
     363      container->AddElement(eveTrack);
     364      eveTrack->SetLineColor(element->GetColor());
     365      eveTrack->MakeTrack();
     366    }
     367  } else if(type=="photon") {
    376368    // Loop over all photons
    377369    Photon *photon;
     
    381373                   photon->P4().Pz(), photon->P4().E(),
    382374                   0., 0., 0., 0.);
    383 
     375      eveTrack = new TEveTrack(&pb, counter, trkProp);
     376      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     377      eveTrack->SetStdTitle();
     378      eveTrack->SetAttLineAttMarker(container);
     379      eveTrack->SetLineStyle(7);
     380      container->AddElement(eveTrack);
     381      eveTrack->SetLineColor(element->GetColor());
     382      eveTrack->MakeTrack();
     383    }
     384  } else if(type=="genparticle") {
     385    // Loop over all particles
     386    GenParticle *particle;
     387    while((particle = (GenParticle *) itTrack.Next())) {
     388      TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
     389                   particle->P4().Px(), particle->P4().Py(),
     390                   particle->P4().Pz(), particle->P4().E(),
     391                   particle->X, particle->Y, particle->Z, particle->T);
    384392      eveTrack = new TEveTrack(&pb, counter, trkProp);
    385393      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     
    388396      container->AddElement(eveTrack);
    389397      eveTrack->SetLineColor(element->GetColor());
     398      if(particle->Charge==0) eveTrack->SetLineStyle(7);
    390399      eveTrack->MakeTrack();
    391400    }
Note: See TracChangeset for help on using the changeset viewer.