]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHv3.cxx
More improvements
[u/mrichter/AliRoot.git] / RICH / AliRICHv3.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16
17 #include <Riostream.h>
18
19 #include <TBRIK.h>
20 #include <TGeometry.h>
21 #include <TLorentzVector.h>
22 #include <TNode.h>
23 #include <TParticle.h>
24 #include <TVector3.h>
25 #include <TVirtualMC.h>
26 #include <TPDGCode.h> //for kNuetron
27 #include <TCanvas.h>
28 #include <TF1.h>
29 #include <TH1.h>
30 #include <TH2.h>
31 #include <TStyle.h>
32
33 #include "AliConst.h"
34 #include "AliMagF.h"
35 #include "AliPDG.h"
36 #include "AliRICHGeometry.h"
37 #include "AliRICHResponseV0.h"
38 #include "AliRICHSegmentationV1.h"
39 #include "AliRICHv3.h"
40 #include "AliRun.h"
41 #include "AliRICHRawCluster.h"
42 #include "AliRICHDigit.h"
43 #include "AliRICHRecHit1D.h"
44 #include "AliMC.h"
45
46
47 ClassImp(AliRICHv3)
48
49 //______________________________________________________________
50 //    Implementation of the RICH version 3 with azimuthal rotation
51
52
53 AliRICHv3::AliRICHv3(const char *sName, const char *sTitle)
54           :AliRICH(sName,sTitle)
55 {
56 // The named ctor currently creates a single copy of 
57 // AliRICHGeometry AliRICHSegmentationV1 AliRICHResponseV0
58 // and initialises the corresponding models of all 7 chambers with these stuctures.
59 // Note: all chambers share the single copy of models. MUST be changed later (???).
60   if(GetDebug())Info("named ctor","Start.");
61
62    fCkovNumber=fFreonProd=0;
63    
64    AliRICHGeometry       *pRICHGeometry    =new AliRICHGeometry;           // ??? to be moved to AlRICHChamber::named ctor
65    AliRICHSegmentationV1 *pRICHSegmentation=new AliRICHSegmentationV1;     // ??? to be moved to AlRICHChamber::named ctor
66    AliRICHResponseV0     *pRICHResponse    =new AliRICHResponseV0;         // ??? to be moved to AlRICHChamber::named ctor
67      
68    for (Int_t i=1; i<=kNCH; i++){    
69       SetGeometryModel(i,pRICHGeometry);
70       SetSegmentationModel(i,pRICHSegmentation);
71       SetResponseModel(i,pRICHResponse);
72       C(i)->Init(i); // ??? to be removed     
73    }
74   if(GetDebug())Info("named ctor","Stop.");
75 }//AliRICHv3::ctor(const char *pcName, const char *pcTitle)
76
77 AliRICHv3::~AliRICHv3()
78 {
79 // Dtor deletes RICH models. In future (???) AliRICHChamber will be responsible for that.
80    if(GetDebug()) cout<<ClassName()<<"::dtor()>\n";
81       
82    if(fChambers) {
83      AliRICHChamber *ch =C(1); 
84      if(ch) {
85        delete ch->GetGeometryModel();
86        delete ch->GetResponseModel();
87        delete ch->GetSegmentationModel();
88      }
89    }
90 }//AliRICHv3::dtor()
91 //______________________________________________________________________________
92 void AliRICHv3::StepManager()
93 {//Full Step Manager
94
95     Int_t          copy, id;
96     static Int_t   idvol;
97     static Int_t   vol[2];
98     Int_t          ipart;
99     static Float_t hits[22];
100     static Float_t ckovData[19];
101     TLorentzVector position;
102     TLorentzVector momentum;
103     Float_t        pos[3];
104     Float_t        mom[4];
105     Float_t        localPos[3];
106     Float_t        localMom[4];
107     Float_t        localTheta,localPhi;
108     Float_t        theta,phi;
109     Float_t        destep, step;
110     Double_t        ranf[2];
111     Float_t        coscerenkov;
112     static Float_t eloss, xhit, yhit, tlength;
113     const  Float_t kBig=1.e10;
114        
115     TClonesArray &lhits = *fHits;
116     TParticle *current = (TParticle*)(*gAlice->GetMCApp()->Particles())[gAlice->GetMCApp()->GetCurrentTrackNumber()];
117
118  //if (current->Energy()>1)
119    //{
120         
121     // Only gas gap inside chamber
122     // Tag chambers and record hits when track enters 
123     
124  
125     id=gMC->CurrentVolID(copy);
126     idvol = copy-1;
127     Float_t cherenkovLoss=0;
128     //gAlice->KeepTrack(gAlice->GetCurrentTrackNumber());
129     
130     gMC->TrackPosition(position);
131     pos[0]=position(0);
132     pos[1]=position(1);
133     pos[2]=position(2);
134     //bzero((char *)ckovData,sizeof(ckovData)*19);
135     ckovData[1] = pos[0];                 // X-position for hit
136     ckovData[2] = pos[1];                 // Y-position for hit
137     ckovData[3] = pos[2];                 // Z-position for hit
138     ckovData[6] = 0;                      // dummy track length
139     //ckovData[11] = gAlice->GetCurrentTrackNumber();
140     
141     //printf("\n+++++++++++\nTrack: %d\n++++++++++++\n",gAlice->GetCurrentTrackNumber());
142
143     //AliRICH *RICH = (AliRICH *) gAlice->GetDetector("RICH"); 
144     
145     /********************Store production parameters for Cerenkov photons************************/ 
146 //is it a Cerenkov photon? 
147     if (gMC->TrackPid() == 50000050) { 
148
149       //if (gMC->VolId("GAP ")==gMC->CurrentVolID(copy))
150         //{                    
151           Float_t ckovEnergy = current->Energy();
152           //energy interval for tracking
153           if  (ckovEnergy > 5.6e-09 && ckovEnergy < 7.8e-09 )       
154             //if (ckovEnergy > 0)
155             {
156               if (gMC->IsTrackEntering()){        //is track entering?
157                 //printf("Track entered (1)\n");
158                 if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
159                   {                                                          //is it in freo?
160                     if (gMC->IsNewTrack()){                          //is it the first step?
161                       //printf("I'm in!\n");
162                       Int_t mother = current->GetFirstMother(); 
163                       
164                       //printf("Second Mother:%d\n",current->GetSecondMother());
165                       
166                       ckovData[10] = mother;
167                       ckovData[11] = gAlice->GetMCApp()->GetCurrentTrackNumber();
168                       ckovData[12] = 1;             //Media where photon was produced 1->Freon, 2->Quarz
169                       //printf("Produced in FREO\n");
170                       fCkovNumber++;
171                       fFreonProd=1;
172                       //printf("Index: %d\n",fCkovNumber);
173                     }    //first step question
174                   }        //freo question
175                 
176                 if (gMC->IsNewTrack()){                                  //is it first step?
177                   if (gMC->VolId("QUAR")==gMC->CurrentVolID(copy))             //is it in quarz?
178                     {
179                       ckovData[12] = 2;
180                       //printf("Produced in QUAR\n");
181                     }    //quarz question
182                 }        //first step question
183                 
184                 //printf("Before %d\n",fFreonProd);
185               }   //track entering question
186               
187               if (ckovData[12] == 1)                                        //was it produced in Freon?
188                 //if (fFreonProd == 1)
189                 {
190                   if (gMC->IsTrackEntering()){                                     //is track entering?
191                     //printf("Track entered (2)\n");
192                     //printf("Current volume (should be META): %s\n",gMC->CurrentVolName());
193                     //printf("VolId: %d, CurrentVolID: %d\n",gMC->VolId("META"),gMC->CurrentVolID(copy));
194                     if (gMC->VolId("META")==gMC->CurrentVolID(copy))                //is it in gap?      
195                       {
196                         //printf("Got in META\n");
197                         gMC->TrackMomentum(momentum);
198                         mom[0]=momentum(0);
199                         mom[1]=momentum(1);
200                         mom[2]=momentum(2);
201                         mom[3]=momentum(3);
202                         
203                         gMC->Gmtod(mom,localMom,2);
204                         Float_t cophi = TMath::Cos(TMath::ATan2(localMom[0], localMom[1]));
205                         Float_t t = (1. - .025 / cophi) * (1. - .05 /  cophi);
206                         /**************** Photons lost in second grid have to be calculated by hand************/ 
207                         gMC->GetRandom()->RndmArray(1,ranf);
208                         if (ranf[0] > t) {
209                           gMC->StopTrack();
210                           ckovData[13] = 5;
211                           AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
212                           //printf("Added One (1)!\n");
213                           //printf("Lost one in grid\n");
214                         }
215                         /**********************************************************************************/
216                       }    //gap
217                     
218                     //printf("Current volume (should be CSI) (1): %s\n",gMC->CurrentVolName());
219                     //printf("VolId: %d, CurrentVolID: %d\n",gMC->VolId("CSI "),gMC->CurrentVolID(copy));
220                     if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy))             //is it in csi?      
221                       {
222                         //printf("Got in CSI\n");
223                         gMC->TrackMomentum(momentum);
224                         mom[0]=momentum(0);
225                         mom[1]=momentum(1);
226                         mom[2]=momentum(2);
227                         mom[3]=momentum(3);
228
229                         gMC->Gmtod(mom,localMom,2);
230                         /********* Photons lost by Fresnel reflection have to be calculated by hand********/ 
231                         /***********************Cerenkov phtons (always polarised)*************************/
232                         Double_t localTc = localMom[0]*localMom[0]+localMom[2]*localMom[2];
233                         Double_t localRt = TMath::Sqrt(localTc);
234                         localTheta   = Float_t(TMath::ATan2(localRt,Double_t(localMom[1])));
235                         Double_t cotheta = TMath::Abs(cos(localTheta));
236                         Float_t t = Fresnel(ckovEnergy*1e9,cotheta,1);
237                             gMC->GetRandom()->RndmArray(1,ranf);
238                             if (ranf[0] < t) {
239                               gMC->StopTrack();
240                               ckovData[13] = 6;
241                               AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
242                                 
243                               //printf("Added One (2)!\n");
244                               //printf("Lost by Fresnel\n");
245                             }
246                             /**********************************************************************************/
247                       }
248                   } //track entering?
249                   
250                   
251                   /********************Evaluation of losses************************/
252                   /******************still in the old fashion**********************/
253                   
254                   TArrayI procs;
255                   Int_t i1 = gMC->StepProcesses(procs);            //number of physics mechanisms acting on the particle
256                   for (Int_t i = 0; i < i1; ++i) {
257                     //        Reflection loss 
258                     if (procs[i] == kPLightReflection) {        //was it reflected
259                       ckovData[13]=10;
260                       if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy)) 
261                         ckovData[13]=1;
262                       if (gMC->CurrentVolID(copy) == gMC->VolId("QUAR")) 
263                         ckovData[13]=2;
264                       //gMC->StopTrack();
265                       //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
266                     } //reflection question
267                      
268                     //        Absorption loss 
269                     else if (procs[i] == kPLightAbsorption) {              //was it absorbed?
270                       //printf("Got in absorption\n");
271                       ckovData[13]=20;
272                       if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy)) 
273                         ckovData[13]=11;
274                       if (gMC->CurrentVolID(copy) == gMC->VolId("QUAR")) 
275                         ckovData[13]=12;
276                       if (gMC->CurrentVolID(copy) == gMC->VolId("META")) 
277                         ckovData[13]=13;
278                       if (gMC->CurrentVolID(copy) == gMC->VolId("GAP ")) 
279                         ckovData[13]=13;
280                       
281                       if (gMC->CurrentVolID(copy) == gMC->VolId("SRIC")) 
282                         ckovData[13]=15;
283                       
284                       //        CsI inefficiency 
285                       if (gMC->CurrentVolID(copy) == gMC->VolId("CSI ")) {
286                         ckovData[13]=16;
287                       }
288                       gMC->StopTrack();
289                       AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
290                       //printf("Added One (3)!\n");
291                       //printf("Added cerenkov %d\n",fCkovNumber);
292                     } //absorption question 
293                     
294                     
295                     //        Photon goes out of tracking scope 
296                     else if (procs[i] == kPStop) {                 //is it below energy treshold?
297                       ckovData[13]=21;
298                       gMC->StopTrack();
299                       AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
300                       //printf("Added One (4)!\n");
301                     }   // energy treshold question         
302                   }  //number of mechanisms cycle
303                   /**********************End of evaluation************************/
304                 } //freon production question
305             } //energy interval question
306         //}//inside the proximity gap question
307     } //cerenkov photon question
308       
309     /**************************************End of Production Parameters Storing*********************/ 
310     
311     
312     /*******************************Treat photons that hit the CsI (Ckovs and Feedbacks)************/ 
313     
314     if (gMC->TrackPid() == 50000050 || gMC->TrackPid() == 50000051) {
315       //printf("Cerenkov\n");
316       
317       //if (gMC->TrackPid() == 50000051)
318         //printf("Tracking a feedback\n");
319       
320       if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy))
321         {
322           //printf("Current volume (should be CSI) (2): %s\n",gMC->CurrentVolName());
323           //printf("VolId: %d, CurrentVolID: %d\n",gMC->VolId("CSI "),gMC->CurrentVolID(copy));
324           //printf("Got in CSI\n");
325           //printf("Tracking a %d\n",gMC->TrackPid());
326           if (gMC->Edep() > 0.){
327                 gMC->TrackPosition(position);
328                 gMC->TrackMomentum(momentum);
329                 pos[0]=position(0);
330                 pos[1]=position(1);
331                 pos[2]=position(2);
332                 mom[0]=momentum(0);
333                 mom[1]=momentum(1);
334                 mom[2]=momentum(2);
335                 mom[3]=momentum(3);
336                 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
337                 Double_t rt = TMath::Sqrt(tc);
338                 theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
339                 phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
340                 
341                 gMC->CurrentVolOffID(2,copy);
342                 vol[0]=copy;
343                 idvol=vol[0]-1;
344                 
345
346                 gMC->Gmtod(pos,localPos,1);
347
348                 //Chamber(idvol).GlobaltoLocal(pos,localPos);
349                                                                     
350                 gMC->Gmtod(mom,localMom,2);
351
352                 //Chamber(idvol).GlobaltoLocal(mom,localMom);
353                 
354                 gMC->CurrentVolOffID(2,copy);
355                 vol[0]=copy;
356                 idvol=vol[0]-1;
357
358                 //Int_t sector=((AliRICHChamber*) (*fChambers)[idvol])
359                         //->Sector(localPos[0], localPos[2]);
360                 //printf("Sector:%d\n",sector);
361
362                 /*if (gMC->TrackPid() == 50000051){
363                   fFeedbacks++;
364                   printf("Feedbacks:%d\n",fFeedbacks);
365                 }*/     
366                 
367         //PH            ((AliRICHChamber*) (*fChambers)[idvol])
368                 ((AliRICHChamber*)fChambers->At(idvol))
369                     ->SigGenInit(localPos[0], localPos[2], localPos[1]);
370                 if(idvol<kNCH) {        
371                     ckovData[0] = gMC->TrackPid();        // particle type
372                     ckovData[1] = pos[0];                 // X-position for hit
373                     ckovData[2] = pos[1];                 // Y-position for hit
374                     ckovData[3] = pos[2];                 // Z-position for hit
375                     ckovData[4] = theta;                      // theta angle of incidence
376                     ckovData[5] = phi;                      // phi angle of incidence 
377                     ckovData[8] = (Float_t) fNsdigits;      // first sdigit
378                     ckovData[9] = -1;                       // last pad hit
379                     ckovData[13] = 4;                       // photon was detected
380                     ckovData[14] = mom[0];
381                     ckovData[15] = mom[1];
382                     ckovData[16] = mom[2];
383                     
384                     destep = gMC->Edep();
385                     gMC->SetMaxStep(kBig);
386                     cherenkovLoss  += destep;
387                     ckovData[7]=cherenkovLoss;
388                     
389                     ckovData[17] = Hits2SDigits(localPos[0],localPos[2],cherenkovLoss,idvol,kPhoton);//for photons in CsI 
390                                     
391                     if (fNsdigits > (Int_t)ckovData[8]) {
392                         ckovData[8]= ckovData[8]+1;
393                         ckovData[9]= (Float_t) fNsdigits;
394                     }
395
396                     
397                     //TClonesArray *Hits = RICH->Hits();
398                     AliRICHhit *mipHit =  (AliRICHhit*) (fHits->UncheckedAt(0));
399                     if (mipHit)
400                       {
401                         mom[0] = current->Px();
402                         mom[1] = current->Py();
403                         mom[2] = current->Pz();
404                         Float_t mipPx = mipHit->MomX();
405                         Float_t mipPy = mipHit->MomY();
406                         Float_t mipPz = mipHit->MomZ();
407                         
408                         Float_t r = mom[0]*mom[0] + mom[1]*mom[1] + mom[2]*mom[2];
409                         Float_t rt = TMath::Sqrt(r);
410                         Float_t mipR = mipPx*mipPx + mipPy*mipPy + mipPz*mipPz; 
411                         Float_t mipRt = TMath::Sqrt(mipR);
412                         if ((rt*mipRt) > 0)
413                           {
414                             coscerenkov = (mom[0]*mipPx + mom[1]*mipPy + mom[2]*mipPz)/(rt*mipRt);
415                           }
416                         else
417                           {
418                             coscerenkov = 0;
419                           }
420                         Float_t cherenkov = TMath::ACos(coscerenkov);
421                         ckovData[18]=cherenkov;
422                       }
423                     //if (sector != -1)
424                     //{
425                     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
426                     AddCerenkov(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,ckovData);
427                     //printf("Added One (5)!\n");
428                     //}
429                 }
430             }
431         }
432     }
433     
434     /***********************************************End of photon hits*********************************************/
435     
436
437     /**********************************************Charged particles treatment*************************************/
438
439     else if (gMC->TrackCharge()){
440 //If MIP
441         /*if (gMC->IsTrackEntering())
442           {                
443             hits[13]=20;//is track entering?
444           }*/
445         if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
446           {
447             gMC->TrackMomentum(momentum);
448             mom[0]=momentum(0);
449             mom[1]=momentum(1);
450             mom[2]=momentum(2);
451             mom[3]=momentum(3);
452             hits [19] = mom[0];
453             hits [20] = mom[1];
454             hits [21] = mom[2];
455             fFreonProd=1;
456           }
457
458         if (gMC->VolId("GAP ")== gMC->CurrentVolID(copy)) {//is in GAP?
459 // Get current particle id (ipart), track position (pos)  and momentum (mom)
460             
461             gMC->CurrentVolOffID(3,copy);
462             vol[0]=copy;
463             idvol=vol[0]-1;
464
465             //Int_t sector=((AliRICHChamber*) (*fChambers)[idvol])
466                         //->Sector(localPos[0], localPos[2]);
467             //printf("Sector:%d\n",sector);
468             
469             gMC->TrackPosition(position);
470             gMC->TrackMomentum(momentum);
471             pos[0]=position(0);
472             pos[1]=position(1);
473             pos[2]=position(2);
474             mom[0]=momentum(0);
475             mom[1]=momentum(1);
476             mom[2]=momentum(2);
477             mom[3]=momentum(3);
478
479             gMC->Gmtod(pos,localPos,1);
480             
481             //Chamber(idvol).GlobaltoLocal(pos,localPos);
482                                                                     
483             gMC->Gmtod(mom,localMom,2);
484
485             //Chamber(idvol).GlobaltoLocal(mom,localMom);
486             
487             ipart  = gMC->TrackPid();
488             //
489             // momentum loss and steplength in last step
490             destep = gMC->Edep();
491             step   = gMC->TrackStep();
492   
493             //
494             // record hits when track enters ...
495             if( gMC->IsTrackEntering()) {
496 //              gMC->SetMaxStep(fMaxStepGas);
497                 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
498                 Double_t rt = TMath::Sqrt(tc);
499                 theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
500                 phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
501                 
502
503                 Double_t localTc = localMom[0]*localMom[0]+localMom[2]*localMom[2];
504                 Double_t localRt = TMath::Sqrt(localTc);
505                 localTheta   = Float_t(TMath::ATan2(localRt,Double_t(localMom[1])))*kRaddeg;                       
506                 localPhi     = Float_t(TMath::ATan2(Double_t(localMom[2]),Double_t(localMom[0])))*kRaddeg;    
507                 
508                 hits[0] = Float_t(ipart);         // particle type
509                 hits[1] = localPos[0];                 // X-position for hit
510                 hits[2] = localPos[1];                 // Y-position for hit
511                 hits[3] = localPos[2];                 // Z-position for hit
512                 hits[4] = localTheta;                  // theta angle of incidence
513                 hits[5] = localPhi;                    // phi angle of incidence 
514                 hits[8] = (Float_t) fNsdigits;    // first sdigit
515                 hits[9] = -1;                     // last pad hit
516                 hits[13] = fFreonProd;           // did id hit the freon?
517                 hits[14] = mom[0];
518                 hits[15] = mom[1];
519                 hits[16] = mom[2];
520                 hits[18] = 0;               // dummy cerenkov angle
521
522                 tlength = 0;
523                 eloss   = 0;
524                 fFreonProd = 0;
525         
526                 Chamber(idvol).LocaltoGlobal(localPos,hits+1);
527            
528                 
529                 //To make chamber coordinates x-y had to pass localPos[0], localPos[2]
530                 xhit    = localPos[0];
531                 yhit    = localPos[2];
532                 // Only if not trigger chamber
533                 if(idvol<kNCH) {
534                     //
535                     //  Initialize hit position (cursor) in the segmentation model 
536           //PH              ((AliRICHChamber*) (*fChambers)[idvol])
537                     ((AliRICHChamber*)fChambers->At(idvol))
538                         ->SigGenInit(localPos[0], localPos[2], localPos[1]);
539                 }
540             }
541             
542             // 
543             // Calculate the charge induced on a pad (disintegration) in case 
544             //
545             // Mip left chamber ...
546             if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
547                 gMC->SetMaxStep(kBig);
548                 eloss   += destep;
549                 tlength += step;
550                 
551                                 
552                 // Only if not trigger chamber
553                 if(idvol<kNCH) {
554                   if (eloss > 0) 
555                     {
556                       if(gMC->TrackPid() == kNeutron)
557                         printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
558                       hits[17] = Hits2SDigits(xhit,yhit,eloss,idvol,kMip); //for MIP 
559                     }
560                 }
561                 
562                 hits[6]=tlength;
563                 hits[7]=eloss;
564                 if (fNsdigits > (Int_t)hits[8]) {
565                     hits[8]= hits[8]+1;
566                     hits[9]= (Float_t) fNsdigits;
567                 }
568                 
569                 //if(sector !=-1)
570                 new(lhits[fNhits++]) AliRICHhit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
571                 eloss = 0; 
572                 //
573                 // Check additional signal generation conditions 
574                 // defined by the segmentation
575                 // model (boundary crossing conditions) 
576             }else if(((AliRICHChamber*)fChambers->At(idvol))->SigGenCond(localPos[0], localPos[2], localPos[1])){
577                 ((AliRICHChamber*)fChambers->At(idvol))->SigGenInit(localPos[0], localPos[2], localPos[1]);
578                 if (eloss > 0) 
579                   {
580                     if(gMC->TrackPid() == kNeutron)
581                       printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
582                     hits[17] = Hits2SDigits(xhit,yhit,eloss,idvol,kMip);//for n
583                   }
584                 xhit     = localPos[0];
585                 yhit     = localPos[2]; 
586                 eloss    = destep;
587                 tlength += step ;
588                 //
589                 // nothing special  happened, add up energy loss
590             } else {        
591                 eloss   += destep;
592                 tlength += step ;
593             }
594         }//is in GAP?
595       }//is MIP?
596     /*************************************************End of MIP treatment**************************************/
597 }//void AliRICHv3::StepManager()
598 //__________________________________________________________________________________________________
599 Int_t AliRICHv3::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol, ResponseType res)
600 {//calls the charge disintegration method of the current chamber and adds all generated sdigits to the list of digits
601    
602    Float_t newclust[4][500];
603    Int_t clhits[5];
604    Int_t iNdigits;
605    clhits[0]=fNhits+1;
606    
607   ((AliRICHChamber*)fChambers->At(idvol))->DisIntegration(eloss, xhit, yhit, iNdigits,newclust, res);
608     
609   for (Int_t i=0; i<iNdigits; i++) {
610     if (Int_t(newclust[0][i]) > 0) {
611             clhits[1] = Int_t(newclust[0][i]);//  Cluster Charge
612             clhits[2] = Int_t(newclust[1][i]);//  Pad: ix
613             clhits[3] = Int_t(newclust[2][i]);//  Pad: iy
614             clhits[4] = Int_t(newclust[3][i]);//  Pad: chamber sector
615             AddSpecialOld(clhits);
616         }
617     }
618   return iNdigits;
619 }//Int_t AliRICHv3::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol, ResponseType res)
620 //__________________________________________________________________________________________________
621 void AliRICHv3::DiagnosticsFE(Int_t evNumber1,Int_t evNumber2)
622 {
623   
624   Int_t NpadX = 162;                 // number of pads on X
625   Int_t NpadY = 162;                 // number of pads on Y
626   
627   Int_t Pad[162][162];
628   for (Int_t i=0;i<NpadX;i++) {
629     for (Int_t j=0;j<NpadY;j++) {
630       Pad[i][j]=0;
631     }
632   }
633   
634   //  Create some histograms
635
636   TH1F *pionspectra1 = new TH1F("pionspectra1","Pion Spectra",200,-4,2);
637   TH1F *pionspectra2 = new TH1F("pionspectra2","Pion Spectra",200,-4,2);
638   TH1F *pionspectra3 = new TH1F("pionspectra3","Pion Spectra",200,-4,2);
639   TH1F *protonspectra1 = new TH1F("protonspectra1","Proton Spectra",200,-4,2);
640   TH1F *protonspectra2 = new TH1F("protonspectra2","Proton Spectra",200,-4,2);
641   TH1F *protonspectra3 = new TH1F("protonspectra3","Proton Spectra",200,-4,2);
642   TH1F *kaonspectra1 = new TH1F("kaonspectra1","Kaon Spectra",100,-4,2);
643   TH1F *kaonspectra2 = new TH1F("kaonspectra2","Kaon Spectra",100,-4,2);
644   TH1F *kaonspectra3 = new TH1F("kaonspectra3","Kaon Spectra",100,-4,2);
645   TH1F *electronspectra1 = new TH1F("electronspectra1","Electron Spectra",100,-4,2);
646   TH1F *electronspectra2 = new TH1F("electronspectra2","Electron Spectra",100,-4,2);
647   TH1F *electronspectra3 = new TH1F("electronspectra3","Electron Spectra",100,-4,2);
648   TH1F *muonspectra1 = new TH1F("muonspectra1","Muon Spectra",100,-4,2);
649   TH1F *muonspectra2 = new TH1F("muonspectra2","Muon Spectra",100,-4,2);
650   TH1F *muonspectra3 = new TH1F("muonspectra3","Muon Spectra",100,-4,2);
651   TH1F *neutronspectra1 = new TH1F("neutronspectra1","Neutron Spectra",100,-4,2);
652   TH1F *neutronspectra2 = new TH1F("neutronspectra2","Neutron Spectra",100,-4,2);
653   TH1F *neutronspectra3 = new TH1F("neutronspectra2","Neutron Spectra",100,-4,2);
654   TH1F *chargedspectra1 = new TH1F("chargedspectra1","Charged particles above 1 GeV Spectra",100,-1,3);
655   TH1F *chargedspectra2 = new TH1F("chargedspectra2","Charged particles above 1 GeV Spectra",100,-1,3);
656   TH1F *chargedspectra3 = new TH1F("chargedspectra2","Charged particles above 1 GeV Spectra",100,-1,3);
657   TH1F *pionptspectrafinal = new TH1F("pionptspectrafinal","Primary Pions Transverse Momenta at HMPID",20,0,5);
658   TH1F *pionptspectravertex = new TH1F("pionptspectravertex","Primary Pions Transverse Momenta at vertex",20,0,5);
659   TH1F *kaonptspectrafinal = new TH1F("kaonptspectrafinal","Primary Kaons Transverse Momenta at HMPID",20,0,5);
660   TH1F *kaonptspectravertex = new TH1F("kaonptspectravertex","Primary Kaons Transverse Momenta at vertex",20,0,5);
661   //TH1F *hitsPhi = new TH1F("hitsPhi","Distribution of phi angle of incidence",100,-180,180);
662   TH1F *hitsTheta = new TH1F("hitsTheta","Distribution of Theta angle of incidence, all tracks",100,0,50);
663   TH1F *hitsTheta500MeV = new TH1F("hitsTheta500MeV","Distribution of Theta angle of incidence, 0.5-1 GeV primary tracks",100,0,50);
664   TH1F *hitsTheta1GeV = new TH1F("hitsTheta1GeV","Distribution of Theta angle of incidence, 1-2 GeV primary tracks",100,0,50);
665   TH1F *hitsTheta2GeV = new TH1F("hitsTheta2GeV","Distribution of Theta angle of incidence, 2-3 GeV primary tracks",100,0,50);
666   TH1F *hitsTheta3GeV = new TH1F("hitsTheta3GeV","Distribution of Theta angle of incidence, >3 GeV primary tracks",100,0,50);
667   TH2F *production = new TH2F("production","Mother production vertices",100,-300,300,100,0,600);
668    
669    
670    
671
672 //   Start loop over events 
673
674   Int_t pion=0, kaon=0, proton=0, electron=0, positron=0, neutron=0, highneutrons=0, muon=0;
675   Int_t chargedpions=0,primarypions=0,highprimarypions=0,chargedkaons=0,primarykaons=0,highprimarykaons=0;
676   Int_t photons=0, primaryphotons=0, highprimaryphotons=0;
677   TRandom* random=0;
678
679    for (int nev=0; nev<= evNumber2; nev++) {
680        Int_t nparticles = gAlice->GetEvent(nev);
681        
682
683        if (nev < evNumber1) continue;
684        if (nparticles <= 0) return;
685        
686 // Get pointers to RICH detector and Hits containers
687        
688        AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH");
689      
690        TTree *treeH = TreeH();
691        Int_t ntracks =(Int_t) treeH->GetEntries();
692             
693 // Start loop on tracks in the hits containers
694        
695        for (Int_t track=0; track<ntracks;track++) {
696            printf ("Processing Track: %d\n",track);
697            gAlice->ResetHits();
698            treeH->GetEvent(track);
699                            
700            for(AliRICHhit* mHit=(AliRICHhit*)pRICH->FirstHit(-1); 
701                mHit;
702                mHit=(AliRICHhit*)pRICH->NextHit()) 
703              {
704                //Int_t nch  = mHit->fChamber;              // chamber number
705                //Float_t x  = mHit->X();                    // x-pos of hit
706                //Float_t y  = mHit->Z();                    // y-pos
707                //Float_t z  = mHit->Y();
708                //Float_t phi = mHit->Phi();                 //Phi angle of incidence
709                Float_t theta = mHit->Theta();             //Theta angle of incidence
710                Float_t px = mHit->MomX();
711                Float_t py = mHit->MomY();
712                Int_t index = mHit->Track();
713                Int_t particle = (Int_t)(mHit->Particle());    
714                Float_t R;
715                Float_t PTfinal;
716                Float_t PTvertex;
717
718               TParticle *current = gAlice->GetMCApp()->Particle(index);
719               
720               //Float_t energy=current->Energy(); 
721
722               R=TMath::Sqrt(current->Vx()*current->Vx() + current->Vy()*current->Vy());
723               PTfinal=TMath::Sqrt(px*px + py*py);
724               PTvertex=TMath::Sqrt(current->Px()*current->Px() + current->Py()*current->Py());
725               
726               
727
728               if (TMath::Abs(particle) < 10000000)
729                 {
730                   hitsTheta->Fill(theta,(float) 1);
731                   if (R<5)
732                     {
733                       if (PTvertex>.5 && PTvertex<=1)
734                         {
735                           hitsTheta500MeV->Fill(theta,(float) 1);
736                         }
737                       if (PTvertex>1 && PTvertex<=2)
738                         {
739                           hitsTheta1GeV->Fill(theta,(float) 1);
740                         }
741                       if (PTvertex>2 && PTvertex<=3)
742                         {
743                           hitsTheta2GeV->Fill(theta,(float) 1);
744                         }
745                       if (PTvertex>3)
746                         {
747                           hitsTheta3GeV->Fill(theta,(float) 1);
748                         }
749                     }
750                   
751                 }
752
753               //if (nch == 3)
754                 //{
755               
756               if (TMath::Abs(particle) < 50000051)
757                 {
758                   //if (TMath::Abs(particle) == 50000050 || TMath::Abs(particle) == 2112)
759                   if (TMath::Abs(particle) == 2112 || TMath::Abs(particle) == 50000050)
760                     {
761                       //gMC->Rndm(&random, 1);
762                       if (random->Rndm() < .1)
763                         production->Fill(current->Vz(),R,(float) 1);
764                       if (TMath::Abs(particle) == 50000050)
765                         //if (TMath::Abs(particle) > 50000000)
766                         {
767                           photons +=1;
768                           if (R<5)
769                             {
770                               primaryphotons +=1;
771                               if (current->Energy()>0.001)
772                                 highprimaryphotons +=1;
773                             }
774                         }       
775                       if (TMath::Abs(particle) == 2112)
776                         {
777                           neutron +=1;
778                           if (current->Energy()>0.0001)
779                             highneutrons +=1;
780                         }
781                     }
782                   if (TMath::Abs(particle) < 50000000)
783                     {
784                       production->Fill(current->Vz(),R,(float) 1);
785                     }
786                   //mip->Fill(x,y,(float) 1);
787                 }
788               
789               if (TMath::Abs(particle)==211 || TMath::Abs(particle)==111)
790                 {
791                   if (R<5)
792                     {
793                       pionptspectravertex->Fill(PTvertex,(float) 1);
794                       pionptspectrafinal->Fill(PTfinal,(float) 1);
795                     }
796                 }
797               
798               if (TMath::Abs(particle)==321 || TMath::Abs(particle)==130 || TMath::Abs(particle)==310 
799                   || TMath::Abs(particle)==311)
800                 {
801                   if (R<5)
802                     {
803                       kaonptspectravertex->Fill(PTvertex,(float) 1);
804                       kaonptspectrafinal->Fill(PTfinal,(float) 1);
805                     }
806                 }
807               
808               
809               if (TMath::Abs(particle)==211 || TMath::Abs(particle)==111)
810                 {
811                   pionspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
812                   if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
813                     pionspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
814                   if (R>250 && R<450)
815                     {
816                       pionspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
817                     }
818                   pion +=1;
819                   if (TMath::Abs(particle)==211)
820                     {
821                       chargedpions +=1;
822                       if (R<5)
823                         {
824                           primarypions +=1;
825                           if (current->Energy()>1)
826                             highprimarypions +=1;
827                         }
828                     }   
829                 }
830               if (TMath::Abs(particle)==2212)
831                 {
832                   protonspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
833                   //ptspectra->Fill(Pt,(float) 1);
834                   if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
835                     protonspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
836                   if (R>250 && R<450)
837                     protonspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
838                   proton +=1;
839                 }
840               if (TMath::Abs(particle)==321 || TMath::Abs(particle)==130 || TMath::Abs(particle)==310 
841                   || TMath::Abs(particle)==311)
842                 {
843                   kaonspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
844                   //ptspectra->Fill(Pt,(float) 1);
845                   if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
846                     kaonspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
847                   if (R>250 && R<450)
848                     kaonspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
849                   kaon +=1;
850                   if (TMath::Abs(particle)==321)
851                     {
852                       chargedkaons +=1;
853                       if (R<5)
854                         {
855                           primarykaons +=1;
856                           if (current->Energy()>1)
857                             highprimarykaons +=1;
858                         }
859                     }
860                 }
861               if (TMath::Abs(particle)==11)
862                 {
863                   electronspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
864                   //ptspectra->Fill(Pt,(float) 1);
865                   if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
866                     electronspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
867                   if (R>250 && R<450)
868                     electronspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
869                   if (particle == 11)
870                     electron +=1;
871                   if (particle == -11)
872                     positron +=1;
873                 }
874               if (TMath::Abs(particle)==13)
875                 {
876                   muonspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
877                   //ptspectra->Fill(Pt,(float) 1);
878                   if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
879                     muonspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
880                   if (R>250 && R<450)
881                     muonspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
882                   muon +=1;
883                 }
884               if (TMath::Abs(particle)==2112)
885                 {
886                   neutronspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
887                   //ptspectra->Fill(Pt,(float) 1);
888                   if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
889                     neutronspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
890                   if (R>250 && R<450)
891                     {
892                       neutronspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
893                     }
894                   neutron +=1;
895                 }
896               if(TMath::Abs(particle)==211 || TMath::Abs(particle)==2212 || TMath::Abs(particle)==321)
897                 {
898                   if (current->Energy()-current->GetCalcMass()>1)
899                     {
900                       chargedspectra1->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
901                       if (current->Vx()>5 && current->Vy()>5 && current->Vz()>5)
902                         chargedspectra2->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
903                       if (R>250 && R<450)
904                         chargedspectra3->Fill(TMath::Log10(current->Energy() - current->GetCalcMass()),(float) 1);
905                     }
906                 }
907               // Fill the histograms
908               //Nh1+=nhits;
909               //h->Fill(x,y,(float) 1);
910               //}
911               //}
912            }          
913            
914        }
915        
916    }
917    //   }
918
919    TStyle *mystyle=new TStyle("Plain","mystyle");
920    mystyle->SetPalette(1,0);
921    mystyle->cd();
922    
923    //Create canvases, set the view range, show histograms
924
925     TCanvas *c2 = new TCanvas("c2","Angles of incidence",150,150,100,150);
926     c2->Divide(2,2);
927     //c2->SetFillColor(42);
928     
929     c2->cd(1);
930     hitsTheta500MeV->SetFillColor(5);
931     hitsTheta500MeV->Draw();
932     c2->cd(2);
933     hitsTheta1GeV->SetFillColor(5);
934     hitsTheta1GeV->Draw();
935     c2->cd(3);
936     hitsTheta2GeV->SetFillColor(5);
937     hitsTheta2GeV->Draw();
938     c2->cd(4);
939     hitsTheta3GeV->SetFillColor(5);
940     hitsTheta3GeV->Draw();
941     
942             
943    
944     TCanvas *c15 = new TCanvas("c15","Mothers Production Vertices",50,50,600,600);
945     c15->cd();
946     production->SetFillColor(42);
947     production->SetXTitle("z (m)");
948     production->SetYTitle("R (m)");
949     production->Draw();
950
951     TCanvas *c10 = new TCanvas("c10","Pt Spectra",50,50,600,700);
952     c10->Divide(2,2);
953     c10->cd(1);
954     pionptspectravertex->SetFillColor(5);
955     pionptspectravertex->SetXTitle("Pt (GeV)");
956     pionptspectravertex->Draw();
957     c10->cd(2);
958     pionptspectrafinal->SetFillColor(5);
959     pionptspectrafinal->SetXTitle("Pt (GeV)");
960     pionptspectrafinal->Draw();
961     c10->cd(3);
962     kaonptspectravertex->SetFillColor(5);
963     kaonptspectravertex->SetXTitle("Pt (GeV)");
964     kaonptspectravertex->Draw();
965     c10->cd(4);
966     kaonptspectrafinal->SetFillColor(5);
967     kaonptspectrafinal->SetXTitle("Pt (GeV)");
968     kaonptspectrafinal->Draw();
969    
970   
971    TCanvas *c16 = new TCanvas("c16","Particles Spectra II",150,150,600,350);
972    c16->Divide(2,1);
973    
974    c16->cd(1);
975    //TCanvas *c13 = new TCanvas("c13","Electron Spectra",400,10,600,700);
976    electronspectra1->SetFillColor(5);
977    electronspectra1->SetXTitle("log(GeV)");
978    electronspectra2->SetFillColor(46);
979    electronspectra2->SetXTitle("log(GeV)");
980    electronspectra3->SetFillColor(10);
981    electronspectra3->SetXTitle("log(GeV)");
982    //c13->SetLogx();
983    electronspectra1->Draw();
984    electronspectra2->Draw("same");
985    electronspectra3->Draw("same");
986    
987    c16->cd(2);
988    //TCanvas *c14 = new TCanvas("c14","Muon Spectra",400,10,600,700);
989    muonspectra1->SetFillColor(5);
990    muonspectra1->SetXTitle("log(GeV)");
991    muonspectra2->SetFillColor(46);
992    muonspectra2->SetXTitle("log(GeV)");
993    muonspectra3->SetFillColor(10);
994    muonspectra3->SetXTitle("log(GeV)");
995    //c14->SetLogx();
996    muonspectra1->Draw();
997    muonspectra2->Draw("same");
998    muonspectra3->Draw("same");
999    
1000    //c16->cd(3);
1001    //TCanvas *c16 = new TCanvas("c16","Neutron Spectra",400,10,600,700);
1002    //neutronspectra1->SetFillColor(42);
1003    //neutronspectra1->SetXTitle("log(GeV)");
1004    //neutronspectra2->SetFillColor(46);
1005    //neutronspectra2->SetXTitle("log(GeV)");
1006    //neutronspectra3->SetFillColor(10);
1007    //neutronspectra3->SetXTitle("log(GeV)");
1008    //c16->SetLogx();
1009    //neutronspectra1->Draw();
1010    //neutronspectra2->Draw("same");
1011    //neutronspectra3->Draw("same");
1012
1013    TCanvas *c9 = new TCanvas("c9","Particles Spectra",150,150,600,700);
1014    //TCanvas *c9 = new TCanvas("c9","Pion Spectra",400,10,600,700);
1015    c9->Divide(2,2);
1016    
1017    c9->cd(1);
1018    pionspectra1->SetFillColor(5);
1019    pionspectra1->SetXTitle("log(GeV)");
1020    pionspectra2->SetFillColor(46);
1021    pionspectra2->SetXTitle("log(GeV)");
1022    pionspectra3->SetFillColor(10);
1023    pionspectra3->SetXTitle("log(GeV)");
1024    //c9->SetLogx();
1025    pionspectra1->Draw();
1026    pionspectra2->Draw("same");
1027    pionspectra3->Draw("same");
1028    
1029    c9->cd(2);
1030    //TCanvas *c10 = new TCanvas("c10","Proton Spectra",400,10,600,700);
1031    protonspectra1->SetFillColor(5);
1032    protonspectra1->SetXTitle("log(GeV)");
1033    protonspectra2->SetFillColor(46);
1034    protonspectra2->SetXTitle("log(GeV)");
1035    protonspectra3->SetFillColor(10);
1036    protonspectra3->SetXTitle("log(GeV)");
1037    //c10->SetLogx();
1038    protonspectra1->Draw();
1039    protonspectra2->Draw("same");
1040    protonspectra3->Draw("same");
1041    
1042    c9->cd(3);
1043    //TCanvas *c11 = new TCanvas("c11","Kaon Spectra",400,10,600,700); 
1044    kaonspectra1->SetFillColor(5);
1045    kaonspectra1->SetXTitle("log(GeV)");
1046    kaonspectra2->SetFillColor(46);
1047    kaonspectra2->SetXTitle("log(GeV)");
1048    kaonspectra3->SetFillColor(10);
1049    kaonspectra3->SetXTitle("log(GeV)");
1050    //c11->SetLogx();
1051    kaonspectra1->Draw();
1052    kaonspectra2->Draw("same");
1053    kaonspectra3->Draw("same");
1054    
1055    c9->cd(4);
1056    //TCanvas *c12 = new TCanvas("c12","Charged Particles Spectra",400,10,600,700);
1057    chargedspectra1->SetFillColor(5);
1058    chargedspectra1->SetXTitle("log(GeV)");
1059    chargedspectra2->SetFillColor(46);
1060    chargedspectra2->SetXTitle("log(GeV)");
1061    chargedspectra3->SetFillColor(10);
1062    chargedspectra3->SetXTitle("log(GeV)");
1063    //c12->SetLogx();
1064    chargedspectra1->Draw();
1065    chargedspectra2->Draw("same");
1066    chargedspectra3->Draw("same");
1067    
1068
1069
1070    printf("*****************************************\n");
1071    printf("* Particle                   *  Counts  *\n");
1072    printf("*****************************************\n");
1073
1074    printf("* Pions:                     *   %4d   *\n",pion);
1075    printf("* Charged Pions:             *   %4d   *\n",chargedpions);
1076    printf("* Primary Pions:             *   %4d   *\n",primarypions);
1077    printf("* Primary Pions (p>1GeV/c):  *   %4d   *\n",highprimarypions);
1078    printf("* Kaons:                     *   %4d   *\n",kaon);
1079    printf("* Charged Kaons:             *   %4d   *\n",chargedkaons);
1080    printf("* Primary Kaons:             *   %4d   *\n",primarykaons);
1081    printf("* Primary Kaons (p>1GeV/c):  *   %4d   *\n",highprimarykaons);
1082    printf("* Muons:                     *   %4d   *\n",muon);
1083    printf("* Electrons:                 *   %4d   *\n",electron);
1084    printf("* Positrons:                 *   %4d   *\n",positron);
1085    printf("* Protons:                   *   %4d   *\n",proton);
1086    printf("* All Charged:               *   %4d   *\n",(chargedpions+chargedkaons+muon+electron+positron+proton));
1087    printf("*****************************************\n");
1088    //printf("* Photons:                   *   %3.1f   *\n",photons); 
1089    //printf("* Primary Photons:           *   %3.1f   *\n",primaryphotons);
1090    //printf("* Primary Photons (p>1MeV/c):*   %3.1f   *\n",highprimaryphotons);
1091    //printf("*****************************************\n");
1092    //printf("* Neutrons:                  *   %3.1f   *\n",neutron);
1093    //printf("* Neutrons (p>100keV/c):     *   %3.1f   *\n",highneutrons);
1094    //printf("*****************************************\n");
1095
1096    if (gAlice->TreeD())
1097      {
1098        gAlice->TreeD()->GetEvent(0);
1099    
1100        Float_t occ[7]; 
1101        Float_t sum=0;
1102        Float_t mean=0; 
1103        printf("\n*****************************************\n");
1104        printf("* Chamber   * Digits      * Occupancy   *\n");
1105        printf("*****************************************\n");
1106        
1107        for (Int_t ich=0;ich<7;ich++)
1108          {
1109            TClonesArray *Digits = DigitsAddress(ich);    //  Raw clusters branch
1110            Int_t ndigits = Digits->GetEntriesFast();
1111            occ[ich] = Float_t(ndigits)/(160*144);
1112            sum += Float_t(ndigits)/(160*144);
1113            printf("*   %d      *    %d      *   %3.1f%%     *\n",ich,ndigits,occ[ich]*100);
1114          }
1115        mean = sum/7;
1116        printf("*****************************************\n");
1117        printf("* Mean occupancy          *   %3.1f%%     *\n",mean*100);
1118        printf("*****************************************\n");
1119      }
1120  
1121   printf("\nEnd of analysis\n");
1122    
1123 }//void AliRICHv3::DiagnosticsFE(Int_t evNumber1,Int_t evNumber2)
1124 //__________________________________________________________________________________________________
1125