25#include "FairMCPoint.h"
26#include "FairRootManager.h"
28#include "FairRuntimeDb.h"
31#include "TClonesArray.h"
33#include "TGeoMatrix.h"
34#include "TGeoPhysicalNode.h"
39#include "TProfile2D.h"
51 : FairTask(
"CbmStsDigitizeQa")
53 , fDigiManager(nullptr)
71 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
87 for (Int_t iStation = 0; iStation <
fNofStation; iStation++) {
100 for (Int_t iChip = 0; iChip < nOfChips; iChip++) {
122 fHM->
H1(
"h_EventNo_DigitizeQa")->Fill(0.5);
128 Int_t nofEvents =
fHM->
H1(
"h_EventNo_DigitizeQa")->GetEntries();
129 TString fileName =
fOutputDir +
"/digiRateChip";
130 fileName += nofEvents;
132 TString rmFile =
"rm " + fileName;
133 gSystem->Exec(rmFile);
134 fOutFile.open(Form(
"%s", fileName.Data()), std::ofstream::app);
135 for (Int_t iStation = 0; iStation <
fNofStation; iStation++) {
144 if (nChannels != 2048) cout <<
"nofChannels = " << nChannels;
145 Int_t nOfChips = Int_t(nChannels / 128.);
146 for (Int_t iChip = 0; iChip < nOfChips; iChip++)
147 fOutFile << iStation <<
"\t" << iLad <<
"\t" << iHla <<
"\t" << iMod <<
"\t" << iChip <<
"\t"
153 gDirectory->mkdir(
"STSDigitizeQA");
154 gDirectory->cd(
"STSDigitizeQA");
156 gDirectory->cd(
"../");
178 FairRootManager* ioman = FairRootManager::Instance();
179 if (NULL == ioman) LOG(fatal) << GetName() <<
": No FairRootManager!";
181 fStsPoints = (TClonesArray*) ioman->GetObject(
"StsPoint");
182 if (NULL ==
fStsPoints) LOG(error) << GetName() <<
": No StsPoint array!";
185 LOG(fatal) << GetName() <<
": No StsDigi branch in input!";
190 LOG(fatal) << GetName() <<
": No StsDigiMatch branch in input!";
199 fHM->
Create1<TH1F>(
"h_EventNo_DigitizeQa",
"h_EventNo_DigitizeQa", 1, 0, 1.);
205 Double_t minX = -0.5;
206 Double_t maxX = 49999.5;
207 string name =
"h_NofObjects_";
208 fHM->
Create1<TH1F>(name +
"Points", name +
"Points;Objects per event;Entries", nofBins, minX, maxX);
209 fHM->
Create1<TH1F>(name +
"Digis", name +
"Digis;Objects per event;Entries", nofBins, minX, maxX);
214 fHM->
Create1<TH1F>(name +
"Points_Station", name +
"Points_Station;Station number;Objects per event", nofBins, minX,
216 fHM->
Create1<TH1F>(name +
"Digis_Station", name +
"Digis_Station;Station number;Oblects per enent", nofBins, minX,
224 Double_t maxX = minX + nofBins;
225 fHM->
Create1<TH1F>(
"h_PointsInDigi",
"PointsInDigi;Number of Points;Entries", nofBins, minX, maxX);
226 fHM->
Create1<TH1F>(
"h_PointsInDigiLog",
"PointsInDigi;Number of Points;Entries", nofBins, minX, maxX);
227 fHM->
Create1<TH1F>(
"h_DigisByPoint",
"DigisByPoint;Number of Digis;Entries", nofBins, minX, maxX);
228 fHM->
Create1<TH1F>(
"h_DigisByPointLog",
"DigisByPoint;Number of Digis;Entries", nofBins, minX, maxX);
230 fHM->
Create1<TH1F>(
"h_DigiCharge",
"DigiCharge;Digi Charge, ADC;Entries", nofBins, 0., Double_t(nofBins));
231 for (Int_t stationId = 0; stationId <
fNofStation; stationId++) {
232 fHM->
Create2<TH2F>(Form(
"h_DigisPerChip_Station%i", stationId),
233 Form(
"Digis per Chip, Station %i;x, cm;y, cm", stationId), 400, -50, 50, 200, -50, 50);
234 fHM->
Create2<TH2F>(Form(
"h_PointsMap_Station%i", stationId), Form(
"Points Map, Station %i;x, cm;y, cm", stationId),
235 100, -50, 50, 100, -50, 50);
236 fHM->
Create2<TH2F>(Form(
"h_MeanAngleMap_Station%i", stationId),
237 Form(
"Mean Angle Map, Station %i;x, cm;y, cm", stationId), 50, -50, 50, 50, -50, 50);
238 fHM->
Create2<TH2F>(Form(
"h_RMSAngleMap_Station%i", stationId),
239 Form(
"RMS Angle Map, Station %i;x, cm;y, cm", stationId), 50, -50, 50, 50, -50, 50);
241 Double_t local[3] = {0., 0., 0.};
245 TGeoPhysicalNode* node = modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
247 TGeoMatrix* matrix = node->GetMatrix();
248 matrix->LocalToMaster(local, global);
250 fHM->
Create1<TH1F>(Form(
"h_ParticleAngles_%s", modu->GetName()),
251 Form(
"Particle Angles (%.0f cm, %.0f cm);Angle, deg;Entries", global[0], global[1]), 90, 0.,
260 std::set<Double_t> pointIndexes;
261 std::map<Double_t, Int_t> stations;
262 std::map<Double_t, Int_t> digisByPoint;
263 std::map<Double_t, Int_t>::iterator map_it;
264 pointIndexes.clear();
265 Double_t local[3] = {0., 0., 0.};
277 TGeoPhysicalNode* node = modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
279 TGeoMatrix* matrix = node->GetMatrix();
280 matrix->LocalToMaster(local, global);
284 Int_t iChip = iChan / 128;
292 fHM->
H2(Form(
"h_DigisPerChip_Station%i", stationId))
293 ->Fill(global[0] + 50. / 400. * ((iChip - 8.) * 2. - 1.), global[1]);
295 for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) {
296 const CbmLink link = digiMatch->GetLink(iLink);
298 pointIndexes.insert(index2);
299 stations.insert(std::pair<Double_t, Int_t>(index2, stationId));
302 Int_t side = channel < Int_t(nOfChannelsM / 2.) ? 0 : 1;
303 map_it = digisByPoint.find(index2 + (side * 0.00001));
304 if (map_it != digisByPoint.end()) { map_it->second++; }
306 digisByPoint.insert(std::pair<Double_t, Int_t>(index2 + (side * 0.00001), 1));
309 fHM->
H1(
"h_NofObjects_Digis_Station")->Fill(stationId);
310 fHM->
H1(
"h_PointsInDigi")->Fill(digiMatch->GetNofLinks());
311 fHM->
H1(
"h_PointsInDigiLog")->Fill(digiMatch->GetNofLinks());
312 fHM->
H1(
"h_DigiCharge")->Fill(stsDigi->GetCharge());
314 fHM->
H1(
"h_NofObjects_Points")->Fill(pointIndexes.size());
315 std::set<Double_t>::iterator set_it;
316 for (set_it = pointIndexes.begin(); set_it != pointIndexes.end(); ++set_it) {
317 fHM->
H1(
"h_NofObjects_Points_Station")->Fill(stations[*set_it]);
318 fHM->
H1(
"h_DigisByPoint")->Fill(digisByPoint[*set_it]);
319 fHM->
H1(
"h_DigisByPoint")->Fill(digisByPoint[*set_it + 0.00001]);
320 fHM->
H1(
"h_DigisByPointLog")->Fill(digisByPoint[*set_it]);
321 fHM->
H1(
"h_DigisByPointLog")->Fill(digisByPoint[*set_it + 0.00001]);
323 if (pointIndexes.size() >
static_cast<size_t>(
fMaxScale))
fMaxScale = pointIndexes.size();
325 Double_t pointX, pointY;
326 Double_t pointPX, pointPZ;
327 for (Int_t iPoint = 0; iPoint <
points->GetEntriesFast(); iPoint++) {
328 const FairMCPoint* stsPoint =
static_cast<const FairMCPoint*
>(
points->At(iPoint));
330 TGeoPhysicalNode* node = modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
332 TGeoMatrix* matrix = node->GetMatrix();
333 matrix->LocalToMaster(local, global);
335 pointX = stsPoint->GetX();
336 pointY = stsPoint->GetY();
338 pointPX = stsPoint->GetPx();
339 pointPZ = stsPoint->GetPz();
341 fHM->
H2(Form(
"h_PointsMap_Station%i", stationId))->Fill(pointX, pointY);
342 fHM->
H1(Form(
"h_ParticleAngles_%s", modu->GetName()))
343 ->Fill(TMath::Abs(TMath::ATan(pointPX / pointPZ)) * 180. / 3.1416);
350 Double_t local[3] = {0., 0., 0.};
352 for (Int_t iStation = 0; iStation <
fNofStation; iStation++) {
360 Double_t mean =
fHM->
H1(Form(
"h_ParticleAngles_%s", modu->GetName()))->GetMean();
361 Double_t rms =
fHM->
H1(Form(
"h_ParticleAngles_%s", modu->GetName()))->GetRMS();
362 TGeoPhysicalNode* node = modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
364 TGeoMatrix* matrix = node->GetMatrix();
365 matrix->LocalToMaster(local, global);
367 fHM->
H2(Form(
"h_MeanAngleMap_Station%i", iStation))->Fill(global[0], global[1], mean);
368 fHM->
H2(Form(
"h_RMSAngleMap_Station%i", iStation))->Fill(global[0], global[1], rms);
@ kSts
Silicon Tracking System.
Base class for simulation reports.
ClassImp(CbmStsDigitizeQa)
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
static Bool_t IsMatchPresent(ECbmModuleId systemId)
Presence of a digi match branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
const CbmMatch * GetMatch(ECbmModuleId systemId, UInt_t index) const
Get a match object.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void WriteToFile()
Write all objects to current opened file.
Bool_t Exists(const std::string &name) const
Check existence of object in manager.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Base class for simulation reports.
void Create(CbmHistManager *histManager, const std::string &outputDir)
Main function which creates report data.
Data class for a single-channel message in the STS.
XPU_D uint16_t GetChannel() const
Channel number in module @value Channel number.
XPU_D int32_t GetAddress() const
virtual void Exec(Option_t *opt)
void CreateDigiHistograms()
const CbmStsParAsic * fAsicPar
CbmStsDigitizeQa(CbmStsDigitize *digitizer=NULL)
void ProcessDigisAndPoints(const TClonesArray *points)
const CbmStsParSim * fSettings
void CreateNofObjectsHistograms()
CbmDigiManager * fDigiManager
virtual void SetParContainers()
virtual ~CbmStsDigitizeQa()
CbmStsParSetModule * fModuleParSet
std::vector< std::vector< std::vector< std::vector< std::vector< Int_t > > > > > fnOfDigisChip
virtual InitStatus Init()
TClonesArray * fStsPoints
Task class for simulating the detector response of the STS.
Class representing an element of the STS setup.
Int_t GetNofDaughters() const
CbmStsElement * GetDaughter(Int_t index) const
Class representing an instance of a readout unit in the CBM-STS.
const CbmStsParModule * GetParameters() const
Module parameters.
uint16_t GetNofAdc() const
Number of ADC channels.
uint32_t GetNofChannels() const
Number of channels.
Parameters container for CbmStsParModule.
const CbmStsParModule & GetParModule(UInt_t address)
Get condition parameters of a sensor.
Settings for STS simulation (digitizer)
Bool_t IsModuleParsInit() const
Initialisation status for module parameters.
Bool_t Init(const char *geometryFile=nullptr)
Initialise the setup.
CbmStsModule * GetModule(Int_t index) const
Get a module from the module array.
CbmStsElement * GetElement(Int_t address, Int_t level)
Int_t GetNofStations() const
static CbmStsSetup * Instance()
UInt_t SetModuleParameters(CbmStsParSetModule *modulePars)
Set module parameters from parameter container.
Int_t GetStationNumber(Int_t address)
Int_t GetNofModules() const
Bool_t IsInit() const
Initialisation status for sensor parameters.