Fixes to coding conventions violations
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
CommitLineData
6309cf6e 1
2
3//Root includes
4
5//AliRoot includes
6#include "AliMUONData.h"
7#include "AliMUONDigit.h"
8#include "AliMUONHit.h"
9#include "AliMUONLocalTrigger.h"
10#include "AliMUONGlobalTrigger.h"
11#include "AliMUONRawCluster.h"
12
13ClassImp(AliMUONData)
14
15//_____________________________________________________________________________
16AliMUONData::AliMUONData():TNamed()
17{
18 fLoader = 0x0;
19 fHits = 0x0; // One event in treeH per primary track
20 fDigits = 0x0; // One event in treeH per detection plane
21 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
22 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
23 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
24//default constructor
25}
26//_____________________________________________________________________________
27AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
28 TNamed(name,title)
29{
30 fLoader = loader;
31 fHits = new TClonesArray("AliMUONHit",1000);
32 fNhits = 0;
33 fDigits = new TObjArray(AliMUONConstants::NCh());
34 fNdigits = new Int_t[AliMUONConstants::NCh()];
35 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
36 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
37 fNdigits[iDetectionPlane]=0;
38 }
39 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
40 fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
41 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
42 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
43 fNrawclusters[iDetectionPlane]=0;
44 }
45 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
46 fNglobaltrigger =0;
47 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
48 fNlocaltrigger = 0;
49 //default constructor
50}
51//_____________________________________________________________________________
52AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
53{
54 // Dummy copy constructor
55 ;
56}
57//_____________________________________________________________________________
58AliMUONData::~AliMUONData()
59{
60 if (fHits) {
61 fHits->Delete();
62 delete fHits;
63 }
64 if (fDigits) {
65 fDigits->Delete();
66 delete fDigits;
67 }
68 if (fRawClusters) {
69 fRawClusters->Delete();
70 delete fRawClusters;
71 }
72 if (fGlobalTrigger){
73 fGlobalTrigger->Delete();
74 delete fGlobalTrigger;
75 }
76 if (fLocalTrigger){
77 fLocalTrigger->Delete();
78 delete fLocalTrigger;
79 }
80 //detructor
81}
82//_____________________________________________________________________________
83void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
84{
85 //
86 // Add a MUON digit to the list of Digits of the detection plane id
87 //
88 TClonesArray &ldigits = * ( (TClonesArray*) fDigits->At(id) );
89 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
90}
91//_____________________________________________________________________________
92void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
93 Int_t *singleUndef,
94 Int_t *pairUnlike, Int_t *pairLike)
95{
96 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
97 TClonesArray &globalTrigger = *fGlobalTrigger;
98 new(globalTrigger[fNglobaltrigger++])
99 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
100}
101//_____________________________________________________________________________
102void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
103 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
104 Float_t tof, Float_t momentum, Float_t theta,
105 Float_t phi, Float_t length, Float_t destep)
106{
107 TClonesArray &lhits = *fHits;
108 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
109 idpart, X, Y, Z,
110 tof, momentum, theta,
111 phi, length, destep);
112}
113//____________________________________________________________________________
114void AliMUONData::AddLocalTrigger(Int_t *localtr)
115{
116 // add a MUON Local Trigger to the list
117 TClonesArray &localTrigger = *fLocalTrigger;
118 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
119}
120//_____________________________________________________________________________
121void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
122{
123 //
124 // Add a MUON rawcluster to the list in the detection plane id
125 //
126 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
127 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
128}
129//_____________________________________________________________________________
130
131//___________________________________________
132void AliMUONData::MakeBranch(Option_t* option)
133{
134 //
135 // Create Tree branches for the MUON.
136 //
137 const Int_t kBufferSize = 4000;
138 char branchname[30];
139
140 const char *cH = strstr(option,"H");
141 const char *cD = strstr(option,"D"); // Digits branches in TreeD
142 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
143 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
144 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
145 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
146
147 TBranch * branch = 0x0;
148
149 // Creating Branches for Hits
150 if (TreeH() && cH) {
151 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
152 fNhits = 0;
153 sprintf(branchname,"%sHits",GetName());
154 branch = TreeH()->GetBranch(branchname);
155 if (branch) {
156 Info("MakeBranch","Branch %s is already in tree.",GetName());
157 return ;
158 }
159 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
160 Info("MakeBranch","Making Branch %s for hits \n",branchname);
161 }
162
163 //Creating Branches for Digits
164 if (TreeD() && cD ) {
165 // one branch for digits per chamber
166 if (fDigits == 0x0) {
167 fDigits = new TObjArray(AliMUONConstants::NCh());
168 fNdigits = new Int_t[AliMUONConstants::NCh()];
169 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
170 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
171 fNdigits[iDetectionPlane]=0;
172 }
173 }
174 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
175 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
176 branch = 0x0;
177 branch = TreeD()->GetBranch(branchname);
178 if (branch) {
179 Info("MakeBranch","Branch %s is already in tree.",GetName());
180 return;
181 }
182 branch = TreeD()->Branch(branchname, &((*fDigits)[iDetectionPlane]),kBufferSize);
183 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
184 }
185 }
186
187 if (TreeR() && cRC ) {
188 // one branch for raw clusters per tracking detection plane
189 //
190 Int_t i;
191 if (fRawClusters == 0x0) {
192 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
193 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
194 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
195 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
196 fNrawclusters[i]=0;
197 }
198 }
199
200 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
201 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
202 branch = 0x0;
203 branch = TreeR()->GetBranch(branchname);
204 if (branch) {
205 Info("MakeBranch","Branch %s is already in tree.",GetName());
206 return;
207 }
208 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
209 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
210 }
211 }
212
213 if (TreeR() && cGLT ) {
214 //
215 // one branch for global trigger
216 //
217 sprintf(branchname,"%sGlobalTrigger",GetName());
218 branch = 0x0;
219
220 if (fGlobalTrigger == 0x0) {
221 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
222 fNglobaltrigger = 0;
223 }
224 branch = TreeR()->GetBranch(branchname);
225 if (branch) {
226 Info("MakeBranch","Branch %s is already in tree.",GetName());
227 return ;
228 }
229 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
230 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
231
232 //
233 // one branch for local trigger
234 //
235 sprintf(branchname,"%sLocalTrigger",GetName());
236 branch = 0x0;
237
238 if (fLocalTrigger == 0x0) {
239 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
240 fNlocaltrigger = 0;
241 }
242 branch = TreeR()->GetBranch(branchname);
243 if (branch) {
244 Info("MakeBranch","Branch %s is already in tree.",GetName());
245 return;
246 }
247 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
248 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
249 }
250
251 if (TreeR() && cRT ) {
252 Info("MakeBranch","Making Branch for TreeT is not yet ready. \n");
253 }
254 if (TreeR() && cRP ) {
255 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
256 }
257}
258
259//____________________________________________________________________________
260void AliMUONData::ResetDigits()
261{
262 //
263 // Reset number of digits and the digits array for this detector
264 //
265 if (fDigits == 0x0) return;
266 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
267 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
268 if (fNdigits) fNdigits[i]=0;
269 }
270}
271//______________________________________________________________________________
272void AliMUONData::ResetHits()
273{
274 // Reset number of clusters and the cluster array for this detector
275 fNhits = 0;
276 if (fHits) fHits->Clear();
277}
278//_______________________________________________________________________________
279void AliMUONData::ResetRawClusters()
280{
281 // Reset number of raw clusters and the raw clust array for this detector
282 //
283 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
284 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
285 if (fNrawclusters) fNrawclusters[i]=0;
286 }
287}
288//_______________________________________________________________________________
289void AliMUONData::ResetTrigger()
290{
291 // Reset Local and Global Trigger
292 fNglobaltrigger = 0;
293 if (fGlobalTrigger) fGlobalTrigger->Clear();
294 fNlocaltrigger = 0;
295 if (fLocalTrigger) fLocalTrigger->Clear();
296}
297//_____________________________________________________________________________
298void AliMUONData::SetTreeAddress()
299{
300 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
301 char branchname[30];
302 TBranch * branch = 0x0;
303
304 //
305 // Branch address for hit tree
306 if ( TreeH() ) {
307 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
308 fNhits =0;
309 }
310 if (TreeH() && fHits) {
311 sprintf(branchname,"%sHits",GetName());
312 branch = TreeH()->GetBranch(branchname);
313 if (branch) {
314 Info("SetTreeAddress","(%s) Setting for Hits",GetName());
315 branch->SetAddress(&fHits);
316 }
317 else { //can be invoked before branch creation
318 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
319 }
320 }
321
322 //
323 // Branch address for digit tree
324 if ( TreeD() ) {
325 if (fDigits == 0x0) {
326 fDigits = new TObjArray(AliMUONConstants::NCh());
327 fNdigits= new Int_t[AliMUONConstants::NCh()];
328 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
329 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
330 fNdigits[i]=0;
331 }
332 }
333 }
334
335 if (TreeD() && fDigits) {
336 for (int i=0; i<AliMUONConstants::NCh(); i++) {
337 sprintf(branchname,"%sDigits%d",GetName(),i+1);
338 branch = TreeD()->GetBranch(branchname);
339 if (branch) branch->SetAddress(&((*fDigits)[i]));
340 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
341 }
342 }
343
344 //
345 // Branch address for rawclusters, globaltrigger and local trigger tree
346 if (TreeR() ) {
347 if (fRawClusters == 0x0) {
348 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
349 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
350 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
351 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
352 fNrawclusters[i]=0;
353 }
354 }
355 if (fLocalTrigger == 0x0) {
356 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
357 }
358 if (fGlobalTrigger== 0x0) {
359 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
360 }
361
362 }
363 if ( TreeR() && fRawClusters ) {
364 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
365 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
366 if (fRawClusters) {
367 branch = TreeR()->GetBranch(branchname);
368 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
369 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
370 }
371 }
372 }
373 if ( TreeR() && fLocalTrigger ) {
374 sprintf(branchname,"%sLocalTrigger",GetName());
375 branch = TreeR()->GetBranch(branchname);
376 if (branch) branch->SetAddress(&fLocalTrigger);
377 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
378 }
379 if ( TreeR() && fGlobalTrigger) {
380 sprintf(branchname,"%sGlobalTrigger",GetName());
381 branch = TreeR()->GetBranch(branchname);
382 if (branch) branch->SetAddress(&fGlobalTrigger);
383 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
384 }
385}
386//_____________________________________________________________________________
387
388