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);
238 Rich()->GetLoader()->LoadHits();
239 Rich()->GetLoader()->LoadRecPoints();
240 Rich()->GetLoader()->LoadDigits();
241 gAlice->GetRunLoader()->LoadHeader();
242 gAlice->GetRunLoader()->LoadKinematics();
244 Rich()->GetLoader()->TreeR()->GetEntry(0);
246 Float_t clusX[7][500],clusY[7][500];
250 for (Int_t ich=0;ich<7;ich++) {
251 nClusters[ich] = Rich()->ClustersOld(ich+1)->GetEntries();
252 for(Int_t k=0;k<nClusters[ich];k++) {
253 AliRICHRawCluster *pCluster = (AliRICHRawCluster *)Rich()->ClustersOld(ich+1)->At(k);
254 clusX[ich][k] = pCluster->fX;
255 clusY[ich][k] = pCluster->fY;
256 clusQ[ich][k] = pCluster->fQ;
257 // pCluster->Print();
261 Int_t nPrimaries = (Int_t)Rich()->GetLoader()->TreeH()->GetEntries();
263 cout << " N. primaries " << nPrimaries << endl;
265 for(Int_t i=0;i<nPrimaries;i++){
267 Rich()->GetLoader()->TreeH()->GetEntry(i);
269 Rich()->Hits()->Print();
274 for(Int_t j=0;j<Rich()->Hits()->GetEntries();j++) {
276 pHit = (AliRICHhit*)Rich()->Hits()->At(j);
277 if(pHit->GetTrack() < nPrimaries) break;
281 cout << " iPrim " << iPrim << endl;
282 // if(iPrim==0) return;
283 // if(iPrim>1) Fatal("StartProcessEvent"," problems with prim to hit!!! = %3i", iPrim);
285 TParticle *pParticle = gAlice->GetRunLoader()->Stack()->Particle(pHit->GetTrack());
286 Float_t pmod = pParticle->P();
287 Float_t pt = pParticle->Pt();
288 Float_t TrackEta = pParticle->Eta();
289 Int_t q = (Int_t)TMath::Sign(1.,pParticle->GetPDG()->Charge());
293 cout << " pmod " << pmod << " pt " << pt << " Eta " << TrackEta << " charge " << q << endl;
295 SetTrackMomentum(pmod);
297 SetTrackEta(TrackEta);
300 TVector3 pGlob(pHit->MomFreoX(),pHit->MomFreoY(),pHit->MomFreoZ());
301 TVector3 pLocal = Rich()->C(pHit->Chamber())->Global2Local(pGlob,1);
303 Float_t primGlobalX = pHit->X();
304 Float_t primGlobalY = pHit->Y();
305 Float_t primGlobalZ = pHit->Z();
306 TVector3 primGlobal(primGlobalX,primGlobalY,primGlobalZ);
307 TVector3 primLocal = Rich()->C(pHit->Chamber())->Global2Local(primGlobal);
309 // Float_t pmodFreo = pLocal.Mag();
310 Float_t TrackTheta = pLocal.Theta();
311 Float_t TrackPhi = pLocal.Phi();
313 cout << " TrackTheta " << TrackTheta << " TrackPhi " << TrackPhi << endl;
315 SetTrackTheta(TrackTheta);
316 SetTrackPhi(TrackPhi);
319 Float_t MinDist = 999.;
321 cout << " n Clusters " << nClusters[pHit->Chamber()-1] << " for chamber n. " << pHit->Chamber() << endl;
323 for(Int_t j=0;j<nClusters[pHit->Chamber()-1];j++)
325 Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][j];
326 Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][j];
328 cout << " cluster x " << clusX[pHit->Chamber()-1][j] << " hit track x " << primLocal.X();
329 cout << " cluster y " << clusY[pHit->Chamber()-1][j] << " hit track y " << primLocal.Y() << endl;
331 Float_t diff = sqrt(diffx*diffx + diffy*diffy);
341 Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][MaxInd];
342 Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][MaxInd];
344 cout << " diffx " << diffx << " diffy " << diffy << endl;
348 h2_diffpos->Fill(diffx,diffy);
350 h2_diffneg->Fill(diffx,diffy);
356 Float_t ShiftX = primLocal.X()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.X();
357 Float_t ShiftY = primLocal.Y()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.Y();
362 Float_t *pclusX = &clusX[pHit->Chamber()-1][0];
363 Float_t *pclusY = &clusY[pHit->Chamber()-1][0];
365 SetCandidatePhotonX(pclusX);
366 SetCandidatePhotonY(pclusY);
367 SetCandidatePhotonsNumber(nClusters[pHit->Chamber()-1]);
369 Int_t qch = clusQ[pHit->Chamber()-1][MaxInd];
371 if(MinDist < 3.0 && qch > 120 && MaxInd !=0)
377 Float_t Xrndm = Xmin + (Xmax-Xmin)*gRandom->Rndm(280964);
378 Float_t Yrndm = Ymin + (Ymax-Ymin)*gRandom->Rndm(280964);
380 cout << " Xrndm " << Xrndm << " Yrndm " << Yrndm << endl;
389 TrackThetaStored = GetTrackTheta();
390 TrackPhiStored = GetTrackPhi();
391 ThetaCerenkovStored = GetThetaCerenkov();
392 HoughPhotonsStored = GetHoughPhotons();
394 Int_t DiffNPhotons = 999;
396 Float_t DiffTrackTheta = 999.;
397 Float_t DiffTrackPhi = 999.;
399 while( kMINIMIZER && GetHoughPhotons() > 2
401 && DiffTrackTheta > 0.0001
405 Int_t HoughPhotonsBefore = GetHoughPhotons();
407 Float_t TrackThetaBefore = GetTrackTheta();
408 Float_t TrackPhiBefore = GetTrackPhi();
414 DiffNPhotons = abs(HoughPhotonsBefore - GetHoughPhotons());
416 Float_t TrackThetaAfter = GetTrackTheta();
417 Float_t TrackPhiAfter = GetTrackPhi();
419 DiffTrackTheta = TMath::Abs(TrackThetaAfter - TrackThetaBefore);
420 DiffTrackPhi = TMath::Abs(TrackPhiAfter - TrackPhiBefore);
423 cout << " HoughPhotonsBefore " << HoughPhotonsBefore
424 << " GetHoughPhotons() " << GetHoughPhotons();
429 SetFittedThetaCerenkov(GetThetaCerenkov());
430 SetFittedHoughPhotons(GetHoughPhotons());
432 SetTrackTheta(TrackThetaStored);
433 SetTrackPhi(TrackPhiStored);
434 SetThetaCerenkov(ThetaCerenkovStored);
435 SetHoughPhotons(HoughPhotonsStored);
441 if(kDISPLAY) DrawEvent(1);
448 if(kDISPLAY) Display->Print("display.ps");
452 void AliRICHRecon::EndProcessEvent()
454 // function called at the end of the event loop
456 printf("Processed events: %d Total events: %d \n",TotEvents,NevTOT);
462 void AliRICHRecon::PatRec()
465 Float_t TrackTheta = GetTrackTheta();
466 Float_t TrackPhi = GetTrackPhi();
467 Float_t pmod = GetTrackMomentum();
468 // Int_t q = GetTrackCharge();
470 // Int_t TrackIndex = GetTrackIndex();
471 Int_t MipIndex = GetMipIndex();
473 Bool_t kPatRec = kFALSE;
475 Int_t CandidatePhotons = 0;
477 Float_t ShiftX = GetShiftX();
478 Float_t ShiftY = GetShiftY();
480 Float_t* CandidatePhotonX = GetCandidatePhotonX();
481 Float_t* CandidatePhotonY = GetCandidatePhotonY();
483 Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
485 if(fDebug) cout << " n " << CandidatePhotonsNumber << endl;
487 SetThetaCerenkov(999.);
489 SetHoughPhotonsNorm(0);
492 for (Int_t j=0; j < CandidatePhotonsNumber; j++)
501 if (j == MipIndex) continue;
503 // h2_test1->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
505 if(CandidatePhotonX[j] < -64.) continue; /* avoid artificial clusters from edge uesd by Yale.... */
507 Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
508 Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
510 // Float_t chargehit = fHits_charge[j];
511 // if(chargehit > 150) continue;
513 SetEntranceX(Xtoentr);
514 SetEntranceY(Ytoentr);
518 Int_t PhotonStatus = PhotonInBand();
522 cout << " Photon n. " << j << " Status " << PhotonStatus << " accepted " << endl;
523 cout << " CandidatePhotonX[j] " << CandidatePhotonX[j] << " CandidatePhotonY[j] " << CandidatePhotonY[j] << endl;
526 if(PhotonStatus == 0) continue;
530 FindThetaPhotonCerenkov();
532 Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
534 if(fDebug) cout << " theta photon " << ThetaPhotonCerenkov << endl;
536 SetPhotonEta(ThetaPhotonCerenkov);
542 // h2_test4->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
544 // if(kDISPLAY) h1_photons->Fill(ThetaPhotonCerenkov);
548 if(CandidatePhotons >= 1) kPatRec = kTRUE;
552 SetThetaCerenkov(999.);
555 SetPhotonsNumber(CandidatePhotonsNumber);
562 Int_t NPhotonHough = GetHoughPhotons();
566 SetThetaCerenkov(999.);
567 SetHoughPhotonsNorm(0.);
571 if(kWEIGHT) FindWeightThetaCerenkov();
573 Float_t ThetaCerenkov = GetThetaCerenkov();
575 SetThetaOfRing(ThetaCerenkov);
576 FindAreaAndPortionOfRing();
578 Float_t NPhotonHoughNorm = ((Float_t)NPhotonHough)/GetPortionOfRing();
579 SetHoughPhotonsNorm(NPhotonHoughNorm);
581 // Calculate the area where the photon are accepted...
583 Float_t ThetaInternal = ThetaCerenkov - 0.5*fWindowWidth;
584 SetThetaOfRing(ThetaInternal);
585 FindAreaAndPortionOfRing();
586 Float_t InternalArea = GetAreaOfRing();
588 Float_t ThetaExternal = ThetaCerenkov + 0.5*fWindowWidth;
589 SetThetaOfRing(ThetaExternal);
590 FindAreaAndPortionOfRing();
591 Float_t ExternalArea = GetAreaOfRing();
593 Float_t HoughArea = ExternalArea - InternalArea;
595 SetHoughArea(HoughArea);
599 cout << " ----- SUMMARY OF RECONSTRUCTION ----- " << endl;
600 cout << " Rings found " << NRings << " with thetac " << ThetaCerenkov << endl;
602 h1_hough->Fill(ThetaCerenkov,1.);
604 cout << " Nphotons " << GetPhotonsNumber()
605 << " Hough " << NPhotonHough
606 << " norm " << NPhotonHoughNorm << endl;
608 cout << " In PatRec:p " << pmod << " theta " << TrackTheta << " phi " << TrackPhi << endl;
609 cout << " ------------------------------------- " << endl;
612 Int_t NPhotons = GetPhotonsNumber();
618 for (Int_t j=0; j < NPhotons;j++)
622 Float_t eta = GetPhotonEta();
626 if(GetPhotonFlag() == 2)
629 if(pmod>2.5&&ThetaCerenkov>0.65) photris->Fill(eta);
640 xmean /=(Float_t)nev;
641 x2mean /=(Float_t)nev;
647 Float_t RMS = sqrt(x2mean - xmean*xmean);
651 if(fDebug) cout << " RMS " << RMS << endl;
655 void AliRICHRecon::FindEmissionPoint()
658 // Find emission point
660 Float_t absorbtionLenght=7.83*RadiatorWidth; //absorption length in the freon (cm)
661 // 7.83 = -1/ln(T0) where
662 // T0->Trasmission freon at 180nm = 0.88 (Eph=6.85eV)
663 Float_t photonLenght, photonLenghtMin, photonLenghtMax;
665 photonLenght=exp(-RadiatorWidth/(absorbtionLenght*cos(fCerenkovAnglePad)));
666 photonLenghtMin=RadiatorWidth*photonLenght/(1.-photonLenght);
667 photonLenghtMax=absorbtionLenght*cos(fCerenkovAnglePad);
668 Float_t EmissionPoint = RadiatorWidth + photonLenghtMin - photonLenghtMax;
670 SetEmissionPoint(EmissionPoint);
674 Int_t AliRICHRecon::PhotonInBand()
677 // Float_t MassOfParticle;
683 Float_t Xtoentr = GetEntranceX();
684 Float_t Ytoentr = GetEntranceY();
689 Float_t phpad = GetPhiPoint();
691 // Float_t pmod = GetTrackMomentum();
692 // Float_t TrackTheta = GetTrackTheta();
693 // Float_t TrackPhi = GetTrackPhi();
696 SetPhotonEnergy(5.6);
697 SetEmissionPoint(RadiatorWidth -0.0001);
698 SetMassHypotesis(0.93828);
701 SetFreonRefractiveIndex();
703 beta = GetBetaOfParticle();
704 nfreon = GetFreonRefractiveIndex();
706 thetacer = Cerenkovangle(nfreon,beta);
710 if(fDebug) cout << " thetacer in photoninband min " << thetacer << endl;
712 FindThetaAtQuartz(thetacer);
714 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
717 SetXInnerRing(-999.);
718 SetYInnerRing(-999.);
719 SetRadiusInnerRing(-999.);
723 SetThetaPhotonInDRS(GetThetaAtQuartz());
724 SetPhiPhotonInDRS(phpad);
726 InnerRadius = FromEmissionToCathode();
727 if(InnerRadius == 999.) InnerRadius = -999.;
729 SetXInnerRing(GetXPointOnCathode());
730 SetYInnerRing(GetYPointOnCathode());
731 SetRadiusInnerRing(InnerRadius);
735 SetPhotonEnergy(7.7);
736 SetEmissionPoint(0.);
737 // SetMassHypotesis(0.139567);
738 SetMassHypotesis(0.);
741 SetFreonRefractiveIndex();
743 beta = GetBetaOfParticle();
744 nfreon = GetFreonRefractiveIndex();
746 thetacer = Cerenkovangle(nfreon,beta);
750 if(fDebug) cout << " thetacer in photoninband max " << thetacer << endl;
752 FindThetaAtQuartz(thetacer);
754 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
759 SetRadiusOuterRing(999.);
763 SetThetaPhotonInDRS(GetThetaAtQuartz());
764 SetPhiPhotonInDRS(phpad);
766 OuterRadius = FromEmissionToCathode();
767 // cout << " OuterRadius " << OuterRadius << endl;
768 SetXOuterRing(GetXPointOnCathode());
769 SetYOuterRing(GetYPointOnCathode());
770 SetRadiusOuterRing(OuterRadius);
773 Float_t padradius = sqrt(TMath::Power(Xtoentr,2)+TMath::Power(Ytoentr,2));
775 if(fDebug) printf(" rmin %f r %f rmax %f \n",InnerRadius,padradius,OuterRadius);
777 if(padradius>=InnerRadius && padradius<=OuterRadius) return 1;
781 void AliRICHRecon::FindThetaAtQuartz(Float_t ThetaCerenkov)
784 if(ThetaCerenkov == 999.)
786 SetThetaAtQuartz(999.);
790 Float_t ThetaAtQuartz = 999.;
792 Float_t TrackTheta = GetTrackTheta();
794 if(TrackTheta == 0) {
796 if(fDebug) cout << " Theta sol unique " << ThetaCerenkov << endl;
798 ThetaAtQuartz = ThetaCerenkov;
799 SetThetaAtQuartz(ThetaAtQuartz);
803 Float_t TrackPhi = GetTrackPhi();
804 Float_t PhiPoint = GetPhiPoint();
806 Double_t den = TMath::Sin((Double_t)TrackTheta)
807 *TMath::Cos((Double_t)TrackPhi)
808 *TMath::Cos((Double_t)PhiPoint) +
809 TMath::Sin((Double_t)TrackTheta)
810 *TMath::Sin((Double_t)TrackPhi)
811 *TMath::Sin((Double_t)PhiPoint);
812 Double_t b = TMath::Cos((Double_t)TrackTheta)/den;
813 Double_t c = -TMath::Cos((Double_t)ThetaCerenkov)/den;
815 Double_t UnderSqrt = 1 + b*b - c*c;
819 cout << " TrackTheta " << TrackTheta << endl;
820 cout << " TrackPhi " << TrackPhi << endl;
821 cout << " PhiPoint " << PhiPoint << endl;
822 cout << " ThetaCerenkov " << ThetaCerenkov << endl;
823 cout << " den b c " << den << " b " << b << " c " << c << endl;
827 if(fDebug) cout << " sqrt negative !!!!" << UnderSqrt << endl;
828 SetThetaAtQuartz(999.);
832 Double_t sol1 = (1+TMath::Sqrt(UnderSqrt))/(b-c);
833 Double_t sol2 = (1-TMath::Sqrt(UnderSqrt))/(b-c);
835 Double_t ThetaSol1 = 2*TMath::ATan(sol1);
836 Double_t ThetaSol2 = 2*TMath::ATan(sol2);
838 if(fDebug) cout << " Theta sol 1 " << ThetaSol1
839 << " Theta sol 2 " << ThetaSol2 << endl;
841 if(ThetaSol1>0 && ThetaSol1 < pi) ThetaAtQuartz = (Float_t)ThetaSol1;
842 if(ThetaSol2>0 && ThetaSol2 < pi) ThetaAtQuartz = (Float_t)ThetaSol2;
844 SetThetaAtQuartz(ThetaAtQuartz);
847 void AliRICHRecon::FindThetaPhotonCerenkov()
850 Float_t ThetaCerMin = 0.;
851 Float_t ThetaCerMax = 0.75;
852 Float_t ThetaCerMean;
854 Float_t RadiusMin, RadiusMax, RadiusMean;
855 Int_t nIteration = 0;
857 const Float_t Tollerance = 0.05;
859 // Float_t pmod = GetTrackMomentum();
860 // Float_t TrackTheta = GetTrackTheta();
861 // Float_t TrackPhi = GetTrackPhi();
863 Float_t PhiPoint = GetPhiPoint();
865 SetPhotonEnergy(6.85);
866 SetEmissionPoint(RadiatorWidth/2);
868 Float_t XPoint = GetEntranceX();
869 Float_t YPoint = GetEntranceY();
870 Float_t DistPoint = sqrt(XPoint*XPoint + YPoint*YPoint);
872 if(fDebug) cout << " DistPoint " << DistPoint << endl;
874 // Star minimization...
878 FindThetaAtQuartz(ThetaCerMin);
880 if(GetThetaAtQuartz() == 999.)
886 SetThetaPhotonInDRS(GetThetaAtQuartz());
887 SetPhiPhotonInDRS(PhiPoint);
889 RadiusMin = FromEmissionToCathode();
894 FindThetaAtQuartz(ThetaCerMax);
895 if(GetThetaAtQuartz() == 999.)
901 SetThetaPhotonInDRS(GetThetaAtQuartz());
902 SetPhiPhotonInDRS(PhiPoint);
904 RadiusMax = FromEmissionToCathode();
908 ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
910 FindThetaAtQuartz(ThetaCerMean);
911 if(GetThetaAtQuartz() == 999.)
917 SetThetaPhotonInDRS(GetThetaAtQuartz());
918 SetPhiPhotonInDRS(PhiPoint);
920 RadiusMean = FromEmissionToCathode();
923 if(fDebug) cout << " r1 " << RadiusMin << " rmean "
924 << RadiusMean << " r2 " << RadiusMax << endl;
926 while (TMath::Abs(RadiusMean-DistPoint) > Tollerance)
929 if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) < 0) ThetaCerMax = ThetaCerMean;
930 if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) > 0) {
932 ThetaCerMin = ThetaCerMean;
934 FindThetaAtQuartz(ThetaCerMin);
935 SetThetaPhotonInDRS(GetThetaAtQuartz());
936 SetPhiPhotonInDRS(PhiPoint);
938 RadiusMin =FromEmissionToCathode();
941 ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
943 FindThetaAtQuartz(ThetaCerMean);
944 SetThetaPhotonInDRS(GetThetaAtQuartz());
945 SetPhiPhotonInDRS(PhiPoint);
947 RadiusMean = FromEmissionToCathode();
951 if(fDebug) printf(" max iterations in FindPhotonCerenkov\n");
952 SetThetaPhotonCerenkov(999.);
957 SetThetaPhotonCerenkov(ThetaCerMean);
961 void AliRICHRecon::FindAreaAndPortionOfRing()
964 Float_t XPoint[NPointsOfRing], YPoint[NPointsOfRing];
966 // Float_t Xtoentr = GetEntranceX();
967 // Float_t Ytoentr = GetEntranceY();
968 Float_t ShiftX = GetShiftX();
969 Float_t ShiftY = GetShiftY();
971 Float_t XEmiss = GetXCoordOfEmission();
972 Float_t YEmiss = GetYCoordOfEmission();
974 Float_t x0 = XEmiss + ShiftX;
975 Float_t y0 = YEmiss + ShiftY;
977 // Float_t pmod = GetTrackMomentum();
978 // Float_t TrackTheta = GetTrackTheta();
979 // Float_t TrackPhi = GetTrackPhi();
981 SetPhotonEnergy(6.85);
982 SetFreonRefractiveIndex();
984 SetEmissionPoint(RadiatorWidth/2.);
986 Float_t Theta = GetThetaOfRing();
989 Int_t NPsiAccepted = 0;
992 for(Int_t i=0;i<NPointsOfRing-1;i++)
995 Float_t Psi = 2*TMath::Pi()*i/NPointsOfRing;
997 SetThetaPhotonInTRS(Theta);
998 SetPhiPhotonInTRS(Psi);
999 FindPhotonAnglesInDRS();
1001 Float_t Radius = FromEmissionToCathode();
1002 if (Radius == 999.) continue;
1006 Float_t XPointRing = GetXPointOnCathode() + ShiftX;
1007 Float_t YPointRing = GetYPointOnCathode() + ShiftY;
1009 SetDetectorWhereX(XPointRing);
1010 SetDetectorWhereY(YPointRing);
1012 Int_t Zone = CheckDetectorAcceptance();
1014 // cout << " XPointing " << XPointRing << " YPointing " << YPointRing << " Zone " << Zone << endl;
1015 // cout << " ShiftX " << ShiftX << " ShiftY " << ShiftY << endl;
1016 // cout << " GetXPointOnCathode() " << GetXPointOnCathode() << endl;
1017 // cout << " GetYPointOnCathode() " << GetYPointOnCathode() << endl;
1021 FindIntersectionWithDetector();
1022 XPoint[nPoints] = GetIntersectionX();
1023 YPoint[nPoints] = GetIntersectionY();
1027 XPoint[nPoints] = XPointRing;
1028 YPoint[nPoints] = YPointRing;
1036 XPoint[nPoints] = XPoint[0];
1037 YPoint[nPoints] = YPoint[0];
1043 for (Int_t i = 0; i < nPoints; i++)
1045 Area += TMath::Abs((XPoint[i]-x0)*(YPoint[i+1]-y0) - (XPoint[i+1]-x0)*(YPoint[i]-y0));
1050 Float_t PortionOfRing = ((Float_t)NPsiAccepted)/((Float_t)(NPsiTotal));
1052 // cout << " Area " << Area << " Portion of ring " << PortionOfRing << endl;
1054 SetAreaOfRing(Area);
1055 SetPortionOfRing(PortionOfRing);
1058 void AliRICHRecon::FindIntersectionWithDetector()
1061 Float_t XIntersect, YIntersect;
1062 Float_t x1, x2, y1, y2;
1064 Float_t ShiftX = GetShiftX();
1065 Float_t ShiftY = GetShiftY();
1067 Float_t XPoint = GetXPointOnCathode() + ShiftX;
1068 Float_t YPoint = GetYPointOnCathode() + ShiftY;
1070 Float_t XEmiss = GetXCoordOfEmission();
1071 Float_t YEmiss = GetYCoordOfEmission();
1073 Float_t Phi = GetPhiPhotonInDRS();
1074 Float_t m = tan(Phi);
1076 Float_t x0 = XEmiss + ShiftX;
1077 Float_t y0 = YEmiss + ShiftY;
1101 YIntersect = m*(XIntersect - x0) + y0;
1102 if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
1104 SetIntersectionX(XIntersect);
1105 SetIntersectionY(YIntersect);
1110 YIntersect = m*(XIntersect - x0) + y0;
1111 if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
1113 SetIntersectionX(XIntersect);
1114 SetIntersectionY(YIntersect);
1119 XIntersect = (YIntersect - y0)/m + x0;
1120 if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
1122 SetIntersectionX(XIntersect);
1123 SetIntersectionY(YIntersect);
1128 XIntersect = (YIntersect - y0)/m + x0;
1129 if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
1131 SetIntersectionX(XIntersect);
1132 SetIntersectionY(YIntersect);
1136 cout << " sono fuori!!!!!!" << endl;
1137 // cout << " x1 " << x1 << " x2 " << x2 << endl;
1138 // cout << " y1 " << y1 << " y2 " << y2 << endl;
1139 // cout << " Xmin " << Xmin << " Xmax " << Xmax << endl;
1140 // cout << " Ymin " << Ymin << " Ymax " << Ymax << endl;
1144 Int_t AliRICHRecon::CheckDetectorAcceptance()
1147 // crosses X -2.6 2.6 cm
1148 // crosses Y -1 1 cm
1150 Float_t Xcoord = GetDetectorWhereX();
1151 Float_t Ycoord = GetDetectorWhereY();
1153 // cout << " Xcoord " << Xcoord << " Ycoord " << Ycoord << endl;
1156 if(Ycoord > Ymax) return 2;
1157 if(Ycoord > Ymin && Ycoord < Ymax) return 3;
1158 if(Ycoord < Ymin) return 4;
1162 if(Ycoord > Ymax) return 8;
1163 if(Ycoord > Ymin && Ycoord < Ymax) return 7;
1164 if(Ycoord < Ymin) return 6;
1166 if(Xcoord > Xmin && Xcoord < Xmax)
1168 if(Ycoord > Ymax) return 1;
1169 if(Ycoord > Ymin && Ycoord < Ymax) return 0;
1170 if(Ycoord < Ymin) return 5;
1175 void AliRICHRecon::DrawRing()
1178 // Float_t xGraph[1000],yGraph[1000];
1181 // Float_t MassOfParticle;
1185 Float_t ThetaCerenkov;
1187 // Float_t Xtoentr = GetEntranceX();
1188 // Float_t Ytoentr = GetEntranceY();
1190 // Float_t pmod = GetTrackMomentum();
1191 // Float_t TrackTheta = GetTrackTheta();
1192 // Float_t TrackPhi = GetTrackPhi();
1194 SetPhotonEnergy(6.85);
1195 SetFreonRefractiveIndex();
1197 SetEmissionPoint(RadiatorWidth/2.);
1203 SetMassHypotesis(0.139567);
1204 SetBetaOfParticle();
1206 beta = GetBetaOfParticle();
1211 ThetaCerenkov = GetThetaCerenkov();
1212 FindBetaFromTheta(ThetaCerenkov);
1215 nfreon = GetFreonRefractiveIndex();
1217 Float_t thetacer = Cerenkovangle(nfreon,beta);
1219 if(fDebug) cout << " TetaCer in DrawRing " << thetacer << endl;
1221 Int_t nPoints = 100;
1223 Int_t nPointsToDraw = 0;
1224 for(Int_t i=0;i<nPoints;i++)
1226 Float_t phpad = 2*TMath::Pi()*i/nPoints;
1227 SetThetaPhotonInTRS(thetacer);
1228 SetPhiPhotonInTRS(phpad);
1229 FindPhotonAnglesInDRS();
1230 Float_t Radius = FromEmissionToCathode();
1231 if (Radius == 999.) continue;
1232 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
1233 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
1234 // cout << " get shift X " << GetShiftX() << endl;
1235 // cout << " get shift Y " << GetShiftY() << endl;
1240 if(fDebug) cout << " Drawing the Ring... with " << nPointsToDraw << " points " << endl;
1242 // pol = new TPolyLine(nPointsToDraw,xGraph,yGraph);
1243 // pol->Draw("same");
1244 gra = new TGraph(nPointsToDraw,xGraph,yGraph);
1246 StarCanvas->Update();
1250 Float_t AliRICHRecon::PhotonPositionOnCathode()
1252 // Float_t MassOfParticle;
1256 // Float_t pmod = GetTrackMomentum();
1257 // Float_t TrackTheta = GetTrackTheta();
1258 // Float_t TrackPhi = GetTrackPhi();
1260 // Float_t phpad = GetPhiPoint();
1262 SetPhotonEnergy(6.85);
1263 SetEmissionPoint(RadiatorWidth/2.);
1264 SetMassHypotesis(0.139567);
1266 SetBetaOfParticle();
1267 SetFreonRefractiveIndex();
1269 beta = GetBetaOfParticle();
1270 nfreon = GetFreonRefractiveIndex();
1272 // Float_t thetacer = Cerenkovangle(nfreon,beta);
1274 // cout << " FromEmissionToCathode: thetacer " << thetacer << " phpad " << phpad << endl;
1276 Float_t Radius = FromEmissionToCathode();
1277 if (Radius == 999.) return 999.;
1279 // Float_t Xphoton = GetXPointOnCathode();
1280 // Float_t Yphoton = GetYPointOnCathode();
1281 // cout << " PhotonPositionOnCathode: Xphoton " << Xphoton << " Yphoton " << Yphoton <<
1282 // " Radius for photon " << Radius << endl;
1286 void AliRICHRecon::FindPhotonAnglesInDRS()
1288 // Setup the rotation matrix of the track...
1295 Float_t TrackTheta = GetTrackTheta();
1296 Float_t TrackPhi = GetTrackPhi();
1298 Mtheta.RotateY(TrackTheta);
1299 Mphi.RotateZ(TrackPhi);
1301 Mrot = Mphi * Mtheta;
1302 // Minv = Mrot.Inverse();
1304 TVector3 PhotonInRadiator(1,1,1);
1306 Float_t ThetaCerenkov = GetThetaPhotonInTRS();
1307 Float_t PhiCerenkov = GetPhiPhotonInTRS();
1309 PhotonInRadiator.SetTheta(ThetaCerenkov);
1310 PhotonInRadiator.SetPhi(PhiCerenkov);
1311 PhotonInRadiator = Mrot * PhotonInRadiator;
1312 Float_t Theta = PhotonInRadiator.Theta();
1313 Float_t Phi = PhotonInRadiator.Phi();
1314 SetThetaPhotonInDRS(Theta);
1315 SetPhiPhotonInDRS(Phi);
1319 Float_t AliRICHRecon::FromEmissionToCathode()
1322 Float_t nfreon, nquartz, ngas;
1324 SetFreonRefractiveIndex();
1325 SetQuartzRefractiveIndex();
1326 SetGasRefractiveIndex();
1328 nfreon = GetFreonRefractiveIndex();
1329 nquartz = GetQuartzRefractiveIndex();
1330 ngas = GetGasRefractiveIndex();
1332 Float_t TrackTheta = GetTrackTheta();
1333 Float_t TrackPhi = GetTrackPhi();
1334 Float_t LengthOfEmissionPoint = GetEmissionPoint();
1336 Float_t Theta = GetThetaPhotonInDRS();
1337 Float_t Phi = GetPhiPhotonInDRS();
1339 // cout << " Theta " << Theta << " Phi " << Phi << endl;
1341 Float_t xEmiss = LengthOfEmissionPoint*tan(TrackTheta)*cos(TrackPhi);
1342 Float_t yEmiss = LengthOfEmissionPoint*tan(TrackTheta)*sin(TrackPhi);
1344 SetXCoordOfEmission(xEmiss);
1345 SetYCoordOfEmission(yEmiss);
1347 Float_t thetaquar = SnellAngle(nfreon, nquartz, Theta);
1349 if(thetaquar == 999.)
1351 SetXPointOnCathode(999.);
1352 SetYPointOnCathode(999.);
1356 Float_t thetagap = SnellAngle( nquartz, ngas, thetaquar);
1358 if(thetagap == 999.)
1360 SetXPointOnCathode(999.);
1361 SetYPointOnCathode(999.);
1365 Float_t xw = (RadiatorWidth - LengthOfEmissionPoint)*cos(Phi)*tan(Theta);
1366 Float_t xq = QuartzWidth*cos(Phi)*tan(thetaquar);
1367 Float_t xg = GapWidth*cos(Phi)*tan(thetagap);
1368 Float_t yw = (RadiatorWidth - LengthOfEmissionPoint)*sin(Phi)*tan(Theta);
1369 Float_t yq = QuartzWidth*sin(Phi)*tan(thetaquar);
1370 Float_t yg = GapWidth*sin(Phi)*tan(thetagap);
1372 // Float_t xtot = x1 + xw + xq + xg;
1373 // Float_t ytot = y1 + yw + yq + yg;
1375 Float_t xtot = xEmiss + xw + xq + xg;
1376 Float_t ytot = yEmiss + yw + yq + yg;
1378 SetXPointOnCathode(xtot);
1379 SetYPointOnCathode(ytot);
1381 // cout << " xtot " << xtot << " ytot " << ytot << endl;
1383 Float_t DistanceFromEntrance = sqrt(TMath::Power(fPhotonLimitX,2)
1384 +TMath::Power(fPhotonLimitY,2));
1386 return DistanceFromEntrance;
1391 void AliRICHRecon::FindPhiPoint()
1394 Float_t Xtoentr = GetEntranceX();
1395 Float_t Ytoentr = GetEntranceY();
1397 Float_t TrackTheta = GetTrackTheta();
1398 Float_t TrackPhi = GetTrackPhi();
1400 Float_t EmissionPoint = GetEmissionPoint();
1402 Float_t argY = Ytoentr - EmissionPoint*tan(TrackTheta)*sin(TrackPhi);
1403 Float_t argX = Xtoentr - EmissionPoint*tan(TrackTheta)*cos(TrackPhi);
1404 Float_t phipad = atan2(argY,argX);
1406 SetPhiPoint(phipad);
1410 Float_t AliRICHRecon::Cerenkovangle(Float_t n, Float_t beta)
1413 // Compute the cerenkov angle
1419 // cout << " warning in Cerenkoangle !!!!!! " << endl;
1423 thetacer = acos (1./(n*beta));
1427 Float_t AliRICHRecon::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
1430 // Compute the Snell angle
1432 Float_t sinrefractangle;
1433 Float_t refractangle;
1435 sinrefractangle = (n1/n2)*sin(theta1);
1437 if(sinrefractangle>1.) {
1438 // cout << " PROBLEMS IN SNELL ANGLE !!!!! " << endl;
1439 refractangle = 999.;
1440 return refractangle;
1443 refractangle = asin(sinrefractangle);
1444 return refractangle;
1448 void AliRICHRecon::HoughResponse()
1452 // Implement Hough response pat. rec. method
1459 int i, j, k, nCorrBand;
1460 float hcs[750],hcsw[750];
1461 float angle, weight;
1462 float lowerlimit,upperlimit;
1468 float etaPeakPos = -1;
1470 Int_t etaPeakCount = -1;
1472 Float_t ThetaCerenkov = 0.;
1474 nBin = (int)(0.5+fThetaMax/(fDTheta));
1475 nCorrBand = (int)(0.5+ fWindowWidth/(2 * fDTheta));
1477 memset ((void *)hcs, 0, fThetaBin*sizeof(float));
1478 memset ((void *)hcsw, 0, fThetaBin*sizeof(float));
1480 Int_t NPhotons = GetPhotonsNumber();
1482 Int_t WeightFlag = 0;
1484 for (k=0; k< NPhotons; k++) {
1488 angle = GetPhotonEta();
1490 if(angle == -999.) continue;
1492 if (angle>=fThetaMin && angle<= fThetaMax)
1496 bin = (int)(0.5+angle/(fDTheta));
1498 bin1= bin-nCorrBand;
1499 bin2= bin+nCorrBand;
1501 // calculate weights
1505 lowerlimit = ((Float_t)bin1)*fDTheta + 0.5*fDTheta;
1506 SetThetaOfRing(lowerlimit);
1507 FindAreaAndPortionOfRing();
1508 Float_t area1 = GetAreaOfRing();
1510 upperlimit = ((Float_t)bin2)*fDTheta + 0.5*fDTheta;
1511 SetThetaOfRing(upperlimit);
1512 FindAreaAndPortionOfRing();
1513 Float_t area2 = GetAreaOfRing();
1515 // cout << "lowerlimit" << lowerlimit << "upperlimit " << upperlimit << endl;
1516 Float_t diffarea = area2 - area1;
1520 weight = 1./(area2-area1);
1528 // cout <<" low "<< lowerlimit << " up " << upperlimit <<
1529 // " area1 " << area1 << " area2 " << area2 << " weight " << weight << endl;
1537 SetPhotonWeight(weight);
1539 // cout << "weight..." << weight << endl;
1541 h1_photons1->Fill(angle);
1542 h1_photons2->Fill(angle,weight);
1545 if (bin2>nBin) bin2=nBin;
1547 for (j=bin1; j<bin2; j++)
1557 // for(Int_t j=0;j<750;j++)
1559 // h1_hcs->Fill(((Float_t)j),hcs[j]);
1560 // h1_hcsw->Fill(((Float_t)j),hcsw[j]);
1571 // cout << " probems with weight...normal procedure adopted " << endl;
1574 HoughFiltering(HCSspace);
1576 for (bin=0; bin <nBin; bin++) {
1577 angle = (bin+0.5) * (fDTheta);
1578 if (HCSspace[bin] && HCSspace[bin] > etaPeakPos) {
1580 etaPeakPos = HCSspace[bin];
1584 if (HCSspace[bin] == etaPeakPos) {
1585 etaPeak[++etaPeakCount] = angle;
1590 for (i=0; i<etaPeakCount+1; i++) {
1591 ThetaCerenkov += etaPeak[i];
1593 if (etaPeakCount>=0) {
1594 ThetaCerenkov /= etaPeakCount+1;
1595 fThetaPeakPos = etaPeakPos;
1598 SetThetaCerenkov(ThetaCerenkov);
1602 void AliRICHRecon::HoughFiltering(float hcs[])
1608 float k[5] = {0.05, 0.25, 0.4, 0.25, 0.05};
1613 nBin = (int)(1+fThetaMax/fDTheta);
1614 sizeHCS = fThetaBin*sizeof(float);
1616 memset ((void *)hcsFilt, 0, sizeHCS);
1618 for (nx = 0; nx < nBin; nx++) {
1619 for (i = 0; i < 5; i++) {
1621 if (nxDx> -1 && nxDx<nBin)
1622 hcsFilt[nx] += hcs[nxDx] * k[i];
1626 for (nx = 0; nx < nBin; nx++) {
1627 hcs[nx] = hcsFilt[nx];
1631 void AliRICHRecon::FindWeightThetaCerenkov()
1635 Float_t WeightThetaCerenkov = 0.;
1637 Int_t NPhotons = GetPhotonsNumber();
1638 for(Int_t i=0;i<NPhotons;i++)
1642 if(GetPhotonFlag() == 2)
1644 Float_t PhotonEta = GetPhotonEta();
1645 Float_t PhotonWeight = GetPhotonWeight();
1646 WeightThetaCerenkov += PhotonEta*PhotonWeight;
1647 wei += PhotonWeight;
1653 WeightThetaCerenkov /= wei;
1657 WeightThetaCerenkov = 0.;
1660 SetThetaCerenkov(WeightThetaCerenkov);
1662 cout << " thetac weighted -> " << WeightThetaCerenkov << endl;
1666 void AliRICHRecon::FlagPhotons()
1669 Int_t NPhotonHough = 0;
1671 Float_t ThetaCerenkov = GetThetaCerenkov();
1672 if(fDebug) cout << " fThetaCerenkov " << ThetaCerenkov << endl;
1674 Float_t ThetaDist= ThetaCerenkov - fThetaMin;
1675 Int_t steps = (Int_t)(ThetaDist / fDTheta);
1677 Float_t tmin = fThetaMin + (Float_t)(steps - 1)*fDTheta;
1678 Float_t tmax = fThetaMin + (Float_t)(steps)*fDTheta;
1679 Float_t tavg = 0.5*(tmin+tmax);
1681 tmin = tavg - 0.5*fWindowWidth;
1682 tmax = tavg + 0.5*fWindowWidth;
1684 if(fDebug) cout << " tmin " << tmin << " tmax " << tmax << endl;
1685 if(fDebug) cout << " thetac " << ThetaCerenkov << endl;
1687 // Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
1689 Int_t NPhotons = GetPhotonsNumber();
1691 // for(Int_t i=0;i<CandidatePhotonsNumber;i++)
1693 for(Int_t i=0;i<NPhotons;i++)
1697 Float_t PhotonEta = GetPhotonEta();
1699 if(PhotonEta == -999.) continue;
1701 if(PhotonEta >= tmin && PhotonEta <= tmax)
1707 SetHoughPhotons(NPhotonHough);
1710 void AliRICHRecon::DrawEvent(Int_t flag)
1713 flag=1; // dummy to be removed...
1715 Float_t xGraph[3000],yGraph[3000];
1717 Float_t ThetaCerenkov;
1721 gStyle->SetPalette(1,0);
1726 // Display = new TCanvas("Display","Star Display",0,0,1200,750);
1728 Display->ToggleEventStatus();
1731 text = new TText(0,0,"");
1732 text->SetTextFont(61);
1733 text->SetTextSize(0.03);
1734 text->SetTextAlign(22);
1740 for(Int_t j=1;j<=nPixels;j++)
1742 Float_t xpad = fPixels_localX[j-1];
1743 Float_t ypad = fPixels_localY[j-1];
1744 h2_disp->Fill(xpad,ypad,fPixels_charge[j-1]);
1747 h2_disp->SetMaximum(200);
1748 // h2_disp->SetMaximum(1);
1749 h2_disp->SetStats(0);
1750 h2_disp->Draw("colz");
1752 for(Int_t i=0; i<nRichPrimaries;i++)
1756 TrackPoints = new TMarker(fRichPrimaries_localPadX[i],
1757 fRichPrimaries_localPadY[i],3);
1759 TrackPoints->SetMarkerSize(1.5);
1761 Float_t pmod = sqrt(fRichPrimaries_localPadPx[i] * fRichPrimaries_localPadPx[i] +
1762 fRichPrimaries_localPadPy[i] * fRichPrimaries_localPadPy[i] +
1763 fRichPrimaries_localPadPz[i] * fRichPrimaries_localPadPz[i]);
1765 if(pmod < 1) TrackPoints->SetMarkerColor(kBlue);
1766 if(pmod > 1 && pmod < 2) TrackPoints->SetMarkerColor(kGreen);
1767 if(pmod > 2) TrackPoints->SetMarkerColor(kRed);
1769 TrackPoints->Draw();
1771 line = new TLine(-0.13,-42.,-0.13,42.);
1773 line = new TLine(0.13,-42.,0.13,42.);
1775 line = new TLine(-64.,-0.13,64.,-0.13);
1777 line = new TLine(-64.,0.13,64.,0.13);
1792 // Float_t Xtoentr = GetEntranceX();
1793 // Float_t Ytoentr = GetEntranceY();
1795 // Float_t pmod = GetTrackMomentum();
1796 // Float_t TrackTheta = GetTrackTheta();
1797 // Float_t TrackPhi = GetTrackPhi();
1799 SetPhotonEnergy(6.85);
1800 SetFreonRefractiveIndex();
1802 SetEmissionPoint(RadiatorWidth/2.);
1804 ThetaCerenkov = GetThetaCerenkov();
1806 if (ThetaCerenkov == 999.) return;
1808 Int_t nPointsToDraw = 0;
1810 for(Int_t i=0;i<99;i++)
1812 Float_t phpad = 2*TMath::Pi()*i/99;
1813 SetThetaPhotonInTRS(ThetaCerenkov);
1814 SetPhiPhotonInTRS(phpad);
1815 FindPhotonAnglesInDRS();
1816 Float_t Radius = FromEmissionToCathode();
1818 if (Radius == 999.) continue;
1820 Float_t ShiftX = GetShiftX();
1821 Float_t ShiftY = GetShiftY();
1823 Float_t XPointRing = GetXPointOnCathode() + ShiftX;
1824 Float_t YPointRing = GetYPointOnCathode() + ShiftY;
1826 SetDetectorWhereX(XPointRing);
1827 SetDetectorWhereY(YPointRing);
1829 Int_t Zone = CheckDetectorAcceptance();
1833 FindIntersectionWithDetector();
1834 xGraph[nPointsToDraw] = GetIntersectionX();
1835 yGraph[nPointsToDraw] = GetIntersectionY();
1840 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
1841 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
1846 xGraph[nPointsToDraw] = xGraph[0];
1847 yGraph[nPointsToDraw] = yGraph[0];
1849 poll = new TPolyLine(nPointsToDraw+1,xGraph,yGraph);
1850 poll->SetLineColor(2);
1851 poll->SetLineWidth(3);
1858 for(Int_t j=0;j<nHits;j++)
1861 Float_t xhit = fHits_localX[j];
1862 Float_t yhit = fHits_localY[j];
1865 Int_t FlagPhoton = GetPhotonFlag();
1867 // if(FlagPhoton >= 1)
1870 // Photon = new TMarker(xhit,yhit,4);
1871 // Photon->SetMarkerSize(1.5);
1872 // Photon->Draw("same");
1880 PhotonAcc = new TMarker(xhit,yhit,30);
1881 PhotonAcc->SetMarkerSize(1.5);
1882 PhotonAcc->SetMarkerColor(50);
1883 PhotonAcc->Draw("same");
1891 // h1_photons->Draw();
1892 // Display->Update();
1895 // h1_photacc->Draw();
1896 // Display->Update();
1900 // Display->Update();
1902 // h1_photons->Reset();
1903 // h1_photacc->Reset();
1908 Float_t AliRICHRecon::FindMassOfParticle()
1911 Float_t pmod = GetTrackMomentum();
1913 SetPhotonEnergy(6.85);
1914 SetFreonRefractiveIndex();
1916 Float_t ThetaCerenkov = GetThetaCerenkov();
1917 FindBetaFromTheta(ThetaCerenkov);
1919 Double_t beta = (Double_t)(GetBetaOfParticle());
1920 Double_t den = 1. - beta*beta;
1921 if(den<=0.) return 999.;
1923 Double_t gamma = 1./TMath::Sqrt(den);
1925 Float_t mass = pmod/(beta*(Float_t)gamma);
1931 void AliRICHRecon::FillHistograms()
1934 Float_t FittedTrackTheta, FittedTrackPhi;
1936 Float_t ThetaCerenkov = GetThetaCerenkov();
1937 if(ThetaCerenkov == 999.) return;
1939 Float_t VertZ = GetEventVertexZ();
1941 Float_t TrackTheta = GetTrackTheta();
1942 Float_t TrackPhi = GetTrackPhi();
1943 Float_t pmod = GetTrackMomentum();
1944 Float_t pt = GetTrackPt();
1945 Float_t TrackEta = GetTrackEta();
1946 Int_t q = GetTrackCharge();
1947 Float_t TPCLastZ = GetTrackTPCLastZ();
1948 Float_t MinDist = GetMinDist();
1950 FittedTrackTheta = GetFittedTrackTheta();
1951 FittedTrackPhi = GetFittedTrackPhi();
1952 Int_t FittedNPhotonHough = GetFittedHoughPhotons();
1956 cout << " p " << pmod << " ThetaC " << ThetaCerenkov
1957 << " rings " << NRings << endl;
1960 Int_t NPhotonHough = GetHoughPhotons();
1961 Float_t NPhotonHoughNorm = GetHoughPhotonsNorm();
1962 Float_t InRing = GetPortionOfRing();
1964 Float_t MassOfParticle = FindMassOfParticle();
1966 Float_t HoughArea = GetHoughArea();
1967 Float_t Multiplicity = GetEventMultiplicity();
1969 // cout << " area " << HoughArea << " mult " << Multiplicity << endl;
1973 // var[0] = (Float_t)runID;
1974 // var[1] = (Float_t)evID;
1981 var[6] = TrackTheta;
1983 var[8] = FittedTrackTheta;
1984 var[9] = FittedTrackPhi;
1986 var[11] = ThetaCerenkov;
1987 var[12] = (Float_t)NPhotonHough;
1988 var[13] = (Float_t)FittedNPhotonHough;
1990 var[15] = MassOfParticle;
1991 var[16] = HoughArea;
1992 var[17] = Multiplicity;
1998 h1_mass->Fill(MassOfParticle);
1999 h2_mvsp->Fill(pmod,MassOfParticle);
2000 h2_mvst->Fill(ThetaCerenkov,MassOfParticle);
2002 FittedTrackTheta = GetFittedTrackTheta();
2003 FittedTrackPhi = GetFittedTrackPhi();
2005 Float_t DiffTheta = FittedTrackTheta - TrackTheta;
2006 Float_t DiffPhi = FittedTrackPhi - TrackPhi;
2008 h1_diffTrackTheta -> Fill(DiffTheta);
2009 h1_diffTrackPhi -> Fill(DiffPhi);
2011 if(ThetaCerenkov > 0.505 && ThetaCerenkov < 0.605)
2013 SetPhotonEnergy(6.85);
2014 SetFreonRefractiveIndex();
2016 Float_t pmom = GetTrackMomentum();
2017 Float_t beta = 1./(cos(ThetaCerenkov)*GetFreonRefractiveIndex());
2018 Float_t gamma = 1./sqrt(1.-beta*beta);
2020 Float_t pmomnew = 0.93828*beta*gamma;
2021 Float_t deltap = pmomnew - pmom;
2022 h1_deltap->Fill(deltap);
2023 Float_t deltapop = deltap/pmom;
2024 h1_deltapop->Fill(deltapop);
2026 h1_nprotons->Fill((Float_t)NPhotonHoughNorm);
2031 h2_tvsppos->Fill(pmod,ThetaCerenkov);
2032 hp_1pos->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
2033 hp_1posnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
2034 h2_1pos->Fill(pmod,(Float_t)NPhotonHough);
2035 h2_1posnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
2036 h1_houghpos->Fill(ThetaCerenkov);
2040 h2_tvspneg->Fill(pmod,ThetaCerenkov);
2041 hp_1neg->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
2042 hp_1negnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
2043 h2_1neg->Fill(pmod,(Float_t)NPhotonHough);
2044 h2_1negnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
2045 h1_houghneg->Fill(ThetaCerenkov);
2048 Int_t NPhotons = GetPhotonsNumber();
2050 for (Int_t j=0; j < NPhotons;j++)
2055 Float_t eta = GetPhotonEta();
2057 if(GetPhotonFlag() == 2)
2059 h1_photacc->Fill(eta);
2060 Float_t photaccspread = eta - ThetaCerenkov;
2061 h1_photaccspread->Fill(photaccspread);
2067 void AliRICHRecon::Minimization()
2073 static Double_t vstart[2];
2074 static Double_t lower[2], upper[2];
2075 static Double_t step[2]={0.001,0.001};
2077 Double_t TrackThetaNew,TrackPhiNew;
2079 Double_t eps, b1, b2;
2082 gMyMinuit = new TMinuit(2);
2083 gMyMinuit->SetObjectFit((TObject *)this);
2084 gMyMinuit->SetFCN(fcn);
2085 gMyMinuit->mninit(5,10,7);
2087 vstart[0] = (Double_t)GetTrackTheta();
2088 vstart[1] = (Double_t)GetTrackPhi();
2090 lower[0] = vstart[0] - 0.03;
2091 if(lower[0] < 0) lower[0] = 0.;
2092 upper[0] = vstart[0] + 0.03;
2093 lower[1] = vstart[1] - 0.03;
2094 upper[1] = vstart[1] + 0.03;
2097 gMyMinuit->mnparm(0,"theta",vstart[0],step[0],lower[0],upper[0],ierflag);
2098 gMyMinuit->mnparm(1," phi ",vstart[1],step[1],lower[1],upper[1],ierflag);
2102 // gMyMinuit->FixParameter(0);
2104 gMyMinuit->SetPrintLevel(-1);
2105 // gMyMinuit->mnexcm("SET PRI",&arglist, 1, ierflag);
2106 gMyMinuit->mnexcm("SET NOGR",&arglist, 1, ierflag);
2107 gMyMinuit->mnexcm("SET NOW",&arglist, 1, ierflag);
2109 gMyMinuit->mnexcm("SET ERR", &arglist, 1,ierflg);
2112 // gMyMinuit->mnscan();
2114 // gMyMinuit->mnexcm("SIMPLEX",&arglist, 0, ierflag);
2115 gMyMinuit->mnexcm("MIGRAD",&arglist, 0, ierflag);
2116 gMyMinuit->mnexcm("EXIT" ,&arglist, 0, ierflag);
2118 gMyMinuit->mnpout(0,chname, TrackThetaNew, eps , b1, b2, ierflg);
2119 gMyMinuit->mnpout(1,chname, TrackPhiNew, eps , b1, b2, ierflg);
2121 //values after the fit...
2122 SetFittedTrackTheta((Float_t)TrackThetaNew);
2123 SetFittedTrackPhi((Float_t)TrackPhiNew);
2129 void AliRICHRecon::EstimationOfTheta()
2134 Float_t ShiftX = GetShiftX();
2135 Float_t ShiftY = GetShiftY();
2137 Float_t *CandidatePhotonX = GetCandidatePhotonX();
2138 Float_t *CandidatePhotonY = GetCandidatePhotonY();
2140 Int_t NPhotonsCandidates = GetCandidatePhotonsNumber();
2142 // cout << "MINIM: Nphotons " << NPhotonsCandidates << endl;
2144 for (Int_t j=0; j < NPhotonsCandidates; j++)
2149 if(!GetPhotonFlag()) continue;
2151 Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
2152 Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
2154 SetEntranceX(Xtoentr);
2155 SetEntranceY(Ytoentr);
2159 FindThetaPhotonCerenkov();
2161 Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
2163 // cout << " ACCEPTED!!! " << ThetaPhotonCerenkov << endl;
2165 SetPhotonEta(ThetaPhotonCerenkov);
2172 Float_t x2mean = 0.;
2175 for (Int_t j=0; j < NPhotonsCandidates;j++)
2179 Float_t eta = GetPhotonEta();
2183 if(GetPhotonFlag() == 2)
2194 xmean /=(Float_t)nev;
2195 x2mean /=(Float_t)nev;
2201 Float_t RMS = sqrt(x2mean - xmean*xmean);
2203 // cout << " RMS " << RMS;
2205 SetEstimationOfTheta(xmean);
2206 SetEstimationOfThetaRMS(RMS);
2209 void fcn(Int_t& /*npar*/, Double_t* /*gin*/, Double_t &f, Double_t *par, Int_t iflag)
2211 AliRICHRecon *gMyRecon = (AliRICHRecon*)gMyMinuit->GetObjectFit();
2213 Float_t p0 = (Float_t)par[0];
2214 Float_t p1 = (Float_t)par[1];
2216 gMyRecon->SetTrackTheta(p0);
2217 gMyRecon->SetTrackPhi(p1);
2219 gMyRecon->EstimationOfTheta();
2220 Float_t RMS = gMyRecon->GetEstimationOfThetaRMS();
2222 Int_t HoughPhotons = gMyRecon->GetHoughPhotons();
2225 f = (Double_t)(1000*RMS/(Float_t)HoughPhotons);
2227 if(fDebug) cout << " f " << f
2228 << " theta " << par[0] << " phi " << par[1]
2229 << " HoughPhotons " << HoughPhotons << endl;
2231 if(fDebug&&iflag == 3)
2233 cout << " --- end convergence...summary --- " << endl;
2234 cout << " theta " << par[0] << endl;
2235 cout << " phi " << par[1] << endl;
2239 void AliRICHRecon::waiting()
2241 if(!kDISPLAY) return;
2242 cout << " Press any key to continue...";
2244 // gSystem->ProcessEvents();
2253 void ~AliRICHRecon()