KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVFAZIARawDataReconstructor.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Fri Jan 23 14:17:23 2015
2 //Author: ,,,
3 
5 #include "KVDataAnalyser.h"
6 #include "KVDataSet.h"
7 #include "KVFAZIADB.h"
9 #include "KVDataRepository.h"
10 #include "RVersion.h"
11 #include "KVFAZIADetector.h"
12 #include "KVFAZIA.h"
13 #include "KVSignal.h"
14 #include "TSystem.h"
15 
17 
18 // BEGIN_HTML <!--
20 /* -->
21 <h2>KVFAZIARawDataReconstructor</h2>
22 <h4>Handle reconstruction of FAZIA events</h4>
23 <!-- */
24 // --> END_HTML
26 
27 
28 
32  : taskname("Reconstruction"), datatype("recon")
33 {
34  //Default constructor
35  file = 0;
36  tree = 0;
37  recev = 0;
38  nb_recon = 0;
39 }
40 
41 
42 
45 
47 {
48  // Destructor
50 }
51 
52 
53 
54 
68 
70 {
71  // Creates new ROOT file with TTree for reconstructed events.
72  // By default this file will be written in the same data repository as the raw data file we are reading.
73  // This can be changed by setting the environment variable(s):
74  //
75  // Reconstruction.DataAnalysisTask.OutputRepository: [name of repository]
76  // [name of dataset].Reconstruction.DataAnalysisTask.OutputRepository: [name of repository]
77  //
78  // If no value is set for the current dataset (second variable), the value of the
79  // first variable will be used. If neither is defined, the new file will be written in the same repository as
80  // the raw file (if possible, i.e. if repository is not remote).
81 
82  // Create new KVReconstructedEvent filled with KVFAZIAReconNuc object
83  // used to reconstruct & store events
84 
85  if (!recev) recev = new KVReconstructedEvent(50, "KVFAZIAReconNuc");
86 
87  // get dataset to which we must associate new run
88  KVDataSet* OutputDataset =
90 
91  file = OutputDataset->NewRunfile(datatype.Data(), GetCurrentRunNumber());
92 
93  std::cout << "Writing \"" << datatype.Data() << "\" events in ROOT file " << file->GetName() << std::endl;
94 
95  //tree for reconstructed events
96  tree = new TTree("ReconstructedEvents", Form("%s : %s : %s events created from raw data",
99  datatype.Data())
100  );
101 
102  //leaves for reconstructed events
103  KVEvent::MakeEventBranch(tree, "FAZIAReconEvent", "KVReconstructedEvent", recev);
104 
105  Info("InitRun", "Created reconstructed data tree %s : %s", tree->GetName(), tree->GetTitle());
106  nb_recon = 0;
107 
108 }
109 
110 
111 
112 
120 
122 {
123  // Analysis of event.
124  // RawData TTree is filled with values of parameters for event.
125  // If event has INDRA trigger information (IsIndraEvent()==kTRUE)
126  // then
127  // *) event reconstruction is performed for 'Physics' events
128  // *) or the GeneTree is filled with pulser/laser data for 'Gene' events
129 
130 
131  recev->SetNumber(GetEvent()->GetNumber());
133 
134  ExtraProcessing();
135 
136  nb_recon++;
137  tree->Fill();
138 
139  recev->Clear();
140 
141  return kTRUE;
142 }
143 
144 
145 
146 
148 
150 {
151  KVString label = "";
152 
153  KVFAZIADetector* det = 0;
154  KVSignal* sig = 0;
155  KVReconstructedNucleus* recnuc = 0;
156  while ((recnuc = recev->GetNextParticle())) {
157  TIter next_d(recnuc->GetDetectorList());
158  while ((det = (KVFAZIADetector*)next_d())) {
159  TIter next_s(det->GetListOfSignals());
160  while ((sig = (KVSignal*)next_s())) {
161  if (sig->HasFPGA()) {
162  for (Int_t ii = 0; ii < sig->GetNFPGAValues(); ii += 1) {
163  //SI2-T3-Q1-B003.Q2.RawAmplitude=14
164  if (ii == 0) label = "FPGAEnergy";
165  if (ii == 1) label = "FastFPGAEnergy"; //only for CsI Q3
166  TString ene = GetEvent()->GetFPGAEnergy(
167  det->GetBlockNumber(),
168  det->GetQuartetNumber(),
169  det->GetTelescopeNumber(),
170  sig->GetType(),
171  ii
172  );
173 
174  recnuc->GetParameters()->SetValue(
175  Form("%s.%s.%s", det->GetName(), sig->GetName(), label.Data()),
176  ene.Data()
177  );
178  }
179  }
180  if (!sig->PSAHasBeenComputed()) {
181  sig->TreateSignal();
182  }
183 
184  sig->GetPSAResult(det);
185 // if (psa.GetNpar()) {
186 // *(recnuc->GetParameters()) += psa;
187 // }
188  }
189  }
190  }
191 }
192 
193 
194 
195 
197 
199 {
200  SafeDelete(recev);
201 
202  std::cout << std::endl << " *** Number of reconstructed FAZIA events : "
203  << nb_recon << " ***" << std::endl << std::endl;
204  file->cd();
206  tree->Write();//write tree to file
207 
208  // get dataset to which we must associate new run
209  KVDataSet* OutputDataset =
211  //add new file to repository
212  OutputDataset->CommitRunfile(datatype.Data(), GetCurrentRunNumber(), file);
213 
214  ProcInfo_t pid;
215  if (gSystem->GetProcInfo(&pid) == 0) {
216  std::cout << " ------------- Process infos -------------" << std::endl;
217  printf(" CpuSys = %f s. CpuUser = %f s. ResMem = %f MB VirtMem = %f MB\n",
218  pid.fCpuSys, pid.fCpuUser, pid.fMemResident / 1024., pid.fMemVirtual / 1024.);
219  }
220 
221 }
222 
223 
int Int_t
KVDataAnalyser * gDataAnalyser
KVDataRepositoryManager * gDataRepositoryManager
KVDataSet * gDataSet
Definition: KVDataSet.cpp:30
KVFAZIADB * gFaziaDB
Definition: KVFAZIADB.cpp:16
KVFAZIA * gFazia
Definition: KVFAZIA.cpp:44
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define SafeDelete(p)
bool Bool_t
const Bool_t kTRUE
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
virtual void SetNumber(UInt_t num)
Definition: KVBase.h:209
void WriteBatchInfo(TTree *)
KVDataSet * GetDataSet(const Char_t *repository, const Char_t *dataset) const
Return pointer to named dataset in the given repository.
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition: KVDataSet.h:207
TString GetOutputRepository(const Char_t *taskname) const
Definition: KVDataSet.cpp:2057
void CommitRunfile(const Char_t *type, Int_t run, TFile *file)
Definition: KVDataSet.cpp:1311
TFile * NewRunfile(const Char_t *type, Int_t run)
Definition: KVDataSet.cpp:1057
virtual void Clear(Option_t *opt="")
Definition: KVEvent.cpp:200
static void MakeEventBranch(TTree *tree, const TString &branchname, const TString &classname, T &event, Int_t bufsize=10000000)
Definition: KVEvent.h:468
KVFAZIADBRun * GetRun(Int_t run) const
Definition: KVFAZIADB.h:47
Base class for FAZIA detectors.
const KVSeqCollection * GetListOfSignals() const
Int_t GetQuartetNumber() const
Int_t GetBlockNumber() const
Int_t GetTelescopeNumber() const
Reconstruction of raw FAZIA data.
virtual ~KVFAZIARawDataReconstructor()
Destructor.
Int_t nb_recon
number of reconstructed events
const Char_t * GetFPGAEnergy(Int_t blk, Int_t qua, Int_t tel, TString signaltype, Int_t idx=0)
Int_t GetCurrentRunNumber() const
Definition: KVFAZIAReader.h:73
KVFAZIARawEvent * GetEvent() const
Definition: KVFAZIAReader.h:81
KVDetectorEvent * GetDetectorEvent() const
Definition: KVFAZIAReader.h:85
virtual void ReconstructEvent(KVReconstructedEvent *, KVDetectorEvent *)
void SetValue(const Char_t *name, value_type value)
KVNameValueList * GetParameters() const
Definition: KVParticle.h:735
Physical event reconstructed from data measured with a detector array using implemented identificatio...
KVReconstructedNucleus * GetNextParticle(Option_t *opt="")
Nuclei reconstructed from data measured by a detector array ,.
const KVSeqCollection * GetDetectorList() const
const Char_t * GetType() const
Definition: KVSignal.h:98
virtual void TreateSignal()
Definition: KVSignal.cpp:406
virtual void GetPSAResult(KVDetector *) const
Definition: KVSignal.h:155
Int_t GetNFPGAValues() const
Definition: KVSignal.h:129
Bool_t PSAHasBeenComputed() const
Definition: KVSignal.h:159
Bool_t HasFPGA() const
Definition: KVSignal.h:134
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
virtual const char * GetName() const
virtual const char * GetName() const
virtual const char * GetTitle() const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
virtual int GetProcInfo(ProcInfo_t *info) const
Long_t fMemVirtual
Float_t fCpuSys
Long_t fMemResident
Float_t fCpuUser