1818#include < utility>
1919#include < map>
2020#include < string>
21+ #include < random>
2122
2223#include " Framework/runDataProcessing.h"
2324#include " Framework/AnalysisTask.h"
@@ -66,6 +67,8 @@ struct AngularCorrelationsInJets {
6667 Configurable<bool > doJetCorrelations{" doJetCorrelations" , false , " measure correlations for all particles inside jets" };
6768 Configurable<bool > doFullCorrelations{" doFullCorrelations" , false , " measure correlations for all particles in an event" };
6869 Configurable<bool > measureKaons{" measureKaons" , false , " measure correlations for K-K" };
70+ Configurable<bool > rejectEvents{" rejectEvents" , false , " reject some events" };
71+ Configurable<int > rejectionPercentage{" rejectionPercentage" , 3 , " percentage of events to reject" };
6972
7073 // Track Cuts
7174 Configurable<int > minNCrossedRowsTPC{" minNCrossedRowsTPC" , 80 , " min number of crossed rows TPC" };
@@ -163,6 +166,7 @@ struct AngularCorrelationsInJets {
163166
164167 // Counters
165168 registryData.add (" numberOfEvents" , " Number of events" , HistType::kTH1I , {{1 , 0 , 1 }});
169+ registryData.add (" numberRejectedEvents" , " Number of events rejected" , HistType::kTH1I , {{2 , 0 , 2 , " counter" }});
166170 registryData.add (" numberOfJets" , " Total number of jets" , HistType::kTH1I , {{1 , 0 , 1 }});
167171 registryData.add (" eventProtocol" , " Event protocol" , HistType::kTH1I , {{20 , 0 , 20 }});
168172 registryData.add (" trackProtocol" , " Track protocol" , HistType::kTH1I , {{20 , 0 , 20 }});
@@ -312,6 +316,18 @@ struct AngularCorrelationsInJets {
312316 mRunNumber = bc.runNumber ();
313317 }
314318
319+ bool shouldRejectEvent ()
320+ {
321+ static std::random_device rd;
322+ static std::mt19937 gen (rd ());
323+ static std::uniform_int_distribution<> dis (0 , 99 );
324+ int randomNumber = dis (gen);
325+ if (randomNumber > rejectionPercentage) {
326+ return false ; // accept event
327+ }
328+ return true ; // reject event
329+ }
330+
315331 template <typename T>
316332 bool hasITSHit (const T& track, int layer)
317333 {
@@ -1250,6 +1266,16 @@ struct AngularCorrelationsInJets {
12501266 BCsWithRun2Info const &)
12511267 {
12521268 for (const auto & collision : collisions) {
1269+ if (rejectEvents) {
1270+ // event counter: before event rejection
1271+ registryData.fill (HIST (" numberRejectedEvents" ), 0 );
1272+
1273+ if (shouldRejectEvent ())
1274+ continue ;
1275+
1276+ // event counter: after event rejection
1277+ registryData.fill (HIST (" numberRejectedEvents" ), 1 );
1278+ }
12531279 auto bc = collision.bc_as <BCsWithRun2Info>();
12541280 initCCDB (bc);
12551281
@@ -1270,6 +1296,16 @@ struct AngularCorrelationsInJets {
12701296 soa::Filtered<FullTracksRun3> const & tracks)
12711297 {
12721298 for (const auto & collision : collisions) {
1299+ if (rejectEvents) {
1300+ // event counter: before event rejection
1301+ registryData.fill (HIST (" numberRejectedEvents" ), 0 );
1302+
1303+ if (shouldRejectEvent ())
1304+ continue ;
1305+
1306+ // event counter: after event rejection
1307+ registryData.fill (HIST (" numberRejectedEvents" ), 1 );
1308+ }
12731309 registryData.fill (HIST (" eventProtocol" ), 0 );
12741310 if (!collision.sel8 ())
12751311 continue ;
@@ -1288,6 +1324,16 @@ struct AngularCorrelationsInJets {
12881324 void processMCRun2 (McCollisions const & collisions, soa::Filtered<McTracksRun2> const & tracks, BCsWithRun2Info const &, aod::McParticles const &, aod::McCollisions const &)
12891325 {
12901326 for (const auto & collision : collisions) {
1327+ if (rejectEvents) {
1328+ // event counter: before event rejection
1329+ registryData.fill (HIST (" numberRejectedEvents" ), 0 );
1330+
1331+ if (shouldRejectEvent ())
1332+ continue ;
1333+
1334+ // event counter: after event rejection
1335+ registryData.fill (HIST (" numberRejectedEvents" ), 1 );
1336+ }
12911337 auto bc = collision.bc_as <BCsWithRun2Info>();
12921338 initCCDB (bc);
12931339
@@ -1307,6 +1353,16 @@ struct AngularCorrelationsInJets {
13071353 void processMCRun3 (McCollisions const & collisions, soa::Filtered<McTracksRun3> const & tracks, aod::McParticles const &, aod::McCollisions const &)
13081354 {
13091355 for (const auto & collision : collisions) {
1356+ if (rejectEvents) {
1357+ // event counter: before event rejection
1358+ registryData.fill (HIST (" numberRejectedEvents" ), 0 );
1359+
1360+ if (shouldRejectEvent ())
1361+ continue ;
1362+
1363+ // event counter: after event rejection
1364+ registryData.fill (HIST (" numberRejectedEvents" ), 1 );
1365+ }
13101366 registryData.fill (HIST (" eventProtocol" ), 0 );
13111367 if (!collision.sel8 ())
13121368 continue ;
0 commit comments