]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDclusterizer.cxx
SetMaxAdc passes integer value consistent with AliMUONResponse and AliMUONChamber
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizer.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 $Log$
18 Revision 1.3  2000/06/08 18:32:58  cblume
19 Make code compliant to coding conventions
20
21 Revision 1.2  2000/05/08 16:17:27  cblume
22 Merge TRD-develop
23
24 Revision 1.1.4.1  2000/05/08 15:08:03  cblume
25 Remove the class AliTRDcluster
26
27 Revision 1.1  2000/02/28 18:57:58  cblume
28 Add new TRD classes
29
30 */
31
32 ///////////////////////////////////////////////////////////////////////////////
33 //                                                                           //
34 //  TRD cluster finder base class                                            //
35 //                                                                           //
36 ///////////////////////////////////////////////////////////////////////////////
37
38 #include "AliRun.h"
39
40 #include "AliTRD.h"
41 #include "AliTRDclusterizer.h"
42
43 ClassImp(AliTRDclusterizer)
44
45 //_____________________________________________________________________________
46 AliTRDclusterizer::AliTRDclusterizer():TNamed()
47 {
48   //
49   // AliTRDclusterizer default constructor
50   //
51
52   fInputFile = NULL;
53   fEvent     = 0;
54
55 }
56
57 //_____________________________________________________________________________
58 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
59                   :TNamed(name, title)
60 {
61   //
62   // AliTRDclusterizer default constructor
63   //
64
65   fInputFile = NULL;
66   fEvent     = 0;
67
68   Init();
69
70 }
71
72 //_____________________________________________________________________________
73 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
74 {
75   //
76   // AliTRDclusterizer copy constructor
77   //
78
79   ((AliTRDclusterizer &) c).Copy(*this);
80
81 }
82
83 //_____________________________________________________________________________
84 AliTRDclusterizer::~AliTRDclusterizer()
85 {
86   //
87   // AliTRDclusterizer destructor
88   //
89
90   if (fInputFile) {
91     fInputFile->Close();
92     delete fInputFile;
93   }
94
95 }
96
97 //_____________________________________________________________________________
98 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
99 {
100   //
101   // Assignment operator
102   //
103
104   if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
105   return *this;
106
107 }
108
109 //_____________________________________________________________________________
110 void AliTRDclusterizer::Copy(TObject &c)
111 {
112   //
113   // Copy function
114   //
115
116   ((AliTRDclusterizer &) c).fInputFile = NULL;
117   ((AliTRDclusterizer &) c).fEvent     = 0;  
118
119 }
120
121 //_____________________________________________________________________________
122 void AliTRDclusterizer::Init()
123 {
124   //
125   // Initializes the cluster finder
126   //
127
128 }
129
130 //_____________________________________________________________________________
131 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
132 {
133   //
134   // Opens a ROOT-file with TRD-hits and reads in the digits-tree
135   //
136
137   // Connect the AliRoot file containing Geometry, Kine, and Hits
138   fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
139   if (!fInputFile) {
140     printf("AliTRDclusterizer::Open -- ");
141     printf("Open the ALIROOT-file %s.\n",name);
142     fInputFile = new TFile(name,"UPDATE");
143   }
144   else {
145     printf("AliTRDclusterizer::Open -- ");
146     printf("%s is already open.\n",name);
147   }
148
149   // Get AliRun object from file or create it if not on file
150   //if (!gAlice) {
151     gAlice = (AliRun*) fInputFile->Get("gAlice");
152     if (gAlice) {
153       printf("AliTRDclusterizer::Open -- ");
154       printf("AliRun object found on file.\n");
155     }
156     else {
157       printf("AliTRDclusterizer::Open -- ");
158       printf("Could not find AliRun object.\n");
159       return kFALSE;
160     }
161   //}
162
163   fEvent = nEvent;
164
165   // Import the Trees for the event nEvent in the file
166   Int_t nparticles = gAlice->GetEvent(fEvent);
167   if (nparticles <= 0) {
168     printf("AliTRDclusterizer::Open -- ");
169     printf("No entries in the trees for event %d.\n",fEvent);
170     return kFALSE;
171   }
172
173   return kTRUE;
174
175 }
176
177 //_____________________________________________________________________________
178 Bool_t AliTRDclusterizer::WriteCluster()
179 {
180   //
181   // Writes out the TRD-cluster
182   //
183
184   // Write the new tree into the input file (use overwrite option)
185   Char_t treeName[7];
186   sprintf(treeName,"TreeR%d",fEvent);
187   printf("AliTRDclusterizer::WriteCluster -- ");
188   printf("Write the cluster tree %s for event %d.\n"
189         ,treeName,fEvent);
190   gAlice->TreeR()->Write(treeName,2);
191
192   return kTRUE;
193
194 }