21 #include "CLHEP/Random/RandomEngine.h"
22 #include "CLHEP/Random/RandFlat.h"
23 #include "CLHEP/Random/RandGaussQ.h"
24 #include "CLHEP/Vector/LorentzVector.h"
30 #include <gsl/gsl_errno.h>
31 #include <gsl/gsl_math.h>
32 #include <gsl/gsl_roots.h>
34 #include "GaudiKernel/PhysicalConstants.h"
42 float *par_float = (
float*)
params;
43 double phi_0 = par_float[0];
44 float *vn = par_float+1;
45 float *psi_n = vn+Harmonic::NumHar;
46 double val=
x +2*( vn[Harmonic::v1]*
sin(1*(
x-psi_n[Harmonic::v1]))/1.0 +
48 vn[Harmonic::v3]*
sin(3*(
x-psi_n[Harmonic::v3]))/3.0 +
49 vn[Harmonic::v4]*
sin(4*(
x-psi_n[Harmonic::v4]))/4.0 +
50 vn[Harmonic::v5]*
sin(5*(
x-psi_n[Harmonic::v5]))/5.0 +
51 vn[Harmonic::v6]*
sin(6*(
x-psi_n[Harmonic::v6]))/6.0 );
60 for(
int ihar = 0; ihar< Harmonic::NumHar; ihar++){
69 ATH_MSG_INFO(
">>> AddFlowByShifting from Initialize <<<");
73 ATH_MSG_INFO(
"**********Settings for Afterburner************");
98 ATH_MSG_INFO(
"********************************r*************");
114 return StatusCode::FAILURE;
121 ATH_MSG_WARNING(
"'FlowInplementation=\"approximate\"' is obsolete, please switch to 'FlowInplementation=\"exact\"' ");
128 return StatusCode::FAILURE;
143 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,
144 8.117, 8.767, 9.373, 9.943,10.479,10.991,11.479,11.947,15.00 ,100.0};
146 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,
147 8.767, 9.373, 9.943,10.479,10.991,11.479,11.947,12.399,15.00 ,100.0};
148 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,
149 0.3935,0.4106,0.4310,0.4574,0.4674,0.4873,0.4796,0.4856,0.5130,0.5130};
152 for(
int i=0;
i<21;
i++){
153 bimp_vals[
i]=(b_lo[
i]+b_hi[
i])/2.0
f;
172 float v2_4 [18]={ 0.0444322, 0.0444322, 0.0476009, 0.0495882, 0.0513053, 0.0527020, 0.0563533, 0.0614435, 0.0650522, 0.0675199, 0.0693970,
173 0.0705456, 0.0706748, 0.0686654, 0.0571383, 0.04 , 0.02 , 0.0 };
174 float bimp4[18]={-1 , 0.481843, 0.886609 , 1.13462 , 1.33981 , 1.52064 , 1.95342 , 2.51881 , 2.97665 , 3.37416 , 3.72876 ,
175 4.05377 , 4.35564 , 4.77463 , 5.30719 , 6.08296 , 7.6415 , 15 };
181 float v2_2 [23]={ 0.0749381, 0.0749381, 0.0782992, 0.0801742, 0.0814646, 0.0826611, 0.0853616, 0.0889407, 0.0913229, 0.0928072, 0.0933774,
182 0.0933299, 0.0926254, 0.0910148, 0.0889322, 0.086161 , 0.0828212, 0.0793132, 0.0755036, 0.0714726, 0.0668264, 0.055 , 0.05};
183 float bimp2[23]={-1 , 0.481843, 0.886609 , 1.13462 , 1.33981 , 1.52064 , 1.95342 , 2.51881 , 2.97665 , 3.37416 , 3.72876 ,
184 4.05377 , 4.35564 , 4.63868 , 4.91057 , 5.17773 , 5.43665 , 5.68739 , 5.94258 , 6.20668 , 6.49519 , 7.6415 , 15};
188 TGraph *graph_v2_4=
new TGraph(18,bimp4,v2_4);
189 TGraph *graph_v2_2=
new TGraph(23,bimp2,v2_2);
191 for(
int i=0;
i<23;
i++){
192 double vn_RP=graph_v2_4->Eval(bimp2[
i]);
193 double vn_2 =graph_v2_2->Eval(bimp2[
i]);
194 double delta=vn_2*vn_2 - vn_RP*vn_RP;
196 ratio[
i]= vn_RP/sqrt(delta/2.0);
200 return StatusCode::FAILURE;
217 return StatusCode::SUCCESS;
222 const EventContext& ctx)
const
226 rngWrapper->
setSeed( rngName, ctx );
234 const EventContext& ctx = Gaudi::Hive::currentContext();
238 if(
evtStore()->
retrieve(hijing_pars,
"Hijing_event_params").isFailure() ) {
240 return StatusCode::FAILURE;
243 " BPhi = " << hijing_pars->
get_bphi());
254 return StatusCode::FAILURE;
262 for (citr = mcCollptr->
begin(); citr!=mcCollptr->
end(); ++citr) {
263 mcFlowCollptr->
push_back(
new HepMC::GenEvent(*(*citr)));
269 for(
int ihar=0;ihar<6;ihar++){
270 m_psi_n[ihar] =(CLHEP::RandFlat::shoot(rndmEngine)-0.5)*2*
M_PI / (ihar+1);
276 ATH_MSG_DEBUG(
" Psi2 for event : "<<(*hijing_pars).get_psi(2));
281 for (itr = mcFlowCollptr->
begin(); itr!=mcFlowCollptr->
end(); ++itr) {
287 auto mainvtx=(*itr)->vertices().front();
289 int particles_in_event = (*itr)->particles().size();
291 for (
auto parent: mainvtx->particles_out())
293 auto mainvtx=*((*itr)->vertices_begin());
295 int particles_in_event = (*itr)->particles_size();
297 for (
auto parent: *mainvtx)
306 " Eta = " <<
momentum.pseudoRapidity()<<
335 ATH_MSG_INFO(
" Particles in event: " << particles_in_event <<
345 return StatusCode::FAILURE;
347 return StatusCode::SUCCESS;
352 ATH_MSG_INFO(
">>> AddFlowByShifting from finalize <<<");
359 return StatusCode::SUCCESS;
364 CLHEP::HepRandomEngine *rndmEngine)
370 double phi, phishift;
377 double rannum = CLHEP::RandFlat::shoot(rndmEngine);
378 double ranphi = (rannum-0.5)*2*
M_PI;
379 phishift = ranphi -
phi;
395 auto endvtx =
parent->end_vertex();
401 if (std::abs(phishift) > 1
e-7) {
402 CLHEP::HepLorentzVector
pos(endvtx->position().x(),
403 endvtx->position().y(),
404 endvtx->position().z(),
405 endvtx->position().t());
407 endvtx->set_position(HepMC::FourVector(
pos.x(),
pos.y(),
pos.z(),
pos.t()));
414 for (
auto child : endvtx->particles_out())
416 for (
auto child : *endvtx)
419 CLHEP::HepLorentzVector
p(child->momentum().px(),
420 child->momentum().py(),
421 child->momentum().pz(),
422 child->momentum().e());
423 if (std::abs(phishift) > 1
e-7) {
425 child->set_momentum(HepMC::FourVector(
p.px(),
p.py(),
p.pz(),
p.e()));
435 for ( HepMC::GenVertex::vertex_iterator
436 descvtxit = endvtx->vertices_begin(HepMC::descendants);
437 descvtxit != endvtx->vertices_end(HepMC::descendants);
439 auto descvtx = (*descvtxit);
445 if(std::abs(phishift) > 1
e-7) {
446 CLHEP::HepLorentzVector position(descvtx->position().x(),
447 descvtx->position().y(),
448 descvtx->position().z(),
449 descvtx->position().t());
451 descvtx->set_position(HepMC::FourVector( position.x(),position.y(),position.z(),position.t()) );
456 for (
auto descpart: descvtx->particles_out())
458 for (
auto descpart: *descvtx)
461 CLHEP::HepLorentzVector
momentum(descpart->momentum().px(),
462 descpart->momentum().py(),
463 descpart->momentum().pz(),
464 descpart->momentum().e());
466 " Eta = " << descpart->momentum().pseudoRapidity() <<
467 " Phi = " << descpart->momentum().phi() );
470 if(std::abs(phishift) > 1
e-7) {
474 " Phi shifted = " <<
momentum.phi());
490 double pt =
parent->momentum().perp();
491 double eta =
parent->momentum().pseudoRapidity();
492 double phi_0 =
parent->momentum().phi();
497 if(phi_0 !=phi_0) {
ATH_MSG_ERROR(
"ERROR phi of track is not defined");error_=1;}
500 <<
parent->momentum().py()<<
" "
501 <<
parent->momentum().pz()<<
" "
502 <<
parent->momentum().e() <<
" "
503 <<
parent->momentum().m() <<
" ");
510 for(
int ihar = 0; ihar< Harmonic::NumHar; ihar++){
m_v_n [ihar]=0.0;}
511 double b = hijing_pars->
get_b();
516 for(
int ihar = 0; ihar< Harmonic::NumHar; ihar++){
542 gsl_root_fsolver *
s = gsl_root_fsolver_alloc (
T);
545 for(
int ipar=0;ipar<13;ipar++) {
params[ipar]=0;}
549 gsl_root_fsolver_set (
s, &
F, x_lo, x_hi);
569 status = gsl_root_fsolver_iterate (
s);
570 phi = gsl_root_fsolver_root (
s);
571 x_lo = gsl_root_fsolver_x_lower (
s);
572 x_hi = gsl_root_fsolver_x_upper (
s);
573 status = gsl_root_test_interval (x_lo, x_hi,0, 0.00001);
575 while (
status == GSL_CONTINUE &&
iter < 1000);
576 gsl_root_fsolver_free (
s);
578 if (
iter>=1000)
return 0;
580 phishift =
phi-phi_0;
583 if(std::abs(phishift) > 1
e-7) {
588 " V1 = " <<
m_v_n[Harmonic::v1] <<
590 " V3 = " <<
m_v_n[Harmonic::v3] <<
591 " V4 = " <<
m_v_n[Harmonic::v4] <<
592 " V5 = " <<
m_v_n[Harmonic::v5] <<
593 " V6 = " <<
m_v_n[Harmonic::v6] <<
594 " Phi shift = " << phishift <<
595 " Phi shifted = " <<
momentum.phi() );
608 a1=0.4397*
std::exp(-(
b-4.526)*(
b-4.526)/72.0) + 0.636;
610 a3=4.79*0.0001*(
b-0.621)*(
b-10.172)*(
b-23)+1.2;
611 a4=0.135*
std::exp(-0.5*(
b-10.855)*(
b-10.855)/4.607/4.607) +0.0120;
615 float temp3 = 0.01 / (1+
std::exp(-(
pt-4.5)/a3));
619 float fb=0.97 +1.06*
std::exp(-0.5*
b*
b/3.2/3.2);
622 float gb= 1.096 +1.36 *
std::exp(-0.5*
b*
b/3.0/3.0);
623 gb=gb*sqrt(
m_v_n[1]);
627 m_v_n[Harmonic::v1]=0;
636 m_v_n[Harmonic::v1] = 0;
637 m_v_n[Harmonic::v3] = 0;
638 m_v_n[Harmonic::v4] = 0;
639 m_v_n[Harmonic::v5] = 0;
640 m_v_n[Harmonic::v6] = 0;
647 m_v_n[Harmonic::v1]=0.0000;
649 m_v_n[Harmonic::v3]=0.0280;
650 m_v_n[Harmonic::v4]=0.0130;
651 m_v_n[Harmonic::v5]=0.0045;
652 m_v_n[Harmonic::v6]=0.0015;
659 for(
int ihar=0;ihar<Harmonic::NumHar;ihar++){
669 m_v_n[Harmonic::v1] = 0;
673 m_v_n[Harmonic::v3]=0.0000;
674 m_v_n[Harmonic::v4]=0.0000;
675 m_v_n[Harmonic::v5]=0.0000;
676 m_v_n[Harmonic::v6]=0.0000;
682 for(
int ihar=0;ihar<Harmonic::NumHar;ihar++){
710 an_val[0][0] = 0.1149;
711 an_val[0][1] = 1.181;
712 an_val[0][2] = 0.3767;
714 an_val[1][0] = 0.0498;
715 an_val[1][1] = 1.688;
716 an_val[1][2] = 0.5046;
718 an_val[2][0] = 0.02095;
719 an_val[2][1] = 2.196;
720 an_val[2][2] = 0.6259;
722 an_val[3][0] = 0.00682*0.5;
723 an_val[3][1] = 4.938;
724 an_val[3][2] = 1.237;
726 m_v_n[Harmonic::v1]=0;
731 m_v_n[Harmonic::v6]=0;
752 static TGraph gr_v2pt;
753 static TGraph gr_v3pt;
754 static TGraph gr_v4pt;
756 static TGraph gr_v2_cent_scale;
757 static TGraph gr_v3_cent_scale;
758 static TGraph gr_v4_cent_scale;
760 static bool is_initialized=
false;
761 if(is_initialized==
false){
765 const int NumPtBins=23;
766 float v2_pt[NumPtBins]={
768 0.049533 ,0.0622719,0.0776591,0.0906141,0.101341 ,0.110451 ,0.117545,
769 0.123217 ,0.126643 ,0.129142 ,0.129176 ,0.128795 ,0.126009 ,0.120966,
770 0.109416 ,0.0966881,0.0825195,0.0708585,0.0615164,0.0508748,
773 float v3_pt[NumPtBins]={
775 0.0186328,0.0262968,0.0366394,0.0467804,0.0562739,0.0639566,0.0714195,
776 0.0783429,0.0838629,0.0886202,0.0907969,0.0922756,0.0948961,0.0947266,
777 0.0898434,0.0839913,0.0801961,0.0685197,0.0648406,0.0600871,
782 float v3_pt_2PC[NumPtBins]={
784 0.0182106,0.0255873,0.0355349,0.0451583,0.0537545,0.0611133,0.0675791,
785 0.0732434,0.0778371,0.0812549,0.0823093,0.0826907,0.082954 ,0.0800712,
786 0.0719686,0.062255 ,0.0498296,0.0370541,0.027638 ,0.0139785,
789 for(
int i=0;
i<NumPtBins;
i++) v3_pt[
i]=(v3_pt[
i]+v3_pt_2PC[
i])/2.0;
792 float v4_pt[NumPtBins]={
794 0.00446155,0.00710366,0.0117637,0.0158203,0.01931 ,0.0234234,0.0268995,
795 0.0299693 ,0.0321662 ,0.0335182,0.0358789,0.0374195,0.0359359,0.0327255,
796 0.0254762 ,0.0273239 ,0.0212901,0.0152591, -0 ,-0 ,
799 float pt_bins[NumPtBins]={
801 0.55 ,0.7 ,0.9 ,1.1 , 1.3, 1.5, 1.7,
802 1.9 ,2.1 ,2.3 ,2.5 , 2.7, 2.9, 3.25,
803 3.75 ,4.25 ,4.75 ,5.25 , 5.75, 6.5,
806 gr_v2pt=TGraph(NumPtBins,pt_bins,v2_pt);
807 gr_v3pt=TGraph(NumPtBins,pt_bins,v3_pt);
808 gr_v4pt=TGraph(NumPtBins,pt_bins,v4_pt);
809 gr_v2pt.SetBit(TGraph::kIsSortedX);
810 gr_v3pt.SetBit(TGraph::kIsSortedX);
811 gr_v4pt.SetBit(TGraph::kIsSortedX);
818 const int NumCentBins=23;
819 float v2_cent[NumCentBins]={
821 0.0749381,0.0782992,0.0801742,0.0814646,0.0826611,0.0853616,0.0889407,
822 0.0913229,0.0928072,0.0933774,0.0933299,0.0926254,0.0910148,0.0889322,
823 0.086161 ,0.0828212,0.0793132,0.0755036,0.0714726,0.0668264,
826 float v3_cent[NumCentBins]={
828 0.0409694,0.0399241,0.0394262,0.0388545,0.0385726,0.0375281,0.0360179,
829 0.0345174,0.0330085,0.0314149,0.0298081,0.0282141,0.02664 ,0.0253094,
830 0.0239221,0.0220779,0.0213821,0.0203176,0.0175276,0.0151146,
833 float v4_cent[NumCentBins]={
835 0.0131927 ,0.0129838,0.0135232 ,0.0132689 ,0.0130435 ,0.0134254 ,0.013706 ,
836 0.0136456 ,0.0136656,0.013245 ,0.0130861 ,0.0125356 ,0.0118006 ,0.0110316,
837 0.00987005,0.0106963,0.00933145,0.00784534,0.00393584,0.00308131,
841 float b_imp[NumCentBins]={
843 0.481843 ,0.886609 , 1.13462 , 1.33981 , 1.52064 , 1.95342 , 2.51881 ,
844 2.97665 ,3.37416 , 3.72876 , 4.05377 , 4.35564 , 4.63868 , 4.91057 ,
845 5.17773 ,5.43665 , 5.68739 , 5.94258 , 6.20668 , 6.49519 ,
850 float vn_0_5[3]={0.078963056, 0.039746672, 0.013202649};
852 for(
int i=0;
i<NumCentBins;
i++){
853 v2_cent[
i]/=vn_0_5[0];
854 v3_cent[
i]/=vn_0_5[1];
855 v4_cent[
i]/=vn_0_5[2];
857 gr_v2_cent_scale=TGraph(NumCentBins, b_imp, v2_cent);
858 gr_v3_cent_scale=TGraph(NumCentBins, b_imp, v3_cent);
859 gr_v4_cent_scale=TGraph(NumCentBins, b_imp, v4_cent);
860 gr_v2_cent_scale.SetBit(TGraph::kIsSortedX);
861 gr_v3_cent_scale.SetBit(TGraph::kIsSortedX);
862 gr_v4_cent_scale.SetBit(TGraph::kIsSortedX);
868 m_v_n[Harmonic::v1]=0;
870 m_v_n[Harmonic::v3]=gr_v3pt.Eval(
pt) * gr_v3_cent_scale.Eval(
b);
871 m_v_n[Harmonic::v4]=gr_v4pt.Eval(
pt) * gr_v4_cent_scale.Eval(
b);
872 m_v_n[Harmonic::v5]=0;
873 m_v_n[Harmonic::v6]=0;
877 for(
int ihar=0;ihar<Harmonic::NumHar;ihar++){
882 for(
int ihar=0;ihar<Harmonic::NumHar;ihar++){
883 float vn_rp=0,delta=0;
891 if (ihar==Harmonic::v1)
continue;
902 delta=1.0f/sqrt(2.0
f);
904 float X=CLHEP::RandGaussQ::shoot(rndmEngine,vn_rp,delta);
905 float Y=CLHEP::RandGaussQ::shoot(rndmEngine,0.0 ,delta);