13 #include "FairRadLenPoint.h"
14 #include "FairRootManager.h"
18 #include "TClonesArray.h"
19 #include "TGeoManager.h"
21 #include "TProfile2D.h"
26 #include "boost/assign/list_of.hpp"
27 #include <boost/algorithm/string.hpp>
33 using boost::assign::list_of;
43 : fHM(NULL), fOutputDir(
""), fRadLen(NULL), fDet() {}
58 static Int_t eventNo = 0;
60 if (0 == eventNo % 10000) {
61 std::cout <<
"-I- CbmLitRadLengthQa::Exec: eventNo=" << eventNo
81 TDirectory* oldir = gDirectory;
82 TFile* outFile = FairRootManager::Instance()->GetOutFile();
83 if (outFile != NULL) {
87 gDirectory->cd(oldir->GetPath());
97 FairRootManager* ioman = FairRootManager::Instance();
98 assert(ioman != NULL);
99 fRadLen = (TClonesArray*) ioman->GetObject(
"RadLen");
103 const Int_t nofBins = 1000;
104 const Int_t nofBinsX = 1000;
105 const Int_t nofBinsY = 1000;
106 const Int_t nofBinsSiliconThicknessX = 1100;
107 const Int_t nofBinsSiliconThicknessY = 1100;
108 const Double_t minX = -550.1;
109 const Double_t maxX = 549.9;
110 const Double_t minY = -550.1;
111 const Double_t maxY = 549.9;
112 vector<string> detNames =
113 list_of(
"Total")(
"Mvd")(
"Sts")(
"Rich")(
"Trd")(
"Much")(
"Tof");
114 Int_t nofDetNames = detNames.size();
115 for (Int_t iDet = 0; iDet < nofDetNames; iDet++) {
116 string detName = detNames[iDet];
117 Bool_t createHistograms =
125 if (!createHistograms)
127 string rtname =
"hrl_RadThickness_" + detName;
130 new TH1D(
string(rtname +
"_H1").c_str(),
131 string(rtname +
"_H1;Radiation thickness [%];Entries").c_str(),
138 string(rtname +
"_P2").c_str(),
139 string(rtname +
"_P2;X [cm];Y [cm];Radiation thickness [%]").c_str(),
146 string tname =
"hrl_Thickness_" + detName;
148 new TH1D(
string(tname +
"_H1").c_str(),
149 string(tname +
"_H1;Thickness [cm];Entries").c_str(),
155 new TProfile2D(
string(tname +
"_P2").c_str(),
156 string(tname +
"_P2;X [cm];Y [cm];Thickness [cm]").c_str(),
163 string tsname =
"hrl_ThicknessSilicon_" + detName;
165 new TH1D(
string(tsname +
"_H1").c_str(),
166 string(tsname +
"_H1;Thickness [cm];Entries").c_str(),
172 string(tsname +
"_P2").c_str(),
173 string(tsname +
"_P2;X [cm];Y [cm];Thickness [cm]").c_str(),
174 nofBinsSiliconThicknessX,
177 nofBinsSiliconThicknessY,
183 vector<string> trackingDetNames =
184 list_of(
"Mvd")(
"Sts")(
"Trd")(
"Much")(
"MuchAbsorber");
185 Int_t nofTrackingDetNames = trackingDetNames.size();
186 for (Int_t iDet = 0; iDet < nofTrackingDetNames; iDet++) {
187 string dname = trackingDetNames[iDet];
199 : (dname ==
"MuchAbsorber")
203 for (Int_t iStation = 0; iStation < nofStations; iStation++) {
205 "hrl_RadThickness_" + dname +
"_" + ToString<Int_t>(iStation) +
"_H1";
208 new TH1D(name.c_str(),
209 string(name +
";Radiation thickness [%];Entries").c_str(),
214 "hrl_RadThickness_" + dname +
"_" + ToString<Int_t>(iStation) +
"_P2";
219 string(name +
";X [cm];Y [cm];Radiation thickness [%]").c_str(),
226 name =
"hrl_Thickness_" + dname +
"_" + ToString<Int_t>(iStation) +
"_H1";
228 new TH1D(name.c_str(),
229 string(name +
";Thickness [cm];Entries").c_str(),
233 name =
"hrl_Thickness_" + dname +
"_" + ToString<Int_t>(iStation) +
"_P2";
236 new TProfile2D(name.c_str(),
237 string(name +
";X [cm];Y [cm];Thickness [cm]").c_str(),
244 name =
"hrl_ThicknessSilicon_" + dname +
"_" + ToString<Int_t>(iStation)
247 new TH1D(name.c_str(),
248 string(name +
";Thickness [cm];Entries").c_str(),
252 name =
"hrl_ThicknessSilicon_" + dname +
"_" + ToString<Int_t>(iStation)
256 new TProfile2D(name.c_str(),
257 string(name +
";X [cm];Y [cm];Thickness [cm]").c_str(),
258 nofBinsSiliconThicknessX,
261 nofBinsSiliconThicknessY,
274 const string& detName) {
275 if (!(detName ==
"Total"
289 thicknessSiliconOnTrack;
293 for (Int_t iRL = 0; iRL <
fRadLen->GetEntriesFast(); iRL++) {
294 FairRadLenPoint* point = (FairRadLenPoint*)
fRadLen->At(iRL);
296 TVector3
pos = point->GetPosition();
297 TVector3 posOut = point->GetPositionOut();
298 TVector3 res = posOut -
pos;
299 TVector3 middle = (
pos + posOut) * 0.5;
304 gGeoManager->FindNode(posOut.X(), posOut.Y(), posOut.Z());
305 Bool_t isOutside = gGeoManager->IsOutside();
306 TGeoNode* node = gGeoManager->FindNode(middle.X(), middle.Y(), middle.Z());
307 TString path = gGeoManager->GetPath();
308 if (!isOutside && path.Contains(TRegexp(pathPattern.c_str()))) {
309 Double_t r2 = posOut.X() * posOut.X() + posOut.Y() * posOut.Y();
315 const Double_t thickness = res.Mag();
316 const Double_t radThickness = 100 * thickness / point->GetRadLength();
317 const Double_t thicknessSilicon =
319 radThicknessOnTrack[point->GetTrackID()] += radThickness;
320 thicknessOnTrack[point->GetTrackID()] += thickness;
321 thicknessSiliconOnTrack[point->GetTrackID()] += thicknessSilicon;
325 map<Int_t, Double_t>::const_iterator it;
326 for (it = radThicknessOnTrack.begin(); it != radThicknessOnTrack.end();
328 Double_t rl = (*it).second;
329 fHM->
H1(
"hrl_RadThickness_" + detName +
"_H1")->Fill(rl);
330 fHM->
P2(
"hrl_RadThickness_" + detName +
"_P2")->Fill(
x,
y, rl);
333 for (it = thicknessOnTrack.begin(); it != thicknessOnTrack.end(); it++) {
334 Double_t tl = (*it).second;
335 fHM->
H1(
"hrl_Thickness_" + detName +
"_H1")->Fill(tl);
336 fHM->
P2(
"hrl_Thickness_" + detName +
"_P2")->Fill(
x,
y, tl);
339 for (it = thicknessSiliconOnTrack.begin();
340 it != thicknessSiliconOnTrack.end();
342 Double_t tl = (*it).second;
343 fHM->
H1(
"hrl_ThicknessSilicon_" + detName +
"_H1")->Fill(tl);
344 fHM->
P2(
"hrl_ThicknessSilicon_" + detName +
"_P2")->Fill(
x,
y, tl);
349 Int_t (*getStationId)(
const TString&)) {
358 map<Int_t, map<Int_t, Double_t>>
360 map<Int_t, map<Int_t, Double_t>>
362 map<Int_t, map<Int_t, Double_t>>
363 thicknessSiliconOnTrack;
364 map<Int_t, map<Int_t, pair<Double_t, Double_t>>>
370 for (Int_t iRL = 0; iRL <
fRadLen->GetEntriesFast(); iRL++) {
371 FairRadLenPoint* point = (FairRadLenPoint*)
fRadLen->At(iRL);
372 Int_t trackId = point->GetTrackID();
373 Int_t detId = point->GetDetectorID();
375 TVector3
pos = point->GetPosition();
376 TVector3 posOut = point->GetPositionOut();
377 TVector3 res = posOut -
pos;
378 TVector3 middle = (
pos + posOut) * 0.5;
382 TGeoNode* node = gGeoManager->FindNode(middle.X(), middle.Y(), middle.Z());
383 TString path = gGeoManager->GetPath();
384 Int_t stationId = getStationId(path);
387 if (stationId >= 0) {
391 pair<Double_t, Double_t>& xy = xyOnTrack[trackId][stationId];
392 xy.first = posOut.X();
393 xy.second = posOut.Y();
396 const Double_t thickness = res.Mag();
397 const Double_t radThickness = 100 * thickness / point->GetRadLength();
398 const Double_t thicknessSilicon =
400 radThicknessOnTrack[trackId][stationId] += radThickness;
401 thicknessOnTrack[trackId][stationId] += thickness;
402 thicknessSiliconOnTrack[trackId][stationId] += thicknessSilicon;
407 radThicknessOnTrack,
"hrl_RadThickness_" + detName +
"_", xyOnTrack);
409 thicknessOnTrack,
"hrl_Thickness_" + detName +
"_", xyOnTrack);
411 "hrl_ThicknessSilicon_" + detName +
"_",
416 const map<Int_t, map<Int_t, Double_t>>& parMap,
417 const string& histName,
418 map<Int_t, map<Int_t, pair<Double_t, Double_t>>>& xyOnTrack) {
419 map<Int_t, map<Int_t, Double_t>>::const_iterator it1;
420 for (it1 = parMap.begin(); it1 != parMap.end(); it1++) {
421 Int_t trackId = (*it1).first;
422 map<Int_t, Double_t>::const_iterator it2;
423 for (it2 = (*it1).second.begin(); it2 != (*it1).second.end(); it2++) {
424 Int_t station = (*it2).first;
425 Double_t param = (*it2).second;
426 string name = histName + ToString<Int_t>(station) +
"_H1";
427 fHM->
H1(name)->Fill(param);
428 name = histName + ToString<Int_t>(station) +
"_P2";
429 const pair<Double_t, Double_t>& xy = xyOnTrack[trackId][station];
430 fHM->
P2(name)->Fill(xy.first, xy.second, param);
437 <<
"-W- CbmLitRadLengthQa::GetMvdStationId: function not implemented\n";
443 Bool_t nodeExists =
false;
444 if (nodePath.Contains(TRegexp(
445 "/cave_1/STS_v[0-9][0-9][a-z]_0/Station[0-9][0-9]_.+"))) {
446 station = std::atoi(
string((gGeoManager->GetPath() + 26), 2)
450 return (nodeExists) ? (station - 1) : -1;
455 if (nodePath.Contains(TRegexp(
456 "/cave_1/trd_v13[a-z]_0/layer[0-9][0-9]_[0-9][0-9][0-9][0-9][0-9]/"
457 "module[0-9]_.+"))) {
458 layerId = std::atoi(
string(nodePath.Data() + 24, 2).c_str()) - 1;
459 }
else if (nodePath.Contains(TRegexp(
"/cave_1/trd_v13[a-z]_[0-9][a-z]_0/"
460 "layer[0-9][0-9]_[0-9][0-9][0-9][0-9][0-"
461 "9]/module[0-9]_.+"))) {
462 layerId = std::atoi(
string(nodePath.Data() + 27, 2).c_str()) - 1;
470 Bool_t nodeExists =
false;
471 if (nodePath.Contains(
472 TRegexp(
"/cave_1/much_0/muchstation[0-9][0-9]_0/"
473 "muchstation[0-9][0-9]layer[0-9]_0/.+"))) {
474 station = std::atoi(
string(gGeoManager->GetPath() + 42, 2)
476 layer = std::atoi(
string(1, *(gGeoManager->GetPath() + 49))
487 Int_t absorberId = -1;
488 if (nodePath.Contains(
489 TRegexp(
"/cave_1/much_0/muchabsorber[0-9][0-9]_0"))) {
490 absorberId = std::atoi(
string(gGeoManager->GetPath() + 27, 2).c_str())
507 const string& detName) {
508 string pattern = (detName ==
"Mvd" || detName ==
"Sts" || detName ==
"Trd"
509 || detName ==
"Much")
510 ?
"hrl_ThicknessSilicon_" + detName +
"_.+_P2"
511 :
"hrl_ThicknessSilicon_" + detName +
"_P2";
513 if (histos.empty())
return;
514 TFile* oldFile = gFile;
515 TDirectory* oldDirectory = gDirectory;
517 new TFile(
string(
fOutputDir +
"/" + boost::algorithm::to_lower_copy(detName)
521 for (vector<TH1*>::const_iterator it = histos.begin(); it != histos.end();
525 if (detName ==
"Much") {
526 vector<TH1*> histos =
527 fHM->
H1Vector(
"hrl_ThicknessSilicon_MuchAbsorber_.+_P2");
528 for (vector<TH1*>::const_iterator it = histos.begin(); it != histos.end();
536 gDirectory = oldDirectory;