SValidStore.cc
Go to the documentation of this file.
1 #include <sstream>
2 #include <iostream>
3 #include <fstream>
4 #include <algorithm>
5 
6 #include "SValidStore.h"
7 #include "SIOValidationObj.h"
8 #include "FIOValidationObj.h"
9 #include "TValidationObj.h"
10 #include "TValidationPtr.h"
11 
12 #include <utl/ErrorLogger.h>
13 
14 #include <det/Detector.h>
15 
16 #include <utl/TimeStamp.h>
17 
18 #include <evt/Event.h>
19 #include <evt/ShowerRecData.h>
20 #include <evt/ShowerSRecData.h>
21 
22 #include <sevt/SEvent.h>
23 #include <sevt/Header.h>
24 #include <sevt/Station.h>
25 #include <sevt/PMT.h>
26 #include <sevt/PMTRecData.h>
27 #include <sevt/StationRecData.h>
28 #include <sevt/SortCriteria.h>
29 #include <fwk/LocalCoordinateSystem.h>
30 
31 #include <utl/Trace.h>
32 #include <utl/AugerUnits.h>
33 #include <utl/MathConstants.h>
34 #include <utl/PhysicalConstants.h>
35 #include <utl/TabulatedFunctionErrors.h>
36 #include <utl/UTMPoint.h>
37 #include <fwk/CentralConfig.h>
38 
39 #include <TFile.h>
40 #include <TObjArray.h>
41 #include <TGraph.h>
42 #include <TGraphErrors.h>
43 #include <TMultiGraph.h>
44 #include <TF1.h>
45 #include <TH2D.h>
46 #include <TVector3.h>
47 #include <TMarker.h>
48 #include <TCanvas.h>
49 #include <TTree.h>
50 #include <TFolder.h>
51 #include <TString.h>
52 #include <TPaveText.h>
53 
54 using namespace det;
55 using namespace evt;
56 using namespace sevt;
57 using namespace std;
58 using namespace fwk;
59 
60 
62  vOutputFile(0),
63  vReferenceTree(0),
64  _TvObjPtr(0)
65 {
66 }
67 
68 
70 {
71  delete vOutputFile;
72 }
73 
74 
77 {
78  // Initialize your module here. This method
79  // is called once at the beginning of the run.
80  // The eSuccess flag indicates the method ended
81  // successfully. For other possible return types,
82  // see the VModule documentation.
83 
85  _xmlSValidStore = theCC->GetTopBranch("SValidStore");
86  string outFileName;
87  _xmlSValidStore.GetChild("Filename").GetData(outFileName);
89 
90  if (_Mode != "check") {
91  vOutputFile = new TFile(outFileName.c_str(), _Mode.c_str());
92  _TvObjPtr = new TValidationPtr();
93  } else {
94  vOutputFile = new TFile(outFileName.c_str());
95  _TvObjPtr = new TValidationPtr();
96  }
97 
98  list<string> module;
99  _xmlSValidStore.GetChild("StoreObj").GetData(module);
100 
101  for (list<string>::const_iterator m = module.begin();
102  m != module.end(); ++m)
103  if (_ObjList.find(*m) == _ObjList.end()) {
104  ValidationObj* vObj = Factory(*m);
105  if (vObj)
106  _ObjList[*m] = vObj;
107  }
108 
109  return eSuccess;
110 }
111 
112 
115 {
116  INFO("SValidStore::Run()");
117 
118  if (_Mode != "check")
119  for (map<string, ValidationObj*>::const_iterator vo =_ObjList.begin();
120  vo != _ObjList.end(); ++vo) {
121  ValidationObj* vObj = vo->second;
122  TValidationObj* TvObj = vObj->GetTObject();
123  _TvObjPtr->SetTVObj(TvObj, vObj->GetModuleName());
124 
125  if (vObj->Fill(event)) {
126  vOutputFile->cd();
127  _TvObjPtr->Write((vObj->GetModuleName()).c_str(), TObject::kWriteDelete);
128  }
129  }
130  else {
131  vOutputFile->cd();
132 
133  for (map<string, ValidationObj*>::const_iterator vo = _ObjList.begin();
134  vo != _ObjList.end(); ++vo) {
135  ValidationObj* const vObj = vo->second;
136 
137  cout << "Retrieving Module Name = " << vObj->GetModuleName() << " ... " << endl;
138 
139  _TvObjPtr = (TValidationPtr*)vOutputFile->Get((vObj->GetModuleName()).c_str());
140  cout << "Module name retrieved!" << endl;
141 
142  TValidationObj* const TvObj = _TvObjPtr->GetTVObj();
143  cout << "INFO::before fill!" << endl;
144 
145  if (vObj->Fill(event)) {
146  if (vObj->Validate(TvObj)) {
147 
148  cout << "\n\n\n Obj " << vObj->GetModuleName() << " validated!\n\n\n";
149  vObj->SetValidationOk();
150  return eSuccess;
151 
152  } else {
153 
154  cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
155  "\n\n\n Obj " << vObj->GetModuleName() << " NOT Validated!\n\n\n"
156  "\nIn Reference file:" << endl;
157  TvObj->Dump();
158  cout << "\nIn last checkout:" << endl;
159  TValidationObj* CurTvObj = vObj->GetTObject();
160  CurTvObj->Dump();
161  cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" << endl;
162  return eFailure;
163  }
164  }
165  }
166  }
167  return eSuccess;
168 }
169 
170 
173 {
174  INFO("SValidStore::Finish()");
175  if (_Mode == "check")
176  for (map<string, ValidationObj*>::const_iterator vo = _ObjList.begin();
177  vo != _ObjList.end(); ++vo) {
178  ValidationObj* const vObj = vo->second;
179  if (!vObj->IsValidate()) {
180  cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
181  "\n\n\n Obj " << vObj->GetModuleName() << " NOT Validated!\n\n\n"<<endl;
182  cout<< "\n\n\n Event rejected before the Validation Module in this Chain \n\n\n" <<endl;
183  cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" << endl;
184  return eFailure;
185  }
186  }
187  vOutputFile->cd();
188  vOutputFile->Close();
189 
190  return eSuccess;
191 }
192 
193 
194 void
196 {
197  // Plotting of stations is switched off for now; causes memeory leak
198  // PlotStations(event.GetSEvent());
199 
200  if (event.HasRecShower()) {
201  RecInfo(event);
202  //PlotLDF(event);
203  }
204 }
205 
206 
207 //OK, let's dump out some reconstruction information
208 
209 void
211 { }
212 
213 
215 SValidStore::Factory(const string& objName)
216 {
217  if (objName == "SIOValidation" || objName == "SIOValidationObj")
218  return new SIOValidationObj();
219  else if (objName == "FIOValidation" || objName == "FIOValidationObj")
220  return new FIOValidationObj();
221  else return 0;
222 }
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: SValidStore.cc:76
virtual std::string GetModuleName() const
virtual ~SValidStore()
Definition: SValidStore.cc:69
virtual bool SetTVObj(TValidationObj *, const std::string &name)
virtual bool Fill(const evt::Event &event)=0
Report success to RunController.
Definition: VModule.h:62
TFile * vOutputFile
Definition: SValidStore.h:47
TValidationPtr * _TvObjPtr
Definition: SValidStore.h:51
bool HasRecShower() const
virtual bool Validate(TValidationObj *const e)
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
Definition: SValidStore.cc:172
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Definition: SValidStore.cc:114
std::string _Mode
Definition: SValidStore.h:52
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
virtual void Dump()=0
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
virtual void SetValidationOk()
Definition: ValidationObj.h:34
utl::Branch _xmlSValidStore
Definition: SValidStore.h:50
virtual bool IsValidate()
Definition: ValidationObj.h:33
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
std::map< std::string, ValidationObj * > _ObjList
Definition: SValidStore.h:49
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
Main configuration utility.
Definition: CentralConfig.h:51
void RecInfo(const evt::Event &event)
Definition: SValidStore.cc:210
ValidationObj * Factory(const std::string &ObjName)
Definition: SValidStore.cc:215
constexpr double m
Definition: AugerUnits.h:121
virtual TValidationObj * GetTObject() const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
void ExamineEvent(const evt::Event &event)
Definition: SValidStore.cc:195
virtual TValidationObj * GetTVObj()

, generated on Tue Sep 26 2023.