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;
82 mGeom->
fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::T2GRot, o2::math_utils::TransformType::T2G));
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();
200 int lay, sta, ssta, mod, chipInMod;
205 for (
int lr = 0; lr < nLr; lr++) {
211 getClusterPatterns(compClus, clusPatt, *mDict);
213 auto pattIt = clusPatt.begin();
214 std::vector<ITSCluster> globalClusters;
217 for (
auto& rofRecord : clusRofRecords) {
218 auto clustersInRof = rofRecord.getROFData(compClus);
219 auto patternsInRof = rofRecord.getROFData(mPatterns);
220 auto locClustersInRof = rofRecord.getROFData(globalClusters);
221 for (
unsigned int clusInd{0}; clusInd < clustersInRof.size(); clusInd++) {
222 const auto& compClus = clustersInRof[clusInd];
223 auto& locClus = locClustersInRof[clusInd];
224 auto& clusPattern = patternsInRof[clusInd];
225 auto gloC = locClus.getXYZGlo(*mGeom);
226 mChipMapping.
expandChipInfoHW(compClus.getChipID(), lay, sta, ssta, mod, chipInMod);
227 if (lay >= nLayProc) {
230 float phi = TMath::ATan2(gloC.Y(), gloC.X());
231 mTFvsPhiHist[lay]->Fill(phi, mTFCount);
232 mTFvsPhiClusSizeHist[lay]->Fill(phi, mTFCount, clusPattern.getNPixels());
234 mROFvsPhiHist[lay]->Fill(phi, (mTFCount - 1) * nROF + rofCount);
235 mROFvsPhiClusSizeHist[lay]->Fill(phi, (mTFCount - 1) * nROF + rofCount, clusPattern.getNPixels());
242 LOGP(info,
"Processed TF: {} in {} s", mTFCount, mStopwatch.RealTime());
249void AnomalyStudy::getClusterPatterns(gsl::span<const o2::itsmft::CompClusterExt>& ITSclus, gsl::span<const unsigned char>& ITSpatt,
const o2::itsmft::TopologyDictionary& mdict)
252 mPatterns.reserve(ITSclus.size());
253 auto pattIt = ITSpatt.begin();
255 for (
unsigned int iClus{0}; iClus < ITSclus.size(); ++iClus) {
256 auto& clus = ITSclus[iClus];
258 auto pattID = clus.getPatternID();
267 mPatterns.push_back(patt);
274 std::vector<OutputSpec> outputs;
275 auto dataRequest = std::make_shared<DataRequest>();
276 dataRequest->setITSPerLayer(itsStag);
277 dataRequest->requestClusters(srcClustersMask, useMC);
280 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
292 AlgorithmSpec{adaptFromTask<AnomalyStudy>(dataRequest, ggRequest, useMC)},
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to process
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
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 ITS Vertex explicitly as messageable.
constexpr int MaxITSLayers
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, bool itsStag)
auto getITSPerLayer() const
auto getITSClustersROFRecords(int layer=0) const
auto getITSClustersPatterns(int layer=0) const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
auto getITSClusters(int layer=0) const