]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSv2.cxx
Added virtual IsVersion. Print of version defered to Init in AliPHOS
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv2.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 /* $Id$ */
17 //_________________________________________________________________________
18 // Version of AliPHOSv1 which keeps all hits in TreeH
19 // AddHit, StepManager,and FinishEvent are redefined 
20 //                  
21 //*-- Author: Gines MARTINEZ (SUBATECH)
22
23
24 // --- ROOT system ---
25
26 #include "TBRIK.h"
27 #include "TNode.h"
28 #include "TRandom.h"
29
30 // --- Standard library ---
31
32 #include <stdio.h>
33 #include <string.h>
34 #include <stdlib.h>
35 #include <strstream.h>
36
37 // --- AliRoot header files ---
38
39 #include "AliPHOSv2.h"
40 #include "AliPHOSHit.h"
41 #include "AliPHOSDigit.h"
42 #include "AliPHOSReconstructioner.h"
43 #include "AliRun.h"
44 #include "AliConst.h"
45
46 ClassImp(AliPHOSv2)
47
48 //____________________________________________________________________________
49 AliPHOSv2::AliPHOSv2()
50 {
51   // default ctor
52   fNTmpHits = 0 ; 
53   fTmpHits  = 0 ; 
54 }
55
56 //____________________________________________________________________________
57 AliPHOSv2::AliPHOSv2(const char *name, const char *title):
58 AliPHOSv1(name,title)
59 {
60   // ctor
61   
62    fHits= new TClonesArray("AliPHOSHit",1000) ;
63 }
64
65 //____________________________________________________________________________
66 AliPHOSv2::~AliPHOSv2()
67 {
68   // dtor
69   if ( fTmpHits) {
70     fTmpHits->Delete() ; 
71     delete fTmpHits ;
72     fTmpHits = 0 ; 
73   }
74   
75   if ( fEmcRecPoints ) { 
76     fEmcRecPoints->Delete() ; 
77     delete fEmcRecPoints ; 
78     fEmcRecPoints = 0 ; 
79   }
80   
81   if ( fPpsdRecPoints ) { 
82     fPpsdRecPoints->Delete() ;
83     delete fPpsdRecPoints ;
84     fPpsdRecPoints = 0 ; 
85   }
86  
87   if ( fTrackSegments ) {
88     fTrackSegments->Delete() ; 
89     delete fTrackSegments ;
90     fTrackSegments = 0 ; 
91   }
92 }
93
94 //____________________________________________________________________________
95 void AliPHOSv2::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t Id, Float_t * hits)
96 {
97   // Add a hit to the hit list.
98   // A PHOS hit is the sum of all hits in a single crystal
99   //   or in a single PPSD gas cell
100
101   Int_t hitCounter ;
102   TClonesArray &ltmphits = *fTmpHits ;
103   AliPHOSHit *newHit ;
104   AliPHOSHit *curHit ;
105   Bool_t deja = kFALSE ;
106
107   // In any case, fills the fTmpHit TClonesArray (with "accumulated hits")
108
109   newHit = new AliPHOSHit(shunt, primary, tracknumber, Id, hits) ;
110
111   // We do want to save in TreeH the raw hits 
112   TClonesArray &lhits = *fHits;
113
114   for ( hitCounter = 0 ; hitCounter < fNTmpHits && !deja ; hitCounter++ ) {
115     curHit = (AliPHOSHit*) ltmphits[hitCounter] ;
116   if( *curHit == *newHit ) {
117     *curHit = *curHit + *newHit ;
118     deja = kTRUE ;
119     }
120   }
121          
122   if ( !deja ) {
123     new(ltmphits[fNTmpHits]) AliPHOSHit(*newHit) ;
124     fNTmpHits++ ;
125   }
126
127   // We do want to save in TreeH the raw hits 
128   new(lhits[fNhits]) AliPHOSHit(*newHit) ;    
129   fNhits++ ;
130
131   // Please note that the fTmpHits array must survive up to the
132   // end of the events, so it does not appear e.g. in ResetHits() (
133   // which is called at the end of each primary).  
134
135   delete newHit;
136
137 }
138
139