Jpp
JHead.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JHEAD__
2 #define __JAANET__JHEAD__
3 
4 #include <string>
5 #include <vector>
6 #include <cmath>
7 #include <ctype.h>
8 
9 #include "TObject.h"
10 
11 #include "evt/Vec.hh"
12 #include "evt/Head.hh"
13 
14 #include "JLang/JException.hh"
16 #include "JROOT/JRootClass.hh"
17 
18 
19 /**
20  * \author mdejong
21  */
22 
23 namespace JAANET {}
24 namespace JPP { using namespace JAANET; }
25 
26 namespace JAANET {
27 
28  using JLANG::JException;
30 
31 
32  static const char AANET_TAG_SEPARATOR = '_'; //!< Separator for AAnet tag extension for multiple tags ("_<counter>").
33 
34  class JHead; // forward declaration for copy methods
35 
36 
37  /**
38  * Copy header from <tt>from</tt> to <tt>to</tt>.
39  *
40  * \param from header
41  * \param to header
42  */
43  extern void copy(const JHead& from, Head& to);
44 
45 
46  /**
47  * Copy header from <tt>from</tt> to <tt>to</tt>.
48  *
49  * \param from header
50  * \param to header
51  */
52  extern void copy(const Head& from, JHead& to);
53 
54 
55  /**
56  * Get tag without aanet extension "_<counter>" for identical tags.
57  *
58  * \param tag tag
59  * \return tag
60  */
61  inline std::string getTag(const std::string& tag)
62  {
63  using namespace std;
64 
65  const string::size_type pos = tag.find(AANET_TAG_SEPARATOR);
66 
67  if (pos != string::npos) {
68 
69  for (string::size_type i = pos + 1; i != tag.size(); ++i) {
70  if (!isdigit(tag[i])) {
71  return tag;
72  }
73  }
74 
75  return tag.substr(0, pos);
76  }
77 
78  return tag;
79  }
80 
81 
82  /**
83  * Start of run record.
84  */
85  struct start_run {
86  /**
87  * Default constructor.
88  */
89  start_run() :
90  run_id(0)
91  {}
92 
93  int run_id; ///< MC run number
94 
96  };
97 
98 
99  /**
100  * General purpose string class.
101  */
102  struct String {
103  /**
104  * Default constructor.
105  */
106  String() :
107  buffer()
108  {}
109 
110  /**
111  * Test match.
112  *
113  * \param object string
114  * \return true if matches; else false
115  */
116  inline bool match(const String& object) const
117  {
118  return buffer == object.buffer;
119  }
120 
121  std::string buffer; ///< General purpose name
122 
123  ClassDefNV(String,1);
124  };
125 
126 
127  /**
128  * Detector file.
129  */
130  struct detector :
131  public String
132  {
133  ClassDefNV(detector,1);
134  };
135 
136 
137  /**
138  * Muon descriptor file.
139  */
140  struct muon_desc_file :
141  public String
142  {
144  };
145 
146 
147  /**
148  * Target.
149  */
150  struct target :
151  public String
152  {
153  ClassDefNV(target,1);
154  };
155 
156 
157  /**
158  * Neutrino cross section file.
159  */
160  struct XSecFile :
161  public String
162  {
163  ClassDefNV(XSecFile,1);
164  };
165 
166 
167  /**
168  * General purpose class of phase space generation.
169  */
170  struct cut {
171  /**
172  * Default constructor.
173  */
174  cut() :
175  Emin(0),
176  Emax(0),
177  cosTmin(0),
178  cosTmax(0)
179  {}
180 
181  /**
182  * Comparison.
183  *
184  * \param object cut
185  * \return true if this cut less than given cut; else false
186  */
187  inline bool less(const cut& object) const
188  {
189  if (Emin == object.Emin &&
190  Emax == object.Emax)
191  return cosTmax < object.cosTmin;
192  else
193  return Emax < object.Emin;
194  }
195 
196  /**
197  * Test match.
198  *
199  * \param object cut
200  * \return true if matches; else false
201  */
202  inline bool match(const cut& object) const
203  {
204  return (Emin == object.Emin &&
205  Emax == object.Emax &&
206  cosTmin == object.cosTmin &&
207  cosTmax == object.cosTmax);
208  }
209 
210  double Emin; ///< Minimal energy [GeV]
211  double Emax; ///< Maximal energy [GeV]
212  double cosTmin; ///< Minimal cosine zenith angle
213  double cosTmax; ///< Maximal cosine zenith angle
214 
215  ClassDefNV(cut,1);
216  };
217 
218 
219  /**
220  * Phase space of primary particle.
221  */
222  struct cut_primary :
223  public cut
224  {
226  };
227 
228 
229  /**
230  * Phase space of atmospheric muon generation.
231  */
232  struct cut_seamuon :
233  public cut
234  {
236  };
237 
238 
239  /**
240  * Phase space of incoming particle
241  */
242  struct cut_in :
243  public cut
244  {
245  ClassDefNV(cut_in,1);
246  };
247 
248 
249  /**
250  * Phase space of incident neutrino.
251  */
252  struct cut_nu :
253  public cut
254  {
255  ClassDefNV(cut_nu,1);
256  };
257 
258 
259  /**
260  * Description of Monte Carlo event generation applications.
261  */
262  struct generator {
263  /**
264  * Default constructor.
265  */
267  program(),
268  version(),
269  date(),
270  time()
271  {}
272 
273  /**
274  * Test match.
275  *
276  * Note that only the name of program is matched.
277  *
278  * \param object generator
279  * \return true if matches; else false
280  */
281  inline bool match(const generator& object) const
282  {
283  return program == object.program;
284  }
285 
286  std::string program; ///< program name
287  std::string version; ///< program version
288  std::string date; ///< processing date
289  std::string time; ///< processing time
290 
292  };
293 
294 
295  /**
296  * Generator for neutrino interaction
297  */
298  struct physics :
299  public generator
300  {
301  ClassDefNV(physics,1);
302  };
303 
304 
305  /**
306  * Generator for simulation.
307  */
308  struct simul :
309  public generator
310  {
311  ClassDefNV(simul,1);
312  };
313 
314 
315  /**
316  * Neutrino energy spectrum.
317  */
318  struct spectrum {
319  /**
320  * Default constructor.
321  */
322  spectrum() :
323  alpha(0)
324  {}
325 
326  /**
327  * Test match.
328  *
329  * \param object spectrum
330  * \return true if matches; else false
331  */
332  inline bool match(const spectrum& object) const
333  {
334  return (alpha == object.alpha);
335  }
336 
337  double alpha; ///< Energy spectrum: \f$ \Phi \propto E^{-\alpha} \f$
338 
339  ClassDefNV(spectrum,1);
340  };
341 
342 
343  /**
344  * The cylinder used for photon tracking.
345  */
346  struct can {
347  /**
348  * Default constructor.
349  */
350  can() :
351  zmin(0),
352  zmax(0),
353  r(0)
354  {}
355 
356  /**
357  * Test match.
358  *
359  * \param object can
360  * \return true if matches; else false
361  */
362  inline bool match(const can& object) const
363  {
364  return (zmin == object.zmin &&
365  zmax == object.zmax &&
366  r == object.r);
367  }
368 
369  double zmin; ///< Bottom [m]
370  double zmax; ///< Top [m]
371  double r; ///< Radius [m]
372 
373  ClassDefNV(can,1);
374  };
375 
376 
377  /**
378  * The fixe cylinder used for photon tracking.
379  */
380  struct fixedcan {
381  /**
382  * Default constructor.
383  */
385  xcenter(0),
386  ycenter(0),
387  zmin(0),
388  zmax(0),
389  radius(0)
390  {}
391 
392  /**
393  * Test match.
394  *
395  * \param object can
396  * \return true if matches; else false
397  */
398  inline bool match(const fixedcan& object) const
399  {
400  return (xcenter == object.xcenter &&
401  xcenter == object.ycenter &&
402  zmin == object.zmin &&
403  zmax == object.zmax &&
404  radius == object.radius);
405  }
406 
407  double xcenter; ///< x-center [m]
408  double ycenter; ///< y-center [m]
409  double zmin; ///< Bottom [m]
410  double zmax; ///< Top [m]
411  double radius; ///< Radius [m]
412 
413  ClassDefNV(fixedcan,1);
414  };
415 
416 
417  /**
418  * Neutrino vertex volume.
419  */
420  struct genvol {
421  /**
422  * Default constructor.
423  */
424  genvol() :
425  zmin(0),
426  zmax(0),
427  r(0),
428  volume(0),
429  numberOfEvents(0)
430  {}
431 
432  /**
433  * Test match.
434  *
435  * \param object generation volume
436  * \return true if matches; else false
437  */
438  inline bool match(const genvol& object) const
439  {
440  return (zmin == object.zmin &&
441  zmax == object.zmax &&
442  r == object.r);
443  }
444 
445  /**
446  * Addition.
447  *
448  * \param object generation volume
449  * \return this generation volume
450  */
451  inline genvol& add(const genvol& object)
452  {
453  numberOfEvents += object.numberOfEvents;
454 
455  return *this;
456  }
457 
458  /**
459  * Scale.
460  *
461  * \param factor 1D scale factor
462  * \param z z position
463  * \return this genvol
464  */
465  inline genvol& mul(const double factor,
466  const double z = 0.0)
467  {
468  zmin = (zmin - z) * factor + z;
469  zmax = (zmax - z) * factor + z;
470  r *= factor;
471  volume *= factor * factor * factor;
472 
473  return *this;
474  }
475 
476  double zmin; ///< Bottom [m]
477  double zmax; ///< Top [m]
478  double r; ///< Radius [m]
479  double volume; ///< Volume [m^3]
480  double numberOfEvents; ///< Number of events
481 
482  ClassDefNV(genvol,1);
483  };
484 
485 
486  /**
487  * Coordinate origin.
488  */
489  struct coord_origin :
490  public Vec
491  {
492  /**
493  * Default constructor.
494  */
496  Vec()
497  {}
498 
499  /**
500  * Constructor.
501  *
502  * \param x x position
503  * \param y y position
504  * \param z z position
505  */
506  coord_origin(const double x,
507  const double y,
508  const double z) :
509  Vec(x,y,z)
510  {}
511 
512  /**
513  * Test match.
514  *
515  * \param object coordinate origin
516  * \return true if matches; else false
517  */
518  inline bool match(const coord_origin& object) const
519  {
520  return (x == object.x &&
521  y == object.y &&
522  z == object.z);
523  }
524 
526  };
527 
528 
529  /**
530  * Phase space for incident neutrino.
531  */
532  struct genhencut {
533  /**
534  * Default constructor.
535  */
537  gDir(0),
538  Emin(0)
539  {}
540 
541  double gDir; ///< Angle
542  double Emin; ///< Minimal energy [GeV]
543 
545  };
546 
547 
548  /**
549  * Normlisation of CORSIKA events.
550  */
551  struct norma {
552  /**
553  * Default constructor.
554  */
555  norma() :
556  primaryFlux(0),
558  {}
559 
560  /**
561  * Test match.
562  *
563  * \param object normalisation
564  * \return true if matches; else false
565  */
566  inline bool match(const norma& object) const
567  {
568  return (primaryFlux == object.primaryFlux);
569  }
570 
571  /**
572  * Addition.
573  *
574  * \param object normalisation
575  * \return this normalisation
576  */
577  inline norma& add(const norma& object)
578  {
579  numberOfPrimaries += object.numberOfPrimaries;
580 
581  return *this;
582  }
583 
584  double primaryFlux; ///< Primary flux
585  double numberOfPrimaries; ///< Number of primaries
586 
587  ClassDefNV(norma,1);
588  };
589 
590 
591  /**
592  * Normalisation of MUPAGE events.
593  */
594  struct livetime {
595  /**
596  * Default constructor.
597  */
599  numberOfSeconds(0),
600  errorOfSeconds(0)
601  {}
602 
603  /**
604  * Test match.
605  *
606  * \param object live time
607  * \return true if matches; else false
608  */
609  inline bool match(const livetime& object) const
610  {
611  return ((numberOfSeconds == 0.0 && object.numberOfSeconds == 0.0) ||
612  (numberOfSeconds > 0.0 && object.numberOfSeconds > 0.0));
613  }
614 
615  /**
616  * Addition.
617  *
618  * \param object live time
619  * \return this live time
620  */
621  inline livetime& add(const livetime& object)
622  {
623  numberOfSeconds += object.numberOfSeconds;
625  object.errorOfSeconds * object.errorOfSeconds);
626 
627  return *this;
628  }
629 
630  /**
631  * Scale.
632  *
633  * \param factor 1D scale factor
634  * \return this livetime
635  */
636  inline livetime& mul(const double factor)
637  {
638  numberOfSeconds /= (factor * factor);
639  errorOfSeconds /= (factor * factor);
640 
641  return *this;
642  }
643 
644  double numberOfSeconds; ///< Live time [s]
645  double errorOfSeconds; ///< Uncertainty on live time [s]
646 
647  ClassDefNV(livetime,1);
648  };
649 
650 
651  /**
652  * Neutrino flux.
653  */
654  struct flux {
655  public:
656  /**
657  * Default constructor.
658  */
659  flux() :
660  type(0),
661  key(),
662  file_1(),
663  file_2()
664  {}
665 
666  int type; ///< Type
667  std::string key; ///< Key
668  std::string file_1; ///< File name
669  std::string file_2; ///< File name
670 
671  ClassDefNV(flux,1);
672  };
673 
674 
675  /**
676  * The bottom of the sea.
677  */
678  struct seabottom {
679  /**
680  * Default constructor.
681  */
683  z(0)
684  {}
685 
686  /**
687  * Test match.
688  *
689  * \param object sea bottom
690  * \return true if matches; else false
691  */
692  inline bool match(const seabottom& object) const
693  {
694  return (z == object.z);
695  }
696 
697  double z; ///< Sea bottom [m]
698 
700  };
701 
702 
703  /**
704  * Livetime of DAQ data.
705  */
706  struct DAQ {
707  public:
708  /**
709  * Default constructor.
710  */
711  DAQ() :
712  livetime_s(0.0)
713  {}
714 
715  /**
716  * Test match.
717  *
718  * \param object DAQ
719  * \return true if matches; else false
720  */
721  inline bool match(const DAQ& object) const
722  {
723  return ((livetime_s == 0.0 && object.livetime_s == 0.0) ||
724  (livetime_s > 0.0 && object.livetime_s > 0.0));
725  }
726 
727  /**
728  * Addition.
729  *
730  * \param object DAQ
731  * \return this DAQ
732  */
733  inline DAQ& add(const DAQ& object)
734  {
735  livetime_s += object.livetime_s;
736 
737  return *this;
738  }
739 
740  double livetime_s; ///< Live time [s]
741 
742  ClassDefNV(DAQ,1);
743  };
744 
745 
746  /**
747  * Scaling time of neutrino interaction generators.
748  */
749  struct tgen {
750  /**
751  * Default constructor.
752  */
753  tgen() :
754  numberOfSeconds(0)
755  {}
756 
757  double numberOfSeconds; ///< Time in seconds
758 
759  ClassDefNV(tgen,1);
760  };
761 
762 
763  /**
764  * Primary particle.
765  */
766  struct primary {
767  /**
768  * Default constructor.
769  */
770  primary() :
771  type(0)
772  {}
773 
774  /**
775  * Comparison.
776  *
777  * \param object primary particle
778  * \return true if this primary particle is less than given primary particle; else false
779  */
780  inline bool less(const primary& object) const
781  {
782  return type < object.type;
783  }
784 
785  /**
786  * Test match.
787  *
788  * \param object primary particle
789  * \return true if matches; else false
790  */
791  inline bool match(const primary& object) const
792  {
793  return (type == object.type);
794  }
795 
796  int type; ///< Particle type
797 
798  ClassDefNV(primary,1);
799  };
800 
801 
802  /**
803  * End of event record.
804  */
805  struct end_event {
806  /**
807  * Default constructor.
808  */
810  {}
811 
813  };
814 
815 
816  /**
817  * Check validity of given value.
818  *
819  * \param value value
820  * \return true if given value does not match the default value; else false
821  */
822  template<class T>
823  inline bool is_valid(const T& value)
824  {
825  return !value.match(T());
826  }
827 
828 
829  /**
830  * Monte Carlo run header.
831  *
832  * This class extends the Head class so that the data from specific tags
833  * can be promoted to concrete data types.
834  *
835  * Note that for the copy of new JHead data (e.g. data not obtained via a previous JAANET::copy) to become effective,
836  * the key words in the corresponding map of the Head class should be set. \n
837  * To this end, member method JHead::push can be used.
838  */
839  struct JHead :
840  public Head
841  {
842  /**
843  * Generators.
844  */
845  static const std::string GENHEN;
846  static const std::string GENIE;
847  static const std::string GSEAGEN;
848  static const std::string MUPAGE;
849  static const std::string JSIRENE;
850  static const std::string KM3;
851  static const std::string KM3SIM;
852 
853 
854  /**
855  * Default constructor.
856  */
858  {}
859 
860 
861  /**
862  * Copy constructor.
863  *
864  * \param header header
865  */
866  JHead(const Head& header)
867  {
868  copy(header, *this);
869  }
870 
871 
872  /**
873  * Virtual destructor.
874  */
875  virtual ~JHead()
876  {}
877 
878 
879  /**
880  * Get header.
881  *
882  * \return header
883  */
884  const JHead& getHeader() const
885  {
886  return static_cast<const JHead&>(*this);
887  }
888 
889 
890  /**
891  * Get header.
892  *
893  * \return header
894  */
896  {
897  return static_cast<JHead&>(*this);
898  }
899 
900 
901  /**
902  * Set header.
903  *
904  * \param header header
905  */
906  void setHeader(const JHead& header)
907  {
908  static_cast<JHead&>(*this) = header;
909  }
910 
911 
912  /**
913  * Pull given data member from Head.
914  *
915  * \param pd pointer to data member
916  * \return iterator of Head
917  */
918  template<class T>
919  inline const_iterator pull(T JHead::*pd) const
920  {
921  return this->find(JROOT::getDataMember(pd)->GetName());
922  }
923 
924 
925  /**
926  * Pull given data member from Head.
927  *
928  * \param pd pointer to data member
929  * \return iterator of Head
930  */
931  template<class T>
932  inline iterator pull(T JHead::*pd)
933  {
934  return this->find(JROOT::getDataMember(pd)->GetName());
935  }
936 
937 
938  /**
939  * Push given data member to Head.
940  *
941  * \param pd pointer to data member
942  */
943  template<class T>
944  inline void push(T JHead::*pd)
945  {
946  (*this)[JROOT::getDataMember(pd)->GetName()] = "";
947  }
948 
949 
950  /**
951  * Remove given data member from Head.
952  *
953  * \param pd pointer to data member
954  */
955  template<class T>
956  inline void erase(T JHead::*pd)
957  {
958  iterator p = this->pull(pd);
959 
960  if (p != this->end()) {
961 
962  this->*pd = T();
963 
964  static_cast<Head*>(this)->erase(p);
965  }
966  }
967 
968 
969  /**
970  * Test match of headers.
971  *
972  * Note that if option is set to <tt>false</tt>,
973  * the match applies only to data which have a corresponding entry in the underlying map of the given header.
974  *
975  * \param header second header
976  * \param option option
977  * \return true if matches; else false
978  */
979  inline bool match(const JHead& header, const bool option = true) const
980  {
981  return (match(*this, header, option, &JHead::cut_primary) &&
982  match(*this, header, option, &JHead::cut_seamuon) &&
983  match(*this, header, option, &JHead::cut_in) &&
984  match(*this, header, option, &JHead::cut_nu) &&
985  match(*this, header, option, &JHead::physics) &&
986  match(*this, header, option, &JHead::simul) &&
987  match(*this, header, option, &JHead::spectrum) &&
988  match(*this, header, option, &JHead::can) &&
989  match(*this, header, option, &JHead::fixedcan) &&
990  match(*this, header, option, &JHead::genvol) &&
991  match(*this, header, option, &JHead::coord_origin) &&
992  match(*this, header, option, &JHead::norma) &&
993  match(*this, header, option, &JHead::livetime) &&
994  match(*this, header, option, &JHead::seabottom) &&
995  match(*this, header, option, &JHead::primary) &&
996  match(*this, header, option, &JHead::DAQ));
997  }
998 
999 
1000  /**
1001  * Comparison of headers.
1002  *
1003  * \param header header
1004  * \return true if this header less than given header; else false
1005  */
1006  inline bool less(const JHead& header) const
1007  {
1008  if (primary.less(header.primary))
1009  return true;
1010  else if (header.primary.less(primary))
1011  return false;
1012  else
1013  return cut_primary.less(header.cut_primary);
1014  }
1015 
1016 
1017  /**
1018  * Addition of headers.
1019  *
1020  * \param header header
1021  * \return this header
1022  */
1023  inline JHead& add(const JHead& header)
1024  {
1025  if (match(header)) {
1026 
1027  genvol .add(header.genvol);
1028  norma .add(header.norma);
1029  livetime.add(header.livetime);
1030  DAQ .add(header.DAQ);
1031 
1032  } else {
1033 
1034  THROW(JException, "JHead::add() headers do not match.");
1035  }
1036 
1037  return *this;
1038  }
1039 
1040 
1041  /**
1042  * Equal operator.
1043  *
1044  * Note that this operator uses the JHead::match method.
1045  *
1046  * \param first first header
1047  * \param second second header
1048  * \return true if two headers are equal; else false
1049  */
1050  friend inline bool operator==(const JHead& first,
1051  const JHead& second)
1052  {
1053  return first.match(second);
1054  }
1055 
1056 
1057  /**
1058  * Less than operator.
1059  *
1060  * \param first first header
1061  * \param second second header
1062  * \return true if first header is less than second header; else false
1063  */
1064  friend inline bool operator<(const JHead& first,
1065  const JHead& second)
1066  {
1067  return first.less(second);
1068  }
1069 
1070 
1071  JAANET::start_run start_run; // first data member
1094  JAANET::end_event end_event; // last data member
1095 
1096 
1097  /**
1098  * Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
1099  * <pre>
1100  * <key>: <value> [<value>]*
1101  * <key>: <value> [<value>]*
1102  * </pre>
1103  *
1104  * \return equation parameters
1105  */
1107  {
1108  static JLANG::JEquationParameters parameters(":", "\n", "", "");
1109 
1110  return parameters;
1111  }
1112 
1113 
1114  /**
1115  * Set equation parameters.
1116  *
1117  * \param equation equation parameters
1118  */
1119  static inline void setEquationParameters(const JLANG::JEquationParameters& equation)
1120  {
1121  getEquationParameters() = equation;
1122  }
1123 
1124 
1125  /**
1126  * Read header from input.
1127  *
1128  * \param in input stream
1129  * \return input stream
1130  */
1131  std::istream& read(std::istream& in);
1132 
1133 
1134  /**
1135  * Write header to output.
1136  *
1137  * \param out output stream
1138  * \param header header
1139  * \return output stream
1140  */
1141  std::ostream& write(std::ostream& out) const;
1142 
1143 
1144  /**
1145  * Print header to output.
1146  *
1147  * \param out output stream
1148  * \return output stream
1149  */
1150  std::ostream& print(std::ostream& out) const;
1151 
1152 
1153  ClassDef(JHead,3);
1154 
1155  private:
1156  /**
1157  * Test match.
1158  *
1159  * \param first first object
1160  * \param second second object
1161  * \return true if matches; else false
1162  */
1163  template<class T>
1164  static inline bool match(const T& first,
1165  const T& second)
1166  {
1167  return first.match(second);
1168  }
1169 
1170 
1171  /**
1172  * Test one container is subset of other container or vice versa.
1173  *
1174  * \param first first object
1175  * \param second second object
1176  * \return true if first (second) is subset of second (first); else false
1177  */
1178  template<class T>
1179  static inline bool match(const std::vector<T>& first,
1180  const std::vector<T>& second)
1181  {
1182  size_t ns = 0;
1183 
1184  for (typename std::vector<T>::const_iterator ix = first.begin(); ix != first.end(); ++ix) {
1185  for (typename std::vector<T>::const_iterator iy = second.begin(); iy != second.end(); ++iy) {
1186  if (match(*ix, *iy)) {
1187  ++ns;
1188  }
1189  }
1190  }
1191 
1192  return ns == first.size() || ns == second.size();
1193  }
1194 
1195 
1196  /**
1197  * Test match of given data member of headers.
1198  *
1199  * Note that if option is set to <tt>false</tt>,
1200  * the match applies only to data which have a corresponding tag in the underlying map of the second header.
1201  *
1202  * \param first first header
1203  * \param second second header
1204  * \param option option
1205  * \param pd pointer to data member
1206  * \return true if matches; else false
1207  */
1208  template<class T>
1209  static inline bool match(const JHead& first,
1210  const JHead& second,
1211  const bool option,
1212  T JHead::*pd)
1213  {
1214  if (option || second.pull(pd) != second.end())
1215  return match(first.*pd, second.*pd);
1216  else
1217  return true;
1218  }
1219  };
1220 
1221 
1222  /**
1223  * Equal operator.
1224  *
1225  * Note that this operator uses the JHead::match method.
1226  *
1227  * \param first first header
1228  * \param second second header
1229  * \return true if two headers are equal; else false
1230  */
1231  inline bool operator==(const Head& first,
1232  const Head& second)
1233  {
1234  return JHead(first).match(JHead(second));
1235  }
1236 
1237 
1238  /**
1239  * Less than operator.
1240  *
1241  * \param first first header
1242  * \param second second header
1243  * \return true if first header is less than second header; else false
1244  */
1245  inline bool operator<(const Head& first,
1246  const Head& second)
1247  {
1248  return JHead(first).less(JHead(second));
1249  }
1250 }
1251 
1252 
1253 /**
1254  * Read header from input.
1255  *
1256  * \param in input stream
1257  * \param header header
1258  * \return input stream
1259  */
1260 inline std::istream& operator>>(std::istream& in, JAANET::JHead& header)
1261 {
1262  return header.read(in);
1263 }
1264 
1265 
1266 /**
1267  * Write header to output.
1268  *
1269  * \param out output stream
1270  * \param header header
1271  * \return output stream
1272  */
1273 inline std::ostream& operator<<(std::ostream& out, const JAANET::JHead& header)
1274 {
1275  return header.write(out);
1276 }
1277 #endif
JAANET::JHead::physics
std::vector< JAANET::physics > physics
Definition: JHead.hh:1076
JException.hh
JAANET::generator::version
std::string version
program version
Definition: JHead.hh:287
JAANET::JHead::simul
std::vector< JAANET::simul > simul
Definition: JHead.hh:1077
JAANET::JHead::match
bool match(const JHead &header, const bool option=true) const
Test match of headers.
Definition: JHead.hh:979
JAANET::cut_in
Phase space of incoming particle.
Definition: JHead.hh:242
JAANET::fixedcan::fixedcan
fixedcan()
Default constructor.
Definition: JHead.hh:384
JAANET::can::match
bool match(const can &object) const
Test match.
Definition: JHead.hh:362
JAANET::JHead::end_event
JAANET::end_event end_event
Definition: JHead.hh:1094
std::iterator
Definition: JSTDTypes.hh:18
JAANET::genhencut::genhencut
genhencut()
Default constructor.
Definition: JHead.hh:536
JAANET::JHead::target
JAANET::target target
Definition: JHead.hh:1075
JAANET::can::r
double r
Radius [m].
Definition: JHead.hh:371
JAANET::end_event::ClassDefNV
ClassDefNV(end_event, 1)
JAANET::generator::ClassDefNV
ClassDefNV(generator, 1)
JAANET::start_run::start_run
start_run()
Default constructor.
Definition: JHead.hh:89
operator>>
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Definition: JHead.hh:1260
JAANET::JHead::fixedcan
JAANET::fixedcan fixedcan
Definition: JHead.hh:1084
operator<<
std::ostream & operator<<(std::ostream &out, const JAANET::JHead &header)
Write header to output.
Definition: JHead.hh:1273
JAANET::DAQ::DAQ
DAQ()
Default constructor.
Definition: JHead.hh:711
JAANET::JHead::tgen
JAANET::tgen tgen
Definition: JHead.hh:1092
JAANET::target
Target.
Definition: JHead.hh:150
JAANET::cut::less
bool less(const cut &object) const
Comparison.
Definition: JHead.hh:187
JAANET::can
The cylinder used for photon tracking.
Definition: JHead.hh:346
JAANET::JHead::detector
JAANET::detector detector
Definition: JHead.hh:1073
JAANET::JHead::GENHEN
static const std::string GENHEN
Generators.
Definition: JHead.hh:845
JAANET::genvol::mul
genvol & mul(const double factor, const double z=0.0)
Scale.
Definition: JHead.hh:465
JAANET::seabottom::ClassDefNV
ClassDefNV(seabottom, 1)
JAANET::JHead::read
std::istream & read(std::istream &in)
Read header from input.
Definition: JHead.cc:41
JAANET::JHead::XSecFile
JAANET::XSecFile XSecFile
Definition: JHead.hh:1072
JAANET::livetime::add
livetime & add(const livetime &object)
Addition.
Definition: JHead.hh:621
JAANET::JHead::livetime
JAANET::livetime livetime
Definition: JHead.hh:1089
JAANET::DAQ
Livetime of DAQ data.
Definition: JHead.hh:706
JAANET::JHead::GENIE
static const std::string GENIE
Definition: JHead.hh:846
JAANET::fixedcan::ycenter
double ycenter
y-center [m]
Definition: JHead.hh:408
JAANET::JHead::coord_origin
JAANET::coord_origin coord_origin
Definition: JHead.hh:1086
JAANET::JHead::DAQ
JAANET::DAQ DAQ
Definition: JHead.hh:1091
JAANET::JHead::match
static bool match(const T &first, const T &second)
Test match.
Definition: JHead.hh:1164
JAANET::is_valid
bool is_valid(const T &value)
Check validity of given value.
Definition: JHead.hh:823
JAANET::genvol::r
double r
Radius [m].
Definition: JHead.hh:478
JAANET::String::match
bool match(const String &object) const
Test match.
Definition: JHead.hh:116
JAANET::fixedcan::zmin
double zmin
Bottom [m].
Definition: JHead.hh:409
JAANET::JHead::JSIRENE
static const std::string JSIRENE
Definition: JHead.hh:849
JAANET::seabottom
The bottom of the sea.
Definition: JHead.hh:678
JAANET::JHead::cut_nu
JAANET::cut_nu cut_nu
Definition: JHead.hh:1081
JAANET::spectrum::match
bool match(const spectrum &object) const
Test match.
Definition: JHead.hh:332
JAANET::target::ClassDefNV
ClassDefNV(target, 1)
JAANET::JHead::erase
void erase(T JHead::*pd)
Remove given data member from Head.
Definition: JHead.hh:956
JAANET::JHead::seabottom
JAANET::seabottom seabottom
Definition: JHead.hh:1090
JAANET::generator::program
std::string program
program name
Definition: JHead.hh:286
JAANET::JHead::print
std::ostream & print(std::ostream &out) const
Print header to output.
Definition: JHead.cc:110
JAANET::genvol::volume
double volume
Volume [m^3].
Definition: JHead.hh:479
JAANET::JHead::JHead
JHead()
Default constructor.
Definition: JHead.hh:857
JAANET::start_run
Start of run record.
Definition: JHead.hh:85
std::vector< JAANET::physics >
JAANET::primary::less
bool less(const primary &object) const
Comparison.
Definition: JHead.hh:780
JAANET::operator==
bool operator==(const Head &first, const Head &second)
Equal operator.
Definition: JHead.hh:1231
JAANET::flux::file_2
std::string file_2
File name.
Definition: JHead.hh:669
JAANET::cut_seamuon
Phase space of atmospheric muon generation.
Definition: JHead.hh:232
JAANET::JHead::start_run
JAANET::start_run start_run
Definition: JHead.hh:1071
JAANET::can::can
can()
Default constructor.
Definition: JHead.hh:350
JAANET::livetime::ClassDefNV
ClassDefNV(livetime, 1)
JAANET::JHead::genhencut
JAANET::genhencut genhencut
Definition: JHead.hh:1087
JAANET::fixedcan::xcenter
double xcenter
x-center [m]
Definition: JHead.hh:407
JAANET::JHead::write
std::ostream & write(std::ostream &out) const
Write header to output.
Definition: JHead.cc:79
JAANET::JHead::operator==
friend bool operator==(const JHead &first, const JHead &second)
Equal operator.
Definition: JHead.hh:1050
JAANET::String::buffer
std::string buffer
General purpose name.
Definition: JHead.hh:121
JAANET::genhencut
Phase space for incident neutrino.
Definition: JHead.hh:532
JAANET::JHead::GSEAGEN
static const std::string GSEAGEN
Definition: JHead.hh:847
JAANET::JHead::~JHead
virtual ~JHead()
Virtual destructor.
Definition: JHead.hh:875
JAANET::genhencut::Emin
double Emin
Minimal energy [GeV].
Definition: JHead.hh:542
JEquationParameters.hh
JAANET::JHead::muon_desc_file
JAANET::muon_desc_file muon_desc_file
Definition: JHead.hh:1074
JAANET::genvol::add
genvol & add(const genvol &object)
Addition.
Definition: JHead.hh:451
JAANET::flux::flux
flux()
Default constructor.
Definition: JHead.hh:659
JAANET::genvol::numberOfEvents
double numberOfEvents
Number of events.
Definition: JHead.hh:480
JAANET::coord_origin
Coordinate origin.
Definition: JHead.hh:489
JAANET::operator<
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1245
JAANET::fixedcan::ClassDefNV
ClassDefNV(fixedcan, 1)
JAANET::copy
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:152
JAANET::genvol::zmax
double zmax
Top [m].
Definition: JHead.hh:477
JAANET::DAQ::livetime_s
double livetime_s
Live time [s].
Definition: JHead.hh:740
JAANET::flux
Neutrino flux.
Definition: JHead.hh:654
JAANET::JHead
Monte Carlo run header.
Definition: JHead.hh:839
JAANET::can::zmin
double zmin
Bottom [m].
Definition: JHead.hh:369
JAANET::JHead::match
static bool match(const std::vector< T > &first, const std::vector< T > &second)
Test one container is subset of other container or vice versa.
Definition: JHead.hh:1179
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JAANET::coord_origin::match
bool match(const coord_origin &object) const
Test match.
Definition: JHead.hh:518
JAANET::JHead::cut_in
JAANET::cut_in cut_in
Definition: JHead.hh:1080
JAANET::JHead::getHeader
JHead & getHeader()
Get header.
Definition: JHead.hh:895
JAANET::muon_desc_file::ClassDefNV
ClassDefNV(muon_desc_file, 1)
JAANET::tgen::numberOfSeconds
double numberOfSeconds
Time in seconds.
Definition: JHead.hh:757
JAANET::spectrum::spectrum
spectrum()
Default constructor.
Definition: JHead.hh:322
JAANET::coord_origin::coord_origin
coord_origin(const double x, const double y, const double z)
Constructor.
Definition: JHead.hh:506
JAANET::JHead::pull
iterator pull(T JHead::*pd)
Pull given data member from Head.
Definition: JHead.hh:932
JAANET::JHead::KM3SIM
static const std::string KM3SIM
Definition: JHead.hh:851
JAANET::JHead::operator<
friend bool operator<(const JHead &first, const JHead &second)
Less than operator.
Definition: JHead.hh:1064
JAANET::genvol::match
bool match(const genvol &object) const
Test match.
Definition: JHead.hh:438
JAANET::genvol::zmin
double zmin
Bottom [m].
Definition: JHead.hh:476
JAANET::JHead::ClassDef
ClassDef(JHead, 3)
JAANET::cut_primary::ClassDefNV
ClassDefNV(cut_primary, 1)
JAANET::genvol::genvol
genvol()
Default constructor.
Definition: JHead.hh:424
JAANET::String::ClassDefNV
ClassDefNV(String, 1)
JAANET::primary::match
bool match(const primary &object) const
Test match.
Definition: JHead.hh:791
JROOT::getDataMember
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:634
JAANET::physics::ClassDefNV
ClassDefNV(physics, 1)
JAANET::norma::numberOfPrimaries
double numberOfPrimaries
Number of primaries.
Definition: JHead.hh:585
JAANET::generator
Description of Monte Carlo event generation applications.
Definition: JHead.hh:262
JAANET::flux::type
int type
Type.
Definition: JHead.hh:666
JAANET::JHead::pull
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:919
JAANET::generator::generator
generator()
Default constructor.
Definition: JHead.hh:266
JAANET::cut_seamuon::ClassDefNV
ClassDefNV(cut_seamuon, 1)
JAANET::AANET_TAG_SEPARATOR
static const char AANET_TAG_SEPARATOR
Separator for AAnet tag extension for multiple tags ("_<counter>").
Definition: JHead.hh:32
JAANET::genhencut::gDir
double gDir
Angle.
Definition: JHead.hh:541
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:669
JAANET::cut_primary
Phase space of primary particle.
Definition: JHead.hh:222
JAANET::livetime::numberOfSeconds
double numberOfSeconds
Live time [s].
Definition: JHead.hh:644
JAANET::end_event::end_event
end_event()
Default constructor.
Definition: JHead.hh:809
JAANET::start_run::run_id
int run_id
MC run number.
Definition: JHead.hh:93
JAANET::cut
General purpose class of phase space generation.
Definition: JHead.hh:170
JAANET::fixedcan::match
bool match(const fixedcan &object) const
Test match.
Definition: JHead.hh:398
JAANET::can::zmax
double zmax
Top [m].
Definition: JHead.hh:370
JAANET::coord_origin::coord_origin
coord_origin()
Default constructor.
Definition: JHead.hh:495
JAANET::norma::primaryFlux
double primaryFlux
Primary flux.
Definition: JHead.hh:584
JAANET::can::ClassDefNV
ClassDefNV(can, 1)
JAANET::JHead::add
JHead & add(const JHead &header)
Addition of headers.
Definition: JHead.hh:1023
JAANET::cut::cosTmin
double cosTmin
Minimal cosine zenith angle.
Definition: JHead.hh:212
JAANET::genhencut::ClassDefNV
ClassDefNV(genhencut, 1)
JAANET::spectrum::ClassDefNV
ClassDefNV(spectrum, 1)
JAANET::JHead::match
static bool match(const JHead &first, const JHead &second, const bool option, T JHead::*pd)
Test match of given data member of headers.
Definition: JHead.hh:1209
JAANET::start_run::ClassDefNV
ClassDefNV(start_run, 1)
JAANET
Extensions to AAnet data format.
Definition: JAAnetToolkit.hh:36
JAANET::cut::cosTmax
double cosTmax
Maximal cosine zenith angle.
Definition: JHead.hh:213
JAANET::genvol::ClassDefNV
ClassDefNV(genvol, 1)
JAANET::flux::ClassDefNV
ClassDefNV(flux, 1)
JAANET::JHead::JHead
JHead(const Head &header)
Copy constructor.
Definition: JHead.hh:866
JAANET::primary::primary
primary()
Default constructor.
Definition: JHead.hh:770
JAANET::JHead::genvol
JAANET::genvol genvol
Definition: JHead.hh:1085
JAANET::JHead::can
JAANET::can can
Definition: JHead.hh:1083
JAANET::cut_in::ClassDefNV
ClassDefNV(cut_in, 1)
JAANET::JHead::push
void push(T JHead::*pd)
Push given data member to Head.
Definition: JHead.hh:944
JAANET::generator::match
bool match(const generator &object) const
Test match.
Definition: JHead.hh:281
JAANET::primary::ClassDefNV
ClassDefNV(primary, 1)
JLANG::JEquationParameters
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Definition: JEquationParameters.hh:20
JAANET::physics
Generator for neutrino interaction.
Definition: JHead.hh:298
JAANET::tgen
Scaling time of neutrino interaction generators.
Definition: JHead.hh:749
JAANET::livetime::match
bool match(const livetime &object) const
Test match.
Definition: JHead.hh:609
JAANET::JHead::KM3
static const std::string KM3
Definition: JHead.hh:850
JAANET::cut::match
bool match(const cut &object) const
Test match.
Definition: JHead.hh:202
JAANET::JHead::norma
JAANET::norma norma
Definition: JHead.hh:1088
JAANET::cut_nu::ClassDefNV
ClassDefNV(cut_nu, 1)
JAANET::detector
Detector file.
Definition: JHead.hh:130
JAANET::getTag
std::string getTag(const std::string &tag)
Get tag without aanet extension "_<counter>" for identical tags.
Definition: JHead.hh:61
JAANET::flux::key
std::string key
Key.
Definition: JHead.hh:667
JAANET::cut::ClassDefNV
ClassDefNV(cut, 1)
std
Definition: jaanetDictionary.h:36
JAANET::JHead::getEquationParameters
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1106
JAANET::JHead::MUPAGE
static const std::string MUPAGE
Definition: JHead.hh:848
JAANET::norma::match
bool match(const norma &object) const
Test match.
Definition: JHead.hh:566
JAANET::detector::ClassDefNV
ClassDefNV(detector, 1)
JAANET::generator::date
std::string date
processing date
Definition: JHead.hh:288
JAANET::norma::ClassDefNV
ClassDefNV(norma, 1)
JAANET::fixedcan::zmax
double zmax
Top [m].
Definition: JHead.hh:410
JAANET::cut::Emax
double Emax
Maximal energy [GeV].
Definition: JHead.hh:211
JAANET::cut::Emin
double Emin
Minimal energy [GeV].
Definition: JHead.hh:210
JAANET::end_event
End of event record.
Definition: JHead.hh:805
JAANET::livetime::errorOfSeconds
double errorOfSeconds
Uncertainty on live time [s].
Definition: JHead.hh:645
JAANET::simul::ClassDefNV
ClassDefNV(simul, 1)
JAANET::livetime
Normalisation of MUPAGE events.
Definition: JHead.hh:594
JAANET::primary::type
int type
Particle type.
Definition: JHead.hh:796
JAANET::generator::time
std::string time
processing time
Definition: JHead.hh:289
JAANET::JHead::cut_seamuon
JAANET::cut_seamuon cut_seamuon
Definition: JHead.hh:1079
JAANET::String::String
String()
Default constructor.
Definition: JHead.hh:106
JAANET::cut::cut
cut()
Default constructor.
Definition: JHead.hh:174
JAANET::norma::norma
norma()
Default constructor.
Definition: JHead.hh:555
JAANET::seabottom::z
double z
Sea bottom [m].
Definition: JHead.hh:697
JAANET::JHead::getHeader
const JHead & getHeader() const
Get header.
Definition: JHead.hh:884
JAANET::norma::add
norma & add(const norma &object)
Addition.
Definition: JHead.hh:577
JAANET::JHead::spectrum
JAANET::spectrum spectrum
Definition: JHead.hh:1082
JAANET::XSecFile
Neutrino cross section file.
Definition: JHead.hh:160
JAANET::livetime::livetime
livetime()
Default constructor.
Definition: JHead.hh:598
JAANET::fixedcan
The fixe cylinder used for photon tracking.
Definition: JHead.hh:380
JAANET::genvol
Neutrino vertex volume.
Definition: JHead.hh:420
JAANET::spectrum
Neutrino energy spectrum.
Definition: JHead.hh:318
JAANET::primary
Primary particle.
Definition: JHead.hh:766
JAANET::tgen::tgen
tgen()
Default constructor.
Definition: JHead.hh:753
JAANET::seabottom::seabottom
seabottom()
Default constructor.
Definition: JHead.hh:682
JAANET::tgen::ClassDefNV
ClassDefNV(tgen, 1)
JAANET::JHead::setHeader
void setHeader(const JHead &header)
Set header.
Definition: JHead.hh:906
JAANET::cut_nu
Phase space of incident neutrino.
Definition: JHead.hh:252
JAANET::fixedcan::radius
double radius
Radius [m].
Definition: JHead.hh:411
JAANET::seabottom::match
bool match(const seabottom &object) const
Test match.
Definition: JHead.hh:692
JAANET::flux::file_1
std::string file_1
File name.
Definition: JHead.hh:668
JAANET::norma
Normlisation of CORSIKA events.
Definition: JHead.hh:551
JAANET::JHead::less
bool less(const JHead &header) const
Comparison of headers.
Definition: JHead.hh:1006
JAANET::JHead::primary
JAANET::primary primary
Definition: JHead.hh:1093
JAANET::simul
Generator for simulation.
Definition: JHead.hh:308
JLANG::JException
General exception.
Definition: JException.hh:40
JAANET::muon_desc_file
Muon descriptor file.
Definition: JHead.hh:140
JAANET::DAQ::ClassDefNV
ClassDefNV(DAQ, 1)
JRootClass.hh
JAANET::coord_origin::ClassDefNV
ClassDefNV(coord_origin, 1)
JAANET::String
General purpose string class.
Definition: JHead.hh:102
JAANET::JHead::cut_primary
JAANET::cut_primary cut_primary
Definition: JHead.hh:1078
JAANET::DAQ::match
bool match(const DAQ &object) const
Test match.
Definition: JHead.hh:721
JAANET::XSecFile::ClassDefNV
ClassDefNV(XSecFile, 1)
JAANET::livetime::mul
livetime & mul(const double factor)
Scale.
Definition: JHead.hh:636
JAANET::DAQ::add
DAQ & add(const DAQ &object)
Addition.
Definition: JHead.hh:733
JAANET::JHead::setEquationParameters
static void setEquationParameters(const JLANG::JEquationParameters &equation)
Set equation parameters.
Definition: JHead.hh:1119
JAANET::spectrum::alpha
double alpha
Energy spectrum: .
Definition: JHead.hh:337