Skip to content

Commit

Permalink
Finalising occupancy study and configParam
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanopolitano committed Dec 15, 2023
1 parent 03e5e79 commit 5013107
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ struct ITSAvgClusSizeParamConfig : public o2::conf::ConfigurableParamHelper<ITSA
O2ParamDef(ITSAvgClusSizeParamConfig, "ITSAvgClusSizeParam");
};

struct ITSOccupancyParamConfig : public o2::conf::ConfigurableParamHelper<ITSOccupancyParamConfig> {
std::string outFileName = "its_occupancy.root";

O2ParamDef(ITSOccupancyParamConfig, "ITSOccupancyParam");
};

struct ITSImpactParameterParamConfig : public o2::conf::ConfigurableParamHelper<ITSImpactParameterParamConfig> {
std::string outFileName = "its_ImpParameter.root";
int minNumberOfContributors = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace study
{
using mask_t = o2::dataformats::GlobalTrackID::mask_t;

o2::framework::DataProcessorSpec getOcccupancy()
o2::framework::DataProcessorSpec getOccupancyStudy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC);
} // namespace study
} // namespace its
} // namespace o2
Expand Down
58 changes: 27 additions & 31 deletions Detectors/ITSMFT/ITS/postprocessing/studies/src/Occupancy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class Occupancy : public Task
public:
Occupancy(std::shared_ptr<DataRequest> dr,
std::shared_ptr<o2::base::GRPGeomRequest> gr,
bool isMC,
std::shared_ptr<o2::steer::MCKinematicsReader> kineReader) : mDataRequest{dr}, mGGCCDBRequest(gr), mUseMC(isMC), mKineReader(kineReader){};
bool isMC) : mDataRequest{dr}, mGGCCDBRequest(gr), mUseMC(isMC){};
~Occupancy() final = default;
void init(InitContext& ic) final;
void run(ProcessingContext&) final;
Expand All @@ -85,8 +84,8 @@ class Occupancy : public Task
// Helper functions
void prepareOutput();
void updateTimeDependentParams(ProcessingContext& pc);
void fillIBmap(TH2F *histo, int sta, int chipInMod, float weight);
void fillOBmap(TH2F *histo, int sta, int chipInMod, float weight, int ssta);
void fillIBmap(TH2F* histo, int sta, int chipInMod, float weight);
void fillOBmap(TH2F* histo, int sta, int chipInMod, float weight, int ssta, int mod);
void getClusters(const gsl::span<const o2::itsmft::CompClusterExt>, float weight);
void saveHistograms();

Expand Down Expand Up @@ -116,25 +115,22 @@ void Occupancy::init(InitContext& ic)

