GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSI/PSAWatchers.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 _PSAWatchers
23 #include "PSAWatchers.h"
24 #endif
25 
26 using namespace ADF;
27 
29 
30 Bool_t PSAWatcher::SetTrigger(ADF::DFTrigger* trigger )
31 {
32  return Watcher::GetFromTrigger(trigger, "data:psa", fFrame);
33 }
34 
36 
37 Float_t PSACrystal3D::fgMetric = 10.;
38 Float_t PSACrystal3D::fRadius = 5. ;
39 Float_t PSACrystal3D::fDepht = 10.;
40 Int_t PSACrystal3D::fNBinX = 50;
41 Int_t PSACrystal3D::fNBinZ = 50;
42 Float_t PSACrystal3D::fDefaultECutMin = 0.;
43 Float_t PSACrystal3D::fDefaultECutMax = 100000000.;
44 
45 
46 PSACrystal3D::PSACrystal3D( const char * name, const char * title, TDirectory *sp_dir, TDirectory *tag_dir):
47  PSAWatcher(name,title,sp_dir,tag_dir),
48  fH3DHitPosition(0x0),
49  fE0(0x0),
50  fE1(0x0),
51  fT0(0x0),
52  fT1(0x0),
53  fTE0(0x0),
54  fTE1(0x0),
55  fEnergySeg(0x0),
56  fNbHits(0x0),
57  fCurrentECutMin(fDefaultECutMin),
58  fCurrentECutMax(fDefaultECutMax)
59 {
60  fH3DHitPosition = MakeTH3<TH3F>("H3DHitPosition", "Distribution of Hits in the crystal; x (cm); y (cm); z (cm)",
63  fNBinZ, 0, fDepht );
64  fE0 = MakeTH1<TH1F>("ECore0", "Core energy 0, (high gain)",6000, 0, 6000);
65  fE1 = MakeTH1<TH1F>("ECore1", "Core energy 1, (low gain) ",1000, 0, 10000);
66  fE1->SetLineColor(kRed);
67  fT0 = MakeTH1<TH1F>("TCore0", "Core time 0",300, 0, 100);
68  fT1 = MakeTH1<TH1F>("TCore1", "Core time 1",300, 0, 100);
69  fT1->SetLineColor(kRed);
70  fTE0 = MakeTH2<TH2F>("TECore0", "Time energy 0",600,0,6000,300, 0, 100);
71  fTE1 = MakeTH2<TH2F>("TECore1", "Time energy 1",600, 0,6000,300, 0, 100);
72 
73  fEnergySeg = MakeTH1<TH1F>("ESum", "Sum of segment",6000, 0, 6000);
74  fNbHits = MakeTH1<TH1F>("NbHits", "Nb hits in crystal",20, 0, 20);
75 }
76 
78 {
79  ;
80 }
81 
82 
83 void PSACrystal3D::DoCanvas(TCanvas * c, Option_t *o)
84 {
85  TString option = o;
86  if ( option == "3D" ) {
87  fH3DHitPosition->Draw(o);
88  }
89  else {
90  c->Divide(3,2);
91  c->cd(1);
92  fE0->Draw();
93  c->cd(2);
94  fE1->Draw();
95  c->cd(3);
96  fEnergySeg->Draw();
97  c->cd(4);
98  fT0->Draw();
99  fT1->Draw("same");
100  c->cd(5);
101  fTE0->Draw("col");
102  c->cd(6);
103  fTE1->Draw("col");
104  }
105 }
106 
107 void PSACrystal3D::Exec(Option_t * /*option*/)
108 {
109  // be sure the frame has been set properly
110  if ( fFrame == 0x0 || !fFrame->IsValid() )
111  { SetLastExecStatus(-1); return; }
112 
113  const PSAInterface *data = GetCstDataPointer<PSAInterface>(fFrame);
114 
115  Double_t e = 0.;
116  for( UShort_t i=0u; i < data->GetNbHits(); i++ ) {
117  e += data->GetHit(i)->GetE();
118  if( data->GetHit(i)->GetE() >= fCurrentECutMin && data->GetHit(i)->GetE() <= fCurrentECutMax )
119  fH3DHitPosition->Fill(data->GetHit(i)->GetX()/fgMetric,
120  data->GetHit(i)->GetY()/fgMetric,
121  data->GetHit(i)->GetZ()/fgMetric);
122  }
123  fNbHits->Fill(data->GetNbHits());
124  fE0->Fill(data->GetE(0u));
125  fE1->Fill(data->GetE(1u));
126  fT0->Fill(data->GetT(0));
127  fT1->Fill(data->GetT(1));
128  fTE0->Fill(data->GetE(0u),data->GetT(0));
129  fTE1->Fill(data->GetE(1u),data->GetT(1));
130  fEnergySeg->Fill(e);
131 }
132 
133 void PSACrystal3D::SetEnergyCut( Float_t EcutMin,Float_t EcutMax ){
134  if( EcutMax < EcutMin ) {
135  std::cerr << "ERROR: PSACrystal3D::SetEnergyCut( Float_t EcutMin,Float_t EcutMax)"
136  << std::endl
137  << "ECutMin greater than ECutMax, the cut has not been changed : "
138  << "ECutMin = " << fCurrentECutMin
139  << " EcutMax = " << fCurrentECutMax << std::endl;
140  return;
141  }
142 
143  if( EcutMin != fCurrentECutMin && EcutMax != fCurrentECutMax ) {
144  fCurrentECutMin = EcutMin;
145  fCurrentECutMax = EcutMax;
146  fH3DHitPosition->Reset();
147  TString newtitle = Form("Distribution of Hits in the crystal E #in [%lf,%lf]; x (cm); y (cm); z (cm)",
148  EcutMin,
149  EcutMax);
150  fH3DHitPosition->SetTitle(newtitle.Data());
151  }
152 }
153 
154 void PSACrystal3D::SetCurrentECutMin( Float_t EcutMin )
155 {
156  fCurrentECutMin = EcutMin;
157 }
158 void PSACrystal3D::SetCurrentECutMax( Float_t EcutMax )
159 {
160  fCurrentECutMax = EcutMax;
161 }
162 Float_t PSACrystal3D::GetCurrentECutMin() const
163 {
164  return(fCurrentECutMin);
165 }
166 Float_t PSACrystal3D::GetCurrentECutMax() const
167 {
168  return(fCurrentECutMax);
169 }
170 
171 
172 
virtual Bool_t IsValid() const
true if it is a valid pointer
Definition: Frame.h:616
virtual UShort_t GetNbHits() const =0
To know the number of Hits currently on the stack.
virtual Double_t GetY() const
Definition: Hits.h:57
Float_t GetCurrentECutMax() const
static Float_t fRadius
static Int_t fNBinZ
void SetCurrentECutMin(Float_t EcutMin)
virtual Double_t GetE(UInt_t=0u) const =0
to get the energy associated to the core
virtual Double_t GetE() const
Definition: Hits.h:67
static Float_t fDepht
void SetCurrentECutMax(Float_t EcutMax)
SharedFP * fFrame
virtual Double_t GetT(UInt_t=0u) const =0
to get the time associated to the core
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
To get a 3D map of hits in a particular crystal.
void SetLastExecStatus(Short_t s=0)
reset last status. 0 means no error, 0 < means error, > 0 means ok with conditions ...
Definition: Watchers.h:294
PSACrystal3D(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
virtual Double_t GetX() const
Definition: Hits.h:55
virtual void Exec(Option_t *option="")
Base class for a trigger on a data flow.
Definition: Trigger.h:155
ADF::LogMessage & endl(ADF::LogMessage &log)
ClassImp(PSAWatcher)
virtual Double_t GetZ() const
Definition: Hits.h:59
Float_t GetCurrentECutMin() const
TH3F * fH3DHitPosition
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
Set the frame to be watched from the trigger.
virtual Hit * GetHit(UShort_t)=0
To get back a particular Hit (already on the stack !)
static Int_t fNBinX
virtual ~PSACrystal3D()
Base Watcher working for any kind of Frame (Frame interface)
void SetEnergyCut(Float_t EcutMin, Float_t EcutMax)
to apply cut on the hits