~ma5/madanalysis5/madanalysis-development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
////////////////////////////////////////////////////////////////////////////////
//  
//  Copyright (C) 2012-2016 Eric Conte, Benjamin Fuks
//  The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
//  
//  This file is part of MadAnalysis 5.
//  Official website: <https://launchpad.net/madanalysis5>
//  
//  MadAnalysis 5 is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//  
//  MadAnalysis 5 is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
//  
////////////////////////////////////////////////////////////////////////////////


#ifndef SAMPLE_DATAFORMAT_H
#define SAMPLE_DATAFORMAT_H


// STL headers
#include <map>
#include <iostream>
#include <vector>

// SampleAnalyzer headers
#include "SampleAnalyzer/Commons/DataFormat/GeneratorInfo.h"
#include "SampleAnalyzer/Commons/DataFormat/MCSampleFormat.h"
#include "SampleAnalyzer/Commons/DataFormat/RecSampleFormat.h"
#include "SampleAnalyzer/Commons/Service/LogService.h"
#include "SampleAnalyzer/Commons/Service/ExceptionService.h"


namespace MA5
{

class LHEReader;
class LHCOReader;
class HEPMCReader;
class SampleAnalyzer;


class SampleFormat
{
  friend class LHEReader;
  friend class LHCOReader;
  friend class SampleAnalyzer;

  // -------------------------------------------------------------
  //                        data members
  // -------------------------------------------------------------
 private:

  std::string                 name_;      /// file name
  MAuint64                    nevents_;   /// number of events in the file
  MCSampleFormat  *           mc_;
  RecSampleFormat *           rec_;
  MA5GEN::GeneratorType       sample_generator_;
  MA5FORMAT::SampleFormatType sample_format_;
  std::vector<std::string>    header_;    /// file header


  // -------------------------------------------------------------
  //                      method members
  // -------------------------------------------------------------
 public :

  /// Constructor withtout arguments
  SampleFormat()
  { 
    rec_=0;
    mc_=0; 
    nevents_=0;
    sample_generator_  = MA5GEN::UNKNOWN;
    sample_format_     = MA5FORMAT::UNKNOWN;
    header_.clear();
  }

  /// Destructor
  ~SampleFormat()
  { 
  }
 
  /// Accessor to Monte Carlo information (read-only)
  const MCSampleFormat * mc() const
  { return mc_; }

  /// Accessor to reconstruction information (read-only)
  const RecSampleFormat * rec() const
  { return rec_; } 

  /// Accessor to Monte Carlo information
  MCSampleFormat * mc()
  { return mc_; }

  /// Accessor to reconstruction information
  RecSampleFormat * rec()
  { return rec_; }

  /// Accessor to the sample name
  const std::string& name() const
  { return name_; }

  /// Accessor to the number of events
  const MAuint64& nevents() const
  { return nevents_; }

  /// Set the sample name
  void setName(const std::string& name)
  {name_=name;}

  /// Set the number of events in the sample
  void setNEvents(MAuint64 v)
  {nevents_=v;}

  /// Initialize MonteCarlo part
  void InitializeMC()
  {
    try
    {
      if (mc_!=0) throw EXCEPTION_WARNING("MC part of the SampleFormat is already initialized.","",0);
      mc_=new MCSampleFormat(&sample_generator_);
    }
    catch(const std::exception& e)
    {
      MANAGE_EXCEPTION(e);
    }    
  }

  /// Initialize Rec part
  void InitializeRec()
  {
    try
    {
      if (rec_!=0) throw EXCEPTION_WARNING("REC part of the SampleFormat is already initialized.","",0);
      rec_=new RecSampleFormat();
    }
    catch(const std::exception& e)
    {
      MANAGE_EXCEPTION(e);
    }    
  }

  /// Free allocates memory
  void Delete()
  {
    if (rec_!=0) delete rec_;
    if (mc_!=0)  delete mc_;
  }

  /// Set the Generator Format
  void SetSampleGenerator(MA5GEN::GeneratorType value)
  { sample_generator_ = value; }

  /// Set the Sample Format
  void SetSampleFormat(MA5FORMAT::SampleFormatType value)
  { sample_format_ = value; }

  /// Accessor to the Generator Format
  const MA5GEN::GeneratorType& sampleGenerator() const
  { return sample_generator_; }

  /// Accessor to the Sample Format
  const MA5FORMAT::SampleFormatType& sampleFormat() const
  { return sample_format_; }

  /// Displaying subtitle for file
  void printSubtitle() const
  {
    // Sample format
    INFO << "        => sample format: ";
    if (sample_format_==MA5FORMAT::UNKNOWN) INFO << "unknown-format";
    else if (sample_format_==MA5FORMAT::LHE) INFO << "LHE";
    else if (sample_format_==MA5FORMAT::SIMPLIFIED_LHE) INFO << "simplified LHE";
    else if (sample_format_==MA5FORMAT::STDHEP) INFO << "STDHEP";
    else if (sample_format_==MA5FORMAT::HEPMC) INFO << "HEPMC";
    else if (sample_format_==MA5FORMAT::LHCO) INFO << "LHCO";
    else if (sample_format_==MA5FORMAT::DELPHES) INFO << "Delphes-ROOT";
    else if (sample_format_==MA5FORMAT::DELPHESMA5TUNE) INFO << "Delphes-MA5tune ROOT";
    else if (sample_format_==MA5FORMAT::DELPHESMA5CARD) INFO << "Delphes-ROOT";
    INFO << " file produced by ";

    // Generator
    if (sample_generator_==MA5GEN::UNKNOWN) 
              INFO << "an unknown generator " 
                   << "(cross section assumed in pb)";
    else if (sample_generator_==MA5GEN::MG5) INFO << "MadGraph5";
    else if (sample_generator_==MA5GEN::MA5) INFO << "MadAnalysi5";
    else if (sample_generator_==MA5GEN::PYTHIA6) INFO << "Pythia6";
    else if (sample_generator_==MA5GEN::PYTHIA8) INFO << "Pythia8";
    else if (sample_generator_==MA5GEN::HERWIG6) INFO << "Herwig6";
    else if (sample_generator_==MA5GEN::HERWIGPP) INFO << "Herwig++";
    else if (sample_generator_==MA5GEN::DELPHES) INFO << "Delphes";
    else if (sample_generator_==MA5GEN::DELPHESMA5TUNE) INFO << "Delphes-MA5tune";
    else if (sample_generator_==MA5GEN::DELPHESMA5CARD) INFO << "Delphes + MA5tuned-cards";
    else if (sample_generator_==MA5GEN::CALCHEP) INFO << "CalcHEP";
    INFO << "." << endmsg;
  }

  /// Accessor to the header
  const std::vector<std::string>& header() const
  { return header_; }

  /// Mutator relative to the header
  void AddHeader(const std::string& line)
  { header_.push_back(line); }


};

}

#endif