CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExhumeProducer.cc
Go to the documentation of this file.
1 #include "ExhumeProducer.h"
2 #include "PYR.h"
6 
15 
16 #include "CLHEP/Random/RandomEngine.h"
17 #include "CLHEP/Random/RandFlat.h"
18 
19 //ExHuME headers
24 
25 #include <iostream>
26 #include "time.h"
27 
28 using namespace edm;
29 using namespace std;
30 
31 
32 // Generator modifications
33 // ***********************
34 //#include "HepMC/include/PythiaWrapper6_2.h"
35 //#include "HepMC/ConvertHEPEVT.h"
36 //#include "HepMC/CBhepevt.h"
37 #include "HepMC/IO_HEPEVT.h"
38 
39 #define pylist pylist_
40 extern "C" {
41  void pylist(int*);
42 }
43 inline void call_pylist( int mode ){ pylist( &mode ); }
44 
45 /*
46 #define my_pythia_init my_pythia_init_
47 extern "C" {
48  void my_pythia_init();
49 }
50 #define pydata pydata_
51 extern "C" {
52  void pydata(void);
53 }
54 */
55 extern struct {
56  int mstp[200];
57  double parp[200];
58  int msti[200];
59  double pari[200];
60 } pypars_;
61 #define pypars pypars_
62 
63 //HepMC::ConvertHEPEVT conv;
64 HepMC::IO_HEPEVT conv;
65 
66 // ***********************
67 
68 
69 //used for defaults
70  static const unsigned long kNanoSecPerSec = 1000000000;
71  static const unsigned long kAveEventPerSec = 200;
72 
74  EDProducer(),
75  evt(0),
76  pythiaPylistVerbosity_ (pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0)),
77  pythiaHepMCVerbosity_ (pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false)),
78  maxEventsToPrint_ (pset.getUntrackedParameter<int>("maxEventsToPrint",1)),
79  comEnergy_(pset.getParameter<double>("comEnergy")),
80  extCrossSect_(pset.getUntrackedParameter<double>("crossSection", -1.)),
81  extFilterEff_(pset.getUntrackedParameter<double>("filterEfficiency", -1.)),
82  eventNumber_(0)
83 {
84  std::ostringstream header_str;
85 
86  header_str << "ExhumeProducer: initializing Exhume/Pythia.\n";
87 
88  // PYLIST Verbosity Level
89  // Valid PYLIST arguments are: 1, 2, 3, 5, 7, 11, 12, 13
90  pythiaPylistVerbosity_ = pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0);
91  header_str << "Pythia PYLIST verbosity level = " << pythiaPylistVerbosity_ << "\n";
92 
93  // HepMC event verbosity Level
94  pythiaHepMCVerbosity_ = pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false);
95  header_str << "Pythia HepMC verbosity = " << pythiaHepMCVerbosity_ << "\n";
96 
97  //Max number of events printed on verbosity level
98  maxEventsToPrint_ = pset.getUntrackedParameter<int>("maxEventsToPrint",0);
99  header_str << "Number of events to be printed = " << maxEventsToPrint_ << "\n";
100 
101  //Exhume Initialization
102  ParameterSet process_pset = pset.getParameter<ParameterSet>("ExhumeProcess") ;
103  string processType = process_pset.getParameter<string>("ProcessType");
104  if(processType == "Higgs"){
105  exhumeProcess_ = new Exhume::Higgs(pset);
106  int higgsDecay = process_pset.getParameter<int>("HiggsDecay");
107  ((Exhume::Higgs*)exhumeProcess_)->SetHiggsDecay(higgsDecay);
108  sigID_ = 100 + higgsDecay;
109  } else if(processType == "QQ"){
110  exhumeProcess_ = new Exhume::QQ(pset);
111  int quarkType = process_pset.getParameter<int>("QuarkType");
112  double thetaMin = process_pset.getParameter<double>("ThetaMin");
113  ((Exhume::QQ*)exhumeProcess_)->SetQuarkType(quarkType);
114  ((Exhume::QQ*)exhumeProcess_)->SetThetaMin(thetaMin);
115  sigID_ = 200 + quarkType;
116  } else if(processType == "GG"){
117  exhumeProcess_ = new Exhume::GG(pset);
118  double thetaMin = process_pset.getParameter<double>("ThetaMin");
119  ((Exhume::GG*)exhumeProcess_)->SetThetaMin(thetaMin);
120  sigID_ = 300;
121  } else{
122  sigID_ = -1;
123  throw edm::Exception(edm::errors::Configuration,"ExhumeError") <<" No valid Exhume Process";
124  }
125 
127  //uint32_t seed = rng->mySeed();
128  fRandomEngine = &(rng->getEngine());
130  fRandomGenerator = new CLHEP::RandFlat(fRandomEngine) ;
131  //exhumeEvent_ = new Exhume::Event(*exhumeProcess_,seed);
133 
134  double massRangeLow = process_pset.getParameter<double>("MassRangeLow");
135  double massRangeHigh = process_pset.getParameter<double>("MassRangeHigh");
136  exhumeEvent_->SetMassRange(massRangeLow,massRangeHigh);
138 
139  header_str << "\n"; // Stetically add for the output
140  //********
141 
142  produces<HepMCProduct>();
143  produces<GenEventInfoProduct>();
144  produces<GenRunInfoProduct, edm::InRun>();
145 
146  header_str << "ExhumeProducer: starting event generation ...\n";
147 
148  edm::LogInfo("") << header_str.str();
149 }
150 
151 
153  std::ostringstream footer_str;
154  footer_str << "ExhumeProducer: event generation done.\n";
155 
156  edm::LogInfo("") << footer_str.str();
157 
158  clear();
159 }
160 
162  delete exhumeEvent_;
163  delete exhumeProcess_;
164 }
165 
167  std::ostringstream footer_str;
168 
170  double eff = exhumeEvent_->GetEfficiency();
171  string name = exhumeProcess_->GetName();
172 
173  footer_str << "\n" <<" You have just been ExHuMEd." << "\n" << "\n";
174  footer_str << " The cross section for process " << name
175  << " is " << cs << " fb" << "\n" << "\n";
176  footer_str << " The efficiency of event generation was " << eff << "%" << "\n" << "\n";
177 
178  edm::LogInfo("") << footer_str.str();
179 
180  auto_ptr<GenRunInfoProduct> genRunInfoProd (new GenRunInfoProduct());
181  genRunInfoProd->setInternalXSec(cs);
182  genRunInfoProd->setFilterEfficiency(extFilterEff_);
183  genRunInfoProd->setExternalXSecLO(extCrossSect_);
184  genRunInfoProd->setExternalXSecNLO(-1.);
185 
186  run.put(genRunInfoProd);
187 }
188 
190 
191  auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
192  edm::LogInfo("") << "ExhumeProducer: Generating event ...\n";
193 
196 
197  HepMC::GenEvent* genEvt = conv.read_next_event();
198  genEvt->set_signal_process_id(sigID_);
199  genEvt->set_event_scale(pypars.pari[16]);
200 // JMM change
201 // genEvt->set_event_number(numberEventsInRun() - remainingEvents() - 1);
202  ++eventNumber_;
203  genEvt->set_event_number(eventNumber_);
204 
205  //******** Verbosity ********
206 
207 // if(event() <= maxEventsToPrint_ &&
208  if(event.id().event() <= maxEventsToPrint_ &&
210 
211  // Prints PYLIST info
214  }
215 
216  // Prints HepMC event
218  edm::LogInfo("") << "Event process = " << exhumeProcess_->GetName() << "\n"
219  << "----------------------" << "\n";
220  genEvt->print();
221  }
222  }
223 
224  if(genEvt) bare_product->addHepMCData(genEvt);
225  event.put(bare_product);
226 
227  std::auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(genEvt));
228  event.put(genEventInfo);
229 }
230 
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
static unsigned long long const kNanoSecPerSec
void call_pylist(int mode)
auto_ptr< ClusterSequence > cs
double CrossSectionCalculation()
int mstp[200]
bool pythiaHepMCVerbosity_
HepMC verbosity flag.
CLHEP::HepRandomEngine * randomEngine
Definition: PYR.cc:4
static HepMC::IO_HEPEVT conv
double parp[200]
std::string GetName()
Definition: CrossSection.h:144
virtual void produce(edm::Event &e, const EventSetup &es)
Interface to the PYGIVE pythia routine, with add&#39;l protections.
DEFINE_FWK_MODULE(HiMixingModule)
double pari[200]
double GetEfficiency()
Definition: Event.h:66
unsigned int pythiaPylistVerbosity_
Pythia PYLIST Verbosity flag.
Exhume::CrossSection * exhumeProcess_
#define pypars
CLHEP::HepRandomEngine * fRandomEngine
struct @263 pypars_
Definition: QQ.h:11
CLHEP::RandFlat * fRandomGenerator
Exhume::Event * exhumeEvent_
void SetMassRange(const double &Min_, const double &Max_)
Definition: Event.h:48
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
virtual ~ExhumeProducer()
Destructor.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void SetParameterSpace()
Definition: GG.h:11
unsigned int eventNumber_
static unsigned long long const kAveEventPerSec
#define pylist
edm::EventID id() const
Definition: EventBase.h:56
void put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Run.h:81
unsigned int maxEventsToPrint_
Events to print if verbosity.
ExhumeProducer(const ParameterSet &)
Constructor.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:33
int msti[200]