Skip to content

Commit

Permalink
adding option for data and mc tf info in occupancy study
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanopolitano committed Dec 15, 2023
1 parent 5013107 commit 2d370d1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
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 getOccupancyStudy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC);
o2::framework::DataProcessorSpec getOccupancyStudy(mask_t srcClustersMask, bool useMC);
} // namespace study
} // namespace its
} // namespace o2
Expand Down
36 changes: 26 additions & 10 deletions Detectors/ITSMFT/ITS/postprocessing/studies/src/Occupancy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Occupancy : public Task
void setClusterDictionary(const o2::itsmft::TopologyDictionary* d) { mDict = d; }

private:
int tfCounter = 0;
int pvCounter = 0;

// Other functions
void process(o2::globaltracking::RecoContainer&);

Expand All @@ -91,6 +94,7 @@ class Occupancy : public Task

// Running options
bool mUseMC;
bool mSuppressNoise = false; // Suppress noise clusters (skip clusters with size 1)

// Data
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
Expand All @@ -103,36 +107,41 @@ class Occupancy : public Task
// Output plots
std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
std::vector<TH2F*> mOccupancyHistos{};
std::unique_ptr<TH1F> mNormalisationCounter{};
std::string mOutName;
std::shared_ptr<o2::steer::MCKinematicsReader> mKineReader;
};

void Occupancy::init(InitContext& ic)
{
LOG(info) << "Initialising";
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
prepareOutput();
}

void Occupancy::prepareOutput()
{
LOG(info) << "Preparing output";
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};
mNormalisationCounter = std::make_unique<TH1F>("mNormalisationCounter", "Normalisation counter", 2, 0, 2);
mNormalisationCounter->SetDirectory(nullptr);
mNormalisationCounter->GetXaxis()->SetBinLabel(1, "TF");
mNormalisationCounter->GetXaxis()->SetBinLabel(2, "PV");

std::vector<int> nStaves{12, 16, 20, 98, 122, 170, 194}; // L3 has 24 staves with 2 sub-staves each with 2 lines of chips each, L4 has 30 staves with 2 sub-staves each with 3 lines of chips each
std::vector<int> nChips{9, 9, 9, 28, 28, 49, 49}; // L3 has 4 modules with 7 chips each, L4 has 4 modules with 7 chips each
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.push_back(new TH2F(Form("Occupancy chip map L%i", layer), "; Chip ID; Stave ID; # Hits ", nChips[layer], -0.5, nChips[layer] - 0.5, nStaves[layer], -0.5, nStaves[layer] - 0.5));
mOccupancyHistos[layer]->SetDirectory(nullptr);
}
}

void Occupancy::run(ProcessingContext& pc)
{
LOG(info) << "Running";
o2::globaltracking::RecoContainer recoData;
recoData.collectData(pc, *mDataRequest.get());
updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
Expand Down Expand Up @@ -163,18 +172,22 @@ void Occupancy::fillIBmap(TH2F* histo, int sta, int chipInMod, float weight)

void Occupancy::fillOBmap(TH2F* histo, int sta, int chipInMod, float weight, int ssta, int mod)
{
// In the OB 14 Pixel Chips are aligned in 2 parallel rows of 7 chip for 7 modules
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)
{
LOG(info) << "Processing";
auto& params = o2::its::study::ITSOccupancyParamConfig::Instance();
bool isMCTarget = false;
PVertex pv;

LOG(info) << "Processing event";
auto compClus = recoData.getITSClusters();
LOG(info) << "Number of clusters " << compClus.size();
getClusters(compClus, 1.); // Default weight is 1
saveHistograms();
}
Expand All @@ -190,6 +203,7 @@ void Occupancy::updateTimeDependentParams(ProcessingContext& pc)
}
}


void Occupancy::saveHistograms()
{
mDBGOut.reset();
Expand All @@ -198,10 +212,12 @@ void Occupancy::saveHistograms()
for (auto& histo : mOccupancyHistos) {
histo->Write();
}

mNormalisationCounter->SetBinContent(1, tfCounter);
mNormalisationCounter->Write();
fout.Close();
}


void Occupancy::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
Expand All @@ -214,14 +230,13 @@ void Occupancy::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
}
}

DataProcessorSpec getOccupancyStudy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC)
DataProcessorSpec getOccupancyStudy(mask_t srcClustersMask, bool useMC)
{
std::vector<OutputSpec> outputs;
auto dataRequest = std::make_shared<DataRequest>();
dataRequest->requestTracks(srcTracksMask, useMC);
dataRequest->requestClusters(srcClustersMask, useMC);
// dataRequest->requestPrimaryVerterticesTMP(useMC);

LOG(info) << "Requesting clusters";
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
true, // GRPECS=true
false, // GRPLHCIF
Expand All @@ -230,6 +245,7 @@ DataProcessorSpec getOccupancyStudy(mask_t srcTracksMask, mask_t srcClustersMask
o2::base::GRPGeomRequest::Aligned, // geometry
dataRequest->inputs,
true);
LOG(info) << "Requesting GRPGeomRequest";
return DataProcessorSpec{
"its-study-Occupancy",
dataRequest->inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,22 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
{"cluster-sources", VariantType::String, std::string{"ITS"}, {"comma-separated list of cluster sources to use"}},
{"disable-root-input", VariantType::Bool, false, {"disable root-files input reader"}},
{"disable-mc", VariantType::Bool, false, {"disable MC propagation even if available"}},
{"disable-tracking", VariantType::Bool, false, {"disable MC propagation even if available"}},
{"cluster-size-study", VariantType::Bool, false, {"Perform the average cluster size study"}},
{"track-study", VariantType::Bool, false, {"Perform the track study"}},
{"occupancy-study", VariantType::Bool, false, {"Perform the occupancy study"}},
{"impact-parameter-study", VariantType::Bool, false, {"Perform the impact parameter study"}},
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
o2::raw::HBFUtilsInitializer::addConfigOption(options, "o2_tfidinfo.root");

// add the option to match the tf id info
bool useMC = !options[3].defaultValue.get<bool>();
if (useMC) {
LOG(info) << "Using MC: adding o2simdigitizerworkflow_configuration.ini";
o2::raw::HBFUtilsInitializer::addConfigOption(options, "o2simdigitizerworkflow_configuration.ini");
} else {
LOG(info) << "Using data: adding o2_tfidinfo.root";
o2::raw::HBFUtilsInitializer::addConfigOption(options, "o2_tfidinfo.root");
}
std::swap(workflowOptions, options);
}

Expand Down Expand Up @@ -91,7 +101,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));
specs.emplace_back(o2::its::study::getOccupancyStudy(srcCls, useMC));
}
if (!anyStudy) {
LOGP(info, "No study selected, dryrunning");
Expand Down

0 comments on commit 2d370d1

Please sign in to comment.