26#include <TStopwatch.h>
36 static constexpr int nChipStavesIB{9};
40 std::shared_ptr<o2::base::GRPGeomRequest> gr,
41 bool isMC) : mDataRequest{dr}, mGGCCDBRequest(gr), mUseMC(isMC) {}
56 TStopwatch mStopwatch;
57 const int mNumberOfStaves[7] = {12, 16, 20, 24, 30, 42, 48};
58 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
59 std::shared_ptr<DataRequest> mDataRequest;
64 std::vector<o2::itsmft::ClusterPattern> mPatterns;
69 std::vector<std::unique_ptr<TH2F>> mTFvsPhiHist;
70 std::vector<std::unique_ptr<TH2F>> mTFvsPhiClusSizeHist;
71 std::vector<std::unique_ptr<TH2F>> mROFvsPhiHist;
72 std::vector<std::unique_ptr<TH2F>> mROFvsPhiClusSizeHist;
78 static bool initOnceDone =
false;
96 mTFvsPhiHist.resize(nLayProc);
97 mTFvsPhiClusSizeHist.resize(nLayProc);
99 mROFvsPhiHist.resize(nLayProc);
100 mROFvsPhiClusSizeHist.resize(nLayProc);
102 for (
unsigned int i = 0;
i < nLayProc;
i++) {
104 mTFvsPhiHist[
i].reset(
new TH2F(Form(
"tf_phi_occup_layer_%d",
i), Form(
"Occupancy layer %d ; #phi ; # TF; Counts",
i), phiBins, -TMath::Pi(), TMath::Pi(), nTF, 0.5, nTF + 0.5));
105 mTFvsPhiClusSizeHist[
i].reset(
new TH2F(Form(
"tf_phi_clsize_layer_%d",
i), Form(
"Cluster size layer %d ; #phi; # TF ; #lt Cluster Size #gt",
i), phiBins, -TMath::Pi(), TMath::Pi(), nTF, 0.5, nTF + 0.5));
107 mROFvsPhiHist[
i].reset(
new TH2F(Form(
"rof_phi_occup_layer_%d",
i), Form(
"Occupancy layer %d ; #phi; # ROF; Counts",
i), phiBins, -TMath::Pi(), TMath::Pi(), nROF * nTF, 0.5, nROF * nTF + 0.5));
108 mROFvsPhiClusSizeHist[
i].reset(
new TH2F(Form(
"rof_phi_clsize_layer_%d",
i), Form(
"Cluster size layer %d; #phi; # ROF; #lt Cluster Size #gt",
i), phiBins, -TMath::Pi(), TMath::Pi(), nROF * nTF, 0.5, nROF * nTF + 0.5));
128 for (
unsigned int i = 0;
i < nLayProc;
i++) {
129 mTFvsPhiClusSizeHist[
i]->Divide(mTFvsPhiHist[
i].
get());
131 mROFvsPhiClusSizeHist[
i]->Divide(mROFvsPhiHist[
i].
get());
136 for (
unsigned int iLayer = 0; iLayer < nLayProc; ++iLayer) {
139 auto* f1 =
new TF1(Form(
"f1_%d", iLayer),
"pol0", -TMath::Pi(), TMath::Pi());
140 auto* hPValue =
new TH1F(Form(
"pValue_%d", iLayer), Form(
"pValue_%d", iLayer), mTFvsPhiClusSizeHist[iLayer]->GetNbinsY(), 0.5, mTFvsPhiClusSizeHist[iLayer]->GetNbinsY() + 0.5);
141 mTFvsPhiClusSizeHist[iLayer]->FitSlicesX(f1, 0, -1, 0,
"QNR", &aSlices);
142 auto* hChi2 = (TH1D*)aSlices.At(1);
143 for (
auto iTF{0}; iTF < hChi2->GetEntries(); ++iTF) {
144 auto pValue = TMath::Prob(hChi2->GetBinContent(iTF + 1) * (phiBins - 1), phiBins - 1);
146 hPValue->SetBinContent(iTF + 1, pValue);
150 for (
unsigned int j = 0;
j < aSlices.GetEntries(); ++
j) {
151 auto h = (TH1D*)aSlices.At(
j);
158 TObjArray aSlicesROF;
159 auto f1ROF =
new TF1(Form(
"f1ROF_%d", iLayer),
"pol0", -TMath::Pi(), TMath::Pi());
160 mROFvsPhiClusSizeHist[iLayer]->FitSlicesX(f1ROF, 0, -1, 0,
"QNR", &aSlicesROF);
162 for (
unsigned int j = 0;
j < aSlicesROF.GetEntries(); ++
j) {
163 auto h = (TH1D*)aSlicesROF.At(
j);
170 for (
unsigned int i = 0;
i < nLayProc;
i++) {
171 mTFvsPhiHist[
i]->Write();
172 mTFvsPhiClusSizeHist[
i]->Write();
174 mROFvsPhiHist[
i]->Write();
175 mROFvsPhiClusSizeHist[
i]->Write();
205 getClusterPatterns(compClus, clusPatt, *mDict);
207 auto pattIt = clusPatt.begin();
208 std::vector<ITSCluster> globalClusters;
211 int lay, sta, ssta, mod, chipInMod;
212 for (
auto& rofRecord : clusRofRecords) {
213 auto clustersInRof = rofRecord.getROFData(compClus);
214 auto patternsInRof = rofRecord.getROFData(mPatterns);
215 auto locClustersInRof = rofRecord.getROFData(globalClusters);
216 for (
unsigned int clusInd{0}; clusInd < clustersInRof.size(); clusInd++) {
217 const auto& compClus = clustersInRof[clusInd];
218 auto& locClus = locClustersInRof[clusInd];
219 auto& clusPattern = patternsInRof[clusInd];
220 auto gloC = locClus.getXYZGlo(*mGeom);
221 mChipMapping.
expandChipInfoHW(compClus.getChipID(), lay, sta, ssta, mod, chipInMod);
222 if (lay >= nLayProc) {
225 float phi = TMath::ATan2(gloC.Y(), gloC.X());
226 mTFvsPhiHist[lay]->Fill(phi, mTFCount);
227 mTFvsPhiClusSizeHist[lay]->Fill(phi, mTFCount, clusPattern.getNPixels());
229 mROFvsPhiHist[lay]->Fill(phi, (mTFCount - 1) * nROF + rofCount);
230 mROFvsPhiClusSizeHist[lay]->Fill(phi, (mTFCount - 1) * nROF + rofCount, clusPattern.getNPixels());
236 LOGP(info,
"Processed TF: {} in {} s", mTFCount, mStopwatch.RealTime());
243void AnomalyStudy::getClusterPatterns(gsl::span<const o2::itsmft::CompClusterExt>& ITSclus, gsl::span<const unsigned char>& ITSpatt,
const o2::itsmft::TopologyDictionary& mdict)
246 mPatterns.reserve(ITSclus.size());
247 auto pattIt = ITSpatt.begin();
249 for (
unsigned int iClus{0}; iClus < ITSclus.size(); ++iClus) {
250 auto& clus = ITSclus[iClus];
252 auto pattID = clus.getPatternID();
261 mPatterns.push_back(patt);
268 std::vector<OutputSpec> outputs;
269 auto dataRequest = std::make_shared<DataRequest>();
270 dataRequest->requestClusters(srcClustersMask, useMC);
273 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
285 AlgorithmSpec{adaptFromTask<AnomalyStudy>(dataRequest, ggRequest, useMC)},
Helper for geometry and GRP related CCDB requests.
Header of the General Run Parameters object.
Definition of the GeometryTGeo class.
Class for time synchronization of RawReader instances.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static const AnomalyStudyParamConfig & Instance()
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
void run(ProcessingContext &) final
AnomalyStudy(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool isMC)
void process(o2::globaltracking::RecoContainer &recoData)
void setClusterDictionary(const o2::itsmft::TopologyDictionary *d)
void finaliseCCDB(ConcreteDataMatcher &, void *) final
void endOfStream(EndOfStreamContext &) final
This is invoked whenever we have an EndOfStream event.
void init(InitContext &ic) final
void updateTimeDependentParams(ProcessingContext &pc)
void expandChipInfoHW(int idSW, int &lay, int &sta, int &ssta, int &mod, int &chipInMod) const
convert global SW chip ID to name in HW conventions
void acquirePattern(iterator &pattIt)
static constexpr unsigned short InvalidPatternID
const ClusterPattern & getPattern(int n) const
Returns the pattern of the topology.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const itsmft::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
o2::framework::DataProcessorSpec getAnomalyStudy(mask_t srcClustersMask, bool useMC)
auto getITSClustersPatterns() const
auto getITSClustersROFRecords() const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
auto getITSClusters() const