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