CbmRoot
Loading...
Searching...
No Matches
CbmMvdReadoutCluster.cxx
Go to the documentation of this file.
1/* Copyright (C) 2016-2021 Institut furr Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdReadoutCluster source file -----
7// ----- Created 17/10/16 by P. Sitzmann -----
8// -------------------------------------------------------------------------
9
11
12#include "CbmMvdCluster.h" // for CbmMvdCluster
13
14#include <FairRootManager.h> // for FairRootManager
15#include <Logger.h> // for LOG, Logger
16
17#include <TClonesArray.h> // for TClonesArray
18#include <TFile.h> // for TFile
19#include <TH1.h> // for TH1F
20#include <TString.h> // for Form
21
22#include <map> // for allocator, map, operator!=, __map_iterator
23#include <utility> // for pair
24
25using std::map;
26using std::pair;
27
28// ----- Default constructor -------------------------------------------
30// -------------------------------------------------------------------------
31
32// ----- Standard constructor ------------------------------------------
33CbmMvdReadoutCluster::CbmMvdReadoutCluster(const char* name, Int_t iVerbose)
34 : FairTask(name, iVerbose)
35 , foutFile(nullptr)
36 , fshow(kFALSE)
37 , fWordsPerRegion()
38 , fWordsPerSuperRegion()
39 , fMvdCluster(nullptr)
40 , fEventNumber(0)
41{
42}
43// -------------------------------------------------------------------------
44
45// ----- Destructor ----------------------------------------------------
47// -------------------------------------------------------------------------
48
49// -------------------------------------------------------------------------
51{
52 FairRootManager* ioman = FairRootManager::Instance();
53 if (!ioman) { LOG(fatal) << "RootManager not instantised!"; }
54
55 fMvdCluster = (TClonesArray*) ioman->GetObject("MvdCluster");
56
57 if (!fMvdCluster) LOG(fatal) << "Data array missing";
58
60
61 return kSUCCESS;
62}
63// -------------------------------------------------------------------------
64
65// -------------------------------------------------------------------------
67{
68 for (Int_t i = 0; i < 350; ++i) {
69 fWordsPerRegion[i] = new TH1F(Form("fWordsPerRegionSensor%d", i), "Words send to a region", 65, 0, 64);
70 fWordsPerSuperRegion[i] = new TH1F(Form("fWordsPerSuperRegionSensor%d", i), "Words send to a region", 16, 0, 15);
71 }
72}
73// -------------------------------------------------------------------------
74
75
76// -------------------------------------------------------------------------
77void CbmMvdReadoutCluster::Exec(Option_t* /*opt*/)
78{
79 LOG(debug) << "//--------------- New Event " << fEventNumber << " -----------------------\\";
80
81 for (Int_t nClusters = 0; nClusters < fMvdCluster->GetEntriesFast(); ++nClusters) {
82 CbmMvdCluster* cluster = (CbmMvdCluster*) fMvdCluster->At(nClusters);
83 Int_t sensorNr = cluster->GetSensorNr();
84 map<pair<Int_t, Int_t>, Int_t> pixelMap = cluster->GetPixelMap();
85
86 for (auto cntr = pixelMap.begin(); cntr != pixelMap.end(); ++cntr) {
87 Int_t xPix = cntr->first.first;
88 // Int_t yPix = cntr->first.second;
89 Int_t regionNr = (Int_t)(xPix / fPixelsPerRegion);
90 fWordsPerRegion[sensorNr]->Fill(regionNr);
91 Int_t superRegionNr = (Int_t)(xPix / fPixelsPerSuperRegion);
92 fWordsPerSuperRegion[sensorNr]->Fill(superRegionNr);
93 }
94 }
95
96 LOG(debug) << "//--------------- End Event -----------------------\\";
98}
99// -------------------------------------------------------------------------
100
101// -------------------------------------------------------------------------
103{
104 foutFile->cd();
105
106 Float_t scale = 1. / (Float_t) fEventNumber;
107 for (Int_t i = 0; i < 350; ++i) {
108 fWordsPerRegion[i]->Scale(scale, "nosw2");
109 fWordsPerSuperRegion[i]->Scale(scale, "nosw2");
110 }
111
112 if (fshow) DrawHistograms();
114}
115// -------------------------------------------------------------------------
116
117// -------------------------------------------------------------------------
119{
120
121 for (Int_t i = 0; i < 350; ++i) {
122 fWordsPerRegion[i]->Write();
123 }
124
125 for (Int_t i = 0; i < 350; ++i) {
126 fWordsPerSuperRegion[i]->Write();
127 }
128}
129// -------------------------------------------------------------------------
130
131// -------------------------------------------------------------------------
133// -------------------------------------------------------------------------
134
ClassImp(CbmMvdReadoutCluster)
int32_t GetSensorNr()
std::map< std::pair< int32_t, int32_t >, int32_t > GetPixelMap()