GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AgataTrackDisplay.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
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 2 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, write to the *
17  * FreAgataTrackDisplaye Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef Gw_AgataTrackDisplay
24 #include "AgataTrackDisplay.h"
25 #endif
26 
27 #ifndef ROOT_TEveRGBAPalette
28 #include "TEveRGBAPalette.h"
29 #endif
30 
31 #ifndef ROOT_TEveVSDStructs
32 #include "TEveVSDStructs.h"
33 #endif
34 
35 using namespace Gw;
36 
37 //
39 
40 //__________________________________________________________
41 AgataTrackDisplay::AgataTrackDisplay(const Text_t* name)
42  : TEveBoxSet(name),
43  fPalette(new TEveRGBAPalette()),
44  fMaxEnergy(-1),
45  fBoxWidth(0.4),
46  fBoxHeight(0.4),
47  fSelectedIdx(-1),
48  fSelectedValue(-1),
49  fBoxVert(),
50  fNofTracks(0),
51  fHitIdPerTrack(0),
52  fStyle("Rectangle"),
53  fLog("AgataTrackDisplay")
54 {
55  // default constructor
56  fBoxVert.Set(32);
57  SetOwnIds(kTRUE);
58 }
59 
60 //__________________________________________________________
62 {
63  // default destructor
64  delete fPalette;
65 }
66 
67 //__________________________________________________________
69 {
70 
71  TEveDigitSet::DigitBase_t* selectedDigit = GetDigit(idx);
72 
73  if (selectedDigit)
74  fSelectedValue = selectedDigit->fValue;
75 
76  fSelectedIdx = idx;
77 
78  SecSelected(this, idx);
79 }
80 
81 //__________________________________________________________
83 {
84  s.ToLower();
85  if (s.Contains("rec") )
86  fStyle = "Rectangle";
87  else if (s.Contains("cone") )
88  fStyle = "Cone";
89  else if (s.Contains("elli") )
90  fStyle = "Elliptic";
91  else {
92  fLog.SetProcessMethod("SetStyle(TString )");
93  fLog << error << "Undefined style for tracks, set to Rectangle" << nline;
94  fStyle = "Rectangle";
95  }
96 
97 }
98 
99 //__________________________________________________________
101 {
102  fPalette->SetMax(Int_t(e+0.5));
103  fMaxEnergy = Int_t(e+0.5);
104  SetPalette(fPalette);
105 }
106 
107 //__________________________________________________________
109 {
110  fNofTracks++;
111  fHitIdPerTrack = 0;
112 }
113 
114 //__________________________________________________________
115 void AgataTrackDisplay::AddTracklet(Float_t e, Float_t x1, Float_t y1, Float_t z1,
116  Float_t x2, Float_t y2, Float_t z2, Bool_t eTot)
117 {
118  Float_t* vert;
119 
120  MakeSize(e);
121  if ( fStyle.Contains("Cone") ) {
122  TEveVector dir, pos;
123  pos.Set(x1, y1, z1);
124  dir.Set(x2-x1, y2-y1, z2-z1);
125  AddCone(pos, dir, fBoxHeight);
126  } else if ( fStyle.Contains("Elliptic") ) {
127  TEveVector dir, pos;
128  pos.Set(x1, y1, z1);
129  dir.Set(x2-x1, y2-y1, z2-z1);
130  AddEllipticCone(pos, dir, fBoxHeight, fBoxHeight/2, 0);
131  } else {
132  vert = MakeRecTVert(x1, y1, z1, x2, y2, z2);
133  AddBox(vert);
134  }
135 
136  DigitValue(Int_t(e+0.5));
137 
138  if (eTot)
139  fTotalEnergyArray.push_back(Int_t(e+0.5));
140 
141  fHitIdPerTrack++;
142  SetIndexes();
143 }
144 
145 //__________________________________________________________
147 {
148 
149  if ( fStyle.Contains("Cone") )
150  Reset(TEveBoxSet::kBT_Cone, kFALSE, 32);
151  else if ( fStyle.Contains("Elliptic") )
152  Reset(TEveBoxSet::kBT_EllipticCone, kFALSE, 32);
153  else
154  Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 32);
155 
156  fMapIdx.clear();
157  fTotalEnergyArray.clear();
158  fNofTracks = 0;
159 }
160 
161 //__________________________________________________________
163 {
164  if (e != 0.)
165  fBoxWidth = fBoxHeight = e*0.8*GetDefWidth()/fMaxEnergy + 0.2*GetDefWidth();
166  else
167  fBoxWidth = fBoxHeight = GetDefWidth()*0.2;
168 }
169 
170 //__________________________________________________________
171 Float_t* AgataTrackDisplay::MakeRecTVert(Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2)
172 {
173  fBoxVert.Reset();
174  fBoxVert[0] = x1+GetBoxWidth(); fBoxVert[3] = x1-GetBoxWidth(); fBoxVert[6] = x1-GetBoxWidth(); fBoxVert[9] = x1+GetBoxWidth();
175  fBoxVert[1] = y1+GetBoxHeight(); fBoxVert[4] = y1+GetBoxHeight(); fBoxVert[7] = y1-GetBoxHeight(); fBoxVert[10] = y1-GetBoxHeight();
176  fBoxVert[2] = z1; fBoxVert[5] = z1; fBoxVert[8] = z1; fBoxVert[11] = z1;
177 
178  fBoxVert[12] = x2+GetBoxWidth(); fBoxVert[15] = x2-GetBoxWidth(); fBoxVert[18] = x2-GetBoxWidth(); fBoxVert[21] = x2+GetBoxWidth();
179  fBoxVert[13] = y2+GetBoxHeight(); fBoxVert[16] = y2+GetBoxHeight(); fBoxVert[19] = y2-GetBoxHeight(); fBoxVert[22] = y2-GetBoxHeight();
180  fBoxVert[14] = z2; fBoxVert[17] = z2; fBoxVert[20] = z2; fBoxVert[23] = z2;
181 
182  return fBoxVert.GetArray();
183 }
184 
185 //__________________________________________________________
187 {
188  Int_t energy = -1;
189 
190  if (fTotalEnergyIter != fTotalEnergyArray.end()) {
191  energy = *fTotalEnergyIter;
192  ++fTotalEnergyIter;
193  }
194 
195  return energy;
196 }
197 
198 
199 //__________________________________________________________
200 std::pair<Int_t, Int_t> AgataTrackDisplay::GetIndexes(Int_t index)
201 {
202  return fMapIdx[index];
203 }
204 
205 //__________________________________________________________
207 {
208  std::pair<Int_t, Int_t> p;
209  p.first = fNofTracks-1;
210  p.second = fHitIdPerTrack-1;
211  fMapIdx[GetPlex()->Size()-1] = p;
212 
213 }
214 
Int_t NextEnergy()
return next total energy
void SetIndexes()
Set indexes.
AgataTrackDisplay a class to display tracks on event.
LogMessage & error(LogMessage &)
ClassImp(AgataTrackDisplay) AgataTrackDisplay
void ResetTracks()
Reset tracks.
LogMessage & nline(LogMessage &)
void SetStyle(TString s)
Set style (rec/cone)
void DigitSelected(Int_t idx)
overwrite base function
void AddTracklet(Float_t e, Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2, Bool_t eTot=false)
Add Track.
std::pair< Int_t, Int_t > GetIndexes(Int_t index)
Get index pair.
void AddNewTrack()
Add new track, resetting counter.
void MakeSize(Float_t e)
Make track size.
void SetMaxEnergy(Float_t e)
Set Max energy.
Float_t GetBoxWidth()
Get width/height of Box.
virtual void SetProcessMethod(const char *)
To set the current method.
Float_t * MakeRecTVert(Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2)
log message