11 #include "TClonesArray.h"
13 #include <TMatrixDSym.h>
20 #include "FairRootManager.h"
23 #include "FairRuntimeDb.h"
26 #include "FairBaseParSet.h"
28 #include "FairTrackParH.h"
29 #include "FairTrackParP.h"
30 #include "TDatabasePDG.h"
41 #include "RKTrackRep.h"
51 FairTask(
"Geane Task for PANDA Lmd"), fEventNr(0), fUseMVDPoint(false) {
62 FairTask(
"Geane Task for PANDA Lmd"), fEventNr(0), fUseMVDPoint(false) {
67 cout <<
"Beam Momentum for particle with PDGid#" <<
fPDGid
68 <<
" this run is " <<
fPbeam << endl;
70 cout <<
"Interaction Point:" << endl;
90 FairRootManager* ioman = FairRootManager::Instance();
92 std::cout <<
"-E- PndLmdPerformanceTask::Init: "
93 <<
"RootManager not instantiated!" << std::endl;
122 true_tracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
128 true_points = (TClonesArray*) ioman->GetObject(
"LMDPoint");
151 fDetName =
new TClonesArray(
"TObjString");
152 ioman->Register(
"DetName",
"Geane",
fDetName, kTRUE);
154 fPro =
new FairGeanePro();
160 lmddim -> Read_transformation_matrices(
"",
true);
161 lmddim -> Read_transformation_matrices(
"",
false);
171 std::cout <<
" Setting up histograms in PndLmdPerformanceTask ";
176 gROOT->SetStyle(
"Plain");
177 const Int_t NRGBs = 5;
178 const Int_t NCont = 255;
179 Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
180 Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
181 Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
182 Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
183 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
184 gStyle->SetNumberContours(NCont);
185 gStyle->SetTitleFont(10*13+2,
"xyz");
186 gStyle->SetTitleSize(0.06,
"xyz");
187 gStyle->SetTitleOffset(1.3,
"y");
188 gStyle->SetTitleOffset(1.3,
"z");
189 gStyle->SetLabelFont(10*13+2,
"xyz");
190 gStyle->SetLabelSize(0.06,
"xyz");
191 gStyle->SetLabelOffset(0.009,
"xyz");
192 gStyle->SetPadBottomMargin(0.16);
193 gStyle->SetPadTopMargin(0.16);
194 gStyle->SetPadLeftMargin(0.16);
195 gStyle->SetPadRightMargin(0.16);
196 gStyle->SetOptTitle(1);
197 gStyle->SetOptStat(1);
199 gStyle->SetFrameFillColor(0);
200 gStyle->SetFrameFillStyle(0);
201 TGaxis::SetMaxDigits(3);
208 "hist_angular_distr_gen", 400, 2.e-3, 12.e-3, 400, -3.141, 3.141);
210 "hist_angular_distr_acc", 400, 2.e-3, 12.e-3, 400, -3.141, 3.141);
219 "hist_theta_over_mom_gen", 2000, 1., 20., 100, 2.e-3, 12.e-3);
221 "hist_theta_over_mom_acc", 2000, 1., 20., 100, 2.e-3, 12.e-3);
224 "hist_phi_over_mom_gen", 2000, 1., 20., 400, -3.141, 3.141);
226 "hist_phi_over_mom_acc", 2000, 1., 20., 400, -3.141, 3.141);
228 tree_results =
new TTree(
"tree_results",
"tree_results");
295 TCanvas temp_canvas(
"temp_canvas",
"canvas for initialization", 100, 100);
298 cout <<
" constructing histograms for " <<
nplanes <<
" planes with "
301 stringstream hist_name;
302 stringstream hist_title;
303 for (
unsigned int _iplane = 0; _iplane <
nplanes; _iplane++) {
308 hist_name <<
"hist_xy_plane_" << _iplane;
309 hist_title <<
"xy hit distribution plane " << _iplane;
310 hist_xy[_iplane] =
new TH2F(hist_name.str().c_str(),
311 hist_title.str().c_str(), 100, -10, 10, 100, -10, 10);
313 hist_xy[_iplane]->GetXaxis()->SetTitle(
"X [cm]");
314 hist_xy[_iplane]->GetYaxis()->SetTitle(
"Y [cm]");
319 hist_name <<
"hist_theta_init_plane_" << _iplane;
320 hist_title <<
"initial #Theta distribution plane " << _iplane;
322 hist_title.str().c_str(), 150, 0, 15e-3, 360, -3.141, +3.141);
330 hist_name <<
"hist_theta_in_plane_" << _iplane;
331 hist_title <<
"#Theta distribution at plane " << _iplane;
333 hist_title.str().c_str(), 200, 0, 20e-3, 360, -3.141, +3.141);
335 hist_theta_in[_iplane]->GetXaxis()->SetTitle(
"#Theta [rad]");
341 hist_name <<
"hist_rec_theta_with_plane_" << _iplane;
342 hist_title <<
"#Theta reconstructed distribution with plane " << _iplane;
344 hist_title.str().c_str(), 200, 0, 20e-3, 360, -3.141, +3.141);
352 hist_name <<
"hist_theta_diff_in_plane_" << _iplane;
353 hist_title <<
"#Delta#Theta distribution at plane " << _iplane;
355 hist_title.str().c_str(), 100, -40e-4, 40e-4, 360, -3.141, +3.141);
363 hist_name <<
"hist_theta_rec_diff_in_plane_" << _iplane;
364 hist_title <<
"#Delta#Theta reco distribution at plane " << _iplane;
366 hist_title.str().c_str(), 100, -40e-4, 40e-4, 360, -3.141, +3.141);
374 hist_name <<
"hist_theta_diff_rel_in_plane_" << _iplane;
375 hist_title <<
"#Delta#Theta/#Theta distribution at plane " << _iplane;
377 hist_title.str().c_str(), 100, -1, 1, 360, -3.141, +3.141);
385 hist_name <<
"hist_theta_rec_diff_rel_in_plane_" << _iplane;
386 hist_title <<
"#Delta#Theta/#Theta reco distribution at plane " << _iplane;
388 hist_title.str().c_str(), 100, -1, 1, 360, -3.141, +3.141);
398 hist_name <<
"hist_xy_plane_" << _iplane <<
"_sensor_" << _isensor;
399 hist_title <<
"xy hit distribution plane " << _iplane <<
" sensor "
401 hists_xy[_iplane][_isensor] =
new TH2F(hist_name.str().c_str(),
402 hist_title.str().c_str(), 100, -10, 10, 100, -10, 10);
403 hists_xy[_iplane][_isensor]->Draw();
404 hists_xy[_iplane][_isensor]->GetXaxis()->SetTitle(
"X [cm]");
405 hists_xy[_iplane][_isensor]->GetYaxis()->SetTitle(
"Y [cm]");
410 hist_name <<
"hist_xy_local_plane_" << _iplane <<
"_sensor_" << _isensor;
411 hist_title <<
"xy local hit distribution plane " << _iplane <<
" sensor "
413 hists_xy_local[_iplane][_isensor] =
new TH2F(hist_name.str().c_str(),
414 hist_title.str().c_str(), 100, -2, 2, 100, -2, 2);
416 hists_xy_local[_iplane][_isensor]->GetXaxis()->SetTitle(
"X [cm]");
417 hists_xy_local[_iplane][_isensor]->GetYaxis()->SetTitle(
"Y [cm]");
419 hist_name <<
"hist_theta_init_plane_" << _iplane <<
"_sensor_"
421 hist_title <<
"initial #Theta distribution plane " << _iplane
422 <<
" sensor " << _isensor;
424 hist_name.str().c_str(), hist_title.str().c_str(), 150, 0,
434 hist_name <<
"hist_theta_in_plane_" << _iplane <<
"_sensor_"
436 hist_title <<
"#Theta distribution at plane " << _iplane
437 <<
" sensor " << _isensor;
438 hists_theta_in[_iplane][_isensor] =
new TH1F(hist_name.str().c_str(),
439 hist_title.str().c_str(), 200, 0, 20e-3);
443 hists_theta_in[_iplane][_isensor]->GetYaxis()->SetTitle(
"entries");
448 hist_name <<
"hist_theta_diff_in_plane_" << _iplane <<
"_sensor_"
450 hist_title <<
"#Delta#Theta distribution at plane " << _iplane
451 <<
" sensor " << _isensor;
453 hist_name.str().c_str(), hist_title.str().c_str(), 100,
457 "#Delta#Theta [rad]");
463 hist_name <<
"hist_theta_diff_rel_in_plane_" << _iplane
464 <<
"_sensor_" << _isensor;
465 hist_title <<
"#Delta#Theta/#Theta distribution at plane "
466 << _iplane <<
" sensor " << _isensor;
468 hist_name.str().c_str(), hist_title.str().c_str(), 100, -1,
472 "#Delta#Theta/#Theta");
481 hist_name <<
"hist_theta_diff_prop_true";
482 hist_title <<
"#Delta#Theta true distribution (Error by Geane back propagation) ";
484 hist_title.str().c_str(), 300, -10e-5, 10e-5, 360, -3.141, +3.141);
492 hist_name <<
"hist_theta_diff_prop_true_o_theta";
493 hist_title <<
"#Delta#Theta true distribution (Error by Geane back propagation) ";
495 hist_title.str().c_str(), 300, -10e-5, 10e-5, 200, 2.e-3, 10.e-3);
501 std::cout <<
" done " << std::endl;
514 fgGeoMan = (TGeoManager*) gROOT->FindObject(
"FAIRGeom");
515 if (!
fgGeoMan) cout <<
"Error: could not find the geometry manager!" << endl;
529 cout <<
" Warning in PndLmdPerformanceTask::SetHistFilename(): output file was set to " <<
hist_output_file->GetName() << endl;
530 cout <<
" Setting it to: " << filename << endl;
598 const int nParticles =
true_tracks->GetEntriesFast();
601 for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
617 if (verbose && npbar != 1)
618 cout <<
"found " << npbar <<
" anti-protons" << endl;
623 for (Int_t iHit = 0; iHit <
nHits; iHit++) {
633 TVector3 _mctrack(mcpoint->GetPx(), mcpoint->GetPy(),
640 TVector3 StartPos, StartPosErr, StartMom, StartMomErr, StartO, StartU, StartV;
644 TVector3 move_upstream_vect(0,0,-0.1);
645 StartPos = _mcpoint + move_upstream_vect ;
646 StartPosErr = TVector3(50.e-4, 50.e-4, 50.e-4);
647 StartMomErr = _mctrack.Mag()*1e-3;
653 TVector3 _vtx(0.,0.,0.);
654 TVector3 gPos(0.,0.,0.);
655 TVector3 gMom(0.,0.,0.);
660 FairTrackParH *fStart =
new FairTrackParH(StartPos, StartMom, StartPosErr, StartMomErr, -1);
661 FairTrackParH *fRes =
new FairTrackParH();
663 fPro->SetPoint(_vtx);
664 fPro->PropagateToPCA(1,-1);
666 Bool_t isProp =
fPro->Propagate(fStart, fRes, PDGCode);
668 cout <<
" Warning in PndLmdPerformanceTask::Exec(): propagation failed! " << endl;
670 gPos.SetXYZ(fRes->GetX(),fRes->GetY(),fRes->GetZ());
671 gMom.SetXYZ(fRes->GetPx(),fRes->GetPy(),fRes->GetPz());
680 double theta_lmd_true = gMom.Theta();
689 cout <<
" Warning in PndLmdPerformanceTask::Exec(): more than 1 IP MC anti proton found -> using first found" << endl;
698 fgGeoMan->FindNode(mcpoint->GetX(), mcpoint->GetY(), mcpoint->GetZ() + 1.e-4);
707 TGeoVolume* local_top =
fgGeoMan->GetVolume(
"lmd_vol_ref_sys");
709 std::cout <<
" Error: Could not set top volume to lmd_vol_ref_sys" << std::endl;
720 std::cout <<
" Error: no node found for the current MC point " << std::endl;
751 _mcpoint = lmddim->Transform_global_to_lmd_local(_mcpoint,
false,
false);
782 det_id = mcpoint->GetDetectorID();
791 sensor += lmddim->n_sensors * 2 * lmddim->nmodules *
ihalf;
806 px_in = _mctrack.X();
807 py_in = _mctrack.Y();
808 pz_in = _mctrack.Z();
812 const TVector3& _mcpoint_mod =
813 lmddim->Transform_lmd_local_to_module_side(_mcpoint,
818 const TVector3& _mcpoint_sens =
819 lmddim->Transform_global_to_sensor(mcpoint->
GetPosition(),
824 const TVector3& _mcpoint_sens_al =
825 lmddim->Transform_global_to_sensor(mcpoint->
GetPosition(),
830 const TVector3& _mcpoint_aligned =
831 lmddim->Transform_global_to_lmd_local(mcpoint->
GetPosition(),
false,
true);
842 <<
" warning: calculated plane or sensor is wrong: plane "
847 TVector3 mctrack_org(mcpoint->GetPx(), mcpoint->GetPy(),
885 if (verbose && nHits > 0)
886 cout <<
"found " << nHits <<
" hit(s) with " << nSdsHits
887 <<
" sds hit(s)" << endl;
891 std::map<int, std::vector<TVector3> >::iterator itplane1, itplane2, itmomin;
896 bool accepted(
false);
901 cout <<
" Warning in PndLmdPerformanceTask::Exec(): more than 1 IP MC anti proton found -> using first found" << endl;
904 if ((*itmomin).second.size() > 0){
905 TVector3 _itmomin = (*itmomin).second[0];
906 if ((*itmomin).second.size() > 1 &&
verbose){
907 cout <<
" Warning in PndLmdPerformanceTask::Exec(): more than 1 IP MC anti proton momentum in the first plane found -> using first found" << endl;
910 if ((*itplane1).second.size() > 0){
911 TVector3 point1 = (*itplane1).second[0];
912 if ((*itplane1).second.size() > 1 &&
verbose){
913 cout <<
" Warning in PndLmdPerformanceTask::Exec(): more than 1 IP MC anti proton hit in the plane 0 found -> using first found" << endl;
916 for (
int _iplane = 1; _iplane <
nplanes; _iplane++){
920 if ((*itplane2).second.size() > 0){
921 TVector3 point2 = (*itplane2).second[0];
922 if ((*itplane2).second.size() > 1 &&
verbose){
923 cout <<
" Warning in PndLmdPerformanceTask::Exec(): more than 1 IP MC anti proton hit in the plane "<< _iplane <<
" found -> using first found" << endl;
925 TVector3 _momrec = point2 - point1;
931 TVector3 StartPos, StartPosErr, StartMom, StartMomErr, StartO, StartU, StartV;
934 StartMom = _momrec.Unit()*itmominit.Mag();
936 StartPosErr = TVector3(50.e-4, 50.e-4, 50.e-4);
937 StartMomErr = _momrec.Unit()*
fPbeam*1e-3;
938 TVector3 _vtx(0.,0.,0.);
944 FairTrackParH *fStart =
new FairTrackParH(StartPos, StartMom, StartPosErr, StartMomErr, -1);
945 FairTrackParH *fRes =
new FairTrackParH();
947 TVector3 gPos(0.,0.,0.);
948 TVector3 gMom(0.,0.,0.);
950 fPro->SetPoint(_vtx);
951 fPro->PropagateToPCA(1,-1);
953 Bool_t isProp =
fPro->Propagate(fStart, fRes, PDGCode);
955 cout <<
" Warning in PndLmdPerformanceTask::Exec(): propagation failed! " << endl;
957 gPos.SetXYZ(fRes->GetX(),fRes->GetY(),fRes->GetZ());
958 gMom.SetXYZ(fRes->GetPx(),fRes->GetPy(),fRes->GetPz());
973 hist_theta_rec_diff_rel[_iplane]->Fill((_momrec.Theta() - itmominit.Theta())/itmominit.Theta(), itmominit.Phi());
1156 TGaxis::SetMaxDigits(3);
1157 TCanvas* canvas1 =
new TCanvas(
"canvas1",
"canvas1", 800, 800);
1158 canvas1->Divide(2, 2);
1183 canvas1->Print(
"Resolution_acceptance_results.ps(");
1189 int xbin_low(-1), xbin_high(-1);
1196 if (xbin_low == -1){
1206 if (0 && xbin_low > -1 && xbin_high > -1){
1234 canvas1->Print(
"Resolution_acceptance_results.ps(");
1238 TCanvas canvas_properties_per_plane(
"canvas_properties_per_plane",
1239 "properties per plane", 800, 800);
1240 canvas_properties_per_plane.cd();
1244 <<
" warning: attempting to draw histograms for a number of planes not 4! "
1246 canvas_properties_per_plane.Divide(2, 2);
1248 TCanvas canvas_properties_per_sensor(
"canvas_properties_per_sensor",
1249 "properties per sensor", 800, 800);
1250 canvas_properties_per_sensor.cd();
1254 <<
" warning: attempting to draw histograms for a number of sensors per plane not 100! "
1256 canvas_properties_per_sensor.Divide(10, 10);
1258 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1259 canvas_properties_per_plane.cd(_iplane + 1);
1260 hist_xy[_iplane]->Draw(
"COLZ");
1261 lmddim->Draw_Sensors(
iplane);
1263 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1264 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1266 canvas_properties_per_sensor.cd(_isensor + 1);
1267 hists_xy[_iplane][_isensor]->Draw(
"COLZ");
1269 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1271 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1273 canvas_properties_per_sensor.cd(_isensor + 1);
1276 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1279 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1280 canvas_properties_per_plane.cd(_iplane + 1);
1283 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1284 canvas_properties_per_plane.cd(_iplane + 1);
1287 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1288 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1290 canvas_properties_per_sensor.cd(_isensor + 1);
1292 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1300 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1303 canvas_properties_per_sensor.cd(_isensor + 1);
1304 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1312 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1314 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1316 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1317 canvas_properties_per_plane.cd(_iplane + 1);
1320 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1321 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1323 canvas_properties_per_sensor.cd(_isensor + 1);
1325 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1332 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1335 canvas_properties_per_sensor.cd(_isensor + 1);
1336 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1341 hists_theta_in[_iplane][_isensor]->SetLineColor(kGray + _iplane);
1344 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1346 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1348 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1349 canvas_properties_per_plane.cd(_iplane + 1);
1352 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1353 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1354 canvas_properties_per_plane.cd(_iplane + 1);
1357 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1358 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1360 canvas_properties_per_sensor.cd(_isensor + 1);
1362 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1370 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1373 canvas_properties_per_sensor.cd(_isensor + 1);
1374 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1382 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1384 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1386 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1387 canvas_properties_per_plane.cd(_iplane + 1);
1390 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1391 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1392 canvas_properties_per_plane.cd(_iplane + 1);
1395 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps(");
1396 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1398 canvas_properties_per_sensor.cd(_isensor + 1);
1400 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1408 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1411 canvas_properties_per_sensor.cd(_isensor + 1);
1412 for (
int _iplane = 0; _iplane <
nplanes; _iplane++) {
1420 canvas_properties_per_sensor.cd(nsensors_per_plane+1);
1422 canvas_properties_per_sensor.Print(
"Resolution_acceptance_results.ps(");
1424 canvas_properties_per_plane.Clear();
1425 canvas_properties_per_plane.Print(
"Resolution_acceptance_results.ps)");
1427 cout <<
"converting to pdf " << system(
1428 "ps2pdf Resolution_acceptance_results.ps") << endl;
1429 cout <<
"deleting ps file " << system(
1430 "rm Resolution_acceptance_results.ps") << endl;
1451 if ((
int) (
last_percent * 100) == (
int) (percent * 100))
1457 for (
int i = 0;
i < len; ++
i) {
1458 if (
i < static_cast<int> (len * percent)) {
1464 cout <<
"[" << progress <<
"] " << (
static_cast<int> (100 * percent))
static PndLmdDim * Instance()
TVector3 GetMomentum() const
Int_t GetSensorID() const
Bool_t IsGeneratorCreated(void) const
Track Representation module based on a Runge-Kutta algorithm including a full material model...
static PndGeoHandling * Instance()
void extrapolateToPoint(const TVector3 &pos, TVector3 &poca, TVector3 &dirInPoca)
This method is to extrapolate the track to point of closest approach to a point in space...
TVector3 GetPosition() const
void init(GFAbsBField *b)
set the magntic field here. Magnetic field classes must be derived from GFAbsBField ...
static GFFieldManager * getInstance()
TVector3 GetStartVertex() const