GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GANIL/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 #include "MetaWatchers.h"
23 #include "GenericFrame.h"
24 
25 using namespace ADF;
26 
27 VertexBuilder *VertexBuilder::gDefautVertexBuilder = 0x0;
28 UShort_t VertexBuilder::gNbVertexBuilder = 0u;
29 
31 fVertexFrame(0x0),
32 fIsToBeDeleted(false)
33 {
34  gNbVertexBuilder++;
35  // NO otherwise endless loop VertexBuilder::theDefault();
36 }
37 
39 {
40  if ( fIsToBeDeleted ) {
41  if ( fVertexFrame ) {
42  delete fVertexFrame; fVertexFrame = 0x0;
43  }
44  }
45 
46  // now take care of the globals
47  gNbVertexBuilder--;
48 
49  // last VertexBuilder delete the globals otherwise the user should call explicitely DestroyGlobals
50  if ( gNbVertexBuilder == 0u )
52 }
53 
54 VertexBuilder *VertexBuilder::theDefault()
55 {
56  if ( gDefautVertexBuilder == 0x0 ) {
57  GlobalVertex *vertex =
58  new GlobalVertex("GCVertex","Global Constant Vertex");
59  vertex->SetVertex();
60 
61  Watcher::SetFirst(vertex);
62 
63  gDefautVertexBuilder = vertex;
64  }
65  return gDefautVertexBuilder;
66 }
67 
69 {
70  VertexBuilder *result_b = 0x0;
71 
72  if ( gDefautVertexBuilder == 0x0 )
73  VertexBuilder::theDefault();
74 
75  Watcher *w =
76  Watcher::GetLastRegistered("VertexBuilder");
77  result_b =
78  dynamic_cast<VertexBuilder *> (w);
79 
80  return result_b;
81 }
82 
84 {
85  if ( gDefautVertexBuilder )
86  { delete gDefautVertexBuilder; gDefautVertexBuilder = 0x0; }
87 }
88 
90 (Double_t x,Double_t y,Double_t z,Double_t Dx,Double_t Dy,Double_t Dz,Double_t beta)
91 {
92  VertexInterface *gdata = GetDataPointer<VertexInterface>(fVertexFrame);
93 
94  gdata->SetPosition(x,y,z);
95  gdata->SetDirection(Dx,Dy,Dz);
96  gdata->SetBeta(beta);
97 }
98 
99 
101 
102 GlobalVertex::GlobalVertex(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir) :
103 WatcherWithTag(name,title,sp_dir,tag_dir),
105 {
106  fVertexFrame = MainFrameFactory::theMainFactory().
107  NewSharedFrame( FactoryItem("Agata","meta:vertex",Version(0,0)), FactoryItem("Agata","meta:vertex",Version(1,1)) );
108 
109  fIsToBeDeleted = true;
110 }
111 
113 {
114 
115 }
116 
118 
119 GlobalDC::GlobalDC(const char *name, const char *title, TDirectory *sp_dir, TDirectory *tag_dir) :
120  WatcherWithTag(name,title,sp_dir,tag_dir),
121  fBeta(0x0),
122  fPosition(0x0),
123  fExpansion(0x0),
124  fDirection(0x0)
125 {
126  fVertexBuilder = dynamic_cast<VertexBuilder *> ( Watcher::GetLastRegistered("VertexBuilder") );
127 
128  fBeta = MakeTH1<TH1F>("Beta","Beta ",500,0.,1.0);
129  TagOn(fBeta);
130 
131  fPosition = MakeTH3<TH3F>("VertexP","Position of the vertex;x;y;z",50,-50.,50.,50,-50.,50.,50,-50.,50.);
132  fExpansion = MakeTH3<TH3F>("VertexE","Expansion of the vertex ;x;y;z",100,-200.,200.,100,-200.,200.,100,-500.,7000.);
133  fDirection = MakeTH3<TH3F>("VertexD","Direction of the recoil nucleus;dx;dy;dz",50,-1.,1.,50,-1.,1.,50,-1.,1.);
134 }
135 
137 {
138 }
139 
140 void GlobalDC::DoCanvas(TCanvas *c, Option_t *o)
141 {
142  TString opt = o;
143  if ( opt.Contains("tag") ) {
144  DrawTag(c,opt);
145  return;
146  }
147 }
148 
150 {
151  Watcher::SetTrigger(trigger);
152  return true;
153  // this watcher does not need a Frame, just to trigg ... it just take the values from static methods of VertexBuilder
154 }
155 
156 void GlobalDC::Exec(Option_t */*option*/)
157 {
158  Double_t x, y, z, wx, wy, wz,dx, dy, dz, beta;
159 
160  if ( gDebug > 3 )
161  printf("GlobalDC::Exec is called \n");
162 
163  VertexInterface *vertex = fVertexBuilder->GetVertex();
164  beta = vertex->GetBeta();
165 
166  // cout << " --> " << VertexBuilder::theCurrentVertex()->GetBeta() << endl;
167 
168  // if ( VertexBuilder::theCurrentVertex()->GetBeta() > 0.00) {
169  vertex->GetPosition(x,y,z);
170  vertex->GetDirection(dx,dy,dz);
171  wx=beta*dx+x;
172  wy=beta*dy+y;
173  wz=beta*dz+z;
174 
175  fBeta->Fill(beta);
176  fPosition->Fill(x,y,z);
177  fExpansion->Fill(wx,wy,wz);
178  fDirection->Fill(dx,dy,dz);
179 // }
180 }
181 
182 
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()
ClassImp(GlobalVertex)
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
static VertexBuilder * theCurrentVertexBuilder()
to get the current VertexWatcher (for other watchers) i.e. the last one registered.