10 #include "FairRootManager.h"
33 :FairTask(
"PndDrcLutReco",verbose){
39 :FairTask(
"PndDrcLutReco",verbose){
51 cout <<
" ---------- INITIALIZATION ------------" << endl;
54 FairRootManager* ioman = FairRootManager::Instance();
56 cout <<
"-E- PndDrcLutReco::Init: " <<
"RootManager not instantiated!" << endl;
61 fMCArray = (TClonesArray*) ioman->GetObject(
"MCTrack");
63 cout <<
"-W- PndDrcLutReco::Init: " <<
"No MCTrack array!" << endl;
70 cout <<
"-W- PndDrcLutReco::Init: " <<
"No DrcBarPoint array!" << endl;
75 fEVPointArray = (TClonesArray*) ioman->GetObject(
"DrcEVPoint");
77 cout <<
"-W- PndDrcLutReco::Init: " <<
"No DrcEVPoint array!" << endl;
82 fPDPointArray = (TClonesArray*) ioman->GetObject(
"DrcPDPoint");
84 cout <<
"-W- PndDrcLutReco::Init: " <<
"No DrcPDPoint array!" << endl;
94 fPDHitArray = (TClonesArray*) ioman->GetObject(
"DrcPDHit");
96 cout <<
"-W- PndDrcLutReco::Init: " <<
"No DrcPDHit array!" << endl;
101 name.Remove(0,name.Last(
'/')+1);
106 for(Int_t l=0; l<5; l++){
107 fLut[l] =
new TClonesArray(
"PndDrcLutNode");
108 fTree->SetBranchAddress(Form(
"LUT%d",l),&
fLut[l]);
124 fHist =
new TH1F(
"chrenkov_angle_hist",
"chrenkov_angle_hist", 100,0.4,0.9);
126 fHist2 =
new TH1F(
"chrenkov_angle_hist2",
"", 400,-30,30);
127 fFit =
new TF1(
"fgaus",
"[0]*exp(-0.5*((x-[1])/[2])*(x-[1])/[2])",0.35,0.85);
128 fSpect =
new TSpectrum(10);
130 cout <<
"-I- PndDrcLutReco: Intialization successfull" << endl;
141 if(
fVerbose>1) std::cout<<
"Event # "<<
nevents<<
" has "<<nHits<<
" hits."<< std::endl;
142 else if(
fVerbose==1 &&
nevents%100==0) std::cout<<
"Event # "<<
nevents<<
" has "<<nHits<<
" hits."<< std::endl;
148 TVector3 momInBar, posInBar;
150 for(Int_t itrack=0; itrack<
fMCArray->GetEntriesFast(); itrack++){
163 std::cout<<
"mcBoxId "<<mcBoxId <<std::endl;
178 if(
fVerbose<2) gROOT->SetBatch(kTRUE);
180 if(
fVerbose<2) gROOT->SetBatch(kFALSE);
194 Int_t lutboxId(3), barId(-1), evpointcount(0);
201 momInBar.RotateZ(-boxPhi/180.*
TMath::Pi());
208 for(Int_t ihit=0; ihit<
fPDHitArray->GetEntriesFast(); ihit++) {
217 Int_t pointID =
fPDHit->GetLink(1).GetIndex();
218 Int_t eventID =
fPDHit->GetLink(1).GetEntry();
220 if(eventID !=
nevents)
continue;
222 std::cout<<
" name "<< FairRootManager::Instance()->GetBranchName(
fPDHit->GetLink(1).GetType()) <<std::endl;
223 std::cout<<
"ERROR 83 " << pointID <<
" out of " <<
fPDPointArray->GetEntriesFast() <<
" "<< eventID<<
"/"<<
nevents<<std::endl;
229 Int_t trackID =
fPDPoint->GetTrackID();
233 if(trackID ==
fEVPoint->GetTrackID()) evpointcount++;
236 else reflected = kFALSE;
238 Int_t recalculatedSensorId = sensorId;
239 if(
fEvType<3) recalculatedSensorId = (sensorId/100 - (boxId - lutboxId)*17)*100 + sensorId%100;
241 if(sensorId>27200 || recalculatedSensorId>27200 || recalculatedSensorId <0) {
242 std::cout<<
"LUT reco: ignore vertical MCPblock for now. sensorId = "<<sensorId
243 <<
" recalculatedSensorId = "<< recalculatedSensorId <<std::endl;
252 FillAmbiguities(&photoninfo, barId, recalculatedSensorId, posInBar.Z()+119, barHitTime);
257 Int_t pdgreco =
FindPdg(momInBar.Mag(), cherenkovreco);
259 trackinfo->
SetPdg(pdgreco);
265 fnX1 = TVector3(1,0,0),
266 fnY1 = TVector3(0,1,0),
269 Double_t evtime, bartime, luttheta, tangle;
273 if(reflected) lenz = 2*240 - lenz;
278 for(
int i=0;
i<size;
i++){
284 for(
int u=0; u<4; u++){
285 if(u == 0) dir = dird;
286 if(u == 1) dir.SetXYZ(-dird.X(), dird.Y(), dird.Z());
287 if(u == 2) dir.SetXYZ( dird.X(),-dird.Y(), dird.Z());
288 if(u == 3) dir.SetXYZ(-dird.X(),-dird.Y(), dird.Z());
289 if(reflected) dir.SetXYZ( dir.X(), dir.Y(),-dir.Z());
291 if(dir.Angle(fnX1) < criticalAngle || dir.Angle(fnY1) < criticalAngle)
continue;
293 luttheta = dir.Theta();
295 bartime = lenz/
cos(luttheta)/19.8;
297 if(
fabs((bartime + evtime)-(pdHitTime-barHitTime))>1.5)
continue;
298 tangle = momInBar.Angle(dir);
307 if(tangle > 0.4 && tangle < 0.9)
fHist->Fill(tangle);
314 if(startPhi < 0) startPhi = 360 + startPhi;
315 if(startPhi >= 0 && startPhi < 90) boxPhi = TMath::Floor(startPhi/
fDphi) *
fDphi +
fDphi/2.;
321 if(barId>4 || barId<0){
322 std::cout<<
"Error in PndDrcLutReco: Bar Id is wrong. barId = "<< barId <<std::endl;
325 std::cout<<
"phi="<<phi<<
" boxPhi "<<boxPhi<<
" startPhi " <<startPhi<<
" 8235fBarPhi "<<
fBarPhi<<std::endl;
333 if(
fHist->GetEntries()>20 ){
334 TCanvas*
c =
new TCanvas(
"c",
"c",0,0,800,600);
336 Float_t *xpeaks = (Float_t*)
fSpect->GetPositionX();
337 if(nfound>0) cherenkovreco = xpeaks[0];
338 fFit->SetParameter(1,cherenkovreco);
339 fFit->SetParameter(2,0.01);
340 fHist->Fit(
"fgaus",
"Q",
"",cherenkovreco-0.02,cherenkovreco+0.02);
341 cherenkovreco =
fFit->GetParameter(1);
342 std::cout<<
"sigma "<<
fFit->GetParameter(2) <<std::endl;
344 if(cherenkovreco<0 || cherenkovreco>1 ) cherenkovreco = 0;
347 fHist->GetXaxis()->SetTitle(
"#theta_{C}, [rad]");
348 fHist->GetYaxis()->SetTitle(
"Entries, [#]");
361 return cherenkovreco;
365 Int_t pdg[]={11,13,211,321,2212};
366 Double_t mass[] = {0.000511,0.1056584,0.139570,0.49368,0.9382723};
369 for(Int_t
i=0;
i<5;
i++){
370 tdiff =
fabs(cangle -
acos(
sqrt(mom*mom + mass[
i]*mass[
i])/mom/1.46907));
381 for(Int_t l=0; l<5; l++){
384 cout <<
"-I- PndDrcLutReco: Finish" << endl;
void SetMcCherenkov(Double_t val)
friend F32vec4 acos(const F32vec4 &a)
TClonesArray * fDrcTrackInfoArray
friend F32vec4 cos(const F32vec4 &a)
void SetEvReflections(Int_t val)
TClonesArray * fEVPointArray
friend F32vec4 sqrt(const F32vec4 &a)
void DetermineBarId(Double_t phi, Double_t &boxPhi, Int_t &boxId, Int_t &barId)
TClonesArray * fPDHitArray
TVector3 GetMomentum() const
void SetMcMomentum(TVector3 val)
Double_t GetThetaC() const
virtual Double_t GetTime()
virtual void Exec(Option_t *option)
cout<< "blue = Monte Carlo "<< endl;cout<< "red = Helix Hit "<< endl;cout<< "green = Center Of Tubes "<< endl;for(Int_t k=0;k< track->GetEntriesFast();k++){PndSttTrack *stttrack=(PndSttTrack *) track-> At(k)
TClonesArray * fPDPointArray
void SetEvTime(Double_t val)
void SetReflected(Bool_t val)
TClonesArray * fBarPointArray
void FillAmbiguities(PndDrcPhotonInfo *photoninfo, Int_t barId, Int_t recalculatedSensorId, Double_t directz, Double_t barHitTime)
void SetBarTime(Double_t val)
Double_t GetMcTimeInBar()
void AddAmbiguity(PndDrcAmbiguityInfo ambiguity)
TVector3 GetMcPositionInBar()
Int_t FindPdg(Double_t mom, Double_t cangle)
void AddPhoton(PndDrcPhotonInfo photon)
friend F32vec4 fabs(const F32vec4 &a)
TVector3 GetEntry(Int_t entry)
TVector3 GetMcMomentumInBar()
Double_t GetTime(Int_t entry)
void SetMcPositionInBar(TVector3 val)
void SetMcPrimeMomentumInBar(TVector3 val)
virtual InitStatus Init()
PndDrcBarPoint * fBarPoint
void SetCherencov(Double_t val)
void SetCherenkov(Double_t val)
void SetMcTimeInBar(Double_t val)
void SetMcMomentumInBar(TVector3 val)
Int_t GetMotherID() const
void SetHitTime(Double_t val)
void DetermineCherenkov(PndDrcTrackInfo *trackinfo, Int_t boxId)
TVector3 GetMcPrimeMomentumInBar()