void Occupancy::prepareOutput()
{
auto& params = o2::its::study::ITSAvgClusSizeParamConfig::Instance();
mOutName = params.outFileName;
mDBGOut = std::make_unique<o2::utils::TreeStreamRedirector>(mOutName.c_str(), "recreate");

std::vector<int> nStaves{12, 16, 20, 24, 30, 42, 48};

for (int layer{0}; layer < 7; layer++) {
if (layer < 3)
{
mOccupancyHistos.push_back(new TH2F(Form("Occupancy chip map L%i", layer), "; Chip ID; Stave ID; # Hits / # PVs", 9, -0.5, 8.5, nStaves[layer], -0.5, nStaves[layer] - 0.5));
}
else {
mOccupancyHistos.push:back(new TH2F(Form("Occupancy chip map L%i", layer), "; Chip ID; Stave ID; #LT Cluster size #GT", 49, -0.5, 48.5, 4 * nStaves[layer], -0.5, 4 * nStaves[layer] - 0.5));
}
mOccupancyHistos[layer]->SetDirectory(nullptr);
auto& params = o2::its::study::ITSOccupancyParamConfig::Instance();
mOutName = params.outFileName;
mDBGOut = std::make_unique<o2::utils::TreeStreamRedirector>(mOutName.c_str(), "recreate");

std::vector<int> nStaves{12, 16, 20, 24, 30, 42, 48};

for (int layer{0}; layer < 7; layer++) {
if (layer < 3) {
mOccupancyHistos.push_back(new TH2F(Form("Occupancy chip map L%i", layer), "; Chip ID; Stave ID; # Hits / # PVs", 9, -0.5, 8.5, nStaves[layer], -0.5, nStaves[layer] - 0.5));
} else {
mOccupancyHistos.push_back(new TH2F(Form("Occupancy chip map L%i", layer), "; Chip ID; Stave ID; #LT Cluster size #GT", 49, -0.5, 48.5, 4 * nStaves[layer], -0.5, 4 * nStaves[layer] - 0.5));
}
mOccupancyHistos[layer]->SetDirectory(nullptr);
}
}


void Occupancy::run(ProcessingContext& pc)
{
o2::globaltracking::RecoContainer recoData;
Expand All @@ -148,39 +144,39 @@ void Occupancy::getClusters(const gsl::span<const o2::itsmft::CompClusterExt> IT
for (unsigned int iClus{0}; iClus < ITSclus.size(); ++iClus) {
auto& clus = ITSclus[iClus];
o2::itsmft::ChipMappingITS chipMapping;
auto chipID = clus.getChipID();
int layer, sta, ssta, mod, chipInMod;
chipMapping.expandChipInfoHW(chipID, layer, sta, ssta, mod, chipInMod);

if (layer < 3) {
fillIBmap(mOccupancyHistos[layer], sta, chipInMod, weight);
} else {
fillOBmap(mOccupancyHistos[layer], sta, chipInMod, weight, ssta);
fillOBmap(mOccupancyHistos[layer], sta, chipInMod, weight, ssta, mod);
}
}
}

void Occupancy::fillIBmap(TH2F *histo, int sta, int chipInMod, float weight)
void Occupancy::fillIBmap(TH2F* histo, int sta, int chipInMod, float weight)
{
histo->Fill(chipInMod, sta, weight);
histo->Fill(chipInMod, sta, weight);
}

void Occupancy::fillOBmap(TH2F *histo, int sta, int chipInMod, float weight, int ssta)
void Occupancy::fillOBmap(TH2F* histo, int sta, int chipInMod, float weight, int ssta, int mod)
{
auto xCoord = chipInMod < 7 ? (mod - 1) * 7 + chipInMod : (mod - 1) * 7 + 14 - chipInMod;
auto yCoord = 4 * sta + ssta * 2 + 1 * (chipInMod < 7);
histo->Fill(xCoord, yCoord, weight);
auto xCoord = chipInMod < 7 ? (mod - 1) * 7 + chipInMod : (mod - 1) * 7 + 14 - chipInMod;
auto yCoord = 4 * sta + ssta * 2 + 1 * (chipInMod < 7);
histo->Fill(xCoord, yCoord, weight);
}

void Occupancy::process(o2::globaltracking::RecoContainer& recoData)
{
auto& params = o2::its::study::ITSAvgClusSizeParamConfig::Instance();
auto& params = o2::its::study::ITSOccupancyParamConfig::Instance();
bool isMCTarget = false;
PVertex pv;

auto compClus = recoData.getITSClusters();
getClusters(compClus, 1.); // Default weight is 1
saveHistograms();

}

void Occupancy::updateTimeDependentParams(ProcessingContext& pc)
Expand Down Expand Up @@ -218,7 +214,7 @@ void Occupancy::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
}
}

DataProcessorSpec getOccupancy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC, std::shared_ptr<o2::steer::MCKinematicsReader> kineReader)
DataProcessorSpec getOccupancyStudy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC)
{
std::vector<OutputSpec> outputs;
auto dataRequest = std::make_shared<DataRequest>();
Expand All @@ -238,7 +234,7 @@ DataProcessorSpec getOccupancy(mask_t srcTracksMask, mask_t srcClustersMask, boo
"its-study-Occupancy",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<Occupancy>(dataRequest, ggRequest, useMC, kineReader)},
AlgorithmSpec{adaptFromTask<Occupancy>(dataRequest, ggRequest, useMC)},
Options{}};
}
} // namespace study
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
}
if (configcontext.options().get<bool>("occupancy-study")) {
anyStudy = true;
specs.emplace_back(o2::its::study::getOccupancyStudy(srcTrc, srcCls, useMC, mcKinematicsReader));
specs.emplace_back(o2::its::study::getOccupancyStudy(srcTrc, srcCls, useMC));
}
if (!anyStudy) {
LOGP(info, "No study selected, dryrunning");
Expand Down

0 comments on commit 5013107

Please sign in to comment.