1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 #include "AliRICHRecon.h"
18 #include "AliRICHParam.h"
19 #include <AliLoader.h>
21 #include <Riostream.h>
23 #include <TParticle.h>
34 #include <TPolyLine.h>
38 #include <TRotation.h>
41 #include <TEventList.h>
43 #define NPointsOfRing 201
45 // Geometry of the RICH at Star...
47 static const Int_t nPadX = AliRICHParam::NpadsY();
48 static const Int_t nPadY = AliRICHParam::NpadsX();
49 static const Float_t PadSizeX = AliRICHParam::PadSizeY();
50 static const Float_t PadSizeY = AliRICHParam::PadSizeX();
51 static const Float_t spacer = AliRICHParam::DeadZone();
52 static const Float_t degree = 180/3.1415926535;
54 static const Float_t pi = TMath::Pi();
56 static const Float_t RadiatorWidth = AliRICHParam::FreonThickness();
57 static const Float_t QuartzWidth = AliRICHParam::QuartzThickness();
58 static const Float_t GapWidth = AliRICHParam::RadiatorToPads();
60 static const Float_t fDTheta = 0.001; // Step for sliding window
61 //static const Float_t fWindowWidth = 0.040; // Hough width of sliding window
62 static const Float_t fWindowWidth = 0.060; // Hough width of sliding window
64 static const Int_t fThetaBin = 750; // Hough bins
65 static const Float_t fThetaMin = 0.0; // Theta band min
66 static const Float_t fThetaMax = 0.75; // Theta band max
68 static const Float_t Xmin = -AliRICHParam::PcSizeY()/2.;
69 static const Float_t Xmax = AliRICHParam::PcSizeY()/2.;
70 static const Float_t Ymin = -AliRICHParam::PcSizeX()/2.;
71 static const Float_t Ymax = AliRICHParam::PcSizeX()/2.;
74 // Global variables...
76 Bool_t fDebug = kFALSE;
77 Bool_t kDISPLAY = kFALSE;
78 Bool_t kWEIGHT = kFALSE;
79 Bool_t kBACKGROUND = kFALSE;
80 Bool_t kMINIMIZER = kFALSE;
85 static Float_t xGraph[3000],yGraph[3000];
87 static Int_t NRings = 0;
88 static Int_t NevTOT = 0;
92 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
94 // Float_t fEmissionPoint;
95 // Float_t fTrackTheta;
104 TH1F *h1_photons,*h1_photacc,*h1_hough;
105 TH2F *h2_tvsppos, *h2_tvspneg,*h2_func;
109 TH2F *h2_test1, *h2_test2, *h2_test4, *h2_testmap;
112 TH1F *h1_photons1, *h1_photons2;
113 TH1F *h1_houghpos, *h1_houghneg;
117 TH1F *h1_hcs, *h1_hcsw;
121 TProfile *hp_1pos, *hp_1neg;
122 TProfile *hp_1posnorm, *hp_1negnorm;
123 TH2F *h2_1pos, *h2_1neg;
124 TH2F *h2_1posnorm, *h2_1negnorm;
127 TH1F *h1_deltap, *h1_deltapop;
128 TH1F *h1_diffTrackTheta, *h1_diffTrackPhi;
129 TH1F *h1_photaccspread;
131 TH2F *h2_diffpos, *h2_diffneg;
132 TH2F *h2_map, *h2_mapw;
138 TCanvas *StarCanvas,*Display,*Displayhcs;
143 TMarker *Point, *TrackPoints, *Photon, *PhotonAcc;
146 AliRICHRecon::AliRICHRecon(const char*, const char*)
149 fRich = (AliRICH*)gAlice->GetDetector("RICH");
153 void AliRICHRecon::InitRecon()
156 outputfile = new TFile("Anal.root","RECREATE","My Analysis histos");
157 if(kDISPLAY) Display = new TCanvas("Display","RICH Display",0,0,1200,750);
159 h1_photons = new TH1F("h1_photons","photons",750,0.,0.75);
160 h1_photacc = new TH1F("h1_photacc","photons",750,0.,0.75);
161 h1_hough = new TH1F("h1_hough","hough",750,0.,0.75);
162 h1_houghpos= new TH1F("h1_houghpos","hough",750,0.,0.75);
163 h1_houghneg= new TH1F("h1_houghneg","hough",750,0.,0.75);
165 h2_tvsppos = new TH2F("h2_tvsppos","thetac vs p",100,0.,5.,750,0.,0.75);
166 h2_tvspneg = new TH2F("h2_tvspneg","thetac vs p",100,0.,5.,750,0.,0.75);
167 h2_func = new TH2F("h2_func"," func ",800,0.,0.8,100,-100.,100.);
168 h2_mvsp = new TH2F("h2_mvsp","mass vs p",100,0.,5.,200,0.,2.);
169 h2_mvst = new TH2F("h2_mvst","mass vs t",750,0.,0.75,200,0.,2.);
170 h2_map = new TH2F("h2_map","h2_map",160,0.,160.,96,0.,96.);
171 h2_mapw = new TH2F("h2_mapw","h2_mapw",160,0.,160.,96,0.,96.);
173 h2_dist_p = new TH2F("h2_dist_p","h2_dist_p",100,0.,5.,100,0.,5.);
176 h2_disp = new TH2F("h2_disp","STAR-RICH Event Display",165,Xmin,Xmax,100,Ymin,Ymax);
178 // h2_test1 = new TH2F("h2_test1","test1 map",165,-64.,64.,100,-42.,42.);
179 h2_test2 = new TH2F("h2_test2","test2 map",165,-64.,64.,100,-42.,42.);
180 // h2_test4 = new TH2F("h2_test4","test4 map",165,-64.,64.,100,-42.,42.);
181 h2_testmap= new TH2F("h2_testmap","test map",165,-64.,64.,100,-42.,42.);
184 h1_photons1 = new TH1F("h1_photons1","photons",750,0.,0.75);
185 h1_photons2 = new TH1F("h1_photons2","photons",750,0.,0.75);
187 h1_hcs = new TH1F("h1_hcs","hcs",750,0.,750.);
188 h1_hcsw = new TH1F("h1_hcsw","hcsw",750,0.,750.);
190 h1_nprotons = new TH1F("h1_nprotons","n prot",30,0.,30.);
192 hp_1pos = new TProfile("hp_1pos","Nphot vs thetac pos",250,0.,0.75);
193 hp_1neg = new TProfile("hp_1neg","Nphot vs thetac neg",250,0.,0.75);
194 hp_1posnorm = new TProfile("hp_1posnorm","Nphot vs thetac pos norm",250,0.,0.75);
195 hp_1negnorm = new TProfile("hp_1negnorm","Nphot vs thetac neg norm",250,0.,0.75);
197 h2_1pos = new TH2F("h2_1pos","Nphot vs p pos",100,0.,5.,30,0.,30.);
198 h2_1neg = new TH2F("h2_1neg","Nphot vs p neg",100,0.,5.,30,0.,30.);
199 h2_1posnorm = new TH2F("h2_1posnorm","Nphot vs p pos norm",100,0.,5.,30,0.,30.);
200 h2_1negnorm = new TH2F("h2_1negnorm","Nphot vs p neg norm",100,0.,5.,30,0.,30.);
202 h1_deltap = new TH1F("h1_deltap","delta_p",200,-0.5,0.5);
203 h1_deltapop = new TH1F("h1_deltapop","deltapop",200,-1.,1.);
204 h1_diffTrackTheta = new TH1F("h1_diffTrackTheta","delta theta",200,-0.25,0.25);
205 h1_diffTrackPhi = new TH1F("h1_diffTrackPhi","delta phi",200,-0.25,0.25);
207 h1_photaccspread = new TH1F("h1_photaccspread","photons spread",200,-0.1,0.1);
211 h1_mass = new TH1F("h1_mass","mass",200,0.,2.);
212 photris = new TH1F("photris","photris",1000,0.,1.);
213 h2_diffneg = new TH2F("h2_diffneg","diff neg",100,-2.5,2.5,100,-2.5,2.5);
214 h2_diffpos = new TH2F("h2_diffpos","diff pos",100,-2.5,2.5,100,-2.5,2.5);
216 hn = new TNtuple("hn","ntuple",
217 "Run:Trig:VertZ:Pmod:Pt:Eta:TrackTheta:TrackPhi:TrackThetaFit:TrackPhiFit:Charge:ThetaCerenkov:NPhotons:NPhotonsFit:InRing:MassOfParticle:HoughArea:Multiplicity:TPCLastZ");
220 void AliRICHRecon::StartProcessEvent()
223 Float_t TrackThetaStored = 0;
224 Float_t TrackPhiStored = 0;
225 Float_t ThetaCerenkovStored = 0;
226 Int_t HoughPhotonsStored = 0;
228 SetFreonScaleFactor(0.994);
236 Rich()->GetLoader()->LoadHits();
237 Rich()->GetLoader()->LoadRecPoints();
238 Rich()->GetLoader()->LoadDigits();
239 gAlice->GetRunLoader()->LoadHeader();
240 gAlice->GetRunLoader()->LoadKinematics();
242 Rich()->GetLoader()->TreeR()->GetEntry(0);
244 Float_t clusX[7][500],clusY[7][500];
248 for (Int_t ich=0;ich<7;ich++) {
249 nClusters[ich] = Rich()->ClustersOld(ich+1)->GetEntries();
250 for(Int_t k=0;k<nClusters[ich];k++) {
251 AliRICHRawCluster *pCluster = (AliRICHRawCluster *)Rich()->ClustersOld(ich+1)->At(k);
252 clusX[ich][k] = pCluster->fX;
253 clusY[ich][k] = pCluster->fY;
254 clusQ[ich][k] = pCluster->fQ;
259 Int_t nPrimaries = (Int_t)Rich()->GetLoader()->TreeH()->GetEntries();
261 for(Int_t i=0;i<nPrimaries;i++){
263 Rich()->GetLoader()->TreeH()->GetEntry(i);
269 for(Int_t j=0;j<Rich()->Hits()->GetEntries();j++) {
271 pHit = (AliRICHhit*)Rich()->Hits()->At(j);
272 if(pHit->GetTrack() > nPrimaries) continue;
276 if(iPrim>1) Fatal("StartProcessEvent"," more than 1 prim to hit!!! = %3i", iPrim);
277 TParticle *pParticle = gAlice->GetRunLoader()->Stack()->Particle(pHit->GetTrack());
278 Float_t pmod = pParticle->P();
279 Float_t pt = pParticle->Pt();
280 Float_t TrackEta = pParticle->Eta();
281 Int_t q = (Int_t)TMath::Sign(1.,pParticle->GetPDG()->Charge());
283 SetTrackMomentum(pmod);
285 SetTrackEta(TrackEta);
288 TVector3 pGlob(pHit->MomFreoX(),pHit->MomFreoY(),pHit->MomFreoZ());
289 TVector3 pLocal = Rich()->C(pHit->Chamber())->G2Lvector(pGlob);
291 Float_t primGlobalX = pHit->X();
292 Float_t primGlobalY = pHit->Y();
293 Float_t primGlobalZ = pHit->Z();
294 TVector3 primGlobal(primGlobalX,primGlobalY,primGlobalZ);
295 TVector3 primLocal = Rich()->C(pHit->Chamber())->G2L(primGlobal);
297 // Float_t pmodFreo = pLocal.Mag();
298 Float_t TrackTheta = pLocal.Theta();
299 Float_t TrackPhi = pLocal.Phi();
301 SetTrackTheta(TrackTheta);
302 SetTrackPhi(TrackPhi);
305 Float_t MinDist = 999.;
307 for(Int_t j=0;j<nClusters[pHit->Chamber()];j++)
309 Float_t diffx = primLocal.X() - clusX[pHit->Chamber()][j];
310 Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()][j];
312 Float_t diff = sqrt(diffx*diffx + diffy*diffy);
322 Float_t diffx = primLocal.X() - clusX[pHit->Chamber()][MaxInd];
323 Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()][MaxInd];
327 h2_diffpos->Fill(diffx,diffy);
329 h2_diffneg->Fill(diffx,diffy);
335 Float_t ShiftX = primLocal.X()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.X();
336 Float_t ShiftY = primLocal.Y()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.Y();
341 Float_t *pclusX = &clusX[pHit->Chamber()][0];
342 Float_t *pclusY = &clusY[pHit->Chamber()][0];
344 SetCandidatePhotonX(pclusX);
345 SetCandidatePhotonY(pclusY);
346 SetCandidatePhotonsNumber(nClusters[pHit->Chamber()]);
348 Int_t qch = clusQ[pHit->Chamber()][MaxInd];
350 if(MinDist < 3.0 && qch > 120 && MaxInd !=0)
356 Float_t Xrndm = Xmin + (Xmax-Xmin)*gRandom->Rndm(280964);
357 Float_t Yrndm = Ymin + (Ymax-Ymin)*gRandom->Rndm(280964);
359 cout << " Xrndm " << Xrndm << " Yrndm " << Yrndm << endl;
368 TrackThetaStored = GetTrackTheta();
369 TrackPhiStored = GetTrackPhi();
370 ThetaCerenkovStored = GetThetaCerenkov();
371 HoughPhotonsStored = GetHoughPhotons();
373 Int_t DiffNPhotons = 999;
375 Float_t DiffTrackTheta = 999.;
376 Float_t DiffTrackPhi = 999.;
378 while( kMINIMIZER && GetHoughPhotons() > 2
380 && DiffTrackTheta > 0.0001
384 Int_t HoughPhotonsBefore = GetHoughPhotons();
386 Float_t TrackThetaBefore = GetTrackTheta();
387 Float_t TrackPhiBefore = GetTrackPhi();
393 DiffNPhotons = abs(HoughPhotonsBefore - GetHoughPhotons());
395 Float_t TrackThetaAfter = GetTrackTheta();
396 Float_t TrackPhiAfter = GetTrackPhi();
398 DiffTrackTheta = TMath::Abs(TrackThetaAfter - TrackThetaBefore);
399 DiffTrackPhi = TMath::Abs(TrackPhiAfter - TrackPhiBefore);
402 cout << " HoughPhotonsBefore " << HoughPhotonsBefore
403 << " GetHoughPhotons() " << GetHoughPhotons();
408 SetFittedThetaCerenkov(GetThetaCerenkov());
409 SetFittedHoughPhotons(GetHoughPhotons());
411 SetTrackTheta(TrackThetaStored);
412 SetTrackPhi(TrackPhiStored);
413 SetThetaCerenkov(ThetaCerenkovStored);
414 SetHoughPhotons(HoughPhotonsStored);
420 if(kDISPLAY) DrawEvent(1);
427 if(kDISPLAY) Display->Print("display.ps");
431 void AliRICHRecon::EndProcessEvent()
433 // function called at the end of the event loop
435 printf("Processed events: %d Total events: %d \n",TotEvents,NevTOT);
441 void AliRICHRecon::PatRec()
444 Float_t TrackTheta = GetTrackTheta();
445 Float_t TrackPhi = GetTrackPhi();
446 Float_t pmod = GetTrackMomentum();
447 // Int_t q = GetTrackCharge();
449 // Int_t TrackIndex = GetTrackIndex();
450 Int_t MipIndex = GetMipIndex();
452 Bool_t kPatRec = kFALSE;
454 Int_t CandidatePhotons = 0;
456 Float_t ShiftX = GetShiftX();
457 Float_t ShiftY = GetShiftY();
459 Float_t* CandidatePhotonX = GetCandidatePhotonX();
460 Float_t* CandidatePhotonY = GetCandidatePhotonY();
462 Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
464 if(fDebug) cout << " n " << CandidatePhotonsNumber << endl;
466 SetThetaCerenkov(999.);
468 SetHoughPhotonsNorm(0);
471 for (Int_t j=0; j < CandidatePhotonsNumber; j++)
480 if (j == MipIndex) continue;
482 // h2_test1->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
484 if(CandidatePhotonX[j] < -64.) continue; /* avoid artificial clusters from edge uesd by Yale.... */
486 Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
487 Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
489 // Float_t chargehit = fHits_charge[j];
490 // if(chargehit > 150) continue;
492 SetEntranceX(Xtoentr);
493 SetEntranceY(Ytoentr);
497 Int_t PhotonStatus = PhotonInBand();
501 cout << " Photon n. " << j << " Status " << PhotonStatus << " accepted " << endl;
502 cout << " CandidatePhotonX[j] " << CandidatePhotonX[j] << " CandidatePhotonY[j] " << CandidatePhotonY[j] << endl;
505 if(PhotonStatus == 0) continue;
509 FindThetaPhotonCerenkov();
511 Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
513 if(fDebug) cout << " theta photon " << ThetaPhotonCerenkov << endl;
515 SetPhotonEta(ThetaPhotonCerenkov);
521 // h2_test4->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
523 // if(kDISPLAY) h1_photons->Fill(ThetaPhotonCerenkov);
527 if(CandidatePhotons >= 1) kPatRec = kTRUE;
531 SetThetaCerenkov(999.);
534 SetPhotonsNumber(CandidatePhotonsNumber);
541 Int_t NPhotonHough = GetHoughPhotons();
545 SetThetaCerenkov(999.);
546 SetHoughPhotonsNorm(0.);
550 if(kWEIGHT) FindWeightThetaCerenkov();
552 Float_t ThetaCerenkov = GetThetaCerenkov();
554 SetThetaOfRing(ThetaCerenkov);
555 FindAreaAndPortionOfRing();
557 Float_t NPhotonHoughNorm = ((Float_t)NPhotonHough)/GetPortionOfRing();
558 SetHoughPhotonsNorm(NPhotonHoughNorm);
560 // Calculate the area where the photon are accepted...
562 Float_t ThetaInternal = ThetaCerenkov - 0.5*fWindowWidth;
563 SetThetaOfRing(ThetaInternal);
564 FindAreaAndPortionOfRing();
565 Float_t InternalArea = GetAreaOfRing();
567 Float_t ThetaExternal = ThetaCerenkov + 0.5*fWindowWidth;
568 SetThetaOfRing(ThetaExternal);
569 FindAreaAndPortionOfRing();
570 Float_t ExternalArea = GetAreaOfRing();
572 Float_t HoughArea = ExternalArea - InternalArea;
574 SetHoughArea(HoughArea);
578 cout << " ----- SUMMARY OF RECONSTRUCTION ----- " << endl;
579 cout << " Rings found " << NRings << " with thetac " << ThetaCerenkov << endl;
581 h1_hough->Fill(ThetaCerenkov,1.);
583 cout << " Nphotons " << GetPhotonsNumber()
584 << " Hough " << NPhotonHough
585 << " norm " << NPhotonHoughNorm << endl;
587 cout << " In PatRec:p " << pmod << " theta " << TrackTheta << " phi " << TrackPhi << endl;
588 cout << " ------------------------------------- " << endl;
591 Int_t NPhotons = GetPhotonsNumber();
597 for (Int_t j=0; j < NPhotons;j++)
601 Float_t eta = GetPhotonEta();
605 if(GetPhotonFlag() == 2)
608 if(pmod>2.5&&ThetaCerenkov>0.65) photris->Fill(eta);
619 xmean /=(Float_t)nev;
620 x2mean /=(Float_t)nev;
626 Float_t RMS = sqrt(x2mean - xmean*xmean);
630 if(fDebug) cout << " RMS " << RMS << endl;
634 void AliRICHRecon::FindEmissionPoint()
637 // Find emission point
639 Float_t absorbtionLenght=7.83*RadiatorWidth; //absorption length in the freon (cm)
640 // 7.83 = -1/ln(T0) where
641 // T0->Trasmission freon at 180nm = 0.88 (Eph=6.85eV)
642 Float_t photonLenght, photonLenghtMin, photonLenghtMax;
644 photonLenght=exp(-RadiatorWidth/(absorbtionLenght*cos(fCerenkovAnglePad)));
645 photonLenghtMin=RadiatorWidth*photonLenght/(1.-photonLenght);
646 photonLenghtMax=absorbtionLenght*cos(fCerenkovAnglePad);
647 Float_t EmissionPoint = RadiatorWidth + photonLenghtMin - photonLenghtMax;
649 SetEmissionPoint(EmissionPoint);
653 Int_t AliRICHRecon::PhotonInBand()
656 // Float_t MassOfParticle;
662 Float_t Xtoentr = GetEntranceX();
663 Float_t Ytoentr = GetEntranceY();
668 Float_t phpad = GetPhiPoint();
670 // Float_t pmod = GetTrackMomentum();
671 // Float_t TrackTheta = GetTrackTheta();
672 // Float_t TrackPhi = GetTrackPhi();
675 SetPhotonEnergy(5.6);
676 SetEmissionPoint(RadiatorWidth -0.0001);
677 SetMassHypotesis(0.93828);
680 SetFreonRefractiveIndex();
682 beta = GetBetaOfParticle();
683 nfreon = GetFreonRefractiveIndex();
685 thetacer = Cerenkovangle(nfreon,beta);
689 if(fDebug) cout << " thetacer in photoninband min " << thetacer << endl;
691 FindThetaAtQuartz(thetacer);
693 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
696 SetXInnerRing(-999.);
697 SetYInnerRing(-999.);
698 SetRadiusInnerRing(-999.);
702 SetThetaPhotonInDRS(GetThetaAtQuartz());
703 SetPhiPhotonInDRS(phpad);
705 InnerRadius = FromEmissionToCathode();
706 if(InnerRadius == 999.) InnerRadius = -999.;
708 SetXInnerRing(GetXPointOnCathode());
709 SetYInnerRing(GetYPointOnCathode());
710 SetRadiusInnerRing(InnerRadius);
714 SetPhotonEnergy(7.7);
715 SetEmissionPoint(0.);
716 // SetMassHypotesis(0.139567);
717 SetMassHypotesis(0.);
720 SetFreonRefractiveIndex();
722 beta = GetBetaOfParticle();
723 nfreon = GetFreonRefractiveIndex();
725 thetacer = Cerenkovangle(nfreon,beta);
729 if(fDebug) cout << " thetacer in photoninband max " << thetacer << endl;
731 FindThetaAtQuartz(thetacer);
733 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
738 SetRadiusOuterRing(999.);
742 SetThetaPhotonInDRS(GetThetaAtQuartz());
743 SetPhiPhotonInDRS(phpad);
745 OuterRadius = FromEmissionToCathode();
746 // cout << " OuterRadius " << OuterRadius << endl;
747 SetXOuterRing(GetXPointOnCathode());
748 SetYOuterRing(GetYPointOnCathode());
749 SetRadiusOuterRing(OuterRadius);
752 Float_t padradius = sqrt(TMath::Power(Xtoentr,2)+TMath::Power(Ytoentr,2));
754 if(fDebug) printf(" rmin %f r %f rmax %f \n",InnerRadius,padradius,OuterRadius);
756 if(padradius>=InnerRadius && padradius<=OuterRadius) return 1;
760 void AliRICHRecon::FindThetaAtQuartz(Float_t ThetaCerenkov)
763 if(ThetaCerenkov == 999.)
765 SetThetaAtQuartz(999.);
769 Float_t ThetaAtQuartz = 999.;
771 Float_t TrackTheta = GetTrackTheta();
773 if(TrackTheta == 0) {
775 if(fDebug) cout << " Theta sol unique " << ThetaCerenkov << endl;
777 ThetaAtQuartz = ThetaCerenkov;
778 SetThetaAtQuartz(ThetaAtQuartz);
782 Float_t TrackPhi = GetTrackPhi();
783 Float_t PhiPoint = GetPhiPoint();
785 Double_t den = TMath::Sin((Double_t)TrackTheta)
786 *TMath::Cos((Double_t)TrackPhi)
787 *TMath::Cos((Double_t)PhiPoint) +
788 TMath::Sin((Double_t)TrackTheta)
789 *TMath::Sin((Double_t)TrackPhi)
790 *TMath::Sin((Double_t)PhiPoint);
791 Double_t b = TMath::Cos((Double_t)TrackTheta)/den;
792 Double_t c = -TMath::Cos((Double_t)ThetaCerenkov)/den;
794 Double_t UnderSqrt = 1 + b*b - c*c;
798 cout << " TrackTheta " << TrackTheta << endl;
799 cout << " TrackPhi " << TrackPhi << endl;
800 cout << " PhiPoint " << PhiPoint << endl;
801 cout << " ThetaCerenkov " << ThetaCerenkov << endl;
802 cout << " den b c " << den << " b " << b << " c " << c << endl;
806 if(fDebug) cout << " sqrt negative !!!!" << UnderSqrt << endl;
807 SetThetaAtQuartz(999.);
811 Double_t sol1 = (1+TMath::Sqrt(UnderSqrt))/(b-c);
812 Double_t sol2 = (1-TMath::Sqrt(UnderSqrt))/(b-c);
814 Double_t ThetaSol1 = 2*TMath::ATan(sol1);
815 Double_t ThetaSol2 = 2*TMath::ATan(sol2);
817 if(fDebug) cout << " Theta sol 1 " << ThetaSol1
818 << " Theta sol 2 " << ThetaSol2 << endl;
820 if(ThetaSol1>0 && ThetaSol1 < pi) ThetaAtQuartz = (Float_t)ThetaSol1;
821 if(ThetaSol2>0 && ThetaSol2 < pi) ThetaAtQuartz = (Float_t)ThetaSol2;
823 SetThetaAtQuartz(ThetaAtQuartz);
826 void AliRICHRecon::FindThetaPhotonCerenkov()
829 Float_t ThetaCerMin = 0.;
830 Float_t ThetaCerMax = 0.75;
831 Float_t ThetaCerMean;
833 Float_t RadiusMin, RadiusMax, RadiusMean;
834 Int_t nIteration = 0;
836 const Float_t Tollerance = 0.05;
838 // Float_t pmod = GetTrackMomentum();
839 // Float_t TrackTheta = GetTrackTheta();
840 // Float_t TrackPhi = GetTrackPhi();
842 Float_t PhiPoint = GetPhiPoint();
844 SetPhotonEnergy(6.85);
845 SetEmissionPoint(RadiatorWidth/2);
847 Float_t XPoint = GetEntranceX();
848 Float_t YPoint = GetEntranceY();
849 Float_t DistPoint = sqrt(XPoint*XPoint + YPoint*YPoint);
851 if(fDebug) cout << " DistPoint " << DistPoint << endl;
853 // Star minimization...
857 FindThetaAtQuartz(ThetaCerMin);
859 if(GetThetaAtQuartz() == 999.)
865 SetThetaPhotonInDRS(GetThetaAtQuartz());
866 SetPhiPhotonInDRS(PhiPoint);
868 RadiusMin = FromEmissionToCathode();
873 FindThetaAtQuartz(ThetaCerMax);
874 if(GetThetaAtQuartz() == 999.)
880 SetThetaPhotonInDRS(GetThetaAtQuartz());
881 SetPhiPhotonInDRS(PhiPoint);
883 RadiusMax = FromEmissionToCathode();
887 ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
889 FindThetaAtQuartz(ThetaCerMean);
890 if(GetThetaAtQuartz() == 999.)
896 SetThetaPhotonInDRS(GetThetaAtQuartz());
897 SetPhiPhotonInDRS(PhiPoint);
899 RadiusMean = FromEmissionToCathode();
902 if(fDebug) cout << " r1 " << RadiusMin << " rmean "
903 << RadiusMean << " r2 " << RadiusMax << endl;
905 while (TMath::Abs(RadiusMean-DistPoint) > Tollerance)
908 if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) < 0) ThetaCerMax = ThetaCerMean;
909 if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) > 0) {
911 ThetaCerMin = ThetaCerMean;
913 FindThetaAtQuartz(ThetaCerMin);
914 SetThetaPhotonInDRS(GetThetaAtQuartz());
915 SetPhiPhotonInDRS(PhiPoint);
917 RadiusMin =FromEmissionToCathode();
920 ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
922 FindThetaAtQuartz(ThetaCerMean);
923 SetThetaPhotonInDRS(GetThetaAtQuartz());
924 SetPhiPhotonInDRS(PhiPoint);
926 RadiusMean = FromEmissionToCathode();
930 if(fDebug) printf(" max iterations in FindPhotonCerenkov\n");
931 SetThetaPhotonCerenkov(999.);
936 SetThetaPhotonCerenkov(ThetaCerMean);
940 void AliRICHRecon::FindAreaAndPortionOfRing()
943 Float_t XPoint[NPointsOfRing], YPoint[NPointsOfRing];
945 // Float_t Xtoentr = GetEntranceX();
946 // Float_t Ytoentr = GetEntranceY();
947 Float_t ShiftX = GetShiftX();
948 Float_t ShiftY = GetShiftY();
950 Float_t XEmiss = GetXCoordOfEmission();
951 Float_t YEmiss = GetYCoordOfEmission();
953 Float_t x0 = XEmiss + ShiftX;
954 Float_t y0 = YEmiss + ShiftY;
956 // Float_t pmod = GetTrackMomentum();
957 // Float_t TrackTheta = GetTrackTheta();
958 // Float_t TrackPhi = GetTrackPhi();
960 SetPhotonEnergy(6.85);
961 SetFreonRefractiveIndex();
963 SetEmissionPoint(RadiatorWidth/2.);
965 Float_t Theta = GetThetaOfRing();
968 Int_t NPsiAccepted = 0;
971 for(Int_t i=0;i<NPointsOfRing-1;i++)
974 Float_t Psi = 2*TMath::Pi()*i/NPointsOfRing;
976 SetThetaPhotonInTRS(Theta);
977 SetPhiPhotonInTRS(Psi);
978 FindPhotonAnglesInDRS();
980 Float_t Radius = FromEmissionToCathode();
981 if (Radius == 999.) continue;
985 Float_t XPointRing = GetXPointOnCathode() + ShiftX;
986 Float_t YPointRing = GetYPointOnCathode() + ShiftY;
988 SetDetectorWhereX(XPointRing);
989 SetDetectorWhereY(YPointRing);
991 Int_t Zone = CheckDetectorAcceptance();
993 // cout << " XPointing " << XPointRing << " YPointing " << YPointRing << " Zone " << Zone << endl;
994 // cout << " ShiftX " << ShiftX << " ShiftY " << ShiftY << endl;
995 // cout << " GetXPointOnCathode() " << GetXPointOnCathode() << endl;
996 // cout << " GetYPointOnCathode() " << GetYPointOnCathode() << endl;
1000 FindIntersectionWithDetector();
1001 XPoint[nPoints] = GetIntersectionX();
1002 YPoint[nPoints] = GetIntersectionY();
1006 XPoint[nPoints] = XPointRing;
1007 YPoint[nPoints] = YPointRing;
1015 XPoint[nPoints] = XPoint[0];
1016 YPoint[nPoints] = YPoint[0];
1022 for (Int_t i = 0; i < nPoints; i++)
1024 Area += TMath::Abs((XPoint[i]-x0)*(YPoint[i+1]-y0) - (XPoint[i+1]-x0)*(YPoint[i]-y0));
1029 Float_t PortionOfRing = ((Float_t)NPsiAccepted)/((Float_t)(NPsiTotal));
1031 // cout << " Area " << Area << " Portion of ring " << PortionOfRing << endl;
1033 SetAreaOfRing(Area);
1034 SetPortionOfRing(PortionOfRing);
1037 void AliRICHRecon::FindIntersectionWithDetector()
1040 Float_t XIntersect, YIntersect;
1041 Float_t x1, x2, y1, y2;
1043 Float_t ShiftX = GetShiftX();
1044 Float_t ShiftY = GetShiftY();
1046 Float_t XPoint = GetXPointOnCathode() + ShiftX;
1047 Float_t YPoint = GetYPointOnCathode() + ShiftY;
1049 Float_t XEmiss = GetXCoordOfEmission();
1050 Float_t YEmiss = GetYCoordOfEmission();
1052 Float_t Phi = GetPhiPhotonInDRS();
1053 Float_t m = tan(Phi);
1055 Float_t x0 = XEmiss + ShiftX;
1056 Float_t y0 = YEmiss + ShiftY;
1080 YIntersect = m*(XIntersect - x0) + y0;
1081 if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
1083 SetIntersectionX(XIntersect);
1084 SetIntersectionY(YIntersect);
1089 YIntersect = m*(XIntersect - x0) + y0;
1090 if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
1092 SetIntersectionX(XIntersect);
1093 SetIntersectionY(YIntersect);
1098 XIntersect = (YIntersect - y0)/m + x0;
1099 if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
1101 SetIntersectionX(XIntersect);
1102 SetIntersectionY(YIntersect);
1107 XIntersect = (YIntersect - y0)/m + x0;
1108 if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
1110 SetIntersectionX(XIntersect);
1111 SetIntersectionY(YIntersect);
1115 cout << " sono fuori!!!!!!" << endl;
1116 // cout << " x1 " << x1 << " x2 " << x2 << endl;
1117 // cout << " y1 " << y1 << " y2 " << y2 << endl;
1118 // cout << " Xmin " << Xmin << " Xmax " << Xmax << endl;
1119 // cout << " Ymin " << Ymin << " Ymax " << Ymax << endl;
1123 Int_t AliRICHRecon::CheckDetectorAcceptance()
1126 // crosses X -2.6 2.6 cm
1127 // crosses Y -1 1 cm
1129 Float_t Xcoord = GetDetectorWhereX();
1130 Float_t Ycoord = GetDetectorWhereY();
1132 // cout << " Xcoord " << Xcoord << " Ycoord " << Ycoord << endl;
1135 if(Ycoord > Ymax) return 2;
1136 if(Ycoord > Ymin && Ycoord < Ymax) return 3;
1137 if(Ycoord < Ymin) return 4;
1141 if(Ycoord > Ymax) return 8;
1142 if(Ycoord > Ymin && Ycoord < Ymax) return 7;
1143 if(Ycoord < Ymin) return 6;
1145 if(Xcoord > Xmin && Xcoord < Xmax)
1147 if(Ycoord > Ymax) return 1;
1148 if(Ycoord > Ymin && Ycoord < Ymax) return 0;
1149 if(Ycoord < Ymin) return 5;
1154 void AliRICHRecon::DrawRing()
1157 // Float_t xGraph[1000],yGraph[1000];
1160 // Float_t MassOfParticle;
1164 Float_t ThetaCerenkov;
1166 // Float_t Xtoentr = GetEntranceX();
1167 // Float_t Ytoentr = GetEntranceY();
1169 // Float_t pmod = GetTrackMomentum();
1170 // Float_t TrackTheta = GetTrackTheta();
1171 // Float_t TrackPhi = GetTrackPhi();
1173 SetPhotonEnergy(6.85);
1174 SetFreonRefractiveIndex();
1176 SetEmissionPoint(RadiatorWidth/2.);
1182 SetMassHypotesis(0.139567);
1183 SetBetaOfParticle();
1185 beta = GetBetaOfParticle();
1190 ThetaCerenkov = GetThetaCerenkov();
1191 FindBetaFromTheta(ThetaCerenkov);
1194 nfreon = GetFreonRefractiveIndex();
1196 Float_t thetacer = Cerenkovangle(nfreon,beta);
1198 if(fDebug) cout << " TetaCer in DrawRing " << thetacer << endl;
1200 Int_t nPoints = 100;
1202 Int_t nPointsToDraw = 0;
1203 for(Int_t i=0;i<nPoints;i++)
1205 Float_t phpad = 2*TMath::Pi()*i/nPoints;
1206 SetThetaPhotonInTRS(thetacer);
1207 SetPhiPhotonInTRS(phpad);
1208 FindPhotonAnglesInDRS();
1209 Float_t Radius = FromEmissionToCathode();
1210 if (Radius == 999.) continue;
1211 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
1212 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
1213 // cout << " get shift X " << GetShiftX() << endl;
1214 // cout << " get shift Y " << GetShiftY() << endl;
1219 if(fDebug) cout << " Drawing the Ring... with " << nPointsToDraw << " points " << endl;
1221 // pol = new TPolyLine(nPointsToDraw,xGraph,yGraph);
1222 // pol->Draw("same");
1223 gra = new TGraph(nPointsToDraw,xGraph,yGraph);
1225 StarCanvas->Update();
1229 Float_t AliRICHRecon::PhotonPositionOnCathode()
1231 // Float_t MassOfParticle;
1235 // Float_t pmod = GetTrackMomentum();
1236 // Float_t TrackTheta = GetTrackTheta();
1237 // Float_t TrackPhi = GetTrackPhi();
1239 // Float_t phpad = GetPhiPoint();
1241 SetPhotonEnergy(6.85);
1242 SetEmissionPoint(RadiatorWidth/2.);
1243 SetMassHypotesis(0.139567);
1245 SetBetaOfParticle();
1246 SetFreonRefractiveIndex();
1248 beta = GetBetaOfParticle();
1249 nfreon = GetFreonRefractiveIndex();
1251 // Float_t thetacer = Cerenkovangle(nfreon,beta);
1253 // cout << " FromEmissionToCathode: thetacer " << thetacer << " phpad " << phpad << endl;
1255 Float_t Radius = FromEmissionToCathode();
1256 if (Radius == 999.) return 999.;
1258 // Float_t Xphoton = GetXPointOnCathode();
1259 // Float_t Yphoton = GetYPointOnCathode();
1260 // cout << " PhotonPositionOnCathode: Xphoton " << Xphoton << " Yphoton " << Yphoton <<
1261 // " Radius for photon " << Radius << endl;
1265 void AliRICHRecon::FindPhotonAnglesInDRS()
1267 // Setup the rotation matrix of the track...
1274 Float_t TrackTheta = GetTrackTheta();
1275 Float_t TrackPhi = GetTrackPhi();
1277 Mtheta.RotateY(TrackTheta);
1278 Mphi.RotateZ(TrackPhi);
1280 Mrot = Mphi * Mtheta;
1281 // Minv = Mrot.Inverse();
1283 TVector3 PhotonInRadiator(1,1,1);
1285 Float_t ThetaCerenkov = GetThetaPhotonInTRS();
1286 Float_t PhiCerenkov = GetPhiPhotonInTRS();
1288 PhotonInRadiator.SetTheta(ThetaCerenkov);
1289 PhotonInRadiator.SetPhi(PhiCerenkov);
1290 PhotonInRadiator = Mrot * PhotonInRadiator;
1291 Float_t Theta = PhotonInRadiator.Theta();
1292 Float_t Phi = PhotonInRadiator.Phi();
1293 SetThetaPhotonInDRS(Theta);
1294 SetPhiPhotonInDRS(Phi);
1298 Float_t AliRICHRecon::FromEmissionToCathode()
1301 Float_t nfreon, nquartz, ngas;
1303 SetFreonRefractiveIndex();
1304 SetQuartzRefractiveIndex();
1305 SetGasRefractiveIndex();
1307 nfreon = GetFreonRefractiveIndex();
1308 nquartz = GetQuartzRefractiveIndex();
1309 ngas = GetGasRefractiveIndex();
1311 Float_t TrackTheta = GetTrackTheta();
1312 Float_t TrackPhi = GetTrackPhi();
1313 Float_t LengthOfEmissionPoint = GetEmissionPoint();
1315 Float_t Theta = GetThetaPhotonInDRS();
1316 Float_t Phi = GetPhiPhotonInDRS();
1318 // cout << " Theta " << Theta << " Phi " << Phi << endl;
1320 Float_t xEmiss = LengthOfEmissionPoint*tan(TrackTheta)*cos(TrackPhi);
1321 Float_t yEmiss = LengthOfEmissionPoint*tan(TrackTheta)*sin(TrackPhi);
1323 SetXCoordOfEmission(xEmiss);
1324 SetYCoordOfEmission(yEmiss);
1326 Float_t thetaquar = SnellAngle(nfreon, nquartz, Theta);
1328 if(thetaquar == 999.)
1330 SetXPointOnCathode(999.);
1331 SetYPointOnCathode(999.);
1335 Float_t thetagap = SnellAngle( nquartz, ngas, thetaquar);
1337 if(thetagap == 999.)
1339 SetXPointOnCathode(999.);
1340 SetYPointOnCathode(999.);
1344 Float_t xw = (RadiatorWidth - LengthOfEmissionPoint)*cos(Phi)*tan(Theta);
1345 Float_t xq = QuartzWidth*cos(Phi)*tan(thetaquar);
1346 Float_t xg = GapWidth*cos(Phi)*tan(thetagap);
1347 Float_t yw = (RadiatorWidth - LengthOfEmissionPoint)*sin(Phi)*tan(Theta);
1348 Float_t yq = QuartzWidth*sin(Phi)*tan(thetaquar);
1349 Float_t yg = GapWidth*sin(Phi)*tan(thetagap);
1351 // Float_t xtot = x1 + xw + xq + xg;
1352 // Float_t ytot = y1 + yw + yq + yg;
1354 Float_t xtot = xEmiss + xw + xq + xg;
1355 Float_t ytot = yEmiss + yw + yq + yg;
1357 SetXPointOnCathode(xtot);
1358 SetYPointOnCathode(ytot);
1360 // cout << " xtot " << xtot << " ytot " << ytot << endl;
1362 Float_t DistanceFromEntrance = sqrt(TMath::Power(fPhotonLimitX,2)
1363 +TMath::Power(fPhotonLimitY,2));
1365 return DistanceFromEntrance;
1370 void AliRICHRecon::FindPhiPoint()
1373 Float_t Xtoentr = GetEntranceX();
1374 Float_t Ytoentr = GetEntranceY();
1376 Float_t TrackTheta = GetTrackTheta();
1377 Float_t TrackPhi = GetTrackPhi();
1379 Float_t EmissionPoint = GetEmissionPoint();
1381 Float_t argY = Ytoentr - EmissionPoint*tan(TrackTheta)*sin(TrackPhi);
1382 Float_t argX = Xtoentr - EmissionPoint*tan(TrackTheta)*cos(TrackPhi);
1383 Float_t phipad = atan2(argY,argX);
1385 SetPhiPoint(phipad);
1389 Float_t AliRICHRecon::Cerenkovangle(Float_t n, Float_t beta)
1392 // Compute the cerenkov angle
1398 // cout << " warning in Cerenkoangle !!!!!! " << endl;
1402 thetacer = acos (1./(n*beta));
1406 Float_t AliRICHRecon::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
1409 // Compute the Snell angle
1411 Float_t sinrefractangle;
1412 Float_t refractangle;
1414 sinrefractangle = (n1/n2)*sin(theta1);
1416 if(sinrefractangle>1.) {
1417 // cout << " PROBLEMS IN SNELL ANGLE !!!!! " << endl;
1418 refractangle = 999.;
1419 return refractangle;
1422 refractangle = asin(sinrefractangle);
1423 return refractangle;
1427 void AliRICHRecon::HoughResponse()
1431 // Implement Hough response pat. rec. method
1438 int i, j, k, nCorrBand;
1439 float hcs[750],hcsw[750];
1440 float angle, weight;
1441 float lowerlimit,upperlimit;
1447 float etaPeakPos = -1;
1449 Int_t etaPeakCount = -1;
1451 Float_t ThetaCerenkov = 0.;
1453 nBin = (int)(0.5+fThetaMax/(fDTheta));
1454 nCorrBand = (int)(0.5+ fWindowWidth/(2 * fDTheta));
1456 memset ((void *)hcs, 0, fThetaBin*sizeof(float));
1457 memset ((void *)hcsw, 0, fThetaBin*sizeof(float));
1459 Int_t NPhotons = GetPhotonsNumber();
1461 Int_t WeightFlag = 0;
1463 for (k=0; k< NPhotons; k++) {
1467 angle = GetPhotonEta();
1469 if(angle == -999.) continue;
1471 if (angle>=fThetaMin && angle<= fThetaMax)
1475 bin = (int)(0.5+angle/(fDTheta));
1477 bin1= bin-nCorrBand;
1478 bin2= bin+nCorrBand;
1480 // calculate weights
1484 lowerlimit = ((Float_t)bin1)*fDTheta + 0.5*fDTheta;
1485 SetThetaOfRing(lowerlimit);
1486 FindAreaAndPortionOfRing();
1487 Float_t area1 = GetAreaOfRing();
1489 upperlimit = ((Float_t)bin2)*fDTheta + 0.5*fDTheta;
1490 SetThetaOfRing(upperlimit);
1491 FindAreaAndPortionOfRing();
1492 Float_t area2 = GetAreaOfRing();
1494 // cout << "lowerlimit" << lowerlimit << "upperlimit " << upperlimit << endl;
1495 Float_t diffarea = area2 - area1;
1499 weight = 1./(area2-area1);
1507 // cout <<" low "<< lowerlimit << " up " << upperlimit <<
1508 // " area1 " << area1 << " area2 " << area2 << " weight " << weight << endl;
1516 SetPhotonWeight(weight);
1518 // cout << "weight..." << weight << endl;
1520 h1_photons1->Fill(angle);
1521 h1_photons2->Fill(angle,weight);
1524 if (bin2>nBin) bin2=nBin;
1526 for (j=bin1; j<bin2; j++)
1536 // for(Int_t j=0;j<750;j++)
1538 // h1_hcs->Fill(((Float_t)j),hcs[j]);
1539 // h1_hcsw->Fill(((Float_t)j),hcsw[j]);
1550 // cout << " probems with weight...normal procedure adopted " << endl;
1553 HoughFiltering(HCSspace);
1555 for (bin=0; bin <nBin; bin++) {
1556 angle = (bin+0.5) * (fDTheta);
1557 if (HCSspace[bin] && HCSspace[bin] > etaPeakPos) {
1559 etaPeakPos = HCSspace[bin];
1563 if (HCSspace[bin] == etaPeakPos) {
1564 etaPeak[++etaPeakCount] = angle;
1569 for (i=0; i<etaPeakCount+1; i++) {
1570 ThetaCerenkov += etaPeak[i];
1572 if (etaPeakCount>=0) {
1573 ThetaCerenkov /= etaPeakCount+1;
1574 fThetaPeakPos = etaPeakPos;
1577 SetThetaCerenkov(ThetaCerenkov);
1581 void AliRICHRecon::HoughFiltering(float hcs[])
1587 float k[5] = {0.05, 0.25, 0.4, 0.25, 0.05};
1592 nBin = (int)(1+fThetaMax/fDTheta);
1593 sizeHCS = fThetaBin*sizeof(float);
1595 memset ((void *)hcsFilt, 0, sizeHCS);
1597 for (nx = 0; nx < nBin; nx++) {
1598 for (i = 0; i < 5; i++) {
1600 if (nxDx> -1 && nxDx<nBin)
1601 hcsFilt[nx] += hcs[nxDx] * k[i];
1605 for (nx = 0; nx < nBin; nx++) {
1606 hcs[nx] = hcsFilt[nx];
1610 void AliRICHRecon::FindWeightThetaCerenkov()
1614 Float_t WeightThetaCerenkov = 0.;
1616 Int_t NPhotons = GetPhotonsNumber();
1617 for(Int_t i=0;i<NPhotons;i++)
1621 if(GetPhotonFlag() == 2)
1623 Float_t PhotonEta = GetPhotonEta();
1624 Float_t PhotonWeight = GetPhotonWeight();
1625 WeightThetaCerenkov += PhotonEta*PhotonWeight;
1626 wei += PhotonWeight;
1632 WeightThetaCerenkov /= wei;
1636 WeightThetaCerenkov = 0.;
1639 SetThetaCerenkov(WeightThetaCerenkov);
1641 cout << " thetac weighted -> " << WeightThetaCerenkov << endl;
1645 void AliRICHRecon::FlagPhotons()
1648 Int_t NPhotonHough = 0;
1650 Float_t ThetaCerenkov = GetThetaCerenkov();
1651 if(fDebug) cout << " fThetaCerenkov " << ThetaCerenkov << endl;
1653 Float_t ThetaDist= ThetaCerenkov - fThetaMin;
1654 Int_t steps = (Int_t)(ThetaDist / fDTheta);
1656 Float_t tmin = fThetaMin + (Float_t)(steps - 1)*fDTheta;
1657 Float_t tmax = fThetaMin + (Float_t)(steps)*fDTheta;
1658 Float_t tavg = 0.5*(tmin+tmax);
1660 tmin = tavg - 0.5*fWindowWidth;
1661 tmax = tavg + 0.5*fWindowWidth;
1663 if(fDebug) cout << " tmin " << tmin << " tmax " << tmax << endl;
1664 if(fDebug) cout << " thetac " << ThetaCerenkov << endl;
1666 // Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
1668 Int_t NPhotons = GetPhotonsNumber();
1670 // for(Int_t i=0;i<CandidatePhotonsNumber;i++)
1672 for(Int_t i=0;i<NPhotons;i++)
1676 Float_t PhotonEta = GetPhotonEta();
1678 if(PhotonEta == -999.) continue;
1680 if(PhotonEta >= tmin && PhotonEta <= tmax)
1686 SetHoughPhotons(NPhotonHough);
1689 void AliRICHRecon::DrawEvent(Int_t flag)
1692 flag=1; // dummy to be removed...
1694 Float_t xGraph[3000],yGraph[3000];
1696 Float_t ThetaCerenkov;
1700 gStyle->SetPalette(1,0);
1705 // Display = new TCanvas("Display","Star Display",0,0,1200,750);
1707 Display->ToggleEventStatus();
1710 text = new TText(0,0,"");
1711 text->SetTextFont(61);
1712 text->SetTextSize(0.03);
1713 text->SetTextAlign(22);
1719 for(Int_t j=1;j<=nPixels;j++)
1721 Float_t xpad = fPixels_localX[j-1];
1722 Float_t ypad = fPixels_localY[j-1];
1723 h2_disp->Fill(xpad,ypad,fPixels_charge[j-1]);
1726 h2_disp->SetMaximum(200);
1727 // h2_disp->SetMaximum(1);
1728 h2_disp->SetStats(0);
1729 h2_disp->Draw("colz");
1731 for(Int_t i=0; i<nRichPrimaries;i++)
1735 TrackPoints = new TMarker(fRichPrimaries_localPadX[i],
1736 fRichPrimaries_localPadY[i],3);
1738 TrackPoints->SetMarkerSize(1.5);
1740 Float_t pmod = sqrt(fRichPrimaries_localPadPx[i] * fRichPrimaries_localPadPx[i] +
1741 fRichPrimaries_localPadPy[i] * fRichPrimaries_localPadPy[i] +
1742 fRichPrimaries_localPadPz[i] * fRichPrimaries_localPadPz[i]);
1744 if(pmod < 1) TrackPoints->SetMarkerColor(kBlue);
1745 if(pmod > 1 && pmod < 2) TrackPoints->SetMarkerColor(kGreen);
1746 if(pmod > 2) TrackPoints->SetMarkerColor(kRed);
1748 TrackPoints->Draw();
1750 line = new TLine(-0.13,-42.,-0.13,42.);
1752 line = new TLine(0.13,-42.,0.13,42.);
1754 line = new TLine(-64.,-0.13,64.,-0.13);
1756 line = new TLine(-64.,0.13,64.,0.13);
1771 // Float_t Xtoentr = GetEntranceX();
1772 // Float_t Ytoentr = GetEntranceY();
1774 // Float_t pmod = GetTrackMomentum();
1775 // Float_t TrackTheta = GetTrackTheta();
1776 // Float_t TrackPhi = GetTrackPhi();
1778 SetPhotonEnergy(6.85);
1779 SetFreonRefractiveIndex();
1781 SetEmissionPoint(RadiatorWidth/2.);
1783 ThetaCerenkov = GetThetaCerenkov();
1785 if (ThetaCerenkov == 999.) return;
1787 Int_t nPointsToDraw = 0;
1789 for(Int_t i=0;i<99;i++)
1791 Float_t phpad = 2*TMath::Pi()*i/99;
1792 SetThetaPhotonInTRS(ThetaCerenkov);
1793 SetPhiPhotonInTRS(phpad);
1794 FindPhotonAnglesInDRS();
1795 Float_t Radius = FromEmissionToCathode();
1797 if (Radius == 999.) continue;
1799 Float_t ShiftX = GetShiftX();
1800 Float_t ShiftY = GetShiftY();
1802 Float_t XPointRing = GetXPointOnCathode() + ShiftX;
1803 Float_t YPointRing = GetYPointOnCathode() + ShiftY;
1805 SetDetectorWhereX(XPointRing);
1806 SetDetectorWhereY(YPointRing);
1808 Int_t Zone = CheckDetectorAcceptance();
1812 FindIntersectionWithDetector();
1813 xGraph[nPointsToDraw] = GetIntersectionX();
1814 yGraph[nPointsToDraw] = GetIntersectionY();
1819 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
1820 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
1825 xGraph[nPointsToDraw] = xGraph[0];
1826 yGraph[nPointsToDraw] = yGraph[0];
1828 poll = new TPolyLine(nPointsToDraw+1,xGraph,yGraph);
1829 poll->SetLineColor(2);
1830 poll->SetLineWidth(3);
1837 for(Int_t j=0;j<nHits;j++)
1840 Float_t xhit = fHits_localX[j];
1841 Float_t yhit = fHits_localY[j];
1844 Int_t FlagPhoton = GetPhotonFlag();
1846 // if(FlagPhoton >= 1)
1849 // Photon = new TMarker(xhit,yhit,4);
1850 // Photon->SetMarkerSize(1.5);
1851 // Photon->Draw("same");
1859 PhotonAcc = new TMarker(xhit,yhit,30);
1860 PhotonAcc->SetMarkerSize(1.5);
1861 PhotonAcc->SetMarkerColor(50);
1862 PhotonAcc->Draw("same");
1870 // h1_photons->Draw();
1871 // Display->Update();
1874 // h1_photacc->Draw();
1875 // Display->Update();
1879 // Display->Update();
1881 // h1_photons->Reset();
1882 // h1_photacc->Reset();
1887 Float_t AliRICHRecon::FindMassOfParticle()
1890 Float_t pmod = GetTrackMomentum();
1892 SetPhotonEnergy(6.85);
1893 SetFreonRefractiveIndex();
1895 Float_t ThetaCerenkov = GetThetaCerenkov();
1896 FindBetaFromTheta(ThetaCerenkov);
1898 Double_t beta = (Double_t)(GetBetaOfParticle());
1899 Double_t den = 1. - beta*beta;
1900 if(den<=0.) return 999.;
1902 Double_t gamma = 1./TMath::Sqrt(den);
1904 Float_t mass = pmod/(beta*(Float_t)gamma);
1910 void AliRICHRecon::FillHistograms()
1913 Float_t FittedTrackTheta, FittedTrackPhi;
1915 Float_t ThetaCerenkov = GetThetaCerenkov();
1916 if(ThetaCerenkov == 999.) return;
1918 Float_t VertZ = GetEventVertexZ();
1920 Float_t TrackTheta = GetTrackTheta();
1921 Float_t TrackPhi = GetTrackPhi();
1922 Float_t pmod = GetTrackMomentum();
1923 Float_t pt = GetTrackPt();
1924 Float_t TrackEta = GetTrackEta();
1925 Int_t q = GetTrackCharge();
1926 Float_t TPCLastZ = GetTrackTPCLastZ();
1927 Float_t MinDist = GetMinDist();
1929 FittedTrackTheta = GetFittedTrackTheta();
1930 FittedTrackPhi = GetFittedTrackPhi();
1931 Int_t FittedNPhotonHough = GetFittedHoughPhotons();
1935 cout << " p " << pmod << " ThetaC " << ThetaCerenkov
1936 << " rings " << NRings << endl;
1939 Int_t NPhotonHough = GetHoughPhotons();
1940 Float_t NPhotonHoughNorm = GetHoughPhotonsNorm();
1941 Float_t InRing = GetPortionOfRing();
1943 Float_t MassOfParticle = FindMassOfParticle();
1945 Float_t HoughArea = GetHoughArea();
1946 Float_t Multiplicity = GetEventMultiplicity();
1948 // cout << " area " << HoughArea << " mult " << Multiplicity << endl;
1952 // var[0] = (Float_t)runID;
1953 // var[1] = (Float_t)evID;
1960 var[6] = TrackTheta;
1962 var[8] = FittedTrackTheta;
1963 var[9] = FittedTrackPhi;
1965 var[11] = ThetaCerenkov;
1966 var[12] = (Float_t)NPhotonHough;
1967 var[13] = (Float_t)FittedNPhotonHough;
1969 var[15] = MassOfParticle;
1970 var[16] = HoughArea;
1971 var[17] = Multiplicity;
1977 h1_mass->Fill(MassOfParticle);
1978 h2_mvsp->Fill(pmod,MassOfParticle);
1979 h2_mvst->Fill(ThetaCerenkov,MassOfParticle);
1981 FittedTrackTheta = GetFittedTrackTheta();
1982 FittedTrackPhi = GetFittedTrackPhi();
1984 Float_t DiffTheta = FittedTrackTheta - TrackTheta;
1985 Float_t DiffPhi = FittedTrackPhi - TrackPhi;
1987 h1_diffTrackTheta -> Fill(DiffTheta);
1988 h1_diffTrackPhi -> Fill(DiffPhi);
1990 if(ThetaCerenkov > 0.505 && ThetaCerenkov < 0.605)
1992 SetPhotonEnergy(6.85);
1993 SetFreonRefractiveIndex();
1995 Float_t pmom = GetTrackMomentum();
1996 Float_t beta = 1./(cos(ThetaCerenkov)*GetFreonRefractiveIndex());
1997 Float_t gamma = 1./sqrt(1.-beta*beta);
1999 Float_t pmomnew = 0.93828*beta*gamma;
2000 Float_t deltap = pmomnew - pmom;
2001 h1_deltap->Fill(deltap);
2002 Float_t deltapop = deltap/pmom;
2003 h1_deltapop->Fill(deltapop);
2005 h1_nprotons->Fill((Float_t)NPhotonHoughNorm);
2010 h2_tvsppos->Fill(pmod,ThetaCerenkov);
2011 hp_1pos->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
2012 hp_1posnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
2013 h2_1pos->Fill(pmod,(Float_t)NPhotonHough);
2014 h2_1posnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
2015 h1_houghpos->Fill(ThetaCerenkov);
2019 h2_tvspneg->Fill(pmod,ThetaCerenkov);
2020 hp_1neg->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
2021 hp_1negnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
2022 h2_1neg->Fill(pmod,(Float_t)NPhotonHough);
2023 h2_1negnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
2024 h1_houghneg->Fill(ThetaCerenkov);
2027 Int_t NPhotons = GetPhotonsNumber();
2029 for (Int_t j=0; j < NPhotons;j++)
2034 Float_t eta = GetPhotonEta();
2036 if(GetPhotonFlag() == 2)
2038 h1_photacc->Fill(eta);
2039 Float_t photaccspread = eta - ThetaCerenkov;
2040 h1_photaccspread->Fill(photaccspread);
2046 void AliRICHRecon::Minimization()
2052 static Double_t vstart[2];
2053 static Double_t lower[2], upper[2];
2054 static Double_t step[2]={0.001,0.001};
2056 Double_t TrackThetaNew,TrackPhiNew;
2058 Double_t eps, b1, b2;
2061 gMyMinuit = new TMinuit(2);
2062 gMyMinuit->SetObjectFit((TObject *)this);
2063 gMyMinuit->SetFCN(fcn);
2064 gMyMinuit->mninit(5,10,7);
2066 vstart[0] = (Double_t)GetTrackTheta();
2067 vstart[1] = (Double_t)GetTrackPhi();
2069 lower[0] = vstart[0] - 0.03;
2070 if(lower[0] < 0) lower[0] = 0.;
2071 upper[0] = vstart[0] + 0.03;
2072 lower[1] = vstart[1] - 0.03;
2073 upper[1] = vstart[1] + 0.03;
2076 gMyMinuit->mnparm(0,"theta",vstart[0],step[0],lower[0],upper[0],ierflag);
2077 gMyMinuit->mnparm(1," phi ",vstart[1],step[1],lower[1],upper[1],ierflag);
2081 // gMyMinuit->FixParameter(0);
2083 gMyMinuit->SetPrintLevel(-1);
2084 // gMyMinuit->mnexcm("SET PRI",&arglist, 1, ierflag);
2085 gMyMinuit->mnexcm("SET NOGR",&arglist, 1, ierflag);
2086 gMyMinuit->mnexcm("SET NOW",&arglist, 1, ierflag);
2088 gMyMinuit->mnexcm("SET ERR", &arglist, 1,ierflg);
2091 // gMyMinuit->mnscan();
2093 // gMyMinuit->mnexcm("SIMPLEX",&arglist, 0, ierflag);
2094 gMyMinuit->mnexcm("MIGRAD",&arglist, 0, ierflag);
2095 gMyMinuit->mnexcm("EXIT" ,&arglist, 0, ierflag);
2097 gMyMinuit->mnpout(0,chname, TrackThetaNew, eps , b1, b2, ierflg);
2098 gMyMinuit->mnpout(1,chname, TrackPhiNew, eps , b1, b2, ierflg);
2100 //values after the fit...
2101 SetFittedTrackTheta((Float_t)TrackThetaNew);
2102 SetFittedTrackPhi((Float_t)TrackPhiNew);
2108 void AliRICHRecon::EstimationOfTheta()
2113 Float_t ShiftX = GetShiftX();
2114 Float_t ShiftY = GetShiftY();
2116 Float_t *CandidatePhotonX = GetCandidatePhotonX();
2117 Float_t *CandidatePhotonY = GetCandidatePhotonY();
2119 Int_t NPhotonsCandidates = GetCandidatePhotonsNumber();
2121 // cout << "MINIM: Nphotons " << NPhotonsCandidates << endl;
2123 for (Int_t j=0; j < NPhotonsCandidates; j++)
2128 if(!GetPhotonFlag()) continue;
2130 Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
2131 Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
2133 SetEntranceX(Xtoentr);
2134 SetEntranceY(Ytoentr);
2138 FindThetaPhotonCerenkov();
2140 Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
2142 // cout << " ACCEPTED!!! " << ThetaPhotonCerenkov << endl;
2144 SetPhotonEta(ThetaPhotonCerenkov);
2151 Float_t x2mean = 0.;
2154 for (Int_t j=0; j < NPhotonsCandidates;j++)
2158 Float_t eta = GetPhotonEta();
2162 if(GetPhotonFlag() == 2)
2173 xmean /=(Float_t)nev;
2174 x2mean /=(Float_t)nev;
2180 Float_t RMS = sqrt(x2mean - xmean*xmean);
2182 // cout << " RMS " << RMS;
2184 SetEstimationOfTheta(xmean);
2185 SetEstimationOfThetaRMS(RMS);
2188 void fcn(Int_t /*&npar*/, Double_t* /*gin*/, Double_t &f, Double_t *par, Int_t iflag)
2190 AliRICHRecon *gMyRecon = (AliRICHRecon*)gMyMinuit->GetObjectFit();
2192 Float_t p0 = (Float_t)par[0];
2193 Float_t p1 = (Float_t)par[1];
2195 gMyRecon->SetTrackTheta(p0);
2196 gMyRecon->SetTrackPhi(p1);
2198 gMyRecon->EstimationOfTheta();
2199 Float_t RMS = gMyRecon->GetEstimationOfThetaRMS();
2201 Int_t HoughPhotons = gMyRecon->GetHoughPhotons();
2204 f = (Double_t)(1000*RMS/(Float_t)HoughPhotons);
2206 if(fDebug) cout << " f " << f
2207 << " theta " << par[0] << " phi " << par[1]
2208 << " HoughPhotons " << HoughPhotons << endl;
2210 if(fDebug&&iflag == 3)
2212 cout << " --- end convergence...summary --- " << endl;
2213 cout << " theta " << par[0] << endl;
2214 cout << " phi " << par[1] << endl;
2218 void AliRICHRecon::waiting()
2220 if(!kDISPLAY) return;
2221 cout << " Press any key to continue...";
2223 // gSystem->ProcessEvents();
2232 void ~AliRICHRecon()