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