MarlinTPC  1.2.0
PhotoelectricXMLHelper.h
1 #ifndef PHOTOELECTRICXMLHELPER_H
2 #define PHOTOELECTRICXMLHELPER_H 1
3 
4 // CLHEP
5 #include <CLHEP/Vector/TwoVector.h>
6 
7 // GEAR
8 #include <gearxml/tinyxml.h>
9 #include <gear/TPCParameters.h>
10 
11 
12 // stl
13 #include <vector>
14 #include <map>
15 #include <set>
16 
17 namespace marlintpc{
33 struct Photodot {
34  CLHEP::Hep2Vector _position;
35  double _diameter;
36  int _module;
37  int _id;
38  gear::TiXmlElement* _element;
42  bool operator== (Photodot a){return a._id == _id;}
43 };
44 
45 struct Photoline {
46  CLHEP::Hep2Vector _start;
47  CLHEP::Hep2Vector _end;
48  double _width;
49  int _module;
50  gear::TiXmlElement* _element;
51  bool operator== (Photoline a){return a._module == _module;}
52 };
53 
55 private:
56  gear::TiXmlDocument _photodotFile;
57 
64  std::vector<Photodot> _photodots;
65 
71  std::vector<Photoline> _photolines;
75  static bool Comparison(std::pair<double, std::vector<Photodot>::const_iterator> i, std::pair<double, std::vector<Photodot>::const_iterator> j);
79  void AddPhotodotProjection(gear::TiXmlElement* element, const CLHEP::Hep2Vector centroid, const std::set<gear::GlobalPadIndex> &pads);
84  bool FillPhotodotInformation();
85 
89  bool FillPhotolineInformation();
90 
91 public:
103  PhotoelectricXMLFile(std::string xmlFile);
117  std::vector<std::pair<double, std::vector<Photodot>::const_iterator> > GetSortedPhotodots(double center_x, double center_y);
118 
123  std::vector<std::vector<Photodot>::const_iterator> GetPhotodots();
124 
129  std::vector<std::vector<Photoline>::const_iterator> GetPhotolines();
130 
142  void SetTimeInfo(float start, float end);
155  bool GetTimeInfo(float &start, float &end);
161  void SaveFile(std::string fileName){_photodotFile.SaveFile(fileName);};
171  gear::TiXmlElement* GetPhotoElectricElement();
185  void AddPhotodotProjection(int photodot_id, const CLHEP::Hep2Vector centroid, const std::set<gear::GlobalPadIndex> &pads);
197  void AddPhotodotProjection(const CLHEP::Hep2Vector centroid, const std::set<gear::GlobalPadIndex> &pads);
203  std::map<int, std::set<gear::GlobalPadIndex> > GetPhotodotPads();
209  std::map<int, std::set<gear::GlobalPadIndex> > GetPhotolinePads();
215  void AddPhotolineProjection(int module_id, const std::set<gear::GlobalPadIndex> &pads);
216 };
217 }
218 #endif
Definition: PhotoelectricXMLHelper.h:33
bool operator==(Photodot a)
Used to find a certain photodot by id.
Definition: PhotoelectricXMLHelper.h:42
void AddPhotolineProjection(int module_id, const std::set< gear::GlobalPadIndex > &pads)
Add pads associated to each photoline.
Definition: PhotoelectricXMLHelper.cc:204
gear::TiXmlElement * GetPhotoElectricElement()
This return the main element in the xml file.
Definition: PhotoelectricXMLHelper.cc:161
std::map< int, std::set< gear::GlobalPadIndex > > GetPhotodotPads()
Get pads associated to each photodot.
Definition: PhotoelectricXMLHelper.cc:226
std::vector< std::vector< Photoline >::const_iterator > GetPhotolines()
Photodots are sorted by the index found in the xml file.
Definition: PhotoelectricXMLHelper.cc:129
void SetTimeInfo(float start, float end)
This adds the time information to the xml file.
Definition: PhotoelectricXMLHelper.cc:141
Definition: PhotoelectricXMLHelper.h:45
std::vector< std::vector< Photodot >::const_iterator > GetPhotodots()
Photodots are sorted by the index found in the xml file.
Definition: PhotoelectricXMLHelper.cc:121
void SaveFile(std::string fileName)
Save the internal xml file.
Definition: PhotoelectricXMLHelper.h:161
PhotoelectricXMLFile(std::string xmlFile)
Constructor expecting a xml file with the true photodot positions stored as follows: ...
Definition: PhotoelectricXMLHelper.cc:18
std::map< int, std::set< gear::GlobalPadIndex > > GetPhotolinePads()
Get pads associated to each photoline.
Definition: PhotoelectricXMLHelper.cc:265
bool GetTimeInfo(float &start, float &end)
This reads the time information from the xml file.
Definition: PhotoelectricXMLHelper.cc:150
This provides some tools on handling the xml file used to store information on the Photoelectric anal...
Definition: PhotoelectricXMLHelper.h:54
std::vector< std::pair< double, std::vector< Photodot >::const_iterator > > GetSortedPhotodots(double center_x, double center_y)
This methods sorts the photodots from the photodot file.
Definition: PhotoelectricXMLHelper.cc:110