Skip to content
Merged
59 changes: 49 additions & 10 deletions PWGUD/Tasks/upcEventITSROFcounter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file upcEventITSROFcounter.cxx
/// \brief Personal task to analyze tau events from UPC collisions
///
/// \author Roman Lavicka <roman.lavicka@cern.ch>, Austrian Academy of Sciences & SMI
/// \since 09.08.2024

#include <utility>
#include <vector>

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include "ITSMFTBase/DPLAlpideParam.h"
#include "CCDB/BasicCCDBManager.h"
#include "ReconstructionDataFormats/Vertex.h"

#include "Common/CCDB/EventSelectionParams.h"
#include "Common/DataModel/EventSelection.h"

#include "PWGUD/DataModel/UDTables.h"
Expand All @@ -25,6 +36,7 @@
using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::dataformats;

using BCsWithRun3Matchings = soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse>;
using CCs = soa::Join<aod::Collisions, aod::EvSels>;
Expand All @@ -39,10 +51,10 @@ struct UpcEventITSROFcounter {
Configurable<int> nTracksForUPCevent{"nTracksForUPCevent", 16, {"Maximum of tracks defining a UPC collision"}};

Configurable<bool> useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}};
Configurable<float> cutMyGapSideFV0{"FV0", -1, "FV0A threshold for SG selector"};
Configurable<float> cutMyGapSideFT0A{"FT0A", 150., "FT0A threshold for SG selector"};
Configurable<float> cutMyGapSideFT0C{"FT0C", 50., "FT0C threshold for SG selector"};
Configurable<float> cutMyGapSideZDC{"ZDC", 10., "ZDC threshold for SG selector"};
Configurable<float> cutMyGapSideFV0{"cutMyGapSideFV0", -1, "FV0A threshold for SG selector"};
Configurable<float> cutMyGapSideFT0A{"cutMyGapSideFT0A", 150., "FT0A threshold for SG selector"};
Configurable<float> cutMyGapSideFT0C{"cutMyGapSideFT0C", 50., "FT0C threshold for SG selector"};
Configurable<float> cutMyGapSideZDC{"cutMyGapSideZDC", 10., "ZDC threshold for SG selector"};
ConfigurableAxis axisRunNumbers{"axisRunNumbers", {1400, 544000.5, 545400.5}, "Range of run numbers"};

void init(InitContext&)
Expand All @@ -53,6 +65,9 @@ struct UpcEventITSROFcounter {
histos.add("Events/hCountCollisionsInROFborderMatching", ";;Number of collision (-)", HistType::kTH1D, {{11, -0.5, 10.5}});
histos.add("Events/hCountUPCcollisionsInROFborderMatching", ";;Number of UPC (mult < 17) collision (-)", HistType::kTH1D, {{11, -0.5, 10.5}});

histos.add("Events/hPVcontribsVsCollisionsPerITSROFstd", "Collisions reconstructed with standard mode;Number of vertex contributors (-); Number of collisions in one ITSROF (-)", HistType::kTH2D, {{101, -0.5, 100.5}, {11, -0.5, 10.5}});
histos.add("Events/hPVcontribsVsCollisionsPerITSROFupc", "Collisions reconstructed with upc mode;Number of vertex contributors (-); Number of collisions in one ITSROF (-)", HistType::kTH2D, {{101, -0.5, 100.5}, {11, -0.5, 10.5}});

histos.add("Runs/hStdModeCollDG", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers});
histos.add("Runs/hUpcModeCollDG", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers});
histos.add("Runs/hStdModeCollSG1", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers});
Expand All @@ -78,7 +93,7 @@ struct UpcEventITSROFcounter {
int64_t ts = bcs.iteratorAt(0).timestamp();
auto alppar = ccdb->getForTimeStamp<o2::itsmft::DPLAlpideParam<0>>("ITS/Config/AlpideParam", ts);

for (auto bc : bcs) {
for (const auto& bc : bcs) {
uint64_t globalBC = bc.globalBC();
uint64_t globalIndex = bc.globalIndex();
if (isFirst) {
Expand All @@ -98,7 +113,7 @@ struct UpcEventITSROFcounter {
previousBCinITSROF = bcInITSROF;
previousBCglobalIndex = globalIndex;
// next is based on exact matching of bc and collision
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
if (collision.has_foundBC()) {
if (collision.foundBCId() == bc.globalIndex()) {
nAllColls++;
Expand All @@ -113,16 +128,16 @@ struct UpcEventITSROFcounter {
}
}
} // end loop over collisions
} // end loop over bcs
} // end loop over bcs

int arrAllColls[1000] = {0};
int arrUPCcolls[1000] = {0};

// next is based on matching of collision bc within ITSROF range in bcs
for (auto& itsrofBorder : vecITSROFborders) {
for (const auto& itsrofBorder : vecITSROFborders) {
int nAllCollsInROF = 0;
int nUpcCollsInROF = 0;
for (auto& collision : collisions) {
for (const auto& collision : collisions) {
if ((itsrofBorder.first < collision.bcId()) && (collision.bcId() < itsrofBorder.second)) {
nAllCollsInROF++;
if (collision.numContrib() < nTracksForUPCevent + 1) {
Expand All @@ -138,6 +153,30 @@ struct UpcEventITSROFcounter {
histos.get<TH1>(HIST("Events/hCountCollisionsInROFborderMatching"))->Fill(ncol, arrAllColls[ncol]);
histos.get<TH1>(HIST("Events/hCountUPCcollisionsInROFborderMatching"))->Fill(ncol, arrUPCcolls[ncol]);
}

// TEST vertex contributors per reconstruction flag (std vs upc)
// matching of collision bc within ITSROF range in bcs
for (const auto& itsrofBorder : vecITSROFborders) {
std::vector<int> vecNumContribsStd;
std::vector<int> vecNumContribsUpc;
for (const auto& collision : collisions) {
if ((itsrofBorder.first < collision.bcId()) && (collision.bcId() < itsrofBorder.second)) {
if (collision.flags() & dataformats::Vertex<o2::dataformats::TimeStamp<int>>::Flags::UPCMode) {
vecNumContribsUpc.push_back(collision.numContrib());
} else {
vecNumContribsStd.push_back(collision.numContrib());
}
}
} // end loop over collisions

for (const auto& numContribs : vecNumContribsStd) {
histos.get<TH2>(HIST("Events/hPVcontribsVsCollisionsPerITSROFstd"))->Fill(numContribs, vecNumContribsStd.size());
}
for (const auto& numContribs : vecNumContribsUpc) {
histos.get<TH2>(HIST("Events/hPVcontribsVsCollisionsPerITSROFupc"))->Fill(numContribs, vecNumContribsUpc.size());
}

} // end loop over ITSROFs
}

void processCounterPerRun(FullSGUDCollision const& coll)
Expand Down Expand Up @@ -179,5 +218,5 @@ struct UpcEventITSROFcounter {
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<UpcEventITSROFcounter>(cfgc, TaskName{"upc-event-itsrof-counter"})};
adaptAnalysisTask<UpcEventITSROFcounter>(cfgc)};
}
Loading