FairRoot/PandaRoot
PndCaloDraw.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- PndCaloDraw source file -----
10 // ----- Created 03/01/08 by M. Al-Turany -----
11 // -------------------------------------------------------------------------
12 #include "PndCaloDraw.h"
13 
14 #include "FairBoxSet.h" // for FairBoxSet
15 #include "FairEventManager.h" // for FairEventManager
16 #include "FairRootManager.h" // for FairRootManager
17 #include "FairRunAna.h" // for FairRunAna
18 #include "FairTSBufferFunctional.h" // for StopTime
19 #include "FairTimeStamp.h" // for FairTimeStamp
20 
21 #include <iosfwd> // for ostream
22 #include "TClonesArray.h" // for TClonesArray
23 #include "TEveBoxSet.h"
24 #include "TEveManager.h" // for TEveManager, gEve
25 #include "TVector3.h" // for TVector3
26 
27 #include <stddef.h> // for NULL
28 #include <iostream> // for operator<<, basic_ostream, etc
29 
30 using std::cout;
31 using std::endl;
32 
33 FairBoxSet* fq;
35 
36 // ----- Default constructor -------------------------------------------
38  : FairTask("PndCaloDraw",0),
39  fVerbose(0),
40  fList(NULL),
41  fEventManager(NULL),
42  fManager(NULL),
43  fTimeWindowPlus(0.),
44  fTimeWindowMinus(0.),
45  fStartTime(0.),
46  fUseEventTime(kTRUE),
47  fStartFunctor(),
48  fStopFunctor()
49 {
50 }
51 // -------------------------------------------------------------------------
52 
53 
54 
55 // ----- Standard constructor ------------------------------------------
57  : FairTask(name, iVerbose),
58  fVerbose(iVerbose),
59  fList(NULL),
60  fEventManager(NULL),
61  fManager(NULL),
62  fTimeWindowPlus(0.),
63  fTimeWindowMinus(0.),
64  fStartTime(0.),
65  fUseEventTime(kTRUE),
66  fStartFunctor(),
67  fStopFunctor()
68 {
69 }
70 // -------------------------------------------------------------------------
71 InitStatus PndCaloDraw::Init()
72 {
73  if(fVerbose>1) {
74  cout<< "PndCaloDraw::Init()" << endl;
75  }
76  fManager = FairRootManager::Instance();
77 
78  fList = (TClonesArray*)FairRootManager::Instance()->GetObject(GetName());
79  //std::cout << fList << std::endl;
80  if (fList==0) {
81  cout << "PndCaloDraw::Init() branch " << GetName() << " Not found! Task will be deactivated "<< endl;
82  SetActive(kFALSE);
83  return kERROR;
84  }
85  if(fVerbose>2) {
86  cout<< "PndCaloDraw::Init() get track list" << fList<< endl;
87  }
88  fEventManager =FairEventManager::Instance();
89  if(fVerbose>2) {
90  cout<< "PndCaloDraw::Init() get instance of FairEventManager " << endl;
91  }
92 
93  fCaloHisto = new TH2F("hBarrelCal","BarrelCal", 350, -5.191, 5.191, 200, -TMath::Pi(), TMath::Pi());
94  fEveHist = new TEveCaloDataHist();
95  fEveHist->AddHistogram(fCaloHisto);
96  fEveHist->RefSliceInfo(0).Setup("BarrelCalorimeter",0.01, kRed);
97  fEveHist->IncDenyDestroy();
98 // gEve->AddToListTree(fEveHist, kFALSE);
99 
100  fCalo3D = new TEveCalo3D(fEveHist);
101  fCalo3D->SetBarrelRadius(64.00);
102  fCalo3D->SetForwardEndCapPos(212);
103  fCalo3D->SetBackwardEndCapPos(-64);
104  fCalo3D->SetMaxTowerH(200.0);
105  fCalo3D->SetScaleAbs(kTRUE);
106  gEve->AddElement(fCalo3D, fEventManager );
107 
108 
109  fStartFunctor = new StopTime();
110  fStopFunctor = new StopTime();
111 
112  return kSUCCESS;
113 }
114 // -------------------------------------------------------------------------
115 void PndCaloDraw::Exec(Option_t*)
116 {
117  if(IsActive()) {
118  TObject* p;
119  Reset();
120  // cout<< "PndCaloDraw::Init() Exec! " << fList->GetEntriesFast() << endl;
121  if (FairRunAna::Instance()->IsTimeStamp()) {
122  fList->Clear();
123  Double_t eventTime = FairRootManager::Instance()->GetEventTime();
124  if (fUseEventTime) { fStartTime = eventTime - fTimeWindowMinus; }
125  cout << "EventTime: " << eventTime << " TimeWindow: " << fStartTime << " - " << eventTime + fTimeWindowPlus << std::endl;
126 
127  fList = FairRootManager::Instance()->GetData(GetName(), fStartFunctor, fStartTime, fStopFunctor, eventTime + fTimeWindowPlus); //FairRootManager::Instance()->GetEventTime() +
128 
129  }
130 
131  //fList = (TClonesArray *)fManager->GetObject(GetName());
132  if (fVerbose > 1) {
133  std::cout << GetName() << " fList: " << fList->GetEntries() << std::endl;
134  }
135  fCaloHisto->Reset();
136  for (Int_t i=0; i<fList->GetEntriesFast(); ++i) {
137  p=fList->At(i);
138  FillHisto(p);
139  }
140  fCalo3D->SetMaxValAbs(fCaloHisto->GetBinContent(fCaloHisto->GetMaximumBin()));
141  std::cout << "CaloHisto MaxValue: " << fEveHist->GetMaxVal(kTRUE) << " " << fCaloHisto->GetBinContent(fCaloHisto->GetMaximumBin()) << std::endl;
142  fCalo3D->DataChanged();
143  gEve->Redraw3D(kFALSE);
144  }
145 }
146 
147 
148 void PndCaloDraw::FillHisto(TObject* obj)
149 {
150  TVector3 position = GetVector(obj);
151  Double_t energy = GetEnergy(obj);
152 
153  fCaloHisto->Fill(position.PseudoRapidity(), position.Phi(), energy);
154 }
155 
156 
158 {
160 }
161 
163 {
165 }
166 
167 // ----- Destructor ----------------------------------------------------
169 {
170 }
171 // -------------------------------------------------------------------------
173 {
174 
175 }
176 // -------------------------------------------------------------------------
179 {
180 }
181 // -------------------------------------------------------------------------
183 {
184  if(fq!=0) {
185  fq->Reset();
186  gEve->RemoveElement(fq, fEventManager );
187  }
188 }
189 
190 
192 
193 
Double_t p
Definition: anasim.C:58
int fVerbose
Definition: poormantracks.C:24
BinaryFunctor * fStartFunctor
Definition: PndCaloDraw.h:108
virtual TVector3 GetVector(TObject *obj)=0
TClonesArray * fList
Definition: PndCaloDraw.h:92
TH2F * fCaloHisto
Definition: PndCaloDraw.h:95
Int_t i
Definition: run_full.C:25
virtual ~PndCaloDraw()
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
Double_t fStartTime
Definition: PndCaloDraw.h:101
Double_t fX
Definition: PndCaloDraw.cxx:34
virtual void Finish()
virtual InitStatus Init()
Definition: PndCaloDraw.cxx:71
Double_t fTimeWindowMinus
Definition: PndCaloDraw.h:100
Double_t fZ
Definition: PndCaloDraw.cxx:34
virtual void SetTimeWindowPlus(Double_t val)
FairBoxSet * fq
Definition: PndCaloDraw.cxx:33
Double_t fTimeWindowPlus
Definition: PndCaloDraw.h:99
virtual void SetTimeWindowMinus(Double_t val)
Double_t
virtual void SetParContainers()
BinaryFunctor * fStopFunctor
Definition: PndCaloDraw.h:109
TString name
FairEventManager * fEventManager
Definition: PndCaloDraw.h:93
Double_t fY
Definition: PndCaloDraw.cxx:34
Int_t fVerbose
Definition: PndCaloDraw.h:82
TEveCalo3D * fCalo3D
Definition: PndCaloDraw.h:97
TEveCaloDataHist * fEveHist
Definition: PndCaloDraw.h:96
Bool_t fUseEventTime
Definition: PndCaloDraw.h:102
ClassImp(PndAnaContFact)
Int_t iVerbose
virtual Double_t GetEnergy(TObject *obj)=0
Double_t Pi
FairRootManager * fManager
Definition: PndCaloDraw.h:94
virtual void Exec(Option_t *option)
virtual void FillHisto(TObject *obj)
Double_t energy
Definition: plot_dirc.C:15