2424#include " CommonConstants/MathConstants.h"
2525#include " TDatabasePDG.h"
2626
27+ #include < TF1.h>
28+ #include < TRandom2.h>
29+
2730using namespace o2 ;
2831using namespace o2 ::framework;
2932using namespace o2 ::framework::expressions;
@@ -37,6 +40,11 @@ struct PseudorapidityDensity {
3740 {VARIABLE_WIDTH , 0 ., 0.01 , 0.1 , 0.5 , 1 , 5 , 10 , 15 , 20 , 30 , 40 , 50 , 70 , 100 },
3841 " Centrality/multiplicity percentile binning" };
3942
43+ Configurable<std::vector<float >> parRatio{" parRatio" , {0.773047 , 0.00131658 , 0.00232244 , 1.53395e-05 , -2.36494e-05 , -3.71754e-08 , 4.4547e-08 }, " parameters of pol6 of mes /reco tracks versus zvtx" };
44+
45+ TF1 * fRatio = 0 ;
46+ TRandom2* rand = 0 ;
47+
4048 HistogramRegistry registry{
4149 " registry" ,
4250 {
@@ -76,6 +84,12 @@ struct PseudorapidityDensity {
7684 x->SetBinLabel (3 , " Reconstructed" );
7785 x->SetBinLabel (4 , " Selected" );
7886 x->SetBinLabel (5 , " Selected INEL>0" );
87+
88+ fRatio = new TF1 (" fRatio" , " pol6" , -15 , 15 );
89+ auto param = (std::vector<float >)parRatio;
90+ fRatio ->SetParameters (param[0 ], param[1 ], param[2 ], param[3 ], param[4 ], param[5 ], param[6 ]);
91+
92+ rand = new TRandom2 ();
7993 }
8094
8195 if (doprocessBinned) {
@@ -100,23 +114,55 @@ struct PseudorapidityDensity {
100114 void process (soa::Join<aod::Collisions, aod::EvSels>::iterator const & collision, Trks const & tracks)
101115 {
102116 registry.fill (HIST (" EventSelection" ), 1 .);
103- if (!useEvSel || (useEvSel && collision.sel7 ())) {
104- registry.fill (HIST (" EventSelection" ), 2 .);
105- auto z = collision.posZ ();
106- auto perCollisionSample = sample->sliceByCached (aod::track::collisionId, collision.globalIndex ());
107- if (perCollisionSample.size () > 0 ) {
108- registry.fill (HIST (" EventSelection" ), 3 .);
117+ if (doprocessGen) // we are sudying the MC, that needs correction
118+ {
119+ if (!useEvSel || (useEvSel && collision.sel7 ())) {
120+
121+ auto z = collision.posZ ();
122+ auto perCollisionSample = sample->sliceByCached (aod::track::collisionId, collision.globalIndex ());
123+ auto v = fRatio ->Eval (z);
124+
125+ double r = rand->Rndm (); // random number between 0 and 1
126+ if ((1 - v) <= r) // then we accept the event
127+ {
128+ registry.fill (HIST (" EventSelection" ), 2 .);
129+ if (perCollisionSample.size () > 0 ) {
130+ registry.fill (HIST (" EventSelection" ), 3 .);
131+ }
132+ registry.fill (HIST (" EventsNtrkZvtx" ), perCollisionSample.size (), z);
133+ for (auto & track : tracks) {
134+ registry.fill (HIST (" TracksEtaZvtx" ), track.eta (), z);
135+ registry.fill (HIST (" TracksPhiEta" ), track.phi (), track.eta ());
136+ if (perCollisionSample.size () > 0 ) {
137+ registry.fill (HIST (" TracksEtaZvtx_gt0" ), track.eta (), z);
138+ }
139+ }
140+ } else // (1-v)>r we discard the event
141+ {
142+ registry.fill (HIST (" EventSelection" ), 4 .);
143+ }
144+ } else {
145+ registry.fill (HIST (" EventSelection" ), 4 .);
109146 }
110- registry.fill (HIST (" EventsNtrkZvtx" ), perCollisionSample.size (), z);
111- for (auto & track : tracks) {
112- registry.fill (HIST (" TracksEtaZvtx" ), track.eta (), z);
113- registry.fill (HIST (" TracksPhiEta" ), track.phi (), track.eta ());
147+ } else {
148+ if (!useEvSel || (useEvSel && collision.sel7 ())) {
149+ registry.fill (HIST (" EventSelection" ), 2 .);
150+ auto z = collision.posZ ();
151+ auto perCollisionSample = sample->sliceByCached (aod::track::collisionId, collision.globalIndex ());
114152 if (perCollisionSample.size () > 0 ) {
115- registry.fill (HIST (" TracksEtaZvtx_gt0 " ), track. eta (), z );
153+ registry.fill (HIST (" EventSelection " ), 3 . );
116154 }
155+ registry.fill (HIST (" EventsNtrkZvtx" ), perCollisionSample.size (), z);
156+ for (auto & track : tracks) {
157+ registry.fill (HIST (" TracksEtaZvtx" ), track.eta (), z);
158+ registry.fill (HIST (" TracksPhiEta" ), track.phi (), track.eta ());
159+ if (perCollisionSample.size () > 0 ) {
160+ registry.fill (HIST (" TracksEtaZvtx_gt0" ), track.eta (), z);
161+ }
162+ }
163+ } else {
164+ registry.fill (HIST (" EventSelection" ), 4 .);
117165 }
118- } else {
119- registry.fill (HIST (" EventSelection" ), 4 .);
120166 }
121167 }
122168
@@ -205,7 +251,7 @@ struct PseudorapidityDensity {
205251 }
206252 }
207253
208- PROCESS_SWITCH (PseudorapidityDensity, processGen, " Process generator-level info" , false );
254+ PROCESS_SWITCH (PseudorapidityDensity, processGen, " Process generator-level info" , true );
209255};
210256
211257WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments