20 #include "FairLogger.h"
21 #include "FairMCPoint.h"
22 #include "FairRootManager.h"
24 #include "FairRuntimeDb.h"
26 #include "TGeoMatrix.h"
27 #include "TGeoPhysicalNode.h"
29 #include "TClonesArray.h"
35 #include "TProfile2D.h"
47 : FairTask(
"CbmStsDigitizeQa")
49 , fDigiManager(nullptr)
63 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
79 for (Int_t iStation = 0; iStation <
fNofStation; iStation++) {
94 for (Int_t iChip = 0; iChip < nOfChips; iChip++) {
115 fHM->
H1(
"h_EventNo_DigitizeQa")->Fill(0.5);
120 Int_t nofEvents =
fHM->
H1(
"h_EventNo_DigitizeQa")->GetEntries();
121 TString fileName =
fOutputDir +
"/digiRateChip";
122 fileName += nofEvents;
124 TString rmFile =
"rm " + fileName;
125 gSystem->Exec(rmFile);
126 fOutFile.open(Form(
"%s", fileName.Data()), std::ofstream::app);
127 for (Int_t iStation = 0; iStation <
fNofStation; iStation++) {
137 if (nChannels != 2048) cout <<
"nofChannels = " << nChannels;
138 Int_t nOfChips = Int_t(nChannels / 128.);
139 for (Int_t iChip = 0; iChip < nOfChips; iChip++)
140 fOutFile << iStation <<
"\t" << iLad <<
"\t" << iHla <<
"\t" << iMod
141 <<
"\t" << iChip <<
"\t"
148 gDirectory->mkdir(
"STSDigitizeQA");
149 gDirectory->cd(
"STSDigitizeQA");
151 gDirectory->cd(
"../");
173 FairRootManager* ioman = FairRootManager::Instance();
174 if (NULL == ioman) LOG(fatal) << GetName() <<
": No FairRootManager!";
176 fStsPoints = (TClonesArray*) ioman->GetObject(
"StsPoint");
177 if (NULL ==
fStsPoints) LOG(error) << GetName() <<
": No StsPoint array!";
180 LOG(fatal) << GetName() <<
": No StsDigi branch in input!";
185 LOG(fatal) << GetName() <<
": No StsDigiMatch branch in input!";
193 fHM->
Create1<TH1F>(
"h_EventNo_DigitizeQa",
"h_EventNo_DigitizeQa", 1, 0, 1.);
198 Double_t minX = -0.5;
199 Double_t maxX = 49999.5;
200 string name =
"h_NofObjects_";
202 name +
"Points;Objects per event;Entries",
207 name +
"Digis;Objects per event;Entries",
216 name +
"Points_Station;Station number;Objects per event",
221 name +
"Digis_Station;Station number;Oblects per enent",
230 Double_t maxX = minX + nofBins;
232 "PointsInDigi;Number of Points;Entries",
237 "PointsInDigi;Number of Points;Entries",
242 "DigisByPoint;Number of Digis;Entries",
247 "DigisByPoint;Number of Digis;Entries",
253 "DigiCharge;Digi Charge, ADC;Entries",
257 for (Int_t stationId = 0; stationId <
fNofStation; stationId++) {
259 Form(
"h_DigisPerChip_Station%i", stationId),
260 Form(
"Digis per Chip, Station %i;x, cm;y, cm", stationId),
267 fHM->
Create2<TH2F>(Form(
"h_PointsMap_Station%i", stationId),
268 Form(
"Points Map, Station %i;x, cm;y, cm", stationId),
276 Form(
"h_MeanAngleMap_Station%i", stationId),
277 Form(
"Mean Angle Map, Station %i;x, cm;y, cm", stationId),
284 fHM->
Create2<TH2F>(Form(
"h_RMSAngleMap_Station%i", stationId),
285 Form(
"RMS Angle Map, Station %i;x, cm;y, cm", stationId),
293 Double_t local[3] = {0., 0., 0.};
297 TGeoPhysicalNode* node =
298 modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
300 TGeoMatrix* matrix = node->GetMatrix();
301 matrix->LocalToMaster(local, global);
304 Form(
"h_ParticleAngles_%s", modu->GetName()),
305 Form(
"Particle Angles (%.0f cm, %.0f cm);Angle, deg;Entries",
316 fHM->
H1(
"h_NofObjects_Digis")
318 std::set<Double_t> pointIndexes;
319 std::map<Double_t, Int_t> stations;
320 std::map<Double_t, Int_t> digisByPoint;
321 std::map<Double_t, Int_t>::iterator map_it;
322 pointIndexes.clear();
323 Double_t local[3] = {0., 0., 0.};
338 TGeoPhysicalNode* node =
339 modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
341 TGeoMatrix* matrix = node->GetMatrix();
342 matrix->LocalToMaster(local, global);
346 Int_t iChip = iChan / 128;
354 fHM->
H2(Form(
"h_DigisPerChip_Station%i", stationId))
355 ->
Fill(global[0] + 50. / 400. * ((iChip - 8.) * 2. - 1.), global[1]);
357 for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks(); iLink++) {
358 const CbmLink link = digiMatch->GetLink(iLink);
361 pointIndexes.insert(index2);
362 stations.insert(std::pair<Double_t, Int_t>(index2, stationId));
365 Int_t side = channel < Int_t(nOfChannelsM / 2.) ? 0 : 1;
366 map_it = digisByPoint.find(index2 + (side * 0.00001));
367 if (map_it != digisByPoint.end()) {
371 std::pair<Double_t, Int_t>(index2 + (side * 0.00001), 1));
374 fHM->
H1(
"h_NofObjects_Digis_Station")->Fill(stationId);
375 fHM->
H1(
"h_PointsInDigi")->Fill(digiMatch->GetNofLinks());
376 fHM->
H1(
"h_PointsInDigiLog")->Fill(digiMatch->GetNofLinks());
379 fHM->
H1(
"h_NofObjects_Points")->Fill(pointIndexes.size());
380 std::set<Double_t>::iterator set_it;
381 for (set_it = pointIndexes.begin(); set_it != pointIndexes.end(); ++set_it) {
382 fHM->
H1(
"h_NofObjects_Points_Station")->Fill(stations[*set_it]);
383 fHM->
H1(
"h_DigisByPoint")->Fill(digisByPoint[*set_it]);
384 fHM->
H1(
"h_DigisByPoint")->Fill(digisByPoint[*set_it + 0.00001]);
385 fHM->
H1(
"h_DigisByPointLog")->Fill(digisByPoint[*set_it]);
386 fHM->
H1(
"h_DigisByPointLog")->Fill(digisByPoint[*set_it + 0.00001]);
388 if (pointIndexes.size() >
static_cast<size_t>(
fMaxScale))
391 Double_t pointX, pointY;
392 Double_t pointPX, pointPZ;
393 for (Int_t iPoint = 0; iPoint <
points->GetEntriesFast(); iPoint++) {
394 const FairMCPoint* stsPoint =
395 static_cast<const FairMCPoint*
>(
points->At(iPoint));
398 TGeoPhysicalNode* node =
399 modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
401 TGeoMatrix* matrix = node->GetMatrix();
402 matrix->LocalToMaster(local, global);
404 pointX = stsPoint->GetX();
405 pointY = stsPoint->GetY();
407 pointPX = stsPoint->GetPx();
408 pointPZ = stsPoint->GetPz();
410 fHM->
H2(Form(
"h_PointsMap_Station%i", stationId))->
Fill(pointX, pointY);
411 fHM->
H1(Form(
"h_ParticleAngles_%s", modu->GetName()))
412 ->Fill(TMath::Abs(TMath::ATan(pointPX / pointPZ)) * 180. / 3.1416);
418 Double_t local[3] = {0., 0., 0.};
420 for (Int_t iStation = 0; iStation <
fNofStation; iStation++) {
429 fHM->
H1(Form(
"h_ParticleAngles_%s", modu->GetName()))->GetMean();
431 fHM->
H1(Form(
"h_ParticleAngles_%s", modu->GetName()))->GetRMS();
432 TGeoPhysicalNode* node =
433 modu->CbmStsElement::GetDaughter(0)->CbmStsElement::GetPnode();
435 TGeoMatrix* matrix = node->GetMatrix();
436 matrix->LocalToMaster(local, global);
438 fHM->
H2(Form(
"h_MeanAngleMap_Station%i", iStation))
439 ->Fill(global[0], global[1], mean);
440 fHM->
H2(Form(
"h_RMSAngleMap_Station%i", iStation))
441 ->Fill(global[0], global[1], rms);