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 fcnrecon(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
94 // Float_t fEmissionPoint;
95 // Float_t fTrackTheta;
102 static TFile *outputfile;
104 static TH1F *h1_photons,*h1_photacc,*h1_hough;
105 static TH2F *h2_tvsppos, *h2_tvspneg,*h2_func;
107 static TH2F *h2_disp;
109 static TH2F *h2_test2, *h2_testmap;
110 //static TH2F *h2_test1, *h2_test4;
111 static TH2F *h2_dist_p;
113 static TH1F *h1_photons1, *h1_photons2;
114 static TH1F *h1_houghpos, *h1_houghneg;
115 static TH1F *h1_mass;
116 static TH2F *h2_mvsp;
118 static TH1F *h1_hcs, *h1_hcsw;
120 static TH1F *h1_nprotons;
122 static TProfile *hp_1pos, *hp_1neg;
123 static TProfile *hp_1posnorm, *hp_1negnorm;
124 static TH2F *h2_1pos, *h2_1neg;
125 static TH2F *h2_1posnorm, *h2_1negnorm;
126 static TH2F *h2_mvst;
128 static TH1F *h1_deltap, *h1_deltapop;
129 static TH1F *h1_diffTrackTheta, *h1_diffTrackPhi;
130 static TH1F *h1_photaccspread;
132 static TH2F *h2_diffpos, *h2_diffneg;
133 static TH2F *h2_map, *h2_mapw;
135 static TH1F *photris;
137 static TH1F *gChargeMipH1, *gMultMipH1;
141 static TCanvas *StarCanvas,*Display;
142 //static TCanvas *Displayhcs;
146 static TPolyLine *poll;
147 static TPolyMarker *polm;
148 static TMarker *Point, *TrackPoints, *Photon, *PhotonAcc;
152 AliRICHRecon::AliRICHRecon(const char*, const char*)
155 fRich = (AliRICH*)gAlice->GetDetector("RICH");
159 void AliRICHRecon::InitRecon()
162 outputfile = new TFile("Anal.root","RECREATE","My Analysis histos");
163 if(kDISPLAY) Display = new TCanvas("Display","RICH Display",0,0,1200,750);
165 h1_photons = new TH1F("h1_photons","photons",750,0.,0.75);
166 h1_photacc = new TH1F("h1_photacc","photons",750,0.,0.75);
167 h1_hough = new TH1F("h1_hough","hough",750,0.,0.75);
168 h1_houghpos= new TH1F("h1_houghpos","hough",750,0.,0.75);
169 h1_houghneg= new TH1F("h1_houghneg","hough",750,0.,0.75);
171 h2_tvsppos = new TH2F("h2_tvsppos","thetac vs p",100,0.,5.,750,0.,0.75);
172 h2_tvspneg = new TH2F("h2_tvspneg","thetac vs p",100,0.,5.,750,0.,0.75);
173 h2_func = new TH2F("h2_func"," func ",800,0.,0.8,100,-100.,100.);
174 h2_mvsp = new TH2F("h2_mvsp","mass vs p",100,0.,5.,200,0.,2.);
175 h2_mvst = new TH2F("h2_mvst","mass vs t",750,0.,0.75,200,0.,2.);
176 h2_map = new TH2F("h2_map","h2_map",160,0.,160.,96,0.,96.);
177 h2_mapw = new TH2F("h2_mapw","h2_mapw",160,0.,160.,96,0.,96.);
179 h2_dist_p = new TH2F("h2_dist_p","h2_dist_p",100,0.,5.,100,0.,5.);
182 h2_disp = new TH2F("h2_disp","STAR-RICH Event Display",165,Xmin,Xmax,100,Ymin,Ymax);
184 // h2_test1 = new TH2F("h2_test1","test1 map",165,-64.,64.,100,-42.,42.);
185 h2_test2 = new TH2F("h2_test2","test2 map",165,-64.,64.,100,-42.,42.);
186 // h2_test4 = new TH2F("h2_test4","test4 map",165,-64.,64.,100,-42.,42.);
187 h2_testmap= new TH2F("h2_testmap","test map",165,-64.,64.,100,-42.,42.);
190 h1_photons1 = new TH1F("h1_photons1","photons",750,0.,0.75);
191 h1_photons2 = new TH1F("h1_photons2","photons",750,0.,0.75);
193 h1_hcs = new TH1F("h1_hcs","hcs",750,0.,750.);
194 h1_hcsw = new TH1F("h1_hcsw","hcsw",750,0.,750.);
196 h1_nprotons = new TH1F("h1_nprotons","n prot",30,0.,30.);
198 hp_1pos = new TProfile("hp_1pos","Nphot vs thetac pos",250,0.,0.75);
199 hp_1neg = new TProfile("hp_1neg","Nphot vs thetac neg",250,0.,0.75);
200 hp_1posnorm = new TProfile("hp_1posnorm","Nphot vs thetac pos norm",250,0.,0.75);
201 hp_1negnorm = new TProfile("hp_1negnorm","Nphot vs thetac neg norm",250,0.,0.75);
203 h2_1pos = new TH2F("h2_1pos","Nphot vs p pos",100,0.,5.,30,0.,30.);
204 h2_1neg = new TH2F("h2_1neg","Nphot vs p neg",100,0.,5.,30,0.,30.);
205 h2_1posnorm = new TH2F("h2_1posnorm","Nphot vs p pos norm",100,0.,5.,30,0.,30.);
206 h2_1negnorm = new TH2F("h2_1negnorm","Nphot vs p neg norm",100,0.,5.,30,0.,30.);
208 h1_deltap = new TH1F("h1_deltap","delta_p",200,-0.5,0.5);
209 h1_deltapop = new TH1F("h1_deltapop","deltapop",200,-1.,1.);
210 h1_diffTrackTheta = new TH1F("h1_diffTrackTheta","delta theta",200,-0.25,0.25);
211 h1_diffTrackPhi = new TH1F("h1_diffTrackPhi","delta phi",200,-0.25,0.25);
213 h1_photaccspread = new TH1F("h1_photaccspread","photons spread",200,-0.1,0.1);
217 h1_mass = new TH1F("h1_mass","mass",200,0.,2.);
218 photris = new TH1F("photris","photris",1000,0.,1.);
219 h2_diffneg = new TH2F("h2_diffneg","diff neg",100,-2.5,2.5,100,-2.5,2.5);
220 h2_diffpos = new TH2F("h2_diffpos","diff pos",100,-2.5,2.5,100,-2.5,2.5);
221 gChargeMipH1 = new TH1F("gChargeMipH1"," Charge Mip ",2000,0.,2000.);
222 gMultMipH1 = new TH1F("gMultMipH1"," Cluster Size Mip ",50,0.,50.);
225 hn = new TNtuple("hn","ntuple",
226 "Run:Trig:VertZ:Pmod:Pt:Eta:TrackTheta:TrackPhi:TrackThetaFit:TrackPhiFit:Charge:ThetaCerenkov:NPhotons:NPhotonsFit:InRing:MassOfParticle:HoughArea:Multiplicity:TPCLastZ");
229 void AliRICHRecon::StartProcessEvent()
232 Float_t TrackThetaStored = 0;
233 Float_t TrackPhiStored = 0;
234 Float_t ThetaCerenkovStored = 0;
235 Int_t HoughPhotonsStored = 0;
237 SetFreonScaleFactor(0.994);
245 Rich()->GetLoader()->LoadHits();
246 Rich()->GetLoader()->LoadRecPoints();
247 Rich()->GetLoader()->LoadDigits();
248 gAlice->GetRunLoader()->LoadHeader();
249 gAlice->GetRunLoader()->LoadKinematics();
251 Rich()->GetLoader()->TreeR()->GetEntry(0);
253 Float_t clusX[7][500],clusY[7][500];
254 Int_t clusQ[7][500],clusMul[7][500];
257 for (Int_t ich=0;ich<7;ich++) {
258 nClusters[ich] = Rich()->ClustersOld(ich+1)->GetEntries();
259 for(Int_t k=0;k<nClusters[ich];k++) {
260 AliRICHRawCluster *pCluster = (AliRICHRawCluster *)Rich()->ClustersOld(ich+1)->At(k);
261 clusX[ich][k] = pCluster->fX;
262 clusY[ich][k] = pCluster->fY;
263 clusQ[ich][k] = pCluster->fQ;
264 clusMul[ich][k] = pCluster->fMultiplicity;
269 Int_t nPrimaries = (Int_t)Rich()->GetLoader()->TreeH()->GetEntries();
271 cout << " N. primaries " << nPrimaries << endl;
273 for(Int_t i=0;i<nPrimaries;i++){
275 Rich()->GetLoader()->TreeH()->GetEntry(i);
277 Rich()->Hits()->Print();
282 for(Int_t j=0;j<Rich()->Hits()->GetEntries();j++) {
284 pHit = (AliRICHhit*)Rich()->Hits()->At(j);
285 if(pHit->GetTrack() < nPrimaries) break;
289 cout << " iPrim " << iPrim << " pHit " << pHit << endl;
290 // if(iPrim==0) return;
291 // if(iPrim>1) Fatal("StartProcessEvent"," problems with prim to hit!!! = %3i", iPrim);
297 TParticle *pParticle = gAlice->GetRunLoader()->Stack()->Particle(pHit->GetTrack());
298 Float_t pmod = pParticle->P();
299 Float_t pt = pParticle->Pt();
300 Float_t TrackEta = pParticle->Eta();
301 Int_t q = (Int_t)TMath::Sign(1.,pParticle->GetPDG()->Charge());
305 cout << " pmod " << pmod << " pt " << pt << " Eta " << TrackEta << " charge " << q << endl;
307 SetTrackMomentum(pmod);
309 SetTrackEta(TrackEta);
312 TVector3 pGlob(pHit->MomFreoX(),pHit->MomFreoY(),pHit->MomFreoZ());
313 TVector3 pLocal = Rich()->C(pHit->Chamber())->Global2Local(pGlob,1);
315 Float_t primGlobalX = pHit->X();
316 Float_t primGlobalY = pHit->Y();
317 Float_t primGlobalZ = pHit->Z();
318 TVector3 primGlobal(primGlobalX,primGlobalY,primGlobalZ);
319 TVector3 primLocal = Rich()->C(pHit->Chamber())->Global2Local(primGlobal);
321 // Float_t pmodFreo = pLocal.Mag();
322 Float_t TrackTheta = pLocal.Theta();
323 Float_t TrackPhi = pLocal.Phi();
325 // cout << " TrackTheta " << TrackTheta << " TrackPhi " << TrackPhi << endl;
327 SetTrackTheta(TrackTheta);
328 SetTrackPhi(TrackPhi);
331 Float_t MinDist = 999.;
333 // cout << " n Clusters " << nClusters[pHit->Chamber()-1] << " for chamber n. " << pHit->Chamber() << endl;
335 for(Int_t j=0;j<nClusters[pHit->Chamber()-1];j++)
337 Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][j];
338 Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][j];
340 // cout << " cluster x " << clusX[pHit->Chamber()-1][j] << " hit track x " << primLocal.X();
341 // cout << " cluster y " << clusY[pHit->Chamber()-1][j] << " hit track y " << primLocal.Y() << endl;
343 Float_t diff = sqrt(diffx*diffx + diffy*diffy);
353 Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][MaxInd];
354 Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][MaxInd];
356 cout << " diffx " << diffx << " diffy " << diffy << endl;
360 h2_diffpos->Fill(diffx,diffy);
362 h2_diffneg->Fill(diffx,diffy);
368 Float_t ShiftX = primLocal.X()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.X();
369 Float_t ShiftY = primLocal.Y()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.Y();
374 Float_t *pclusX = &clusX[pHit->Chamber()-1][0];
375 Float_t *pclusY = &clusY[pHit->Chamber()-1][0];
377 SetCandidatePhotonX(pclusX);
378 SetCandidatePhotonY(pclusY);
379 SetCandidatePhotonsNumber(nClusters[pHit->Chamber()-1]);
381 Int_t qch = clusQ[pHit->Chamber()-1][MaxInd];
383 gChargeMipH1->Fill(qch);
384 gMultMipH1->Fill((Float_t)clusMul[pHit->Chamber()-1][MaxInd]);
386 if(MinDist < 3.0 && qch > 120 && MaxInd !=0)
392 Float_t Xrndm = Xmin + (Xmax-Xmin)*gRandom->Rndm(280964);
393 Float_t Yrndm = Ymin + (Ymax-Ymin)*gRandom->Rndm(280964);
395 cout << " Xrndm " << Xrndm << " Yrndm " << Yrndm << endl;
404 TrackThetaStored = GetTrackTheta();
405 TrackPhiStored = GetTrackPhi();
406 ThetaCerenkovStored = GetThetaCerenkov();
407 HoughPhotonsStored = GetHoughPhotons();
409 Int_t DiffNPhotons = 999;
411 Float_t DiffTrackTheta = 999.;
412 Float_t DiffTrackPhi = 999.;
414 while( kMINIMIZER && GetHoughPhotons() > 2
416 && DiffTrackTheta > 0.0001
420 Int_t HoughPhotonsBefore = GetHoughPhotons();
422 Float_t TrackThetaBefore = GetTrackTheta();
423 Float_t TrackPhiBefore = GetTrackPhi();
429 DiffNPhotons = abs(HoughPhotonsBefore - GetHoughPhotons());
431 Float_t TrackThetaAfter = GetTrackTheta();
432 Float_t TrackPhiAfter = GetTrackPhi();
434 DiffTrackTheta = TMath::Abs(TrackThetaAfter - TrackThetaBefore);
435 DiffTrackPhi = TMath::Abs(TrackPhiAfter - TrackPhiBefore);
438 cout << " HoughPhotonsBefore " << HoughPhotonsBefore
439 << " GetHoughPhotons() " << GetHoughPhotons();
444 SetFittedThetaCerenkov(GetThetaCerenkov());
445 SetFittedHoughPhotons(GetHoughPhotons());
447 SetTrackTheta(TrackThetaStored);
448 SetTrackPhi(TrackPhiStored);
449 SetThetaCerenkov(ThetaCerenkovStored);
450 SetHoughPhotons(HoughPhotonsStored);
456 if(kDISPLAY) DrawEvent(1);
463 if(kDISPLAY) Display->Print("display.ps");
467 void AliRICHRecon::EndProcessEvent()
469 // function called at the end of the event loop
471 printf("Processed events: %d Total events: %d \n",TotEvents,NevTOT);
477 void AliRICHRecon::PatRec()
480 cout << " in PatRec:: " << endl;
482 Float_t TrackTheta = GetTrackTheta();
483 Float_t TrackPhi = GetTrackPhi();
484 Float_t pmod = GetTrackMomentum();
485 // Int_t q = GetTrackCharge();
487 // Int_t TrackIndex = GetTrackIndex();
488 Int_t MipIndex = GetMipIndex();
490 Bool_t kPatRec = kFALSE;
492 Int_t CandidatePhotons = 0;
494 Float_t ShiftX = GetShiftX();
495 Float_t ShiftY = GetShiftY();
497 Float_t* CandidatePhotonX = GetCandidatePhotonX();
498 Float_t* CandidatePhotonY = GetCandidatePhotonY();
500 Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
502 if(fDebug) cout << " n " << CandidatePhotonsNumber << endl;
504 SetThetaCerenkov(999.);
506 SetHoughPhotonsNorm(0);
509 for (Int_t j=0; j < CandidatePhotonsNumber; j++)
518 if (j == MipIndex) continue;
520 // h2_test1->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
522 if(CandidatePhotonX[j] < -64.) continue; /* avoid artificial clusters from edge uesd by Yale.... */
524 Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
525 Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
527 // Float_t chargehit = fHits_charge[j];
528 // if(chargehit > 150) continue;
530 SetEntranceX(Xtoentr);
531 SetEntranceY(Ytoentr);
535 Int_t PhotonStatus = PhotonInBand();
539 cout << " Photon n. " << j << " Status " << PhotonStatus << " accepted " << endl;
540 cout << " CandidatePhotonX[j] " << CandidatePhotonX[j] << " CandidatePhotonY[j] " << CandidatePhotonY[j] << endl;
543 if(PhotonStatus == 0) continue;
547 FindThetaPhotonCerenkov();
549 Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
551 if(fDebug) cout << " theta photon " << ThetaPhotonCerenkov << endl;
553 SetPhotonEta(ThetaPhotonCerenkov);
559 // h2_test4->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
561 // if(kDISPLAY) h1_photons->Fill(ThetaPhotonCerenkov);
565 if(CandidatePhotons >= 1) kPatRec = kTRUE;
569 SetThetaCerenkov(999.);
572 SetPhotonsNumber(CandidatePhotonsNumber);
579 Int_t NPhotonHough = GetHoughPhotons();
583 SetThetaCerenkov(999.);
584 SetHoughPhotonsNorm(0.);
588 if(kWEIGHT) FindWeightThetaCerenkov();
590 Float_t ThetaCerenkov = GetThetaCerenkov();
592 SetThetaOfRing(ThetaCerenkov);
593 FindAreaAndPortionOfRing();
595 Float_t NPhotonHoughNorm = ((Float_t)NPhotonHough)/GetPortionOfRing();
596 SetHoughPhotonsNorm(NPhotonHoughNorm);
598 // Calculate the area where the photon are accepted...
600 Float_t ThetaInternal = ThetaCerenkov - 0.5*fWindowWidth;
601 SetThetaOfRing(ThetaInternal);
602 FindAreaAndPortionOfRing();
603 Float_t InternalArea = GetAreaOfRing();
605 Float_t ThetaExternal = ThetaCerenkov + 0.5*fWindowWidth;
606 SetThetaOfRing(ThetaExternal);
607 FindAreaAndPortionOfRing();
608 Float_t ExternalArea = GetAreaOfRing();
610 Float_t HoughArea = ExternalArea - InternalArea;
612 SetHoughArea(HoughArea);
616 cout << " ----- SUMMARY OF RECONSTRUCTION ----- " << endl;
617 cout << " Rings found " << NRings << " with thetac " << ThetaCerenkov << endl;
619 h1_hough->Fill(ThetaCerenkov,1.);
621 cout << " Nphotons " << GetPhotonsNumber()
622 << " Hough " << NPhotonHough
623 << " norm " << NPhotonHoughNorm << endl;
625 cout << " In PatRec:p " << pmod << " theta " << TrackTheta << " phi " << TrackPhi << endl;
626 cout << " ------------------------------------- " << endl;
629 Int_t NPhotons = GetPhotonsNumber();
635 for (Int_t j=0; j < NPhotons;j++)
639 Float_t eta = GetPhotonEta();
643 if(GetPhotonFlag() == 2)
646 if(pmod>2.5&&ThetaCerenkov>0.65) photris->Fill(eta);
657 xmean /=(Float_t)nev;
658 x2mean /=(Float_t)nev;
664 Float_t RMS = sqrt(x2mean - xmean*xmean);
668 if(fDebug) cout << " RMS " << RMS << endl;
672 void AliRICHRecon::FindEmissionPoint()
675 // Find emission point
677 Float_t absorbtionLenght=7.83*RadiatorWidth; //absorption length in the freon (cm)
678 // 7.83 = -1/ln(T0) where
679 // T0->Trasmission freon at 180nm = 0.88 (Eph=6.85eV)
680 Float_t photonLenght, photonLenghtMin, photonLenghtMax;
682 photonLenght=exp(-RadiatorWidth/(absorbtionLenght*cos(fCerenkovAnglePad)));
683 photonLenghtMin=RadiatorWidth*photonLenght/(1.-photonLenght);
684 photonLenghtMax=absorbtionLenght*cos(fCerenkovAnglePad);
685 Float_t EmissionPoint = RadiatorWidth + photonLenghtMin - photonLenghtMax;
687 SetEmissionPoint(EmissionPoint);
691 Int_t AliRICHRecon::PhotonInBand()
694 // Float_t MassOfParticle;
700 Float_t Xtoentr = GetEntranceX();
701 Float_t Ytoentr = GetEntranceY();
706 Float_t phpad = GetPhiPoint();
708 // Float_t pmod = GetTrackMomentum();
709 // Float_t TrackTheta = GetTrackTheta();
710 // Float_t TrackPhi = GetTrackPhi();
713 SetPhotonEnergy(5.6);
714 SetEmissionPoint(RadiatorWidth -0.0001);
715 SetMassHypotesis(0.93828);
718 SetFreonRefractiveIndex();
720 beta = GetBetaOfParticle();
721 nfreon = GetFreonRefractiveIndex();
723 thetacer = Cerenkovangle(nfreon,beta);
727 if(fDebug) cout << " thetacer in photoninband min " << thetacer << endl;
729 FindThetaAtQuartz(thetacer);
731 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
734 SetXInnerRing(-999.);
735 SetYInnerRing(-999.);
736 SetRadiusInnerRing(-999.);
740 SetThetaPhotonInDRS(GetThetaAtQuartz());
741 SetPhiPhotonInDRS(phpad);
743 InnerRadius = FromEmissionToCathode();
744 if(InnerRadius == 999.) InnerRadius = -999.;
746 SetXInnerRing(GetXPointOnCathode());
747 SetYInnerRing(GetYPointOnCathode());
748 SetRadiusInnerRing(InnerRadius);
752 SetPhotonEnergy(7.7);
753 SetEmissionPoint(0.);
754 // SetMassHypotesis(0.139567);
755 SetMassHypotesis(0.);
758 SetFreonRefractiveIndex();
760 beta = GetBetaOfParticle();
761 nfreon = GetFreonRefractiveIndex();
763 thetacer = Cerenkovangle(nfreon,beta);
767 if(fDebug) cout << " thetacer in photoninband max " << thetacer << endl;
769 FindThetaAtQuartz(thetacer);
771 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
776 SetRadiusOuterRing(999.);
780 SetThetaPhotonInDRS(GetThetaAtQuartz());
781 SetPhiPhotonInDRS(phpad);
783 OuterRadius = FromEmissionToCathode();
784 // cout << " OuterRadius " << OuterRadius << endl;
785 SetXOuterRing(GetXPointOnCathode());
786 SetYOuterRing(GetYPointOnCathode());
787 SetRadiusOuterRing(OuterRadius);
790 Float_t padradius = sqrt(TMath::Power(Xtoentr,2)+TMath::Power(Ytoentr,2));
792 if(fDebug) printf(" rmin %f r %f rmax %f \n",InnerRadius,padradius,OuterRadius);
794 if(padradius>=InnerRadius && padradius<=OuterRadius) return 1;
798 void AliRICHRecon::FindThetaAtQuartz(Float_t ThetaCerenkov)
801 if(ThetaCerenkov == 999.)
803 SetThetaAtQuartz(999.);
807 Float_t ThetaAtQuartz = 999.;
809 Float_t TrackTheta = GetTrackTheta();
811 if(TrackTheta == 0) {
813 if(fDebug) cout << " Theta sol unique " << ThetaCerenkov << endl;
815 ThetaAtQuartz = ThetaCerenkov;
816 SetThetaAtQuartz(ThetaAtQuartz);
820 Float_t TrackPhi = GetTrackPhi();
821 Float_t PhiPoint = GetPhiPoint();
823 Double_t den = TMath::Sin((Double_t)TrackTheta)
824 *TMath::Cos((Double_t)TrackPhi)
825 *TMath::Cos((Double_t)PhiPoint) +
826 TMath::Sin((Double_t)TrackTheta)
827 *TMath::Sin((Double_t)TrackPhi)
828 *TMath::Sin((Double_t)PhiPoint);
829 Double_t b = TMath::Cos((Double_t)TrackTheta)/den;
830 Double_t c = -TMath::Cos((Double_t)ThetaCerenkov)/den;
832 Double_t UnderSqrt = 1 + b*b - c*c;
836 cout << " TrackTheta " << TrackTheta << endl;
837 cout << " TrackPhi " << TrackPhi << endl;
838 cout << " PhiPoint " << PhiPoint << endl;
839 cout << " ThetaCerenkov " << ThetaCerenkov << endl;
840 cout << " den b c " << den << " b " << b << " c " << c << endl;
844 if(fDebug) cout << " sqrt negative !!!!" << UnderSqrt << endl;
845 SetThetaAtQuartz(999.);
849 Double_t sol1 = (1+TMath::Sqrt(UnderSqrt))/(b-c);
850 Double_t sol2 = (1-TMath::Sqrt(UnderSqrt))/(b-c);
852 Double_t ThetaSol1 = 2*TMath::ATan(sol1);
853 Double_t ThetaSol2 = 2*TMath::ATan(sol2);
855 if(fDebug) cout << " Theta sol 1 " << ThetaSol1
856 << " Theta sol 2 " << ThetaSol2 << endl;
858 if(ThetaSol1>0 && ThetaSol1 < pi) ThetaAtQuartz = (Float_t)ThetaSol1;
859 if(ThetaSol2>0 && ThetaSol2 < pi) ThetaAtQuartz = (Float_t)ThetaSol2;
861 SetThetaAtQuartz(ThetaAtQuartz);
864 void AliRICHRecon::FindThetaPhotonCerenkov()
867 Float_t ThetaCerMin = 0.;
868 Float_t ThetaCerMax = 0.75;
869 Float_t ThetaCerMean;
871 Float_t RadiusMin, RadiusMax, RadiusMean;
872 Int_t nIteration = 0;
874 const Float_t Tollerance = 0.05;
876 // Float_t pmod = GetTrackMomentum();
877 // Float_t TrackTheta = GetTrackTheta();
878 // Float_t TrackPhi = GetTrackPhi();
880 Float_t PhiPoint = GetPhiPoint();
882 SetPhotonEnergy(6.85);
883 SetEmissionPoint(RadiatorWidth/2);
885 Float_t XPoint = GetEntranceX();
886 Float_t YPoint = GetEntranceY();
887 Float_t DistPoint = sqrt(XPoint*XPoint + YPoint*YPoint);
889 if(fDebug) cout << " DistPoint " << DistPoint << endl;
891 // Star minimization...
895 FindThetaAtQuartz(ThetaCerMin);
897 if(GetThetaAtQuartz() == 999.)
903 SetThetaPhotonInDRS(GetThetaAtQuartz());
904 SetPhiPhotonInDRS(PhiPoint);
906 RadiusMin = FromEmissionToCathode();
911 FindThetaAtQuartz(ThetaCerMax);
912 if(GetThetaAtQuartz() == 999.)
918 SetThetaPhotonInDRS(GetThetaAtQuartz());
919 SetPhiPhotonInDRS(PhiPoint);
921 RadiusMax = FromEmissionToCathode();
925 ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
927 FindThetaAtQuartz(ThetaCerMean);
928 if(GetThetaAtQuartz() == 999.)
934 SetThetaPhotonInDRS(GetThetaAtQuartz());
935 SetPhiPhotonInDRS(PhiPoint);
937 RadiusMean = FromEmissionToCathode();
940 if(fDebug) cout << " r1 " << RadiusMin << " rmean "
941 << RadiusMean << " r2 " << RadiusMax << endl;
943 while (TMath::Abs(RadiusMean-DistPoint) > Tollerance)
946 if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) < 0) ThetaCerMax = ThetaCerMean;
947 if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) > 0) {
949 ThetaCerMin = ThetaCerMean;
951 FindThetaAtQuartz(ThetaCerMin);
952 SetThetaPhotonInDRS(GetThetaAtQuartz());
953 SetPhiPhotonInDRS(PhiPoint);
955 RadiusMin =FromEmissionToCathode();
958 ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
960 FindThetaAtQuartz(ThetaCerMean);
961 SetThetaPhotonInDRS(GetThetaAtQuartz());
962 SetPhiPhotonInDRS(PhiPoint);
964 RadiusMean = FromEmissionToCathode();
968 if(fDebug) printf(" max iterations in FindPhotonCerenkov\n");
969 SetThetaPhotonCerenkov(999.);
974 SetThetaPhotonCerenkov(ThetaCerMean);
978 void AliRICHRecon::FindAreaAndPortionOfRing()
981 Float_t XPoint[NPointsOfRing], YPoint[NPointsOfRing];
983 // Float_t Xtoentr = GetEntranceX();
984 // Float_t Ytoentr = GetEntranceY();
985 Float_t ShiftX = GetShiftX();
986 Float_t ShiftY = GetShiftY();
988 Float_t XEmiss = GetXCoordOfEmission();
989 Float_t YEmiss = GetYCoordOfEmission();
991 Float_t x0 = XEmiss + ShiftX;
992 Float_t y0 = YEmiss + ShiftY;
994 // Float_t pmod = GetTrackMomentum();
995 // Float_t TrackTheta = GetTrackTheta();
996 // Float_t TrackPhi = GetTrackPhi();
998 SetPhotonEnergy(6.85);
999 SetFreonRefractiveIndex();
1001 SetEmissionPoint(RadiatorWidth/2.);
1003 Float_t Theta = GetThetaOfRing();
1006 Int_t NPsiAccepted = 0;
1007 Int_t NPsiTotal = 0;
1009 for(Int_t i=0;i<NPointsOfRing-1;i++)
1012 Float_t Psi = 2*TMath::Pi()*i/NPointsOfRing;
1014 SetThetaPhotonInTRS(Theta);
1015 SetPhiPhotonInTRS(Psi);
1016 FindPhotonAnglesInDRS();
1018 Float_t Radius = FromEmissionToCathode();
1019 if (Radius == 999.) continue;
1023 Float_t XPointRing = GetXPointOnCathode() + ShiftX;
1024 Float_t YPointRing = GetYPointOnCathode() + ShiftY;
1026 SetDetectorWhereX(XPointRing);
1027 SetDetectorWhereY(YPointRing);
1029 Int_t Zone = CheckDetectorAcceptance();
1031 // cout << " XPointing " << XPointRing << " YPointing " << YPointRing << " Zone " << Zone << endl;
1032 // cout << " ShiftX " << ShiftX << " ShiftY " << ShiftY << endl;
1033 // cout << " GetXPointOnCathode() " << GetXPointOnCathode() << endl;
1034 // cout << " GetYPointOnCathode() " << GetYPointOnCathode() << endl;
1038 FindIntersectionWithDetector();
1039 XPoint[nPoints] = GetIntersectionX();
1040 YPoint[nPoints] = GetIntersectionY();
1044 XPoint[nPoints] = XPointRing;
1045 YPoint[nPoints] = YPointRing;
1053 XPoint[nPoints] = XPoint[0];
1054 YPoint[nPoints] = YPoint[0];
1060 for (Int_t i = 0; i < nPoints; i++)
1062 Area += TMath::Abs((XPoint[i]-x0)*(YPoint[i+1]-y0) - (XPoint[i+1]-x0)*(YPoint[i]-y0));
1067 Float_t PortionOfRing = ((Float_t)NPsiAccepted)/((Float_t)(NPsiTotal));
1069 // cout << " Area " << Area << " Portion of ring " << PortionOfRing << endl;
1071 SetAreaOfRing(Area);
1072 SetPortionOfRing(PortionOfRing);
1075 void AliRICHRecon::FindIntersectionWithDetector()
1078 Float_t XIntersect, YIntersect;
1079 Float_t x1, x2, y1, y2;
1081 Float_t ShiftX = GetShiftX();
1082 Float_t ShiftY = GetShiftY();
1084 Float_t XPoint = GetXPointOnCathode() + ShiftX;
1085 Float_t YPoint = GetYPointOnCathode() + ShiftY;
1087 Float_t XEmiss = GetXCoordOfEmission();
1088 Float_t YEmiss = GetYCoordOfEmission();
1090 Float_t Phi = GetPhiPhotonInDRS();
1091 Float_t m = tan(Phi);
1093 Float_t x0 = XEmiss + ShiftX;
1094 Float_t y0 = YEmiss + ShiftY;
1118 YIntersect = m*(XIntersect - x0) + y0;
1119 if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
1121 SetIntersectionX(XIntersect);
1122 SetIntersectionY(YIntersect);
1127 YIntersect = m*(XIntersect - x0) + y0;
1128 if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
1130 SetIntersectionX(XIntersect);
1131 SetIntersectionY(YIntersect);
1136 XIntersect = (YIntersect - y0)/m + x0;
1137 if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
1139 SetIntersectionX(XIntersect);
1140 SetIntersectionY(YIntersect);
1145 XIntersect = (YIntersect - y0)/m + x0;
1146 if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
1148 SetIntersectionX(XIntersect);
1149 SetIntersectionY(YIntersect);
1153 cout << " sono fuori!!!!!!" << endl;
1154 // cout << " x1 " << x1 << " x2 " << x2 << endl;
1155 // cout << " y1 " << y1 << " y2 " << y2 << endl;
1156 // cout << " Xmin " << Xmin << " Xmax " << Xmax << endl;
1157 // cout << " Ymin " << Ymin << " Ymax " << Ymax << endl;
1161 Int_t AliRICHRecon::CheckDetectorAcceptance()
1164 // crosses X -2.6 2.6 cm
1165 // crosses Y -1 1 cm
1167 Float_t Xcoord = GetDetectorWhereX();
1168 Float_t Ycoord = GetDetectorWhereY();
1170 // cout << " Xcoord " << Xcoord << " Ycoord " << Ycoord << endl;
1173 if(Ycoord > Ymax) return 2;
1174 if(Ycoord > Ymin && Ycoord < Ymax) return 3;
1175 if(Ycoord < Ymin) return 4;
1179 if(Ycoord > Ymax) return 8;
1180 if(Ycoord > Ymin && Ycoord < Ymax) return 7;
1181 if(Ycoord < Ymin) return 6;
1183 if(Xcoord > Xmin && Xcoord < Xmax)
1185 if(Ycoord > Ymax) return 1;
1186 if(Ycoord > Ymin && Ycoord < Ymax) return 0;
1187 if(Ycoord < Ymin) return 5;
1192 void AliRICHRecon::DrawRing()
1195 // Float_t xGraph[1000],yGraph[1000];
1198 // Float_t MassOfParticle;
1202 Float_t ThetaCerenkov;
1204 // Float_t Xtoentr = GetEntranceX();
1205 // Float_t Ytoentr = GetEntranceY();
1207 // Float_t pmod = GetTrackMomentum();
1208 // Float_t TrackTheta = GetTrackTheta();
1209 // Float_t TrackPhi = GetTrackPhi();
1211 SetPhotonEnergy(6.85);
1212 SetFreonRefractiveIndex();
1214 SetEmissionPoint(RadiatorWidth/2.);
1220 SetMassHypotesis(0.139567);
1221 SetBetaOfParticle();
1223 beta = GetBetaOfParticle();
1228 ThetaCerenkov = GetThetaCerenkov();
1229 FindBetaFromTheta(ThetaCerenkov);
1232 nfreon = GetFreonRefractiveIndex();
1234 Float_t thetacer = Cerenkovangle(nfreon,beta);
1236 if(fDebug) cout << " TetaCer in DrawRing " << thetacer << endl;
1238 Int_t nPoints = 100;
1240 Int_t nPointsToDraw = 0;
1241 for(Int_t i=0;i<nPoints;i++)
1243 Float_t phpad = 2*TMath::Pi()*i/nPoints;
1244 SetThetaPhotonInTRS(thetacer);
1245 SetPhiPhotonInTRS(phpad);
1246 FindPhotonAnglesInDRS();
1247 Float_t Radius = FromEmissionToCathode();
1248 if (Radius == 999.) continue;
1249 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
1250 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
1251 // cout << " get shift X " << GetShiftX() << endl;
1252 // cout << " get shift Y " << GetShiftY() << endl;
1257 if(fDebug) cout << " Drawing the Ring... with " << nPointsToDraw << " points " << endl;
1259 // pol = new TPolyLine(nPointsToDraw,xGraph,yGraph);
1260 // pol->Draw("same");
1261 gra = new TGraph(nPointsToDraw,xGraph,yGraph);
1263 StarCanvas->Update();
1267 Float_t AliRICHRecon::PhotonPositionOnCathode()
1269 // Float_t MassOfParticle;
1273 // Float_t pmod = GetTrackMomentum();
1274 // Float_t TrackTheta = GetTrackTheta();
1275 // Float_t TrackPhi = GetTrackPhi();
1277 // Float_t phpad = GetPhiPoint();
1279 SetPhotonEnergy(6.85);
1280 SetEmissionPoint(RadiatorWidth/2.);
1281 SetMassHypotesis(0.139567);
1283 SetBetaOfParticle();
1284 SetFreonRefractiveIndex();
1286 beta = GetBetaOfParticle();
1287 nfreon = GetFreonRefractiveIndex();
1289 // Float_t thetacer = Cerenkovangle(nfreon,beta);
1291 // cout << " FromEmissionToCathode: thetacer " << thetacer << " phpad " << phpad << endl;
1293 Float_t Radius = FromEmissionToCathode();
1294 if (Radius == 999.) return 999.;
1296 // Float_t Xphoton = GetXPointOnCathode();
1297 // Float_t Yphoton = GetYPointOnCathode();
1298 // cout << " PhotonPositionOnCathode: Xphoton " << Xphoton << " Yphoton " << Yphoton <<
1299 // " Radius for photon " << Radius << endl;
1303 void AliRICHRecon::FindPhotonAnglesInDRS()
1305 // Setup the rotation matrix of the track...
1312 Float_t TrackTheta = GetTrackTheta();
1313 Float_t TrackPhi = GetTrackPhi();
1315 Mtheta.RotateY(TrackTheta);
1316 Mphi.RotateZ(TrackPhi);
1318 Mrot = Mphi * Mtheta;
1319 // Minv = Mrot.Inverse();
1321 TVector3 PhotonInRadiator(1,1,1);
1323 Float_t ThetaCerenkov = GetThetaPhotonInTRS();
1324 Float_t PhiCerenkov = GetPhiPhotonInTRS();
1326 PhotonInRadiator.SetTheta(ThetaCerenkov);
1327 PhotonInRadiator.SetPhi(PhiCerenkov);
1328 PhotonInRadiator = Mrot * PhotonInRadiator;
1329 Float_t Theta = PhotonInRadiator.Theta();
1330 Float_t Phi = PhotonInRadiator.Phi();
1331 SetThetaPhotonInDRS(Theta);
1332 SetPhiPhotonInDRS(Phi);
1336 Float_t AliRICHRecon::FromEmissionToCathode()
1339 Float_t nfreon, nquartz, ngas;
1341 SetFreonRefractiveIndex();
1342 SetQuartzRefractiveIndex();
1343 SetGasRefractiveIndex();
1345 nfreon = GetFreonRefractiveIndex();
1346 nquartz = GetQuartzRefractiveIndex();
1347 ngas = GetGasRefractiveIndex();
1349 Float_t TrackTheta = GetTrackTheta();
1350 Float_t TrackPhi = GetTrackPhi();
1351 Float_t LengthOfEmissionPoint = GetEmissionPoint();
1353 Float_t Theta = GetThetaPhotonInDRS();
1354 Float_t Phi = GetPhiPhotonInDRS();
1356 // cout << " Theta " << Theta << " Phi " << Phi << endl;
1358 Float_t xEmiss = LengthOfEmissionPoint*tan(TrackTheta)*cos(TrackPhi);
1359 Float_t yEmiss = LengthOfEmissionPoint*tan(TrackTheta)*sin(TrackPhi);
1361 SetXCoordOfEmission(xEmiss);
1362 SetYCoordOfEmission(yEmiss);
1364 Float_t thetaquar = SnellAngle(nfreon, nquartz, Theta);
1366 if(thetaquar == 999.)
1368 SetXPointOnCathode(999.);
1369 SetYPointOnCathode(999.);
1373 Float_t thetagap = SnellAngle( nquartz, ngas, thetaquar);
1375 if(thetagap == 999.)
1377 SetXPointOnCathode(999.);
1378 SetYPointOnCathode(999.);
1382 Float_t xw = (RadiatorWidth - LengthOfEmissionPoint)*cos(Phi)*tan(Theta);
1383 Float_t xq = QuartzWidth*cos(Phi)*tan(thetaquar);
1384 Float_t xg = GapWidth*cos(Phi)*tan(thetagap);
1385 Float_t yw = (RadiatorWidth - LengthOfEmissionPoint)*sin(Phi)*tan(Theta);
1386 Float_t yq = QuartzWidth*sin(Phi)*tan(thetaquar);
1387 Float_t yg = GapWidth*sin(Phi)*tan(thetagap);
1389 // Float_t xtot = x1 + xw + xq + xg;
1390 // Float_t ytot = y1 + yw + yq + yg;
1392 Float_t xtot = xEmiss + xw + xq + xg;
1393 Float_t ytot = yEmiss + yw + yq + yg;
1395 SetXPointOnCathode(xtot);
1396 SetYPointOnCathode(ytot);
1398 // cout << " xtot " << xtot << " ytot " << ytot << endl;
1400 Float_t DistanceFromEntrance = sqrt(TMath::Power(fPhotonLimitX,2)
1401 +TMath::Power(fPhotonLimitY,2));
1403 return DistanceFromEntrance;
1408 void AliRICHRecon::FindPhiPoint()
1411 Float_t Xtoentr = GetEntranceX();
1412 Float_t Ytoentr = GetEntranceY();
1414 Float_t TrackTheta = GetTrackTheta();
1415 Float_t TrackPhi = GetTrackPhi();
1417 Float_t EmissionPoint = GetEmissionPoint();
1419 Float_t argY = Ytoentr - EmissionPoint*tan(TrackTheta)*sin(TrackPhi);
1420 Float_t argX = Xtoentr - EmissionPoint*tan(TrackTheta)*cos(TrackPhi);
1421 Float_t phipad = atan2(argY,argX);
1423 SetPhiPoint(phipad);
1427 Float_t AliRICHRecon::Cerenkovangle(Float_t n, Float_t beta)
1430 // Compute the cerenkov angle
1436 // cout << " warning in Cerenkoangle !!!!!! " << endl;
1440 thetacer = acos (1./(n*beta));
1444 Float_t AliRICHRecon::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
1447 // Compute the Snell angle
1449 Float_t sinrefractangle;
1450 Float_t refractangle;
1452 sinrefractangle = (n1/n2)*sin(theta1);
1454 if(sinrefractangle>1.) {
1455 // cout << " PROBLEMS IN SNELL ANGLE !!!!! " << endl;
1456 refractangle = 999.;
1457 return refractangle;
1460 refractangle = asin(sinrefractangle);
1461 return refractangle;
1465 void AliRICHRecon::HoughResponse()
1469 // Implement Hough response pat. rec. method
1476 int i, j, k, nCorrBand;
1477 float hcs[750],hcsw[750];
1478 float angle, weight;
1479 float lowerlimit,upperlimit;
1485 float etaPeakPos = -1;
1487 Int_t etaPeakCount = -1;
1489 Float_t ThetaCerenkov = 0.;
1491 nBin = (int)(0.5+fThetaMax/(fDTheta));
1492 nCorrBand = (int)(0.5+ fWindowWidth/(2 * fDTheta));
1494 memset ((void *)hcs, 0, fThetaBin*sizeof(float));
1495 memset ((void *)hcsw, 0, fThetaBin*sizeof(float));
1497 Int_t NPhotons = GetPhotonsNumber();
1499 Int_t WeightFlag = 0;
1501 for (k=0; k< NPhotons; k++) {
1505 angle = GetPhotonEta();
1507 if(angle == -999.) continue;
1509 if (angle>=fThetaMin && angle<= fThetaMax)
1513 bin = (int)(0.5+angle/(fDTheta));
1515 bin1= bin-nCorrBand;
1516 bin2= bin+nCorrBand;
1518 // calculate weights
1522 lowerlimit = ((Float_t)bin1)*fDTheta + 0.5*fDTheta;
1523 SetThetaOfRing(lowerlimit);
1524 FindAreaAndPortionOfRing();
1525 Float_t area1 = GetAreaOfRing();
1527 upperlimit = ((Float_t)bin2)*fDTheta + 0.5*fDTheta;
1528 SetThetaOfRing(upperlimit);
1529 FindAreaAndPortionOfRing();
1530 Float_t area2 = GetAreaOfRing();
1532 // cout << "lowerlimit" << lowerlimit << "upperlimit " << upperlimit << endl;
1533 Float_t diffarea = area2 - area1;
1537 weight = 1./(area2-area1);
1545 // cout <<" low "<< lowerlimit << " up " << upperlimit <<
1546 // " area1 " << area1 << " area2 " << area2 << " weight " << weight << endl;
1554 SetPhotonWeight(weight);
1556 // cout << "weight..." << weight << endl;
1558 h1_photons1->Fill(angle);
1559 h1_photons2->Fill(angle,weight);
1562 if (bin2>nBin) bin2=nBin;
1564 for (j=bin1; j<bin2; j++)
1574 // for(Int_t j=0;j<750;j++)
1576 // h1_hcs->Fill(((Float_t)j),hcs[j]);
1577 // h1_hcsw->Fill(((Float_t)j),hcsw[j]);
1588 // cout << " probems with weight...normal procedure adopted " << endl;
1591 HoughFiltering(HCSspace);
1593 for (bin=0; bin <nBin; bin++) {
1594 angle = (bin+0.5) * (fDTheta);
1595 if (HCSspace[bin] && HCSspace[bin] > etaPeakPos) {
1597 etaPeakPos = HCSspace[bin];
1601 if (HCSspace[bin] == etaPeakPos) {
1602 etaPeak[++etaPeakCount] = angle;
1607 for (i=0; i<etaPeakCount+1; i++) {
1608 ThetaCerenkov += etaPeak[i];
1610 if (etaPeakCount>=0) {
1611 ThetaCerenkov /= etaPeakCount+1;
1612 fThetaPeakPos = etaPeakPos;
1615 SetThetaCerenkov(ThetaCerenkov);
1619 void AliRICHRecon::HoughFiltering(float hcs[])
1625 float k[5] = {0.05, 0.25, 0.4, 0.25, 0.05};
1630 nBin = (int)(1+fThetaMax/fDTheta);
1631 sizeHCS = fThetaBin*sizeof(float);
1633 memset ((void *)hcsFilt, 0, sizeHCS);
1635 for (nx = 0; nx < nBin; nx++) {
1636 for (i = 0; i < 5; i++) {
1638 if (nxDx> -1 && nxDx<nBin)
1639 hcsFilt[nx] += hcs[nxDx] * k[i];
1643 for (nx = 0; nx < nBin; nx++) {
1644 hcs[nx] = hcsFilt[nx];
1648 void AliRICHRecon::FindWeightThetaCerenkov()
1652 Float_t WeightThetaCerenkov = 0.;
1654 Int_t NPhotons = GetPhotonsNumber();
1655 for(Int_t i=0;i<NPhotons;i++)
1659 if(GetPhotonFlag() == 2)
1661 Float_t PhotonEta = GetPhotonEta();
1662 Float_t PhotonWeight = GetPhotonWeight();
1663 WeightThetaCerenkov += PhotonEta*PhotonWeight;
1664 wei += PhotonWeight;
1670 WeightThetaCerenkov /= wei;
1674 WeightThetaCerenkov = 0.;
1677 SetThetaCerenkov(WeightThetaCerenkov);
1679 cout << " thetac weighted -> " << WeightThetaCerenkov << endl;
1683 void AliRICHRecon::FlagPhotons()
1686 Int_t NPhotonHough = 0;
1688 Float_t ThetaCerenkov = GetThetaCerenkov();
1689 if(fDebug) cout << " fThetaCerenkov " << ThetaCerenkov << endl;
1691 Float_t ThetaDist= ThetaCerenkov - fThetaMin;
1692 Int_t steps = (Int_t)(ThetaDist / fDTheta);
1694 Float_t tmin = fThetaMin + (Float_t)(steps - 1)*fDTheta;
1695 Float_t tmax = fThetaMin + (Float_t)(steps)*fDTheta;
1696 Float_t tavg = 0.5*(tmin+tmax);
1698 tmin = tavg - 0.5*fWindowWidth;
1699 tmax = tavg + 0.5*fWindowWidth;
1701 if(fDebug) cout << " tmin " << tmin << " tmax " << tmax << endl;
1702 if(fDebug) cout << " thetac " << ThetaCerenkov << endl;
1704 // Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
1706 Int_t NPhotons = GetPhotonsNumber();
1708 // for(Int_t i=0;i<CandidatePhotonsNumber;i++)
1710 for(Int_t i=0;i<NPhotons;i++)
1714 Float_t PhotonEta = GetPhotonEta();
1716 if(PhotonEta == -999.) continue;
1718 if(PhotonEta >= tmin && PhotonEta <= tmax)
1724 SetHoughPhotons(NPhotonHough);
1727 void AliRICHRecon::DrawEvent(Int_t flag)
1730 flag=1; // dummy to be removed...
1732 Float_t xGraph[3000],yGraph[3000];
1734 Float_t ThetaCerenkov;
1738 gStyle->SetPalette(1,0);
1743 // Display = new TCanvas("Display","Star Display",0,0,1200,750);
1745 Display->ToggleEventStatus();
1748 text = new TText(0,0,"");
1749 text->SetTextFont(61);
1750 text->SetTextSize(0.03);
1751 text->SetTextAlign(22);
1757 for(Int_t j=1;j<=nPixels;j++)
1759 Float_t xpad = fPixels_localX[j-1];
1760 Float_t ypad = fPixels_localY[j-1];
1761 h2_disp->Fill(xpad,ypad,fPixels_charge[j-1]);
1764 h2_disp->SetMaximum(200);
1765 // h2_disp->SetMaximum(1);
1766 h2_disp->SetStats(0);
1767 h2_disp->Draw("colz");
1769 for(Int_t i=0; i<nRichPrimaries;i++)
1773 TrackPoints = new TMarker(fRichPrimaries_localPadX[i],
1774 fRichPrimaries_localPadY[i],3);
1776 TrackPoints->SetMarkerSize(1.5);
1778 Float_t pmod = sqrt(fRichPrimaries_localPadPx[i] * fRichPrimaries_localPadPx[i] +
1779 fRichPrimaries_localPadPy[i] * fRichPrimaries_localPadPy[i] +
1780 fRichPrimaries_localPadPz[i] * fRichPrimaries_localPadPz[i]);
1782 if(pmod < 1) TrackPoints->SetMarkerColor(kBlue);
1783 if(pmod > 1 && pmod < 2) TrackPoints->SetMarkerColor(kGreen);
1784 if(pmod > 2) TrackPoints->SetMarkerColor(kRed);
1786 TrackPoints->Draw();
1788 line = new TLine(-0.13,-42.,-0.13,42.);
1790 line = new TLine(0.13,-42.,0.13,42.);
1792 line = new TLine(-64.,-0.13,64.,-0.13);
1794 line = new TLine(-64.,0.13,64.,0.13);
1809 // Float_t Xtoentr = GetEntranceX();
1810 // Float_t Ytoentr = GetEntranceY();
1812 // Float_t pmod = GetTrackMomentum();
1813 // Float_t TrackTheta = GetTrackTheta();
1814 // Float_t TrackPhi = GetTrackPhi();
1816 SetPhotonEnergy(6.85);
1817 SetFreonRefractiveIndex();
1819 SetEmissionPoint(RadiatorWidth/2.);
1821 ThetaCerenkov = GetThetaCerenkov();
1823 if (ThetaCerenkov == 999.) return;
1825 Int_t nPointsToDraw = 0;
1827 for(Int_t i=0;i<99;i++)
1829 Float_t phpad = 2*TMath::Pi()*i/99;
1830 SetThetaPhotonInTRS(ThetaCerenkov);
1831 SetPhiPhotonInTRS(phpad);
1832 FindPhotonAnglesInDRS();
1833 Float_t Radius = FromEmissionToCathode();
1835 if (Radius == 999.) continue;
1837 Float_t ShiftX = GetShiftX();
1838 Float_t ShiftY = GetShiftY();
1840 Float_t XPointRing = GetXPointOnCathode() + ShiftX;
1841 Float_t YPointRing = GetYPointOnCathode() + ShiftY;
1843 SetDetectorWhereX(XPointRing);
1844 SetDetectorWhereY(YPointRing);
1846 Int_t Zone = CheckDetectorAcceptance();
1850 FindIntersectionWithDetector();
1851 xGraph[nPointsToDraw] = GetIntersectionX();
1852 yGraph[nPointsToDraw] = GetIntersectionY();
1857 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
1858 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
1863 xGraph[nPointsToDraw] = xGraph[0];
1864 yGraph[nPointsToDraw] = yGraph[0];
1866 poll = new TPolyLine(nPointsToDraw+1,xGraph,yGraph);
1867 poll->SetLineColor(2);
1868 poll->SetLineWidth(3);
1875 for(Int_t j=0;j<nHits;j++)
1878 Float_t xhit = fHits_localX[j];
1879 Float_t yhit = fHits_localY[j];
1882 Int_t FlagPhoton = GetPhotonFlag();
1884 // if(FlagPhoton >= 1)
1887 // Photon = new TMarker(xhit,yhit,4);
1888 // Photon->SetMarkerSize(1.5);
1889 // Photon->Draw("same");
1897 PhotonAcc = new TMarker(xhit,yhit,30);
1898 PhotonAcc->SetMarkerSize(1.5);
1899 PhotonAcc->SetMarkerColor(50);
1900 PhotonAcc->Draw("same");
1908 // h1_photons->Draw();
1909 // Display->Update();
1912 // h1_photacc->Draw();
1913 // Display->Update();
1917 // Display->Update();
1919 // h1_photons->Reset();
1920 // h1_photacc->Reset();
1925 Float_t AliRICHRecon::FindMassOfParticle()
1928 Float_t pmod = GetTrackMomentum();
1930 SetPhotonEnergy(6.85);
1931 SetFreonRefractiveIndex();
1933 Float_t ThetaCerenkov = GetThetaCerenkov();
1934 FindBetaFromTheta(ThetaCerenkov);
1936 Double_t beta = (Double_t)(GetBetaOfParticle());
1937 Double_t den = 1. - beta*beta;
1938 if(den<=0.) return 999.;
1940 Double_t gamma = 1./TMath::Sqrt(den);
1942 Float_t mass = pmod/(beta*(Float_t)gamma);
1948 void AliRICHRecon::FillHistograms()
1951 Float_t FittedTrackTheta, FittedTrackPhi;
1953 Float_t ThetaCerenkov = GetThetaCerenkov();
1954 if(ThetaCerenkov == 999.) return;
1956 Float_t VertZ = GetEventVertexZ();
1958 Float_t TrackTheta = GetTrackTheta();
1959 Float_t TrackPhi = GetTrackPhi();
1960 Float_t pmod = GetTrackMomentum();
1961 Float_t pt = GetTrackPt();
1962 Float_t TrackEta = GetTrackEta();
1963 Int_t q = GetTrackCharge();
1964 Float_t TPCLastZ = GetTrackTPCLastZ();
1965 Float_t MinDist = GetMinDist();
1967 FittedTrackTheta = GetFittedTrackTheta();
1968 FittedTrackPhi = GetFittedTrackPhi();
1969 Int_t FittedNPhotonHough = GetFittedHoughPhotons();
1973 cout << " p " << pmod << " ThetaC " << ThetaCerenkov
1974 << " rings " << NRings << endl;
1977 Int_t NPhotonHough = GetHoughPhotons();
1978 Float_t NPhotonHoughNorm = GetHoughPhotonsNorm();
1979 Float_t InRing = GetPortionOfRing();
1981 Float_t MassOfParticle = FindMassOfParticle();
1983 Float_t HoughArea = GetHoughArea();
1984 Float_t Multiplicity = GetEventMultiplicity();
1986 // cout << " area " << HoughArea << " mult " << Multiplicity << endl;
1990 // var[0] = (Float_t)runID;
1991 // var[1] = (Float_t)evID;
1998 var[6] = TrackTheta;
2000 var[8] = FittedTrackTheta;
2001 var[9] = FittedTrackPhi;
2003 var[11] = ThetaCerenkov;
2004 var[12] = (Float_t)NPhotonHough;
2005 var[13] = (Float_t)FittedNPhotonHough;
2007 var[15] = MassOfParticle;
2008 var[16] = HoughArea;
2009 var[17] = Multiplicity;
2015 h1_mass->Fill(MassOfParticle);
2016 h2_mvsp->Fill(pmod,MassOfParticle);
2017 h2_mvst->Fill(ThetaCerenkov,MassOfParticle);
2019 FittedTrackTheta = GetFittedTrackTheta();
2020 FittedTrackPhi = GetFittedTrackPhi();
2022 Float_t DiffTheta = FittedTrackTheta - TrackTheta;
2023 Float_t DiffPhi = FittedTrackPhi - TrackPhi;
2025 h1_diffTrackTheta -> Fill(DiffTheta);
2026 h1_diffTrackPhi -> Fill(DiffPhi);
2028 if(ThetaCerenkov > 0.505 && ThetaCerenkov < 0.605)
2030 SetPhotonEnergy(6.85);
2031 SetFreonRefractiveIndex();
2033 Float_t pmom = GetTrackMomentum();
2034 Float_t beta = 1./(cos(ThetaCerenkov)*GetFreonRefractiveIndex());
2035 Float_t gamma = 1./sqrt(1.-beta*beta);
2037 Float_t pmomnew = 0.93828*beta*gamma;
2038 Float_t deltap = pmomnew - pmom;
2039 h1_deltap->Fill(deltap);
2040 Float_t deltapop = deltap/pmom;
2041 h1_deltapop->Fill(deltapop);
2043 h1_nprotons->Fill((Float_t)NPhotonHoughNorm);
2048 h2_tvsppos->Fill(pmod,ThetaCerenkov);
2049 hp_1pos->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
2050 hp_1posnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
2051 h2_1pos->Fill(pmod,(Float_t)NPhotonHough);
2052 h2_1posnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
2053 h1_houghpos->Fill(ThetaCerenkov);
2057 h2_tvspneg->Fill(pmod,ThetaCerenkov);
2058 hp_1neg->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
2059 hp_1negnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
2060 h2_1neg->Fill(pmod,(Float_t)NPhotonHough);
2061 h2_1negnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
2062 h1_houghneg->Fill(ThetaCerenkov);
2065 Int_t NPhotons = GetPhotonsNumber();
2067 for (Int_t j=0; j < NPhotons;j++)
2072 Float_t eta = GetPhotonEta();
2074 if(GetPhotonFlag() == 2)
2076 h1_photacc->Fill(eta);
2077 Float_t photaccspread = eta - ThetaCerenkov;
2078 h1_photaccspread->Fill(photaccspread);
2084 void AliRICHRecon::Minimization()
2090 static Double_t vstart[2];
2091 static Double_t lower[2], upper[2];
2092 static Double_t step[2]={0.001,0.001};
2094 Double_t TrackThetaNew,TrackPhiNew;
2096 Double_t eps, b1, b2;
2099 gMyMinuit = new TMinuit(2);
2100 gMyMinuit->SetObjectFit((TObject *)this);
2101 gMyMinuit->SetFCN(fcnrecon);
2102 gMyMinuit->mninit(5,10,7);
2104 vstart[0] = (Double_t)GetTrackTheta();
2105 vstart[1] = (Double_t)GetTrackPhi();
2107 lower[0] = vstart[0] - 0.03;
2108 if(lower[0] < 0) lower[0] = 0.;
2109 upper[0] = vstart[0] + 0.03;
2110 lower[1] = vstart[1] - 0.03;
2111 upper[1] = vstart[1] + 0.03;
2114 gMyMinuit->mnparm(0,"theta",vstart[0],step[0],lower[0],upper[0],ierflag);
2115 gMyMinuit->mnparm(1," phi ",vstart[1],step[1],lower[1],upper[1],ierflag);
2119 // gMyMinuit->FixParameter(0);
2121 gMyMinuit->SetPrintLevel(-1);
2122 // gMyMinuit->mnexcm("SET PRI",&arglist, 1, ierflag);
2123 gMyMinuit->mnexcm("SET NOGR",&arglist, 1, ierflag);
2124 gMyMinuit->mnexcm("SET NOW",&arglist, 1, ierflag);
2126 gMyMinuit->mnexcm("SET ERR", &arglist, 1,ierflg);
2129 // gMyMinuit->mnscan();
2131 // gMyMinuit->mnexcm("SIMPLEX",&arglist, 0, ierflag);
2132 gMyMinuit->mnexcm("MIGRAD",&arglist, 0, ierflag);
2133 gMyMinuit->mnexcm("EXIT" ,&arglist, 0, ierflag);
2135 gMyMinuit->mnpout(0,chname, TrackThetaNew, eps , b1, b2, ierflg);
2136 gMyMinuit->mnpout(1,chname, TrackPhiNew, eps , b1, b2, ierflg);
2138 //values after the fit...
2139 SetFittedTrackTheta((Float_t)TrackThetaNew);
2140 SetFittedTrackPhi((Float_t)TrackPhiNew);
2146 void AliRICHRecon::EstimationOfTheta()
2151 Float_t ShiftX = GetShiftX();
2152 Float_t ShiftY = GetShiftY();
2154 Float_t *CandidatePhotonX = GetCandidatePhotonX();
2155 Float_t *CandidatePhotonY = GetCandidatePhotonY();
2157 Int_t NPhotonsCandidates = GetCandidatePhotonsNumber();
2159 // cout << "MINIM: Nphotons " << NPhotonsCandidates << endl;
2161 for (Int_t j=0; j < NPhotonsCandidates; j++)
2166 if(!GetPhotonFlag()) continue;
2168 Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
2169 Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
2171 SetEntranceX(Xtoentr);
2172 SetEntranceY(Ytoentr);
2176 FindThetaPhotonCerenkov();
2178 Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
2180 // cout << " ACCEPTED!!! " << ThetaPhotonCerenkov << endl;
2182 SetPhotonEta(ThetaPhotonCerenkov);
2189 Float_t x2mean = 0.;
2192 for (Int_t j=0; j < NPhotonsCandidates;j++)
2196 Float_t eta = GetPhotonEta();
2200 if(GetPhotonFlag() == 2)
2211 xmean /=(Float_t)nev;
2212 x2mean /=(Float_t)nev;
2218 Float_t RMS = sqrt(x2mean - xmean*xmean);
2220 // cout << " RMS " << RMS;
2222 SetEstimationOfTheta(xmean);
2223 SetEstimationOfThetaRMS(RMS);
2226 void fcnrecon(Int_t& /*npar*/, Double_t* /*gin*/, Double_t &f, Double_t *par, Int_t iflag)
2228 AliRICHRecon *gMyRecon = (AliRICHRecon*)gMyMinuit->GetObjectFit();
2230 Float_t p0 = (Float_t)par[0];
2231 Float_t p1 = (Float_t)par[1];
2233 gMyRecon->SetTrackTheta(p0);
2234 gMyRecon->SetTrackPhi(p1);
2236 gMyRecon->EstimationOfTheta();
2237 Float_t RMS = gMyRecon->GetEstimationOfThetaRMS();
2239 Int_t HoughPhotons = gMyRecon->GetHoughPhotons();
2242 f = (Double_t)(1000*RMS/(Float_t)HoughPhotons);
2244 if(fDebug) cout << " f " << f
2245 << " theta " << par[0] << " phi " << par[1]
2246 << " HoughPhotons " << HoughPhotons << endl;
2248 if(fDebug&&iflag == 3)
2250 cout << " --- end convergence...summary --- " << endl;
2251 cout << " theta " << par[0] << endl;
2252 cout << " phi " << par[1] << endl;
2256 void AliRICHRecon::waiting()
2258 if(!kDISPLAY) return;
2259 cout << " Press any key to continue...";
2261 // gSystem->ProcessEvents();
2270 void ~AliRICHRecon()