15 #define BINNING_CHARGE 100, 0, 300.0
16 #define BINNING_LENGTH 100, 0, 2.5
17 #define BINNING_CHARGE_LOG 100, 3, 10
18 #define BINNING_ENERGY_LOG 100, -0.5, 4.5
19 #define BINNING_ENERGY_LOG_EL 100, -0.5, 4.5
23 : FairTask(name, verbose)
26 , fPointInfos(new TClonesArray(
"CbmMuchPointInfo", 10))
27 , fOutFolder(
"MuchDigiQA",
"MuchDigitizerQA")
33 , fvPadOccupancyR() {}
63 TDirectory* oldDirectory = gDirectory;
64 FairRootManager* fManager = FairRootManager::Instance();
65 fMCTracks = (TClonesArray*) fManager->GetObject(
"MCTrack");
66 fPoints = (TClonesArray*) fManager->GetObject(
"MuchPoint");
85 gDirectory = oldDirectory;
123 printf(
"=========================================================\n");
124 printf(
" Station Nr.\t| Sectors\t| Channels\t| Pad min size\t\t| Pad max"
126 printf(
"---------------------------------------------------------\n");
129 Int_t nTotSectors = 0;
130 Int_t nTotChannels = 0;
131 for (Int_t iStation = 0; iStation <
fNstations; iStation++) {
142 nTotSectors += nSectors;
143 nTotChannels += nChannels;
146 printf(
"%i\t\t| %i\t\t| %i\t| %5.4fx%5.4f\t\t| %5.4fx%5.4f\n",
154 printf(
"%i\t\t| %i\t\t\n", iStation + 1, nChannels);
157 printf(
"-----------------------------------------------------------\n");
158 printf(
" Total:\t\t| %i\t\t\n", nTotChannels);
159 printf(
"===========================================================\n");
165 new CbmQaCanvas(
"cMcPointCharge",
"MC point charge", 2 * 800, 2 * 400);
169 "cMcPointChargeVsStation",
"MC point charge per station", 2 * 800, 2 * 400);
173 "MC point charge vs particle Energy",
179 "MC point charge vs track length",
185 new CbmQaCanvas(
"cTrackLength",
"track length", 2 * 800, 2 * 400);
189 new CbmQaCanvas(
"cNpadsVsArea",
"N pads Vs Area", 2 * 800, 2 * 400);
192 "cPadsFiredXY",
"Number of pads fired vs XY", 2 * 800, 2 * 400);
196 "cPadOccupancyR",
"Pad occupancy [%] vs radius", 2 * 800, 2 * 400);
200 new CbmQaCanvas(
"cPadsTotalR",
"Total pads vs radius", 2 * 800, 2 * 400);
217 new TH1F(
"hCharge",
"Charge distribution from tracks",
BINNING_CHARGE);
225 new TH1F(
"hChargePr_1GeV_3mm",
"Charge for 1 GeV protons",
BINNING_CHARGE);
229 new TH2F(
"hChargeEnergyLog",
230 "Charge vs energy (log.) for all tracks",
235 new TH2F(
"hChargeEnergyLogPi",
236 "Charge vs energy (log.) for pions",
241 new TH2F(
"hChargeEnergyLogPr",
242 "Charge vs energy (log.) for protons",
247 new TH2F(
"hChargeEnergyLogEl",
248 "Charge vs energy (log.) for electrons",
253 "Charge vs length for all tracks",
258 "Charge vs length for pions",
263 "Charge vs length for proton",
268 "Charge vs length for electrons",
271 std::vector<TH2F*> vChargeHistos;
281 for (UInt_t
i = 0;
i < vChargeHistos.size();
i++) {
282 TH2F* histo = vChargeHistos[
i];
284 histo->GetYaxis()->SetDecimals(kTRUE);
285 histo->GetYaxis()->SetTitleOffset(1.4);
286 histo->GetYaxis()->CenterTitle();
287 histo->GetYaxis()->SetTitle(
"Charge [10^{4} electrons]");
289 histo->GetXaxis()->SetTitle(
"Lg(E_{kin} [MeV])");
291 histo->GetXaxis()->SetTitle(
"Track length [cm]");
302 new TH1F(
"hTrackLengthPi",
"Track length for pions",
BINNING_LENGTH);
305 new TH1F(
"hTrackLengthPr",
"Track length for protons",
BINNING_LENGTH);
308 new TH1F(
"hTrackLengthEl",
"Track length for electrons",
BINNING_LENGTH);
310 std::vector<TH1F*> vLengthHistos;
316 for (UInt_t
i = 0;
i < vLengthHistos.size();
i++) {
317 TH1F* histo = vLengthHistos[
i];
318 histo->GetXaxis()->SetTitle(
"Track length [cm]");
334 Double_t rMax = station->
GetRmax();
335 Double_t rMin = station->
GetRmin();
338 Form(
"hMcPointCharge%i",
i + 1),
339 Form(
"MC point charge : Station %i; Charge [10^4 e]; Count",
i + 1),
343 new TH1F(Form(
"hPadsTotal%i",
i + 1),
344 Form(
"Number of pads vs radius: Station %i;Radius [cm]",
i + 1),
350 Form(
"hUsPadsFired%i",
i + 1),
351 Form(
"Number of fired pads vs radius: Station %i;Radius [cm]",
i + 1),
357 new TH2F(Form(
"hUsPadsFiredXY%i",
i + 1),
358 Form(
"Pads fired XY : Station %i; X; Y",
i + 1),
367 Form(
"hPadsFired%i",
i + 1),
368 Form(
"Number of fired pads vs radius: Station %i;Radius [cm]",
i + 1),
374 Form(
"hOccupancy%i",
i + 1),
375 Form(
"Pad occupancy vs radius: Station %i;Radius [cm];Occupancy, %%",
388 "Number of fired pads vs pad area:area:n pads",
401 for (vector<CbmMuchModule*>::iterator im = modules.begin();
408 vector<CbmMuchPad*> pads = module->
GetPads();
409 for (UInt_t ip = 0; ip < pads.size(); ip++) {
412 Double_t x0 = pad->
GetX();
413 Double_t y0 = pad->
GetY();
414 Double_t r0 = TMath::Sqrt(x0 * x0 + y0 * y0);
420 Double_t errors[100];
421 for (Int_t
i = 0;
i < 100;
i++) {
433 fFitEl->SetParameter(0, 0.511);
435 fFitEl->SetLineColor(kBlack);
438 fFitPi->SetParameter(0, 139.57);
440 fFitPi->SetLineColor(kBlack);
443 fFitPr->SetParameter(0, 938.27);
445 fFitPr->SetLineColor(kBlack);
477 TDirectory* oldDirectory = gDirectory;
486 gDirectory = oldDirectory;
492 for (
int i = 0;
i <
fPoints->GetEntriesFast();
i++) {
495 if (stId != 0)
continue;
497 if (layerId != 0)
continue;
498 printf(
"point %4i xin=%6.2f yin=%6.2f xout=%6.2f yout=%6.2f zin=%6.2f\n",
514 if (stId != 0)
continue;
516 if (layerId != 0)
continue;
519 if (!module)
continue;
521 Double_t x0 = pad->
GetX();
522 Double_t y0 = pad->
GetY();
523 UInt_t charge = digi->
GetAdc();
524 printf(
"digi %4i x0=%5.1f y0=%5.1f charge=%3i\n",
i, x0, y0, charge);
538 for (Int_t
i = 0;
i < 4;
i++) {
541 gStyle->SetOptStat(1110);
552 for (Int_t
i = 0;
i < 4;
i++) {
554 gPad->Range(0, 0, 200, 200);
555 gPad->SetBottomMargin(0.11);
556 gPad->SetRightMargin(0.14);
557 gPad->SetLeftMargin(0.12);
572 for (Int_t
i = 0;
i < 4;
i++) {
574 gPad->Range(0, 0, 200, 200);
575 gPad->SetBottomMargin(0.11);
576 gPad->SetRightMargin(0.14);
577 gPad->SetLeftMargin(0.12);
612 printf(
"FinishTask\n");
613 cout <<
"\n\n SG: Finish task!" << endl;
615 TDirectory* oldDirectory = gDirectory;
616 bool oldBatchMode = gROOT->IsBatch();
618 if (!FairRootManager::Instance() || !FairRootManager::Instance()->GetSink()) {
619 cout <<
"No sink found" << endl;
623 gROOT->SetBatch(kFALSE);
624 gStyle->SetPaperSize(20, 20);
630 FairSink* sink = FairRootManager::Instance()->GetSink();
632 gDirectory = oldDirectory;
633 gROOT->SetBatch(oldBatchMode);
638 TCanvas* c =
new TCanvas(
"nMeanVsS",
"nMeanVsS", 2 * 800, 2 * 400);
639 printf(
"===================================\n");
640 printf(
"DigitizerQa:\n");
644 for (Int_t iS = 1; iS <= 10; iS++) {
646 s[iS] = -5.25 + 0.5 * iS;
648 for (Int_t iN = 1; iN <= 10; iN++) {
649 nMean[iS] += iN *
fhNpadsVsS->GetBinContent(iS, iN);
652 if (total > 0) nMean[iS] /= total;
653 printf(
"%f %f\n", s[iS], nMean[iS]);
657 TGraph* gNvsS =
new TGraph(11, s, nMean);
660 gNvsS->SetMarkerColor(4);
661 gNvsS->SetMarkerSize(1.5);
662 gNvsS->SetMarkerStyle(21);
663 gNvsS->SetTitle(
"nMeanVsS");
664 gNvsS->GetYaxis()->SetTitle(
"nMean");
665 gNvsS->GetYaxis()->SetTitle(
"nMean");
667 gNvsS->DrawClone(
"AP");
673 printf(
"All tracks: ;");
677 printf(
"------------;");
681 printf(
"Primary: ;");
685 printf(
"Secondary: ;");
689 printf(
"-------------");
693 printf(
"Protons: ;");
695 printf(
"%8i;",
fNpr[
i]);
699 printf(
"%8i;",
fNpi[
i]);
701 printf(
"Electrons: ;");
703 printf(
"%8i;",
fNel[
i]);
707 printf(
"%8i;",
fNmu[
i]);
711 printf(
"%8i;",
fNka[
i]);
717 Double_t gaz_gain_mean = 1.7e+4;
718 Double_t scale = 1.e+6;
719 gaz_gain_mean /= scale;
720 Double_t mass = par[0];
721 Double_t
x = TMath::Power(10, lg_x[0]);
722 return gaz_gain_mean *
MPV_n_e(
x, mass);
733 for (Int_t
i = 0;
i <
fPoints->GetEntriesFast();
i++) {
738 Int_t trackId = point->GetTrackID();
751 TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdgCode);
752 if (!particle || pdgCode == 22 ||
763 Double_t mass = particle->Mass();
767 Double_t length = (vOut - vIn).Mag();
768 Double_t kine =
sqrt(p.Mag2() + mass * mass) - mass;
773 if (motherTrack) motherPdg = motherTrack->
GetPdgCode();
774 new ((*fPointInfos)[
i])
789 else if (pdgCode == -211 || pdgCode == 211)
791 else if (pdgCode == -11 || pdgCode == 11)
793 else if (pdgCode == -13 || pdgCode == 13)
795 else if (pdgCode == -321 || pdgCode == 321)
813 if (!module)
continue;
817 LOG(debug) << GetName() <<
" Processing MuchDigi " <<
i <<
" at address "
827 for (Int_t pt = 0; pt < nofLinks; pt++) {
839 Bool_t verbose = (fVerbose > 2);
847 Double_t kine = 1000 * (info->
GetKine());
850 if (pdg == 0)
continue;
851 if (charge <= 0)
continue;
852 Double_t log_kine = TMath::Log10(kine);
853 Double_t log_charge = TMath::Log10(charge);
854 charge = charge / 1.e+4;
857 Double_t area = info->
GetArea() / nPads;
871 }
else if (pdg == 211 || pdg == -211) {
875 }
else if (pdg == 11 || pdg == -11) {
880 if (pdg == 2212 && length > 0.3 && length < 0.32 && kine > 1000
894 if (!module)
continue;
902 Double_t x0 = pad->
GetX();
903 Double_t y0 = pad->
GetY();
904 r0 = TMath::Sqrt(x0 * x0 + y0 * y0);
915 for (UInt_t im = 0; im < modules.size(); im++) {
919 if (!module)
continue;
929 for (UInt_t im = 0; im < modules.size(); im++) {
933 if (!module)
continue;
944 for (UInt_t im = 0; im < modules.size(); im++) {
948 vector<CbmMuchPad*> pads = module->
GetPads();
949 for (UInt_t ip = 0; ip < pads.size(); ip++) {
951 if (pad->
GetDx() < padMinLx) padMinLx = pad->
GetDx();
952 if (pad->
GetDy() < padMinLy) padMinLy = pad->
GetDy();
955 return TVector2(padMinLx, padMinLy);
964 for (UInt_t im = 0; im < modules.size(); im++) {
968 vector<CbmMuchPad*> pads = module->
GetPads();
969 for (UInt_t ip = 0; ip < pads.size(); ip++) {
971 if (pad->
GetDx() > padMaxLx) padMaxLx = pad->
GetDx();
972 if (pad->
GetDy() > padMaxLy) padMaxLy = pad->
GetDy();
975 return TVector2(padMaxLx, padMaxLy);
982 TF1 fPol6(
"fPol6",
"pol6", -5, 10);
984 logT =
log(Tkin * 0.511 / mass);
985 if (logT > 9.21034) logT = 9.21034;
987 return fPol6.EvalPar(&logT,
mpv_e);
988 }
else if (mass >= 0.1 && mass < 0.2) {
989 logT =
log(Tkin * 105.658 / mass);
990 if (logT > 9.21034) logT = 9.21034;
992 return fPol6.EvalPar(&logT,
mpv_mu);
994 logT =
log(Tkin * 938.272 / mass);
995 if (logT > 9.21034) logT = 9.21034;
997 return fPol6.EvalPar(&logT,
mpv_p);
1003 if (!c || nPads < 1) {
return; }
1004 int rows = (int)
sqrt(nPads);
1005 int cols = nPads / rows;
1006 if (cols * rows < nPads) { cols++; }
1007 c->Divide(cols, rows);