2 // Author: Matevz Tadel 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 #include "AliEveTrackCounter.h"
12 #include "TEveManager.h"
13 #include "AliEveTrack.h"
14 #include "TEveGedEditor.h"
16 //==============================================================================
18 //==============================================================================
20 //______________________________________________________________________________
22 // Provides event-based method for tagging of good / bad (or primary /
23 // secondary) tracks. A report can be written into a text file.
25 // AliEveTrack status is toggled by using secondary-selection / ctrl-click
26 // functionality of the GL viewer.
28 // Some of the functionality is implemented in AliEveTrackCounterEditor
31 ClassImp(AliEveTrackCounter)
33 //______________________________________________________________________________
34 AliEveTrackCounter* AliEveTrackCounter::fgInstance = 0;
36 //______________________________________________________________________________
37 AliEveTrackCounter::AliEveTrackCounter(const Text_t* name, const Text_t* title) :
42 fClickAction (kCA_ToggleTrack),
49 // Connects to global signal "AliEveTrack", "SecSelected(AliEveTrack*)".
51 if (fgInstance == 0) fgInstance = this;
52 TQObject::Connect("AliEveTrack", "SecSelected(AliEveTrack*)",
53 "AliEveTrackCounter", this, "DoTrackAction(AliEveTrack*)");
56 //______________________________________________________________________________
57 AliEveTrackCounter::~AliEveTrackCounter()
60 // Disconnect from the global track signals.
62 TQObject::Disconnect("AliEveTrack", "DoTrackAction(AliEveTrack*)");
63 if (fgInstance == this) fgInstance = 0;
66 /******************************************************************************/
68 //______________________________________________________________________________
69 void AliEveTrackCounter::Reset()
71 // Reset internal track-counters and track-list.
75 TIter next(&fTrackLists);
77 while ((tlist = dynamic_cast<TEveTrackList*>(next())))
78 tlist->DecDenyDestroy();
79 fTrackLists.Clear("nodelete");
82 //______________________________________________________________________________
83 void AliEveTrackCounter::RegisterTracks(TEveTrackList* tlist, Bool_t goodTracks)
85 // Register tracks from tlist and tlist itself.
86 // If goodTracks is true, they are considered as primary/good
89 tlist->IncDenyDestroy();
90 fTrackLists.Add(tlist);
92 List_i i = tlist->BeginChildren();
93 while (i != tlist->EndChildren())
95 AliEveTrack* t = dynamic_cast<AliEveTrack*>(*i);
102 t->SetLineStyle(fBadLineStyle);
110 //______________________________________________________________________________
111 void AliEveTrackCounter::DoTrackAction(AliEveTrack* track)
113 // Slot called when track is ctrl-clicked.
115 // No check is done if track actually belongs to one of the
116 // registered track-lists.
118 // Probably it would be safer to copy good/bad tracks into special
120 // In this case one should also override RemoveElementLocal.
122 static const TEveException eh("AliEveTrackCounter::DoTrackAction ");
124 switch (fClickAction)
127 case kCA_PrintTrackInfo:
129 printf("AliEveTrack '%s'\n", track->GetObject(eh)->GetName());
130 const TEveVector &v = track->GetVertex();
131 const TEveVector &p = track->GetMomentum();;
132 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
133 v.fX, v.fY, v.fZ, p.Perp(), p.fZ, TMath::RadToDeg()*p.Phi());
134 printf(" <other information should be printed ... full AliESDtrack>\n");
138 case kCA_ToggleTrack:
140 if (track->GetLineStyle() == 1)
142 track->SetLineStyle(fBadLineStyle);
145 track->SetLineStyle(1);
148 track->ElementChanged();
151 printf("AliEveTrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
152 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
154 if (gEve->GetEditor()->GetModel() == GetObject(eh))
155 gEve->EditElement(this);
160 } // end switch fClickAction
163 /******************************************************************************/
165 //______________________________________________________________________________
166 void AliEveTrackCounter::OutputEventTracks(FILE* out)
168 // Print good-track summary into a plain-text file by iteration
169 // through all registered track-lists.
170 // State of each track is determined by its line-style, it is
171 // considered a good track if it's line style is solid.
176 fprintf(out, "AliEveTrackCounter::FinalizeEvent()\n");
179 fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks);
181 TIter tlists(&fTrackLists);
182 TEveTrackList* tlist;
184 while ((tlist = (TEveTrackList*) tlists()) != 0)
186 List_i i = tlist->BeginChildren();
187 while (i != tlist->EndChildren())
189 AliEveTrack* t = dynamic_cast<AliEveTrack*>(*i);
190 if (t != 0 && t->GetLineStyle() == 1)
193 fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n",
194 cnt, t->GetCharge(), t->GetMomentum().Perp(), t->GetMomentum().Eta());