ATLAS Offline Software
AddFlowByShifting.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // File: Generators/FlowAfterburnber/AddFlowByShifting.cxx
6 // Description:
7 // This code is used to introduce particle flow
8 // to particles from generated events
9 //
10 // AuthorList:
11 // Andrzej Olszewski: Initial Code February 2006
12 // 11.10.2006: Add predefined flow function by name
13 
15 
16 #include <set>
17 #include <cmath>
18 
19 // For the Athena-based random numbers
21 #include "CLHEP/Random/RandFlat.h"
22 #include "CLHEP/Random/RandGaussQ.h"
23 #include "CLHEP/Vector/LorentzVector.h"
24 
25 #include "GaudiKernel/PhysicalConstants.h"
26 
28 
29 #include "TGraph.h"
30 
31 double AddFlowByShifting::vn_func(double x, void *params)
32 {
33  float *par_float = (float*) params;
34  float phi_0 = par_float[0];
35  float *vn = par_float+1;
36  float *psi_n = vn+6;
37  double val=x +2*( vn[0]*sin(1*(x-psi_n[0]))/1.0 + vn[1]*sin(2*(x-psi_n[1]))/2.0 +
38  vn[2]*sin(3*(x-psi_n[2]))/3.0 + vn[3]*sin(4*(x-psi_n[3]))/4.0 +
39  vn[4]*sin(5*(x-psi_n[4]))/5.0 + vn[5]*sin(6*(x-psi_n[5]))/6.0 );
40  return val-phi_0;
41 }
42 
43 
45 {
46  float *par_float = (float*) params;
47  float *vn = par_float+1;
48  float *psi_n = vn+6;
49  double val=1 +2*( vn[0]*cos(1*(x-psi_n[0]))/1.0 + vn[1]*cos(2*(x-psi_n[1]))/2.0 +
50  vn[2]*cos(3*(x-psi_n[2]))/3.0 + vn[3]*cos(4*(x-psi_n[3]))/4.0 +
51  vn[4]*cos(5*(x-psi_n[4]))/5.0 + vn[5]*cos(6*(x-psi_n[5]))/6.0 );
52  return val;
53 }
54 
55 
56 AddFlowByShifting::AddFlowByShifting(const std::string& name, ISvcLocator* pSvcLocator) :
57  AthAlgorithm(name, pSvcLocator)
58 {
59  m_flow_function= NULL;
60  for(int ihar = 0; ihar< 6; ihar++){
61  m_psi_n[ihar] =0.0;
62  m_v_n [ihar] =0.0;
63  m_EbE_Multiplier_vn[ihar]=1.0;
64  }
65 }
66 
67 
69  ATH_MSG_INFO(">>> AddFlowByShifting from Initialize <<<");
70 
71  ATH_CHECK(m_rndmSvc.retrieve());
72 
73  ATH_MSG_INFO("**********Settings for Afterburner************");
74  ATH_MSG_INFO("McTruthKey : " << m_inkey );
75  ATH_MSG_INFO("McFlowKey : " << m_outkey );
76 
77  ATH_MSG_INFO("FlowFunctionName : " << m_flow_function_name );
78  ATH_MSG_INFO("FlowInplementation : " << m_flow_implementation);
79  ATH_MSG_INFO("FlowFluctuations : " << m_flow_fluctuations );
80 
81  ATH_MSG_INFO("RandomizePhi : " << m_ranphi_sw );
82 
83  ATH_MSG_INFO("FlowEtaSwitch : " << m_floweta_sw );
84  ATH_MSG_INFO("FlowMinEtaCut : " << m_flow_mineta );
85  ATH_MSG_INFO("FlowMaxEtaCut : " << m_flow_maxeta );
86 
87  ATH_MSG_INFO("FlowPtSwitch : " << m_flowpt_sw );
88  ATH_MSG_INFO("FlowMinPtCut : " << m_flow_minpt );
89  ATH_MSG_INFO("FlowMaxPtCut : " << m_flow_maxpt );
90 
91  ATH_MSG_INFO("FlowV1 : " << m_custom_v1 );
92  ATH_MSG_INFO("FlowV2 : " << m_custom_v2 );
93  ATH_MSG_INFO("FlowV3 : " << m_custom_v3 );
94  ATH_MSG_INFO("FlowV4 : " << m_custom_v4 );
95  ATH_MSG_INFO("FlowV5 : " << m_custom_v5 );
96  ATH_MSG_INFO("FlowV6 : " << m_custom_v6 );
97  ATH_MSG_INFO("FlowBSwitch : " << m_flowb_sw );
98  ATH_MSG_INFO("********************************r*************");
99 
100 
101  // Select the flow-implementing function based of the function-choice variable
111 
115 
116 
117 
118  //TGraph storing the v2_RP/delta Vs b_imp values to be used in implementing the EbyE fluctuations
119  //the values below are b_imp-low,b_imp-high, delta/v2_RP for different centralities
120  //underflow and overflow bins are added for smooth extrapolation
121  //The delta/v2_RP values are taken from Fig15 of EbE vn paper (arXiv:1305.2942)
122  // <0 , 0-1 , 1-2 , 2-3 , 3-4 , 4-5 , 5-10 , 10-15, 15-20, 20-25, 25-30,
123  float b_lo[21]={ -1.00, 0.000, 1.483, 2.098, 2.569, 2.966, 3.317, 4.687, 5.739, 6.627, 7.409,
124  8.117, 8.767, 9.373, 9.943,10.479,10.991,11.479,11.947,15.00 ,100.0};
125  // 30-35, 35-40, 40-45, 45-50, 50-55, 55-60, 60-65, 65-70, 70-
126  float b_hi[21]={ -1.00 , 1.483, 2.098, 2.569, 2.966, 3.317, 4.687, 5.739, 6.627, 7.409, 8.117,//bimp_high
127  8.767, 9.373, 9.943,10.479,10.991,11.479,11.947,12.399,15.00 ,100.0};
128  float val [21]={ 5.600, 5.600, 5.600,1.175 ,0.8253,0.7209,0.5324,0.4431,0.3984,0.3844,0.3847,
129  0.3935,0.4106,0.4310,0.4574,0.4674,0.4873,0.4796,0.4856,0.5130,0.5130};
130  float bimp_vals[21];
131  for(int i=0;i<21;i++) bimp_vals[i]=(b_lo[i]+b_hi[i])/2.0;
132  if(m_flow_fluctuations) m_graph_fluc=new TGraph(21,bimp_vals,val);
133 
134 
135  // Initialization terminated
136  return StatusCode::SUCCESS;
137 }
138 
139 
140 CLHEP::HepRandomEngine* AddFlowByShifting::getRandomEngine(const std::string& streamName,
141  const EventContext& ctx) const
142 {
143  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName);
144  std::string rngName = name()+streamName;
145  rngWrapper->setSeed( rngName, ctx );
146  return rngWrapper->getEngine(ctx);
147 }
148 
149 
151  ATH_MSG_INFO(">>> AddFlowByShifting from execute");
152 
153  const EventContext& ctx = Gaudi::Hive::currentContext();
154  CLHEP::HepRandomEngine *rndmEngine = getRandomEngine("FLOW", ctx);
155  // Get hijing event parameters
156  const HijingEventParams *hijing_pars;
157  if( evtStore()->retrieve(hijing_pars, "Hijing_event_params").isFailure() ) {
158  ATH_MSG_ERROR("Could not retrieve Hijing_event_params");
159  return StatusCode::FAILURE;
160  }
161  ATH_MSG_INFO("Event parameters: B = " << hijing_pars->get_b()<<
162  " BPhi = " << hijing_pars->get_bphi());
163 
164 
165  // FIXME: changing data in the event store
166  HijingEventParams *hijing_pars_nc = const_cast<HijingEventParams*> (hijing_pars);
167 
168 
169  // Read Data from Transient Store
170  const McEventCollection* mcCollptr;
171  if ( evtStore()->retrieve(mcCollptr, m_inkey).isFailure() ) {
172  ATH_MSG_ERROR("Could not retrieve truth McEventCollection");
173  return StatusCode::FAILURE;
174  }
175 
176 
177  // Loop over all events in original McEventCollection and
178  // Copy to a new (modifiable) collection
180  McEventCollection* mcFlowCollptr = new McEventCollection();
181  for (citr = mcCollptr->begin(); citr!=mcCollptr->end(); ++citr) {
182  mcFlowCollptr->push_back(new HepMC::GenEvent(*(*citr)));
183  }
184 
185 
186  //Geneate the event-plane angles (some of them may or may not be used later on)
187  //Store the angles into the hijing event parameters
188  for(int ihar=0;ihar<6;ihar++){
189  m_psi_n[ihar] =(CLHEP::RandFlat::shoot(rndmEngine)-0.5)*2*M_PI / (ihar+1); //Principal value must be within -PI/n to PI/n
190  hijing_pars_nc->set_psi(ihar+1,m_psi_n[ihar]);
191  }
192  m_psi_n[1]=hijing_pars->get_bphi() ;//the psi2 plane is aligned with the impact parameter
193  m_psi_n[1]=std::atan2(std::sin(2*m_psi_n[1]),std::cos(2*m_psi_n[1]))/2.0;//ensure that Psi2 is within [-PI/2,PI/2]
194  hijing_pars_nc->set_psi(2,m_psi_n[1]);
195  ATH_MSG_DEBUG(" Psi2 for event : "<<(*hijing_pars).get_psi(2));
196 
197 
198  // Add flow by phi angle shifting
200  for (itr = mcFlowCollptr->begin(); itr!=mcFlowCollptr->end(); ++itr) {
201  ATH_MSG_DEBUG("Next event in the bag ...");
202 
203 
204 
205 #ifdef HEPMC3
206  auto mainvtx=(*itr)->vertices().front();
207  if(m_flow_fluctuations) Set_EbE_Fluctuation_Multipliers(mainvtx,hijing_pars->get_b(),rndmEngine);
208  int particles_in_event = (*itr)->particles().size();
210  for ( auto parent: mainvtx->particles_out())
211 #else
212  auto mainvtx=*((*itr)->vertices_begin());
213  if(m_flow_fluctuations) Set_EbE_Fluctuation_Multipliers(mainvtx,hijing_pars->get_b(),rndmEngine);
214  int particles_in_event = (*itr)->particles_size();
216  for ( auto parent: *mainvtx)
217 #endif
218  {
219  // Process particles from main vertex
220  CLHEP::HepLorentzVector momentum(parent->momentum().px(),
221  parent->momentum().py(),
222  parent->momentum().pz(),
223  parent->momentum().e());
224  ATH_MSG_DEBUG("Parent particle: " << parent <<
225  " Eta = " << momentum.pseudoRapidity()<<
226  " Phi = " << momentum.phi() );
227 
228  //skip particle if eta is outside implementation range
229  if(m_floweta_sw){
230  float eta=std::abs(momentum.pseudoRapidity());
231  if (eta<m_flow_mineta || eta> m_flow_maxeta) continue;
232  }
233 
234  //skip particle if pT is outside implementation range
235  if(m_flowpt_sw){
236  float pT=momentum.perp();
237  if (pT<m_flow_minpt || pT> m_flow_maxpt) continue;
238  }
239 
240  // Randomize phi if explicitely requested
241  if(m_ranphi_sw) {
242  double phishift = SetParentToRanPhi(parent, rndmEngine);
243  MoveDescendantsToParent(parent, phishift) ;// adjust decsandants to parent position
244  }
245 
246  // Add flow to particles from main vertex
247  double phishift = AddFlowToParent(parent, hijing_pars);
248  MoveDescendantsToParent(parent, phishift);// adjust decsandants to parent position
249  }
250 
251  // correct for double counting
253  // correct for incoming particles
254  ATH_MSG_INFO( " Particles in event: " << particles_in_event <<
255  " Processed for flow: " << m_particles_processed+2);
256  }
257 
258  if(evtStore()->record(mcFlowCollptr, m_outkey).isFailure()){
259  ATH_MSG_ERROR("Could not record flow McEventCollection");
260  return StatusCode::FAILURE;
261  }
262  return StatusCode::SUCCESS;
263 }
264 
265 
267  ATH_MSG_INFO(">>> AddFlowByShifting from finalize <<<");
268  // End of finalization step
269  return StatusCode::SUCCESS;
270 }
271 
272 
274  CLHEP::HepRandomEngine *rndmEngine)
275 {
276  // Set particle to random phi
277  // Return phi shift
279 
280  double phi, phishift;
281  CLHEP::HepLorentzVector momentum(parent->momentum().px(),
282  parent->momentum().py(),
283  parent->momentum().pz(),
284  parent->momentum().e());
285  phi = momentum.phi();
286 
287  double rannum = CLHEP::RandFlat::shoot(rndmEngine);
288  double ranphi = (rannum-0.5)*2*M_PI;
289  phishift = ranphi - phi;
290 
291  momentum.setPhi(ranphi*Gaudi::Units::rad);
292  parent->set_momentum( HepMC::FourVector(momentum.px(),momentum.py(),momentum.pz(),momentum.e()) );
293 
294  ATH_MSG_INFO("Parent phi randomized = " << momentum.phi());
295 
296  return phishift;
297 }
298 
299 
301 (HepMC::GenParticlePtr parent, double phishift)
302 {
303  // Move the branch of descendant vertices and particles
304  // by phishift to parent particle position
305  auto endvtx = parent->end_vertex();
306  if ( endvtx ) {
307  ATH_MSG_DEBUG("Processing branch of parent particle "<< parent);
308 
309  // now rotate descendant vertices
310 #ifdef HEPMC3
311  for (HepMC::GenVertexPtr descvtx: HepMC::descendant_vertices(endvtx)) {
312 #else
313  for ( HepMC::GenVertex::vertex_iterator
314  descvtxit = endvtx->vertices_begin(HepMC::descendants);
315  descvtxit != endvtx->vertices_end(HepMC::descendants);
316  ++descvtxit) {
317  auto descvtx = (*descvtxit);
318 #endif
319 
320  ATH_MSG_DEBUG("Processing vertex " << descvtx);
321 
322  // rotate vertex
323  if(std::abs(phishift) > 1e-7) {
324  CLHEP::HepLorentzVector position(descvtx->position().x(),
325  descvtx->position().y(),
326  descvtx->position().z(),
327  descvtx->position().t());
328  position.rotateZ(phishift*Gaudi::Units::rad);
329  descvtx->set_position(HepMC::FourVector( position.x(),position.y(),position.z(),position.t()) );
330  }
331 
332  // now rotate their associated particles
333 #ifdef HEPMC3
334  for (auto descpart: descvtx->particles_out())
335 #else
336  for (auto descpart: *descvtx)
337 #endif
338  {
339  ATH_MSG_DEBUG("Descendant particle: " << descpart <<
340  " Eta = " << descpart->momentum().pseudoRapidity() <<
341  " Phi = " << descpart->momentum().phi() );
342  }
343  }
344  }
345  return;
346 }
347 
348 
350 {
352  CLHEP::HepLorentzVector momentum(parent->momentum().px(),
353  parent->momentum().py(),
354  parent->momentum().pz(),
355  parent->momentum().e());
356  double pt = parent->momentum().perp();
357  double eta = parent->momentum().pseudoRapidity();
358  double phi_0 = parent->momentum().phi();
359 
360  int error_=0;
361  if(pt !=pt) {ATH_MSG_ERROR("ERROR pt of track is not defined");error_=1;} //true if pt==nan
362  if(eta !=eta) {ATH_MSG_ERROR("ERROR eta of track is not defined");error_=1;}
363  if(phi_0 !=phi_0) {ATH_MSG_ERROR("ERROR phi of track is not defined");error_=1;}
364  if(error_==1){
365  ATH_MSG_ERROR("Original Particle Momentum(px,py,pz,e,m)="<<parent->momentum().px()<<" "
366  <<parent->momentum().py()<<" "
367  <<parent->momentum().pz()<<" "
368  <<parent->momentum().e() <<" "
369  <<parent->momentum().m() <<" ");
370  }
371 
372 
373 
374 
375  //Call the appropriate function to set the vn values
376  for(int ihar = 0; ihar< 6; ihar++){m_v_n [ihar]=0.0;} //reset the vn for this particle
377  double b = hijing_pars->get_b();
378  (*this.*m_flow_function)(b,eta,pt);//get the vn for this particle
379  if(m_flow_fluctuations){//add EbE fluctuations
380  for(int ihar = 0; ihar< 6; ihar++){
381  m_v_n[ihar] *= m_EbE_Multiplier_vn[ihar];
382  if(m_v_n[ihar]>0.5) {ATH_MSG_WARNING(" Vn Too large "<<ihar+1<<" "<<m_EbE_Multiplier_vn[ihar]<<" "<<m_v_n[ihar]);m_v_n[ihar]=0.5;}
383  }
384  }
385 
386  double phishift=0;
387 
388  // Old fashioned rotation(approximate)
390  float phi=phi_0;
391  phishift= -2*( m_v_n[0]*sin(1*(phi-m_psi_n[0]))/1.0 + m_v_n[1]*sin(2*(phi-m_psi_n[1]))/2.0 +
392  m_v_n[2]*sin(3*(phi-m_psi_n[2]))/3.0 + m_v_n[3]*sin(4*(phi-m_psi_n[3]))/4.0 +
393  m_v_n[4]*sin(5*(phi-m_psi_n[4]))/5.0 + m_v_n[5]*sin(6*(phi-m_psi_n[5]))/6.0 );
394 
395  }
396 
397  // New fashioned rotation(exact)
398  else if (m_flow_implementation_type==1){
399  // Thread-safe according to https://www.gnu.org/software/gsl/doc/html/roots.html
400  const gsl_root_fsolver_type *T ATLAS_THREAD_SAFE = gsl_root_fsolver_brent;
401  gsl_root_fsolver *s = gsl_root_fsolver_alloc (T);
402  double x_lo=-2*M_PI,x_hi=2*M_PI;
403  float params[13];
404  for(int ipar=0;ipar<13;ipar++) {params[ipar]=0;}
405  gsl_function F;
406  F.function = &(AddFlowByShifting::vn_func);
407  F.params =&params;
408  gsl_root_fsolver_set (s, &F, x_lo, x_hi);
409  int iter=0;
410  params[0]=phi_0;
411  params[1]=m_v_n [0]; params[2]=m_v_n [1]; params[3]=m_v_n [2]; params[4 ]=m_v_n [3]; params[5 ]=m_v_n [4]; params[6 ]=m_v_n [5];
412  params[7]=m_psi_n[0]; params[8]=m_psi_n[1]; params[9]=m_psi_n[2]; params[10]=m_psi_n[3]; params[11]=m_psi_n[4]; params[12]=m_psi_n[5];
413  int status;
414  double phi=phi_0;
415  do
416  {
417  iter++;
418  status = gsl_root_fsolver_iterate (s);
419  phi = gsl_root_fsolver_root (s);
420  x_lo = gsl_root_fsolver_x_lower (s);
421  x_hi = gsl_root_fsolver_x_upper (s);
422  status = gsl_root_test_interval (x_lo, x_hi,0, 0.00001);
423  }
424  while (status == GSL_CONTINUE && iter < 1000);
425  gsl_root_fsolver_free (s);
426 
427  if (iter>=1000) return 0;
428 
429  phishift = phi-phi_0;
430  }
431 
432  if(std::abs(phishift) > 1e-7) {
433  momentum.rotateZ(phishift*Gaudi::Units::rad);
434  parent->set_momentum( HepMC::FourVector(momentum.px(),momentum.py(),momentum.pz(),momentum.e()) );
435  }
436  ATH_MSG_DEBUG( "Parent particle: V1 = " << m_v_n[0] <<
437  " V2 = " << m_v_n[1] <<
438  " V3 = " << m_v_n[2] <<
439  " V4 = " << m_v_n[3] <<
440  " V5 = " << m_v_n[4] <<
441  " V6 = " << m_v_n[5] <<
442  " Phi shift = " << phishift <<
443  " Phi shifted = " << momentum.phi() );
444 
445  return phishift;
446 }
447 
448 
449 
450 // New parameterization for vn
451 void AddFlowByShifting::jjia_minbias_new(double b, double eta, double pt)
452 {
453  pt=pt/1000.0; //convert to GeV
454 
455  float a1,a2,a3,a4;
456  a1=0.4397*std::exp(-(b-4.526)*(b-4.526)/72.0) + 0.636;
457  a2=1.916/(b+2) +0.1;
458  a3=4.79*0.0001*(b-0.621)*(b-10.172)*(b-23)+1.2; // this is >0 for b>0
459  a4=0.135*std::exp(-0.5*(b-10.855)*(b-10.855)/4.607/4.607) +0.0120;
460 
461  float temp1 = std::pow(pt , a1) / (1+std::exp( (pt-3.0)/a3));
462  float temp2 = std::pow(pt+0.1,-a2) / (1+std::exp(-(pt-4.5)/a3));
463  float temp3 = 0.01 / (1+std::exp(-(pt-4.5)/a3));
464 
465  m_v_n[1] = ( a4*(temp1+temp2) + temp3 )* std::exp(-0.5* eta*eta /6.27/6.27) ;
466 
467  float fb=0.97 +1.06*std::exp(-0.5*b*b/3.2/3.2);
468  m_v_n[2]=std::pow(fb*std::sqrt(m_v_n[1]),3);
469 
470  float gb= 1.096 +1.36 *std::exp(-0.5*b*b/3.0/3.0);
471  gb=gb*sqrt(m_v_n[1]);
472  m_v_n[3]=pow(gb,4);
473  m_v_n[4]=pow(gb,5);
474  m_v_n[5]=pow(gb,6);
475  m_v_n[0]=0;
476 }
477 
478 
479 // New parameterization for vn
481 {
482  pt=pt/1000.0; //convert to GeV
483 
484  float a1,a2,a3,a4;
485  a1=0.4397*std::exp(-(b-4.526)*(b-4.526)/72.0) + 0.636;
486  a2=1.916/(b+2) +0.1;
487  a3=4.79*0.0001*(b-0.621)*(b-10.172)*(b-23)+1.2; // this is >0 for b>0
488  a4=0.135*std::exp(-0.5*(b-10.855)*(b-10.855)/4.607/4.607) +0.0120;
489 
490  float temp1 = std::pow(pt , a1) / (1+std::exp( (pt-3.0)/a3));
491  float temp2 = std::pow(pt+0.1,-a2) / (1+std::exp(-(pt-4.5)/a3));
492  float temp3 = 0.01 / (1+std::exp(-(pt-4.5)/a3));
493 
494  m_v_n[1] = ( a4*(temp1+temp2) + temp3 )* std::exp(-0.5* eta*eta /6.27/6.27) ;
495 
496  m_v_n[0]=0;
497  m_v_n[2]=0;
498  m_v_n[3]=0;
499  m_v_n[4]=0;
500  m_v_n[5]=0;
501 }
502 
503 
504 // Fixed vn
505 void AddFlowByShifting::fixed_vn(double /*b*/, double /*eta*/, double /*pt*/)
506 {
507  m_v_n[0]=0.0000; m_v_n[1]=0.0500;
508  m_v_n[2]=0.0280; m_v_n[3]=0.0130;
509  m_v_n[4]=0.0045; m_v_n[5]=0.0015;
510 }
511 
512 
513 // Fixed 5% v2 (other vn=0)
514 void AddFlowByShifting::fixed_v2(double /*b*/, double /*eta*/, double /*pt*/)
515 {
516  m_v_n[0]=0.0000; m_v_n[1]=0.0500;
517  m_v_n[2]=0.0000; m_v_n[3]=0.0000;
518  m_v_n[4]=0.0000; m_v_n[5]=0.0000;
519 }
520 
521 // Old parameterization for v2
522 void AddFlowByShifting::jjia_minbias_old(double b, double eta, double pt)
523 {
524  m_v_n[0] = 0;
525  m_v_n[1] = 0.03968 * b
526  * (1 - 2.1/(1 + std::exp(1.357*(pt/1000))))
527  * std::exp(-(eta*eta)/(2*6.37*6.37));
528  m_v_n[2]=0.0000; m_v_n[3]=0.0000;
529  m_v_n[4]=0.0000; m_v_n[5]=0.0000;
530 }
531 
532 
533 void AddFlowByShifting::ao_test (double b, double /*eta*/, double pt)
534 {
535  pt/=1000;
536  if(pt>2) pt = 2; // flat max at pt > 2
537  m_v_n[1] = 0.02 * b * pt;
538  m_v_n[0] = 0;
539 }
540 
541 
542 void AddFlowByShifting::custom_vn (double /*b*/, double /*eta*/, double /*pt*/)
543 {
544  m_v_n[0]=m_custom_v1;
545  m_v_n[1]=m_custom_v2;
546  m_v_n[2]=m_custom_v3;
547  m_v_n[3]=m_custom_v4;
548  m_v_n[4]=m_custom_v5;
549  m_v_n[5]=m_custom_v6;
550 }
551 
552 // p_Pb vn
553 void AddFlowByShifting::p_Pb_cent_eta_indep(double /*b*/, double /*eta*/, double pt)
554 {
555  pt=pt/1000.0; //convert to GeV
556 
557  float an_val[4][3];
558 
559  an_val[0][0] = 0.1149;
560  an_val[0][1] = 1.181;
561  an_val[0][2] = 0.3767;
562 
563  an_val[1][0] = 0.0498;
564  an_val[1][1] = 1.688;
565  an_val[1][2] = 0.5046;
566 
567  an_val[2][0] = 0.02095;
568  an_val[2][1] = 2.196;
569  an_val[2][2] = 0.6259;
570 
571  an_val[3][0] = 0.00682*0.5;//added in 0.5 factor by hand
572  an_val[3][1] = 4.938;
573  an_val[3][2] = 1.237;
574 
575  m_v_n[0]=0;
576  m_v_n[1]=an_val[0][0]*std::pow(pt,an_val[0][1])*std::exp(-an_val[0][2]*pt);
577  m_v_n[2]=an_val[1][0]*std::pow(pt,an_val[1][1])*std::exp(-an_val[1][2]*pt);
578  m_v_n[3]=an_val[2][0]*std::pow(pt,an_val[2][1])*std::exp(-an_val[2][2]*pt);
579  m_v_n[4]=an_val[3][0]*std::pow(pt,an_val[3][1])*std::exp(-an_val[3][2]*pt);
580  m_v_n[5]=0;
581 }
582 
583 
584 void AddFlowByShifting::Set_EbE_Fluctuation_Multipliers(HepMC::GenVertexPtr mainvtx,float b, CLHEP::HepRandomEngine *rndmEngine){
585  int Total_Multiplicity=0;
586  double EbE_Vn[6];
587  for(int ihar=0;ihar<6;ihar++){m_EbE_Multiplier_vn[ihar]=1.0;EbE_Vn[ihar]=0.0;}
588 
589  for(auto parent: *mainvtx) {
590  float eta= parent->momentum().pseudoRapidity();
591  float pT = parent->momentum().perp();
592 
593  for(int ihar = 0; ihar< 6; ihar++){m_v_n [ihar]=0.0;}
594  (*this.*m_flow_function)(b,eta,pT);
595  for(int ihar = 0; ihar< 6; ihar++){EbE_Vn[ihar] += m_v_n [ihar];}
596  Total_Multiplicity++;
597  }
598 
599 
600  for(int ihar = 0; ihar< 6; ihar++){m_v_n [ihar]=0.0;}//keep vn as zero before we return from function
601  if(Total_Multiplicity<=0) return;
602 
603 
604  for(int ihar=0;ihar<6;ihar++){
605  EbE_Vn[ihar]/=Total_Multiplicity;
606  float vn_rp=0,delta=0;//BG parameterizations
607 
608  //in the following we assume that the vn in the event is sqrt(<vn^2>)
609  //This is because the vn(pT) were tuned to 2PC/EP measurements
610  //then : vn_evt=vn_rp^2 + 2*(delta^2)
611  //which is used together with the "alpha" to get the "vn_rp" and "delta"
612  if(ihar==0) continue; //No EbE fluctuation for v1
613  else if(ihar==1) { //v2
614  float alpha=1.0/m_graph_fluc->Eval(b);// ratio of V2_RP over delta (from Fig 15 of EbE vn paper)
615  delta=EbE_Vn[ihar]/sqrt(2.0+alpha*alpha);
616  vn_rp=alpha*delta;
617  }
618  else if(ihar>=2) { //v3-v6
619  vn_rp =0;
620  delta=EbE_Vn[ihar]/sqrt(2.0);
621  }
622  if(EbE_Vn[ihar]==0) {ATH_MSG_WARNING("Zero EbeV"<<ihar+1); continue;}
623  float X=CLHEP::RandGaussQ::shoot(rndmEngine,vn_rp,delta);
624  float Y=CLHEP::RandGaussQ::shoot(rndmEngine,0.0 ,delta);
625  m_EbE_Multiplier_vn[ihar]=sqrt(X*X+ Y*Y)/EbE_Vn[ihar];
626  ATH_MSG_INFO("EbE_Multiplier_v"<<ihar+1<<"="<<m_EbE_Multiplier_vn[ihar]);
627  }
628 }
AddFlowByShifting::m_flow_function_name
StringProperty m_flow_function_name
Definition: AddFlowByShifting.h:86
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AddFlowByShifting::m_flow_function
void(AddFlowByShifting::* m_flow_function)(double b, double eta, double pt)
Definition: AddFlowByShifting.h:64
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
AddFlowByShifting::finalize
StatusCode finalize()
Definition: AddFlowByShifting.cxx:266
AddFlowByShifting::m_flow_implementation
StringProperty m_flow_implementation
Definition: AddFlowByShifting.h:87
AddFlowByShifting::m_flow_implementation_type
int m_flow_implementation_type
Definition: AddFlowByShifting.h:88
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
AddFlowByShifting::Set_EbE_Fluctuation_Multipliers
void Set_EbE_Fluctuation_Multipliers(HepMC::GenVertexPtr mainvtx, float b, CLHEP::HepRandomEngine *rndmEngine)
Definition: AddFlowByShifting.cxx:584
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AddFlowByShifting::m_graph_fluc
TGraph * m_graph_fluc
Definition: AddFlowByShifting.h:74
AddFlowByShifting::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition: AddFlowByShifting.cxx:140
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
AddFlowByShifting::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: AddFlowByShifting.h:78
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
AddFlowByShifting::AddFlowToParent
double AddFlowToParent(HepMC::GenParticlePtr parent, const HijingEventParams *hijing_pars)
Definition: AddFlowByShifting.cxx:349
McEventCollection
McEventCollection
Definition: GeneratorObjectsTPCnv.cxx:60
test_pyathena.pt
pt
Definition: test_pyathena.py:11
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AddFlowByShifting::m_custom_v2
FloatProperty m_custom_v2
Definition: AddFlowByShifting.h:101
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
AddFlowByShifting::vn_func_derivative
static double vn_func_derivative(double x, void *params)
Definition: AddFlowByShifting.cxx:44
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
x
#define x
AddFlowByShifting::MoveDescendantsToParent
void MoveDescendantsToParent(HepMC::GenParticlePtr parent, double phishift)
Definition: AddFlowByShifting.cxx:301
AddFlowByShifting::AddFlowByShifting
AddFlowByShifting(const std::string &name, ISvcLocator *pSvcLocator)
Definition: AddFlowByShifting.cxx:56
AddFlowByShifting::m_custom_v4
FloatProperty m_custom_v4
Definition: AddFlowByShifting.h:103
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
AddFlowByShifting::m_flowb_sw
IntegerProperty m_flowb_sw
Definition: AddFlowByShifting.h:99
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AddFlowByShifting::m_EbE_Multiplier_vn
float m_EbE_Multiplier_vn[6]
Definition: AddFlowByShifting.h:111
AddFlowByShifting::m_psi_n
float m_psi_n[6]
Definition: AddFlowByShifting.h:110
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AddFlowByShifting::m_flow_fluctuations
BooleanProperty m_flow_fluctuations
Definition: AddFlowByShifting.h:89
AddFlowByShifting::m_custom_v6
FloatProperty m_custom_v6
Definition: AddFlowByShifting.h:105
HijingEventParams
Definition: HijingEventParams.h:23
AddFlowByShifting::m_v_n
float m_v_n[6]
Definition: AddFlowByShifting.h:110
AddFlowByShifting::jjia_minbias_old
void jjia_minbias_old(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:522
AddFlowByShifting::m_flowpt_sw
IntegerProperty m_flowpt_sw
Definition: AddFlowByShifting.h:95
AddFlowByShifting::custom_vn
void custom_vn(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:542
HijingEventParams::set_psi
void set_psi(int ihar, float psi)
Definition: HijingEventParams.h:107
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AddFlowByShifting::m_inkey
StringProperty m_inkey
Definition: AddFlowByShifting.h:81
AddFlowByShifting::m_flow_mineta
FloatProperty m_flow_mineta
Definition: AddFlowByShifting.h:93
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
AddFlowByShifting::execute
StatusCode execute()
Definition: AddFlowByShifting.cxx:150
HijingEventParams::get_bphi
float get_bphi() const
Definition: HijingEventParams.h:92
AddFlowByShifting::m_ranphi_sw
IntegerProperty m_ranphi_sw
Definition: AddFlowByShifting.h:84
AthAlgorithm
Definition: AthAlgorithm.h:47
AddFlowByShifting.h
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
AddFlowByShifting::m_flow_maxeta
FloatProperty m_flow_maxeta
Definition: AddFlowByShifting.h:92
AddFlowByShifting::jjia_minbias_new_v2only
void jjia_minbias_new_v2only(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:480
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
AddFlowByShifting::m_custom_v5
FloatProperty m_custom_v5
Definition: AddFlowByShifting.h:104
AddFlowByShifting::jjia_minbias_new
void jjia_minbias_new(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:451
AddFlowByShifting::initialize
StatusCode initialize()
Definition: AddFlowByShifting.cxx:68
AddFlowByShifting::m_outkey
StringProperty m_outkey
Definition: AddFlowByShifting.h:82
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
RNGWrapper.h
HijingEventParams::get_b
float get_b() const
Definition: HijingEventParams.h:91
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
AddFlowByShifting::fixed_vn
void fixed_vn(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:505
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
AddFlowByShifting::vn_func
static double vn_func(double x, void *params)
Definition: AddFlowByShifting.cxx:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
F
#define F(x, y, z)
Definition: MD5.cxx:112
AddFlowByShifting::m_particles_processed
int m_particles_processed
Definition: AddFlowByShifting.h:107
AddFlowByShifting::m_custom_v1
FloatProperty m_custom_v1
Definition: AddFlowByShifting.h:100
merge.status
status
Definition: merge.py:17
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
AddFlowByShifting::m_custom_v3
FloatProperty m_custom_v3
Definition: AddFlowByShifting.h:102
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
AddFlowByShifting::p_Pb_cent_eta_indep
void p_Pb_cent_eta_indep(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:553
AddFlowByShifting::m_floweta_sw
IntegerProperty m_floweta_sw
Definition: AddFlowByShifting.h:91
checker_macros.h
Define macros for attributes used to control the static checker.
AddFlowByShifting::m_flow_minpt
FloatProperty m_flow_minpt
Definition: AddFlowByShifting.h:97
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
AddFlowByShifting::ao_test
void ao_test(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:533
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
AddFlowByShifting::m_flow_maxpt
FloatProperty m_flow_maxpt
Definition: AddFlowByShifting.h:96
AddFlowByShifting::fixed_v2
void fixed_v2(double b, double eta, double pt)
Definition: AddFlowByShifting.cxx:514
AddFlowByShifting::SetParentToRanPhi
double SetParentToRanPhi(HepMC::GenParticlePtr parent, CLHEP::HepRandomEngine *rndmEngine)
Definition: AddFlowByShifting.cxx:273