13 #include "FairRootManager.h"
21 #include "FairRunAna.h"
22 #include "FairRuntimeDb.h"
23 #include "FairBaseParSet.h"
24 #include "FairGeoVolume.h"
26 #include "FairGeoTransform.h"
27 #include "FairGeoVector.h"
28 #include "FairGeoMedium.h"
29 #include "FairGeoNode.h"
34 #include "TParticlePDG.h"
35 #include "TDatabasePDG.h"
37 #include "TGeoManager.h"
45 #include "TPolyLine.h"
56 :FairTask(
"PndDrcRecoLookupMap")
65 :FairTask(
"PndDrcRecoLookupMap")
84 cout <<
" ---------- INITIALIZATION ------------" << endl;
87 FairRootManager* ioman = FairRootManager::Instance();
89 cout <<
"-E- PndDrcRecoLookupMap::Init: "
90 <<
"RootManager not instantiated!" << endl;
95 fMCArray = (TClonesArray*) ioman->GetObject(
"MCTrack");
97 cout <<
"-W- PndDrcRecoLookupMap::Init: "
98 <<
"No MCTrack array!" << endl;
104 cout <<
"-W- PndDrcRecoLookupMap::Init: "
105 <<
"No DrcBarPoint array!" << endl;
109 fPDPointArray = (TClonesArray*) ioman->GetObject(
"DrcPDPoint");
111 cout <<
"-W- PndDrcRecoLookupMap::Init: "
112 <<
"No DrcPDPoint array!" << endl;
125 fDigiArray = (TClonesArray*) ioman->GetObject(
"DrcDigi");
127 cout <<
"-W- PndDrcRecoLookupMap::Init: " <<
"No DrcDigi array!" << endl;
132 fPDHitArray = (TClonesArray*) ioman->GetObject(
"DrcPDHit");
134 cout <<
"-W- PndDrcRecoLookupMap::Init: "
135 <<
"No DrcPDHit array!" << endl;
162 fnX1.SetXYZ(-1., 0.,0.);
163 fnY1.SetXYZ( 0., 1.,0.);
166 timeres =
new TF1(
"timeres",
"[0] + [1]*x", 0., 1000.);
167 timeres->SetParameters(23.2773, 1.11008);
169 cout <<
"-I- PndDrcRecoLookupMap: Intialization successfull" << endl;
179 FairRunAna*
run = FairRunAna::Instance();
180 if ( ! run ) Fatal(
"SetParContainers",
"No analysis run");
182 FairRuntimeDb* db = run->GetRuntimeDb();
183 if ( ! db ) Fatal(
"SetParContainers",
"No runtime database");
187 cout <<
"-I- PndDrcRecoLookupMap::SetParContainers(). read parameters" << endl;
188 cout<<
"read them!"<<endl;
194 if(
fVerbose>1) Info(
"SetParContainers",
"done.");
209 cout<<
"EVENT # "<<
nevents<<endl;
220 cout <<
"PndDrcRecoLookupMap: Number of Detected MC Tracks : "<<
fMCArray->GetEntries()<<endl;
233 for(Int_t j=0; j<
fHitArray->GetEntriesFast(); j++) {
238 Int_t chtrID= pt->GetTrackID();
241 cout<<
"nother track px = "<<pt->GetPx()<<
", py = "<<pt->GetPy()<<endl;
258 cout <<
"PndDrcRecoLookupMap: Number of Detected Photon MCPDPoints : "<<
fPDPointArray->GetEntries()<<endl;
259 cout <<
"PndDrcRecoLookupMap: Number of Detected Photon PDHits : "<<
fPDHitArray->GetEntries()<<endl;
263 for(Int_t k=0; k<
fPDHitArray->GetEntriesFast(); k++) {
272 fBarId = fBarPoint->GetDetectorID();
275 Int_t trID= Ppt->GetTrackID();
293 if(
fabs(trMpdg) == 11){Mrmass = 0.000511; MoSign = 1;}
294 if(
fabs(trMpdg) == 13){Mrmass = 0.105658; MoSign = 1;}
295 if(
fabs(trMpdg) == 211){Mrmass = 0.139570; MoSign = -1;}
296 if(
fabs(trMpdg) == 321){Mrmass = 0.49368; MoSign = -1;}
297 if(
fabs(trMpdg) == 2212){Mrmass = 0.938; MoSign = -1;}
298 if(
fabs(trMpdg) == 50000050){Mrmass = 0.0; MoSign = -1;}
302 cout<<
"+++++++++++++++++++++++++++"<<endl;
303 cout<<
"CH expected = "<<
CHexp<<endl;
311 fpixID = pdhit->GetDetectorID();
312 cout<<
"hit id "<<
fpixID<<
", x = "<<pdhit->GetX()<<
", y = "<<pdhit->GetY()<<
", time = "<<
ftime<<endl;
317 lutinfo.SetPath(Ppt->GetLength());
320 fPphoPD.SetXYZ(Ppt->GetPx(), Ppt->GetPy(), Ppt->GetPz());
329 cout<<
"mother phi = "<<
fPMo.Phi()/3.1415*180.<<endl;
338 fPMo.SetPhi(phi_extra);
344 fBarPoint->Momentum(
fPMo);
349 cout<<
"Mother vector (global cs) : "<<endl;
350 TVector3 motherMom =
fPMo.Unit();
355 cout<<
"Initial momentum of the photon :"<<endl;
384 cout<<
"PhiRot = "<<
fPhiRot/
fpi*180.<<
", Mother phi = "<<
fPMo.Phi()/
fpi*180.<<endl;
393 cout<<
"photon momentum in the bar = "<<endl;
401 cout<<
"Mother vector (bar' cs): "<<endl;
419 cout<<
"N amb = "<<
NAmb<<endl;
424 cout<<
"NO SUCH HIT IN LUT!!!"<<endl;
428 cout<<
"LOOKUP!!!!"<<endl;
431 cout<<
"NPixPar = "<<
NPixPar<<endl;
463 std::vector<TVector3> ambig;
464 std::vector<Double_t> CHreco;
465 std::vector<Double_t> Tamb;
466 std::vector<Double_t> Path;
470 TVectorD CHdiff(8*NumAmb);
471 TVectorD Adiff(8*NumAmb);
473 for(Int_t
i=0;
i<NumAmb;
i++){
477 kZ = -
sqrt(1. - pow(kX,2.) - pow(kY,2.));
479 fkBar.SetXYZ(kX, kY, kZ);
483 for(Int_t jamb=0; jamb <8; jamb++){
484 if(jamb == 1){
fkBar.SetXYZ(-kX, kY, kZ);}
485 if(jamb == 2){
fkBar.SetXYZ(kX, -kY, kZ);}
486 if(jamb == 3){
fkBar.SetXYZ(kX, kY, -kZ);}
487 if(jamb == 4){
fkBar.SetXYZ(-kX, -kY, kZ);}
488 if(jamb == 5){
fkBar.SetXYZ(kX, -kY, -kZ);}
489 if(jamb == 6){
fkBar.SetXYZ(-kX, kY, -kZ);}
490 if(jamb == 7){
fkBar.SetXYZ(-kX, -kY, -kZ);}
495 ambig.push_back(
fkBar);
496 CHreco.push_back(
fkBar.Angle(PMoBar));
499 Path.push_back(
fPath);
517 ambig.push_back((0.,0.,0.));
518 CHreco.push_back(-999.);
519 CHdiff(8*
i+jamb) = -999.;
520 Tamb.push_back(-999.);
521 Path.push_back(-999.);
522 Adiff(8*
i+jamb) = -999.;
543 cout<<
"mother phi angle = "<<
fPMo.Phi()/
fpi*180.<<endl;
544 cout<<
"mother phi in the name of histo = "<<(Int_t)(
fPMo.Phi()/
fpi*180.*100.)<<endl;
548 TString PhiTWeight = Form(
"t%g_phi%d_weight",
fPMo.Theta()/
fpi*180., (Int_t)(
fPMo.Phi()/
fpi*180.*100.));
560 TH1F* newThetaPhiPoint =
new TH1F(PhiT.Data(),
"Cherenkov angle difference for theta",
nbins, -
fWidth,
fWidth);
562 TH1F* newThetaPhiPointCut =
new TH1F(PhiTCut.Data(),
"Cherenkov angle difference for theta with time cut",
nbins, -
fWidth,
fWidth);
564 TH1F* newThetaPhiPointWeight =
new TH1F(PhiTWeight.Data(),
"Cherenkov angle difference for theta with time weights",
nbins, -
fWidth,
fWidth);
566 TH1F* newNbo =
new TH1F(Nbo.Data(),
"Number of bounces", 1000,0.,500.);
577 for(Int_t j=0; j< CHreco.size(); j++){
615 if(startPhi < 0.){startPhi = 360. + startPhi;}
621 if(startPhi >= 0. && startPhi < 90.){
624 if(startPhi >= 90. && startPhi < 270.){
627 if(startPhi >= 270. && startPhi < 360.){
632 TVector3 ver1, ver2, ver3, ver4;
638 ver1.RotateZ(PhiRot/180.*
fpi);
639 ver2.RotateZ(PhiRot/180.*
fpi);
640 ver3.RotateZ(PhiRot/180.*
fpi);
641 ver4.RotateZ(PhiRot/180.*
fpi);
648 return PhiRot/180.*
fpi;
657 hit.SetXYZ(xhit, yhit, 0.);
659 if(phi < 0.){phi = 360. + hit.Phi()*180./
fpi;}
670 return 5.+TMath::Floor((360.-phi)/
fDphi);
693 if(dir.Theta() < 3.1415/2.){
696 if(dir.Theta() >= 3.1415/2.){
697 Z0 = -(start.Z() -
fzup);
722 if(printt){std::cout<<
"n = "<<n<<
", NN = "<<*NN<<
", x0 = "<<x0<<
", a = "<<a<<std::endl;}
724 if(x0 < 0.){x1 = x0 - (n+1)*a;}
725 if(printt){std::cout<<
"xy = "<< x1<<std::endl;}
727 if((m/2. - TMath::Floor(m/2.)) == 0.) {
728 if(
print){std::cout<<
"odd==0"<<std::endl;}
729 if(x0 >= 0. && x1 + xEn <= a){xK = x1 + xEn;}
730 if(x0 >= 0. && x1 + xEn > a){xK = 2*a - x1 - xEn; n = 1. +
n;}
731 if(x0 < 0. && x1 + xEn >= 0.){xK = a - (x1 + xEn); n = -1. -
n;}
732 if(x0 < 0. && x1 + xEn < 0.) {xK = a + x1 + xEn; n = -
n;}
733 if(printt){std::cout<<
"xK = "<< xK<<
", n = "<<n<<std::endl;}
737 if((m/2. - TMath::Floor(m/2.)) != 0.) {
738 if(
print){std::cout<<
"even!=0"<<std::endl;}
739 if(x0 >= 0. && x1 + xEn <= a){xK = a - (x1 + xEn);}
740 if(x0 >= 0. && x1 + xEn > a){xK = x1 + xEn -
a; n = 1. +
n;}
741 if(x0 < 0. && x1 + xEn >= 0.){xK = x1 + xEn; n = -1. -
n;}
742 if(x0 < 0. && x1 + xEn < 0.) {xK = - (x1 + xEn); n = -
n;}
743 if(printt){std::cout<<
"xK = "<< xK<<
", n = "<<n<<std::endl;}
755 xx[0] = v1.X(); xx[1] = v2.X(); xx[2] = v3.X(); xx[3] = v4.X(); xx[4] = v1.X();
756 yy[0] = v1.Y(); yy[1] = v2.Y(); yy[2] = v3.Y(); yy[3] = v4.Y(); yy[4] = v1.Y();
757 TPolyLine *p6 =
new TPolyLine(5,xx,yy);
781 if(kb.Z() < 0.){Z0 = start.Z() -
fGeo->
barBoxZUp(); kz = kb.Z();}
785 cout<<
"-I- Reco ambig Time: Zstart = "<<start.Z()<<
", Z0 = "<<Z0<<endl;
792 cout<<
"RECO ambig TIME: thetas are: quartz = "<<kb.Theta()/
fpi*180.<<
", oil = "<<thetaOil/
fpi*180.<<endl;
794 kb.SetTheta(thetaOil);
799 cout<<
"-I- Reco ambig Time: Zev = "<<
fGeo->
EVlen()<<endl;
800 cout<<
"-I- Reco ambig Time: L0 = "<<L0<<
", L1 = "<<L1<<endl;
801 cout<<
"-I- Reco ambig Time: time is "<< L0/u_quartz + L1/u_oil <<endl;
806 return L0/u_quartz + L1/u_oil;
814 fhPDTime =
new TH1D(
"fhPDTime",
"Time of photons in ns",1000,0,100);
815 fhRecoT1 =
new TH2F(
"fhRecoT1",
"Reconstructed group velocity using MC track path [ns]", 500, 200.,700., 1000, 0., 40.);
816 fhPDHits =
new TH2D(
"fhPDHits",
"Photon hits on the PD plane", 2500, -250, 250, 2500, -250, 250);
818 fhDiff =
new TH1F(
"fhDiff",
"Difference btw reco and expected Cherenkov Angle", 50, -
fWidth,
fWidth);
820 fhCHreal =
new TH1F(
"fhCHreal",
"Generated cherenkov angle", 100, 0.7, 0.9);
821 fhLam =
new TH1F(
"fhLam",
"Lambda of detected Cherenkov photons", 480, 200., 800.);
823 fhNboLam =
new TH2F(
"fhNboLam",
"Nbo as a function of lambda", 600, 200.,800., 100, 0.,500.);
836 fMapHist =
new TH2F(
"fMapHist",
"Photon yield",30,2.5,152.5,20,0.35,20.35);
837 fSigHist =
new TH2F(
"fSigHist",
"fSigHist",30,2.5,152.5, 20,0.35,20.35);
838 fCheHist =
new TH2F(
"fCheHist",
"fCheHist",30,2.5,152.5, 20,0.35,20.35);
839 fkBarXHist =
new TH2F(
"fkBarXHist",
"fkBarXHist",200,-1.,1.,200,-1.,1.);
840 fkBarYHist =
new TH2F(
"fkBarYHist",
"fkBarYHist",200,-1.,1.,200,-1.,1.);
855 gDirectory->mkdir(
"diff");
856 gDirectory->cd(
"diff");
861 gDirectory->cd(
"../");
862 gDirectory->mkdir(
"diffCut");
863 gDirectory->cd(
"diffCut");
868 gDirectory->cd(
"../");
869 gDirectory->mkdir(
"diffWeight");
870 gDirectory->cd(
"diffWeight");
875 gDirectory->cd(
"../");
876 gDirectory->mkdir(
"Nbounces");
877 gDirectory->cd(
"Nbounces");
881 gDirectory->cd(
"../");
883 while ( TH1* histo = ((TH1*)
next()) ) histo->Write();
890 cout <<
"-I- PndDrcRecoLookupMap: Finish" << endl;
894 TString hnam, num1, num2, num3;
898 TF1* fit =
new TF1(
"fit",
"gaus(0)+pol1(3)");
899 fit->SetParameters(10.,-0.001,0.017,1.,1.);
901 sig =
fabs(fit->GetParameter(2));
902 chr = fit->GetParameter(1);
907 num1.Remove(num1.Index(
"_"), (num1.Length()-num1.Index(
"_")));
911 num2.Remove(0,num2.Index(
"i")+1);
914 cout<<
"i = "<<
i<<endl;
916 cout<<
"SigHIST was filled with "<<sig<<
" in phi = "<<yy <<
", theta - "<<xx <<endl;
936 gStyle->SetOptFit(0111);
938 TCanvas *C1 =
new TCanvas(
"C1",
"Time", 500,500);
945 TCanvas *C2 =
new TCanvas(
"C2",
"PD Plane", 500, 500);
951 TCanvas *C3 =
new TCanvas(
"C3",
"Diff", 500,500);
952 fhDiff->GetXaxis()->SetTitle(
"[rad]");
958 TCanvas *C8=
new TCanvas(
"C8",
"Nentries map",500,500);
960 gStyle->SetOptStat(11);
961 fMapHist->GetXaxis()->SetTitle(
"#Theta_{track} [degrees]");
962 fMapHist->GetYaxis()->SetTitle(
"#phi_{track} [degrees]");
963 fMapHist->GetZaxis()->SetTitle(
"nEntries");
971 TCanvas *C9=
new TCanvas(
"C9",
"Mean CHreco map",500,500);
973 gStyle->SetOptStat(11);
974 fCheHist->GetXaxis()->SetTitle(
"#theta track angle [degrees]");
975 fCheHist->GetYaxis()->SetTitle(
"#phi track angle [degrees]");
976 fCheHist->GetZaxis()->SetTitle(
"<CHreco - CHexp> [rad]");
982 TCanvas *C10=
new TCanvas(
"C10",
"Sigma map",500,500);
984 gStyle->SetOptStat(11);
987 fSigHist->GetXaxis()->SetTitle(
"#theta track angle [degrees]");
988 fSigHist->GetYaxis()->SetTitle(
"#phi track angle [degrees]");
989 fSigHist->GetZaxis()->SetTitle(
"#sigma_{CHreco - CHexp}");
994 TCanvas *C11=
new TCanvas(
"C11",
"kBar LUT & kBar gen",500,500);
997 fkBarXHist->GetXaxis()->SetTitle(
"kxBar from LUT");
998 fkBarXHist->GetYaxis()->SetTitle(
"kxBar generated");
1000 TLine *l1 =
new TLine(1.,1.,-1.,-1.);
1001 TLine *l2 =
new TLine(-1.,1.,1.,-1.);
1002 l1->SetLineColor(8);
1003 l2->SetLineColor(8);
1007 fkBarYHist->GetXaxis()->SetTitle(
"kyBar from LUT");
1008 fkBarYHist->GetYaxis()->SetTitle(
"kyBar generated");
1013 TCanvas *C12=
new TCanvas(
"C12",
"Lam & CHreal",500,500);
void SetChPartDirInBar2(TVector3 val)
friend F32vec4 acos(const F32vec4 &a)
void AddChDiff(Double_t val)
friend F32vec4 cos(const F32vec4 &a)
TClonesArray * fPDPointArray
friend F32vec4 exp(const F32vec4 &a)
PndGeoDrc * fGeo
Basic geometry data of barrel DRC.
friend F32vec4 sqrt(const F32vec4 &a)
Bool_t GetParamsForPixel(Int_t, Double_t *)
virtual void SetParContainers()
friend F32vec4 sin(const F32vec4 &a)
Double_t RecoAmbigTime(TVector3, TVector3, Double_t *, Bool_t)
Double_t SectorNum(Double_t, Double_t)
TVector3 GetMomentum() const
void SetChPartPdg(Int_t val)
void SetChPartDirInBar(TVector3 val)
std::vector< TH1F * > PhiThetaPointsCut
std::vector< TH1F * > PhiThetaPoints
virtual Double_t GetTime()
TString pt(TString pts, TString exts="px py pz")
void SetCherenkovReal(Double_t val)
Int_t GetBarPointID() const
virtual Int_t GetRefIndex()
TClonesArray * fDrcLutInfoArray
void AddAngle(Double_t val)
void SetChPartDir(TVector3 val)
std::vector< TH1F * > PhiThetaPointsWeight
virtual void Exec(Option_t *option)
void AddTime(Double_t val)
void AddNOfBounces(Double_t val)
TClonesArray * fBarPointArray
friend F32vec4 fabs(const F32vec4 &a)
void SetCherenkovMC(Double_t val)
static PndGeoHandling * Instance()
TVector3 MasterToLocalShortId(const TVector3 &master, const Int_t &shortId)
Double_t InBarCoordSyst(TVector3, TVector3 *, TVector3 *, TVector3 *, TVector3 *)
TClonesArray * fPDHitArray
Digitization Parameter Class for DIRC barrel part.
virtual InitStatus Init()
Double_t FindOutPoint(Double_t, Double_t, Double_t, Double_t *, Bool_t)
virtual Int_t GetRefIndex()
void AddPath(Double_t val)
virtual void SetParContainers()
TVector3 GetStartVertex() const
TClonesArray * fDigiArray
void DrawBarBox(TVector3, TVector3, TVector3, TVector3)
Int_t GetMotherID() const
std::vector< TH1F * > NboPoints
Int_t NumberOfBounces(TVector3, TVector3, Int_t)
virtual ~PndDrcRecoLookupMap()
Double_t GetStartTime() const