GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LNL/MetaWatchers.C
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.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  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 // Watcher definition
22 #ifndef _MetaWatchers
23 #include "MetaWatchers.h"
24 #endif
25 
26 #include "GenericFrame.h"
27 
28 using namespace ADF;
29 
30 VertexBuilder *VertexBuilder::gDefautVertexBuilder = 0x0;
31 UShort_t VertexBuilder::gNbVertexBuilder = 0u;
32 
34 fVertexFrame(0x0),
35 fIsToBeDeleted(false)
36 {
37  gNbVertexBuilder++;
38  // NO otherwise endless loop VertexBuilder::theDefault();
39 }
40 
42 {
43  if ( fIsToBeDeleted ) {
44  if ( fVertexFrame ) {
45  delete fVertexFrame; fVertexFrame = 0x0;
46  }
47  }
48 
49  // now take care of the globals
50  gNbVertexBuilder--;
51 
52  // last VertexBuilder delete the globals otherwise the user should call explicitely DestroyGlobals
53  if ( gNbVertexBuilder == 0u )
55 }
56 
57 VertexBuilder *VertexBuilder::theDefault()
58 {
59  if ( gDefautVertexBuilder == 0x0 ) {
60  GlobalVertex *vertex =
61  new GlobalVertex("GCVertex","Global Constant Vertex");
62  vertex->SetVertex();
63 
64  Watcher::SetFirst(vertex);
65 
66  gDefautVertexBuilder = vertex;
67  }
68  return gDefautVertexBuilder;
69 }
70 
72 {
73  VertexBuilder *result_b = 0x0;
74 
75  if ( gDefautVertexBuilder == 0x0 )
76  VertexBuilder::theDefault();
77 
78  Watcher *w =
79  Watcher::GetLastRegistered("VertexBuilder");
80  result_b =
81  dynamic_cast<VertexBuilder *> (w);
82 
83  return result_b;
84 }
85 
87 {
88  if ( gDefautVertexBuilder )
89  { delete gDefautVertexBuilder; gDefautVertexBuilder = 0x0; }
90 }
91 
93 (Double_t x,Double_t y,Double_t z,Double_t Dx,Double_t Dy,Double_t Dz,Double_t beta)
94 {
95  VertexInterface *gdata = GetDataPointer<VertexInterface>(fVertexFrame);
96 
97  gdata->SetPosition(x,y,z);
98  gdata->SetDirection(Dx,Dy,Dz);
99  gdata->SetBeta(beta);
100 }
101 
102 
104 
105 GlobalVertex::GlobalVertex(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir) :
106 WatcherWithTag(name,title,sp_dir,tag_dir),
108 {
109  fVertexFrame = MainFrameFactory::theMainFactory().
110  NewSharedFrame( FactoryItem("Agata","meta:vertex",Version(0,0)), FactoryItem("Agata","meta:vertex",Version(1,1)) );
111 
112  fIsToBeDeleted = true;
113 }
114 
116 {
117 
118 }
119 
121 
122 GlobalDC::GlobalDC(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir) :
123  WatcherWithTag(name,title,sp_dir,tag_dir),
124  fBeta(0x0),
125  fPosition(0x0),
126  fExpansion(0x0),
127  fDirection(0x0)
128 {
129  fVertexBuilder = dynamic_cast<VertexBuilder *> ( Watcher::GetLastRegistered("VertexBuilder") );
130 
131  fBeta = MakeTH1<TH1F>("Beta","Beta ",500,0.,1.0);
132  TagOn(fBeta);
133 
134  fPosition = MakeTH3<TH3F>("VertexP","Position of the vertex;x;y;z",50,-50.,50.,50,-50.,50.,50,-50.,50.);
135  fExpansion = MakeTH3<TH3F>("VertexE","Expansion of the vertex ;x;y;z",100,-200.,200.,100,-200.,200.,100,-500.,7000.);
136  fDirection = MakeTH3<TH3F>("VertexD","Direction of the recoil nucleus;dx;dy;dz",50,-1.,1.,50,-1.,1.,50,-1.,1.);
137 }
138 
140 {
141 }
142 
143 void GlobalDC::DoCanvas(TCanvas *c, Option_t *o)
144 {
145  TString opt = o;
146  if ( opt.Contains("tag") ) {
147  DrawTag(c,opt);
148  return;
149  }
150 }
151 
152 Bool_t GlobalDC::SetTrigger( ADF::DFTrigger *trigger )
153 {
154  Watcher::SetTrigger(trigger);
155  return true;
156  // this watcher does not need a Frame, just to trigg ... it just take the values from static methods of VertexBuilder
157 }
158 
159 void GlobalDC::Exec(Option_t */*option*/)
160 {
161  Double_t x, y, z, wx, wy, wz,dx, dy, dz, beta;
162 
163  if ( gDebug > 3 )
164  printf("GlobalDC::Exec is called \n");
165 
166  VertexInterface *vertex = fVertexBuilder->GetVertex();
167  beta = vertex->GetBeta();
168 
169  // cout << " --> " << VertexBuilder::theCurrentVertex()->GetBeta() << endl;
170 
171  // if ( VertexBuilder::theCurrentVertex()->GetBeta() > 0.00) {
172  vertex->GetPosition(x,y,z);
173  vertex->GetDirection(dx,dy,dz);
174  wx=beta*dx+x;
175  wy=beta*dy+y;
176  wz=beta*dz+z;
177 
178  fBeta->Fill(beta);
179  fPosition->Fill(x,y,z);
180  fExpansion->Fill(wx,wy,wz);
181  fDirection->Fill(dx,dy,dz);
182 // }
183 }
184 
185 
virtual void GetDirection(Double_t &, Double_t &, Double_t &, Double_t=0.0) const =0
get the direction of the source (last argument is used in case the position depends on time) ...
virtual VertexInterface * GetVertex()
Get the vertex data interface.
printf("******************************************************************** \n")
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
To set the Frames (through a trigger) associated to this watcher.
Interface for any watcher that is a VertexBuilder.
virtual void SetVertex(Double_t=0., Double_t=0., Double_t=0., Double_t=0., Double_t=0., Double_t=1., Double_t=0.02)
modify the current vertext definition. In principle done by event by event in Exec ...
Watcher that built the spectra expected for a Vertex.
virtual void GetPosition(Double_t &, Double_t &, Double_t &, Double_t=0.0) const =0
get the position of the source (last argument is used in case the position depends on time) ...
GlobalDC(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
virtual ~GlobalVertex()
virtual void SetPosition(Double_t, Double_t, Double_t, Double_t=0.0)=0
Set the position of the source (last argument is used in case the position depends on time) ...
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
Bool_t fIsToBeDeleted
True if the vertex frame is to be deleted by this. Otherwise it is extracted from a trigger i...
virtual ~GlobalDC()
virtual ~VertexBuilder()
virtual Double_t GetBeta(Double_t=0.0) const =0
get recoil velocity
Base class for a Watcher.
Definition: Watchers.h:60
void DrawTag(TCanvas *, Option_t *)
To display tagged histograms and their reference.
Definition: Watchers.cpp:1003
static void DestroyGlobals()
to delete the default VertexWatcher
Base class for version numbers.
Definition: Version.h:38
suitable for a vertex that is not based on event by event basis
GlobalVertex(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
virtual void Exec(Option_t *option="")
watch the current frame
void TagOn(TObject *)
Add this histogram to the list of tagged histograms.
Definition: Watchers.cpp:901
Base class for a trigger on a data flow.
Definition: Trigger.h:155
virtual void SetDirection(Double_t, Double_t, Double_t, Double_t=0.0)=0
set the direction of the source (last argument is used in case the position depends on time) ...
SharedFP * fVertexFrame
Pointer to a Vertex Frame. Has to do SharedFP since can be in the data flow.
virtual void SetBeta(Double_t, Double_t=0.0)=0
set recoil velocity
Base class that described an item in a Factory.
Definition: FactoryItem.h:52
ClassImp(GlobalVertex)
static VertexBuilder * theCurrentVertexBuilder()
to get the current VertexWatcher (for other watchers) i.e. the last one registered.