CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CosMuoGenSource.cc
Go to the documentation of this file.
4 
8 
10 
11 
13  GeneratedInputSource(pset, desc ) ,
14  //RanS(pset.getParameter<int>("RanSeed", 123456)), //get seed now from Framework
15  MinP(pset.getParameter<double>("MinP")),
16  MinP_CMS(pset.getParameter<double>("MinP_CMS")),
17  MaxP(pset.getParameter<double>("MaxP")),
18  MinT(pset.getParameter<double>("MinTheta")),
19  MaxT(pset.getParameter<double>("MaxTheta")),
20  MinPh(pset.getParameter<double>("MinPhi")),
21  MaxPh(pset.getParameter<double>("MaxPhi")),
22  MinS(pset.getParameter<double>("MinT0")),
23  MaxS(pset.getParameter<double>("MaxT0")),
24  ELSF(pset.getParameter<double>("ElossScaleFactor")),
25  RTarget(pset.getParameter<double>("RadiusOfTarget")),
26  ZTarget(pset.getParameter<double>("ZDistOfTarget")),
27  ZCTarget(pset.getParameter<double>("ZCentrOfTarget")),
28  TrackerOnly(pset.getParameter<bool>("TrackerOnly")),
29  MultiMuon(pset.getParameter<bool>("MultiMuon")),
30  MultiMuonFileName(pset.getParameter<std::string>("MultiMuonFileName")),
31  MultiMuonFileFirstEvent(pset.getParameter<int>("MultiMuonFileFirstEvent")),
32  MultiMuonNmin(pset.getParameter<int>("MultiMuonNmin")),
33  TIFOnly_constant(pset.getParameter<bool>("TIFOnly_constant")),
34  TIFOnly_linear(pset.getParameter<bool>("TIFOnly_linear")),
35  MTCCHalf(pset.getParameter<bool>("MTCCHalf")),
36  PlugVtx(pset.getParameter<double>("PlugVx")),
37  PlugVtz(pset.getParameter<double>("PlugVz")),
38  VarRhoAir(pset.getParameter<double>("RhoAir")),
39  VarRhoWall(pset.getParameter<double>("RhoWall")),
40  VarRhoRock(pset.getParameter<double>("RhoRock")),
41  VarRhoClay(pset.getParameter<double>("RhoClay")),
42  VarRhoPlug(pset.getParameter<double>("RhoPlug")),
43  ClayLayerWidth(pset.getParameter<double>("ClayWidth")),
44  MinEn(pset.getParameter<double>("MinEnu")),
45  MaxEn(pset.getParameter<double>("MaxEnu")),
46  NuPrdAlt(pset.getParameter<double>("NuProdAlt")),
47  AllMu(pset.getParameter<bool>("AcptAllMu")),
48  extCrossSect(pset.getUntrackedParameter<double>("crossSection", -1.)),
49  extFilterEff(pset.getUntrackedParameter<double>("filterEfficiency", -1.)),
50  cmVerbosity_(pset.getParameter<bool>("Verbosity"))
51  {
52 
53  //if not specified (i.e. negative) then use MinP also for MinP_CMS
54  if(MinP_CMS < 0) MinP_CMS = MinP;
55 
56  //get seed now from Framework
58  RanS = rng->mySeed();
59  // set up the generator
97  produces<HepMCProduct>();
98  // fEvt = new HepMC::GenEvent();
99  produces<GenRunInfoProduct, edm::InRun>();
100  }
101 
103  //CosMuoGen->terminate();
104  delete CosMuoGen;
105  // delete fEvt;
106  clear();
107 }
108 
109 
111 
112  std::auto_ptr<GenRunInfoProduct> genRunInfo(new GenRunInfoProduct());
113 
114  double cs = CosMuoGen->getRate(); // flux in Hz, not s^-1m^-2
115  genRunInfo->setInternalXSec(cs);
116  genRunInfo->setExternalXSecLO(extCrossSect);
117  genRunInfo->setFilterEfficiency(extFilterEff);
118 
119  r.put(genRunInfo);
120 
121  CosMuoGen->terminate();
122 }
123 
124 
126 
128 {
129  // generate event
130  if (!MultiMuon) {
131  CosMuoGen->nextEvent();
132  }
133  else {
134  bool success = CosMuoGen->nextMultiEvent();
135  if (!success) return false;
136  }
137 
138  if (Debug) {
139  std::cout << "CosMuoGenSource.cc: CosMuoGen->EventWeight=" << CosMuoGen->EventWeight
140  << " CosMuoGen: Nmuons=" << CosMuoGen->Id_sf.size() << std::endl;
141  std::cout << "CosMuoGen->Id_at=" << CosMuoGen->Id_at
142  << " CosMuoGen->Vx_at=" << CosMuoGen->Vx_at
143  << " CosMuoGen->Vy_at=" << CosMuoGen->Vy_at
144  << " CosMuoGen->Vz_at=" << CosMuoGen->Vz_at
145  << " CosMuoGen->T0_at=" << CosMuoGen->T0_at << std::endl;
146  std::cout << " Px=" << CosMuoGen->Px_at
147  << " Py=" << CosMuoGen->Py_at
148  << " Pz=" << CosMuoGen->Pz_at << std::endl;
149  for (unsigned int i=0; i<CosMuoGen->Id_sf.size(); ++i) {
150  std::cout << "Id_sf[" << i << "]=" << CosMuoGen->Id_sf[i]
151  << " Vx_sf[" << i << "]=" << CosMuoGen->Vx_sf[i]
152  << " Vy_sf=" << CosMuoGen->Vy_sf[i]
153  << " Vz_sf=" << CosMuoGen->Vz_sf[i]
154  << " T0_sf=" << CosMuoGen->T0_sf[i]
155  << " Px_sf=" << CosMuoGen->Px_sf[i]
156  << " Py_sf=" << CosMuoGen->Py_sf[i]
157  << " Pz_sf=" << CosMuoGen->Pz_sf[i] << std::endl;
158  std::cout << "phi_sf=" << atan2(CosMuoGen->Px_sf[i],CosMuoGen->Pz_sf[i]) << std::endl;
159  std::cout << "Id_ug[" << i << "]=" << CosMuoGen->Id_ug[i]
160  << " Vx_ug[" << i << "]=" << CosMuoGen->Vx_ug[i]
161  << " Vy_ug=" << CosMuoGen->Vy_ug[i]
162  << " Vz_ug=" << CosMuoGen->Vz_ug[i]
163  << " T0_ug=" << CosMuoGen->T0_ug[i]
164  << " Px_ug=" << CosMuoGen->Px_ug[i]
165  << " Py_ug=" << CosMuoGen->Py_ug[i]
166  << " Pz_ug=" << CosMuoGen->Pz_ug[i] << std::endl;
167  std::cout << "phi_ug=" << atan2(CosMuoGen->Px_ug[i],CosMuoGen->Pz_ug[i]) << std::endl;;
168  }
169  }
170 
171 
172  fEvt = new HepMC::GenEvent();
173 
174  HepMC::GenVertex* Vtx_at = new HepMC::GenVertex(HepMC::FourVector(CosMuoGen->Vx_at, //[mm]
175  CosMuoGen->Vy_at, //[mm]
176  CosMuoGen->Vz_at, //[mm]
177  CosMuoGen->T0_at)); //[mm]
178  //cout << "CosMuoGenSource.cc: Vy_at=" << CosMuoGen->Vy_at << endl;
179  HepMC::FourVector p_at(CosMuoGen->Px_at,CosMuoGen->Py_at,CosMuoGen->Pz_at,CosMuoGen->E_at);
180  HepMC::GenParticle* Part_at =
181  new HepMC::GenParticle(p_at,CosMuoGen->Id_at, 3);//Comment mother particle in
182  Vtx_at->add_particle_in(Part_at);
183 
184 
185  //loop here in case of multi muon events (else just one iteration)
186  for (unsigned int i=0; i<CosMuoGen->Id_sf.size(); ++i) {
187 
188  HepMC::FourVector p_sf(CosMuoGen->Px_sf[i],CosMuoGen->Py_sf[i],CosMuoGen->Pz_sf[i],CosMuoGen->E_sf[i]);
189  HepMC::GenParticle* Part_sf_in =
190  new HepMC::GenParticle(p_sf,CosMuoGen->Id_sf[i], 3); //Comment daughter particle
191  Vtx_at->add_particle_out(Part_sf_in);
192 
193  HepMC::GenVertex* Vtx_sf = new HepMC::GenVertex(HepMC::FourVector(CosMuoGen->Vx_sf[i], CosMuoGen->Vy_sf[i], CosMuoGen->Vz_sf[i], CosMuoGen->T0_sf[i])); //[mm]
194  HepMC::GenParticle* Part_sf_out =
195  new HepMC::GenParticle(p_sf,CosMuoGen->Id_sf[i], 3); //Comment daughter particle
196 
197  Vtx_sf->add_particle_in(Part_sf_in);
198  Vtx_sf->add_particle_out(Part_sf_out);
199 
200  fEvt->add_vertex(Vtx_sf); //one per muon
201 
202  HepMC::GenVertex* Vtx_ug = new HepMC::GenVertex(HepMC::FourVector(CosMuoGen->Vx_ug[i], CosMuoGen->Vy_ug[i], CosMuoGen->Vz_ug[i], CosMuoGen->T0_ug[i])); //[mm]
203 
204  HepMC::FourVector p_ug(CosMuoGen->Px_ug[i],CosMuoGen->Py_ug[i],CosMuoGen->Pz_ug[i],CosMuoGen->E_ug[i]);
205  HepMC::GenParticle* Part_ug =
206  new HepMC::GenParticle(p_ug,CosMuoGen->Id_ug[i], 1);//Final state daughter particle
207 
208  Vtx_ug->add_particle_in(Part_sf_out);
209  Vtx_ug->add_particle_out(Part_ug);
210 
211  fEvt->add_vertex(Vtx_ug); //one per muon
212 
213  }
214 
215  fEvt->add_vertex(Vtx_at);
216  fEvt->set_signal_process_vertex(Vtx_at);
217 
218  fEvt->set_event_number(event());
219  fEvt->set_signal_process_id(13);
220 
221  fEvt->weights().push_back( CosMuoGen->EventWeight ); // just one event weight
222  fEvt->weights().push_back( CosMuoGen->Trials ); // int Trials number (unweighted)
223 
224 
225  if (cmVerbosity_) fEvt->print();
226 
227  std::auto_ptr<HepMCProduct> CMProduct(new HepMCProduct());
228  CMProduct->addHepMCData( fEvt );
229  e.put(CMProduct);
230 
231  return true;
232 }
233 
void setZDistOfTarget(double Z)
int i
Definition: DBlmapReader.cc:9
void initialize(CLHEP::HepRandomEngine *rng=0)
void setMinEnu(double MinEn)
auto_ptr< ClusterSequence > cs
void setTIFOnly_constant(bool TIF)
void setNuProdAlt(double NuPrdAlt)
void setZCentrOfTarget(double Z)
std::string MultiMuonFileName
void setRhoAir(double VarRhoAir)
void setRadiusOfTarget(double R)
void setNumberOfEvents(unsigned int N)
virtual bool produce(Event &e)
void setMultiMuonFileFirstEvent(int MultiMuFile1stEvt)
void setRhoPlug(double VarRhoPlug)
void setMinPhi(double Phi)
void setMaxPhi(double Phi)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:168
void setMultiMuonNmin(int MultiMuNmin)
CosMuoGenSource(const ParameterSet &, const InputSourceDescription &)
void setMinTheta(double Theta)
void setMaxEnu(double MaxEn)
void setMultiMuon(bool MultiMu)
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 setClayWidth(double ClayLaeyrWidth)
CosmicMuonGenerator * CosMuoGen
unsigned int numberEventsInRun() const
void setAcptAllMu(bool AllMu)
void setPlugVz(double PlugVtz)
void setTIFOnly_linear(bool TIF)
void setMultiMuonFileName(std::string MultiMuonFileName)
void setElossScaleFactor(double ElossScaleFact)
void setMaxTheta(double Theta)
tuple cout
Definition: gather_cfg.py:121
void put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Run.h:81
void setRhoWall(double VarRhoSWall)
void setPlugVx(double PlugVtx)
void setRhoRock(double VarRhoRock)
virtual uint32_t mySeed() const =0
Exists for backward compatibility.
const bool Debug
void setRhoClay(double VarRhoClay)
Definition: Run.h:33
void setTrackerOnly(bool Tracker)