]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONData.cxx
Implementation of ITS tracking for HLT. The tracking is based on the off-line AliITSt...
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
CommitLineData
50837721 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$ */
9140dcef 17// AliMUONData classes
18// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc ..
19// The classe makes the lik between the MUON data lists and the event trees from loaders
20// Gines Martinez, Subatech, September 2003
21//
22
374ebd7d 23//AliRoot include
30178c30 24//#include "AliRun.h"
25//#include "AliMC.h"
1a1cdff8 26#include "AliMUONConstants.h"
6309cf6e 27#include "AliMUONData.h"
28#include "AliMUONDigit.h"
29#include "AliMUONHit.h"
30#include "AliMUONLocalTrigger.h"
31#include "AliMUONGlobalTrigger.h"
32#include "AliMUONRawCluster.h"
dcd2690d 33#include "AliMUONTrack.h"
276c44b7 34#include "AliMUONTriggerTrack.h"
8c343c7c 35#include "AliLog.h"
30178c30 36
6309cf6e 37ClassImp(AliMUONData)
38
39//_____________________________________________________________________________
1017e5bf 40 AliMUONData::AliMUONData():
41 TNamed(),
42 fLoader(0x0),
43 fHits(0x0),
44 fDigits(0x0),
45 fSDigits(0x0),
46 fRawClusters(0x0),
47 fGlobalTrigger(0x0),
48 fLocalTrigger(0x0),
49 fRecTracks(0x0),
50 fRecTriggerTracks(0x0),
51 fNhits(0),
52 fNdigits(0x0),
53 fNSdigits(0x0),
54 fNrawclusters(0x0),
55 fNglobaltrigger(0),
56 fNlocaltrigger(0),
57 fNrectracks(0),
58 fNrectriggertracks(0),
59 fSplitLevel(0)
6309cf6e 60{
9140dcef 61 // Default constructor
6309cf6e 62}
63//_____________________________________________________________________________
64AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
1017e5bf 65 TNamed(name,title),
66 fLoader(loader),
67 fHits(0x0),
68 fDigits(0x0),
69 fSDigits(0x0),
70 fRawClusters(0x0),
71 fGlobalTrigger(0x0),
72 fLocalTrigger(0x0),
73 fRecTracks(0x0),
74 fRecTriggerTracks(0x0),
75 fNhits(0),
76 fNdigits(0x0),
77 fNSdigits(0x0),
78 fNrawclusters(0x0),
79 fNglobaltrigger(0),
80 fNlocaltrigger(0),
81 fNrectracks(0),
82 fNrectriggertracks(0),
83 fSplitLevel(0)
6309cf6e 84{
9140dcef 85 // Constructor for AliMUONData
1017e5bf 86
b1c7d777 87// fHits = new TClonesArray("AliMUONHit",1000);
88// fNhits = 0;
89// fDigits = new TObjArray(AliMUONConstants::NCh());
90// fNdigits = new Int_t[AliMUONConstants::NCh()];
91// for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
92// fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
93// fNdigits[iDetectionPlane]=0;
94// }
95// fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
96// fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
97// for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
98// fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
99// fNrawclusters[iDetectionPlane]=0;
100// }
101// fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
102// fNglobaltrigger =0;
103// fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
104// fNlocaltrigger = 0;
374ebd7d 105// fRecTracks = new TClonesArray("AliMUONTrack", 100);
b1c7d777 106// fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
107
108
6309cf6e 109}
e3ea1889 110
6309cf6e 111//_____________________________________________________________________________
112AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
113{
e3ea1889 114// Protected copy constructor
115
8c343c7c 116 AliFatal("Not implemented.");
6309cf6e 117}
e3ea1889 118
6309cf6e 119//_____________________________________________________________________________
120AliMUONData::~AliMUONData()
121{
9140dcef 122 // Destructor for AliMUONData
6309cf6e 123 if (fHits) {
124 fHits->Delete();
125 delete fHits;
126 }
127 if (fDigits) {
128 fDigits->Delete();
129 delete fDigits;
130 }
d1775029 131 if (fSDigits) {
132 fSDigits->Delete();
133 delete fSDigits;
134 }
6309cf6e 135 if (fRawClusters) {
136 fRawClusters->Delete();
137 delete fRawClusters;
138 }
139 if (fGlobalTrigger){
140 fGlobalTrigger->Delete();
141 delete fGlobalTrigger;
142 }
143 if (fLocalTrigger){
144 fLocalTrigger->Delete();
145 delete fLocalTrigger;
146 }
dcd2690d 147 if (fRecTracks){
148 fRecTracks->Delete();
149 delete fRecTracks;
150 }
276c44b7 151 if (fRecTriggerTracks){
152 fRecTriggerTracks->Delete();
153 delete fRecTriggerTracks;
154 }
6309cf6e 155 //detructor
156}
e3ea1889 157
158//_____________________________________________________________________________
159AliMUONData& AliMUONData::operator=(const AliMUONData& rhs)
160{
161// Protected assignement operator
162
163 if (this == &rhs) return *this;
164
8c343c7c 165 AliFatal("Not implemented.");
e3ea1889 166
167 return *this;
168}
169
170
6309cf6e 171//_____________________________________________________________________________
172void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
173{
174 //
175 // Add a MUON digit to the list of Digits of the detection plane id
176 //
1a1cdff8 177 TClonesArray &ldigits = * Digits(id) ;
6309cf6e 178 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
179}
180//_____________________________________________________________________________
61adb9bd 181void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
182{
183 //
184 // Add a MUON digit to the list of Digits of the detection plane id
185 //
186 TClonesArray &ldigits = * Digits(id) ;
187 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
188}
189//_____________________________________________________________________________
30178c30 190void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
d1775029 191{
192 //
193 // Add a MUON Sdigit to the list of SDigits of the detection plane id
194 //
195 TClonesArray &lSdigits = * SDigits(id) ;
30178c30 196 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
d1775029 197}
198//_____________________________________________________________________________
199void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
200{
201 //
202 // Add a MUON Sdigit to the list of SDigits of the detection plane id
203 //
204 TClonesArray &lSdigits = * SDigits(id) ;
205 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
206}
207//_____________________________________________________________________________
6309cf6e 208void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
209 Int_t *singleUndef,
210 Int_t *pairUnlike, Int_t *pairLike)
211{
212 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
ce3e25a8 213
6309cf6e 214 TClonesArray &globalTrigger = *fGlobalTrigger;
215 new(globalTrigger[fNglobaltrigger++])
216 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
217}
218//_____________________________________________________________________________
61adb9bd 219void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
220{
ce3e25a8 221 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
61adb9bd 222 TClonesArray &globalTrigger = *fGlobalTrigger;
223 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
224}
225//_____________________________________________________________________________
6309cf6e 226void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
227 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
228 Float_t tof, Float_t momentum, Float_t theta,
229 Float_t phi, Float_t length, Float_t destep)
230{
9140dcef 231 // Add new hit to the hit list
6309cf6e 232 TClonesArray &lhits = *fHits;
233 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
234 idpart, X, Y, Z,
235 tof, momentum, theta,
236 phi, length, destep);
237}
238//____________________________________________________________________________
1391e633 239void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
240 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
241 Float_t tof, Float_t momentum, Float_t theta,
242 Float_t phi, Float_t length, Float_t destep,
243 Float_t Xref,Float_t Yref,Float_t Zref)
244{
9140dcef 245 // Add new hit to the hit list
1391e633 246 TClonesArray &lhits = *fHits;
247 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
248 idpart, X, Y, Z,
249 tof, momentum, theta,
250 phi, length, destep,
251 Xref,Yref,Zref);
252}
253//____________________________________________________________________________
61adb9bd 254void AliMUONData::AddHit(const AliMUONHit& hit)
255{
256 TClonesArray &lhits = *fHits;
257 new(lhits[fNhits++]) AliMUONHit(hit);
258}
259//____________________________________________________________________________
6309cf6e 260void AliMUONData::AddLocalTrigger(Int_t *localtr)
261{
262 // add a MUON Local Trigger to the list
263 TClonesArray &localTrigger = *fLocalTrigger;
264 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
265}
61adb9bd 266//____________________________________________________________________________
267void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
268{
269 // add a MUON Local Trigger to the list
270 TClonesArray &localTrigger = *fLocalTrigger;
271 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
272}
6309cf6e 273//_____________________________________________________________________________
274void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
275{
276 //
277 // Add a MUON rawcluster to the list in the detection plane id
278 //
279 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
280 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
281}
dcd2690d 282//_____________________________________________________________________________
283void AliMUONData::AddRecTrack(const AliMUONTrack& track)
284{
285 //
286 // Add a MUON rectrack
287 //
288 TClonesArray &lrectracks = *fRecTracks;
289 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
61adb9bd 290 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
dcd2690d 291}
276c44b7 292//_____________________________________________________________________________
293void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
294{
295 //
296 // Add a MUON triggerrectrack
297 //
298 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
299 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
300 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
301}
302
ce3f5e87 303//____________________________________________________________________________
1eccde20 304TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
305{
9140dcef 306 //Getting List of Digits
1eccde20 307 if (fDigits)
308 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
309 else
310 return NULL;
311}
312//____________________________________________________________________________
d1775029 313TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane)
314{
315 //Getting List of SDigits
316 if (fSDigits)
317 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
318 else
319 return NULL;
320}
321//____________________________________________________________________________
c1d45bdf 322Bool_t AliMUONData::IsRawClusterBranchesInTree()
323{
9140dcef 324 // Checking if there are RawCluster Branches In TreeR
c1d45bdf 325 if (TreeR()==0x0) {
8c343c7c 326 AliError("No treeR in memory");
c1d45bdf 327 return kFALSE;
328 }
329 else {
330 char branchname[30];
331 sprintf(branchname,"%sRawClusters1",GetName());
332 TBranch * branch = 0x0;
333 branch = TreeR()->GetBranch(branchname);
334 if (branch) return kTRUE;
335 else return kFALSE;
336 }
337}
338//____________________________________________________________________________
ce3e25a8 339Bool_t AliMUONData::IsDigitsBranchesInTree()
340{
341 // Checking if there are RawCluster Branches In TreeR
342 if (TreeD()==0x0) {
8c343c7c 343 AliError("No treeD in memory");
ce3e25a8 344 return kFALSE;
345 }
346 else {
347 char branchname[30];
348 sprintf(branchname,"%sDigits1",GetName());
349 TBranch * branch = 0x0;
350 branch = TreeD()->GetBranch(branchname);
351 if (branch) return kTRUE;
352 else return kFALSE;
353 }
354}
355//____________________________________________________________________________
c1d45bdf 356Bool_t AliMUONData::IsTriggerBranchesInTree()
357{
9140dcef 358 // Checking if there are Trigger Branches In TreeR
c1d45bdf 359 if (TreeR()==0x0) {
8c343c7c 360 AliError("No treeR in memory");
c1d45bdf 361 return kFALSE;
362 }
363 else {
364 char branchname[30];
365 sprintf(branchname,"%sLocalTrigger",GetName());
366 TBranch * branch = 0x0;
367 branch = TreeR()->GetBranch(branchname);
368 if (branch) return kTRUE;
369 else return kFALSE;
370 }
371}
ce3e25a8 372//____________________________________________________________________________
373Bool_t AliMUONData::IsTriggerBranchesInTreeD()
374{
375 // Checking if there are Trigger Branches In TreeR
376 if (TreeD()==0x0) {
8c343c7c 377 AliError("No treeD in memory");
ce3e25a8 378 return kFALSE;
379 }
380 else {
381 char branchname[30];
382 sprintf(branchname,"%sLocalTrigger",GetName());
383 TBranch * branch = 0x0;
384 branch = TreeD()->GetBranch(branchname);
385 if (branch) return kTRUE;
386 else return kFALSE;
387 }
388}
389
c1d45bdf 390//____________________________________________________________________________
276c44b7 391Bool_t AliMUONData::IsTrackBranchesInTree()
392{
393 // Checking if there are Track Branches In TreeT
394 if (TreeT()==0x0) {
8c343c7c 395 AliError("No treeT in memory");
276c44b7 396 return kFALSE;
397 }
398 else {
399 char branchname[30];
400 sprintf(branchname,"%sTrack",GetName());
401 TBranch * branch = 0x0;
402 branch = TreeT()->GetBranch(branchname);
403 if (branch) return kTRUE;
404 else return kFALSE;
405 }
406}
407//____________________________________________________________________________
408Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
409{
410 // Checking if there are TriggerTrack Branches In TreeT
411 if (TreeT()==0x0) {
8c343c7c 412 AliError("No treeT in memory");
276c44b7 413 return kFALSE;
414 }
415 else {
416 char branchname[30];
417 sprintf(branchname,"%sTriggerTrack",GetName());
418 TBranch * branch = 0x0;
419 branch = TreeT()->GetBranch(branchname);
420 if (branch) return kTRUE;
421 else return kFALSE;
422 }
423}
424//____________________________________________________________________________
1a1cdff8 425void AliMUONData::Fill(Option_t* option)
426{
427 // Method to fill the trees
428 const char *cH = strstr(option,"H");
429 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 430 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
1a1cdff8 431 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 432 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
433 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
1a1cdff8 434 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
ce3e25a8 435 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 436
1a1cdff8 437 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
438
439 char branchname[30];
440 TBranch * branch = 0x0;
441
1a1cdff8 442 // Filling TreeH
443 if ( TreeH() && cH ) {
444 TreeH()->Fill();
445 }
ce3e25a8 446
1a1cdff8 447 // Filling TreeD
ce3e25a8 448
449 if ( TreeD() && cD ) {
450 if ( IsTriggerBranchesInTreeD() ) {
451 for (int i=0; i<AliMUONConstants::NCh(); i++) {
452 sprintf(branchname,"%sDigits%d",GetName(),i+1);
453 branch = TreeD()->GetBranch(branchname);
454 branch->Fill();
455 }
456 } else
457 TreeD()->Fill();
1a1cdff8 458 }
ce3e25a8 459
460 // filling trigger
461 if ( TreeD() && cGLT ) {
462 if ( IsDigitsBranchesInTree() ) {
463 sprintf(branchname,"%sLocalTrigger",GetName());
464 branch = TreeD()->GetBranch(branchname);
465 branch->Fill();
466 sprintf(branchname,"%sGlobalTrigger",GetName());
467 branch = TreeD()->GetBranch(branchname);
468 branch->Fill();
469 } else
470 TreeD()->Fill();
471 }
472
d1775029 473 // Filling TreeS
474 if ( TreeS() && cS) {
475 TreeS()->Fill();
476 }
c1d45bdf 477
1a1cdff8 478 //
479 // filling rawclusters
c1d45bdf 480 if ( TreeR() && cRC ) {
481 if ( IsTriggerBranchesInTree() ) {
482 // Branch per branch filling
483 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
484 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
485 branch = TreeR()->GetBranch(branchname);
486 branch->Fill();
487 }
488 }
489 else TreeR()->Fill();
1a1cdff8 490 }
c1d45bdf 491
1a1cdff8 492 //
493 // filling trigger
ce3e25a8 494 if ( TreeR() && cTC) {
346357f4 495 if (IsRawClusterBranchesInTree()) {
c1d45bdf 496 // Branch per branch filling
497 sprintf(branchname,"%sLocalTrigger",GetName());
498 branch = TreeR()->GetBranch(branchname);
499 branch->Fill();
500 sprintf(branchname,"%sGlobalTrigger",GetName());
501 branch = TreeR()->GetBranch(branchname);
502 branch->Fill();
503 }
504 else TreeR()->Fill();
1a1cdff8 505 }
506 //
507 // filling tracks
508 if ( TreeT() && cRT ) {
276c44b7 509 if (IsTriggerTrackBranchesInTree()) {
510 sprintf(branchname,"%sTrack",GetName());
511 branch = TreeT()->GetBranch(branchname);
512 branch->Fill();
513 }
514 else TreeT()->Fill();
515 }
516 // filling trigger tracks
517 if ( TreeT() && cRL ) {
518 if (IsTrackBranchesInTree()) {
519 sprintf(branchname,"%sTriggerTrack",GetName());
520 branch = TreeT()->GetBranch(branchname);
521 branch->Fill();
522 }
523 else TreeT()->Fill();
1a1cdff8 524 }
276c44b7 525// if ( TreeT() && cRL ) {
61adb9bd 526// sprintf(branchname,"%sTrackTrig",GetName());
527// TreeT()->Fill();
528// }
1a1cdff8 529}
530//_____________________________________________________________________________
6309cf6e 531void AliMUONData::MakeBranch(Option_t* option)
532{
533 //
534 // Create Tree branches for the MUON.
535 //
536 const Int_t kBufferSize = 4000;
537 char branchname[30];
538
276c44b7 539
6309cf6e 540 const char *cH = strstr(option,"H");
541 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 542 const char *cS = strstr(option,"S"); // Digits branches in TreeS
6309cf6e 543 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 544 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
545 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
6309cf6e 546 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 547 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 548 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
276c44b7 549
6309cf6e 550 TBranch * branch = 0x0;
551
552 // Creating Branches for Hits
553 if (TreeH() && cH) {
1988766a 554
555 if (fHits == 0x0) {
556 fHits = new TClonesArray("AliMUONHit",1000);
307d9d04 557// if (gAlice->GetMCApp())
558// gAlice->GetMCApp()->AddHitList (fHits);
1988766a 559 }
560
6309cf6e 561 fNhits = 0;
562 sprintf(branchname,"%sHits",GetName());
563 branch = TreeH()->GetBranch(branchname);
564 if (branch) {
8c343c7c 565 AliInfo(Form("MakeBranch","Branch %s is already in tree.",GetName()));
6309cf6e 566 return ;
567 }
c6ce342a 568 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
cba99c31 569 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
6309cf6e 570 }
571
572 //Creating Branches for Digits
573 if (TreeD() && cD ) {
574 // one branch for digits per chamber
575 if (fDigits == 0x0) {
ce3f5e87 576 fDigits = new TObjArray(AliMUONConstants::NCh());
6309cf6e 577 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
1017e5bf 578 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
579 tca->SetOwner();
580 fDigits->AddAt(tca,iDetectionPlane);
ce3f5e87 581 }
582 }
583 if (fNdigits == 0x0) {
584 fNdigits = new Int_t[AliMUONConstants::NCh()];
585 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
6309cf6e 586 fNdigits[iDetectionPlane]=0;
587 }
588 }
589 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
590 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
591 branch = 0x0;
592 branch = TreeD()->GetBranch(branchname);
593 if (branch) {
8c343c7c 594 AliInfo(Form("Branch %s is already in tree.",GetName()));
6309cf6e 595 return;
596 }
1a1cdff8 597 TClonesArray * digits = Digits(iDetectionPlane);
d652f85c 598 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
cba99c31 599 //Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
6309cf6e 600 }
601 }
ce3e25a8 602
603 if (TreeD() && cGLT ) {
604 //
605 // one branch for global trigger
606 //
607 sprintf(branchname,"%sGlobalTrigger",GetName());
608 branch = 0x0;
609
610 if (fGlobalTrigger == 0x0) {
611 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
612 fNglobaltrigger = 0;
613 }
614 branch = TreeD()->GetBranch(branchname);
615 if (branch) {
8c343c7c 616 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
ce3e25a8 617 return ;
618 }
619 branch = TreeD()->Branch(branchname, &fGlobalTrigger, kBufferSize);
620 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
621
622 //
623 // one branch for local trigger
624 //
625 sprintf(branchname,"%sLocalTrigger",GetName());
626 branch = 0x0;
627
628 if (fLocalTrigger == 0x0) {
629 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
630 fNlocaltrigger = 0;
631 }
632 branch = TreeD()->GetBranch(branchname);
633 if (branch) {
8c343c7c 634 AliInfo(Form("Branch LocalTrigger is already in treeD."));
ce3e25a8 635 return;
636 }
637 branch = TreeD()->Branch(branchname, &fLocalTrigger, kBufferSize);
638 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
639 }
640
641
d1775029 642 //Creating Branches for SDigits
643 if (TreeS() && cS ) {
644 // one branch for Sdigits per chamber
645 if (fSDigits == 0x0) {
646 fSDigits = new TObjArray(AliMUONConstants::NCh());
647 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
1017e5bf 648 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
649 tca->SetOwner();
650 fSDigits->AddAt(tca,iDetectionPlane);
d1775029 651 }
652 }
653 if (fNSdigits == 0x0) {
654 fNSdigits = new Int_t[AliMUONConstants::NCh()];
655 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
656 fNSdigits[iDetectionPlane]=0;
657 }
658 }
659 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
660 sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
661 branch = 0x0;
662 branch = TreeS()->GetBranch(branchname);
663 if (branch) {
8c343c7c 664 AliInfo(Form("Branch %s is already in tree.",GetName()));
d1775029 665 return;
666 }
30178c30 667 TClonesArray * sdigits = SDigits(iDetectionPlane);
668 branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
669 //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
d1775029 670 }
671 }
672
6309cf6e 673 if (TreeR() && cRC ) {
674 // one branch for raw clusters per tracking detection plane
675 //
676 Int_t i;
677 if (fRawClusters == 0x0) {
678 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
6309cf6e 679 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
1017e5bf 680 TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
681 tca->SetOwner();
682 fRawClusters->AddAt(tca,i);
ce3f5e87 683 }
684 }
685
686 if (fNrawclusters == 0x0) {
687 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
688 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
6309cf6e 689 fNrawclusters[i]=0;
690 }
691 }
692
693 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
694 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
695 branch = 0x0;
696 branch = TreeR()->GetBranch(branchname);
697 if (branch) {
8c343c7c 698 AliInfo(Form("Branch %s is already in tree.",GetName()));
6309cf6e 699 return;
700 }
c6ce342a 701 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
cba99c31 702 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
6309cf6e 703 }
704 }
705
ce3e25a8 706 if (TreeR() && cTC ) {
6309cf6e 707 //
708 // one branch for global trigger
709 //
710 sprintf(branchname,"%sGlobalTrigger",GetName());
711 branch = 0x0;
712
713 if (fGlobalTrigger == 0x0) {
c6ce342a 714 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
6309cf6e 715 fNglobaltrigger = 0;
716 }
717 branch = TreeR()->GetBranch(branchname);
718 if (branch) {
8c343c7c 719 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
6309cf6e 720 return ;
721 }
c6ce342a 722 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
cba99c31 723 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 724
725 //
726 // one branch for local trigger
727 //
728 sprintf(branchname,"%sLocalTrigger",GetName());
729 branch = 0x0;
730
731 if (fLocalTrigger == 0x0) {
732 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
733 fNlocaltrigger = 0;
734 }
735 branch = TreeR()->GetBranch(branchname);
736 if (branch) {
8c343c7c 737 AliInfo(Form("Branch LocalTrigger is already in treeR."));
6309cf6e 738 return;
739 }
c6ce342a 740 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
cba99c31 741 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 742 }
743
dcd2690d 744 if (TreeT() && cRT ) {
374ebd7d 745 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
dcd2690d 746 fNrectracks = 0;
747 sprintf(branchname,"%sTrack",GetName());
748 branch = TreeT()->GetBranch(branchname);
749 if (branch) {
8c343c7c 750 AliInfo(Form("Branch %s is already in tree.",GetName()));
dcd2690d 751 return ;
752 }
753 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
cba99c31 754 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
dcd2690d 755 }
276c44b7 756// trigger tracks
757 if (TreeT() && cRL ) {
758 if (fRecTriggerTracks == 0x0) fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
759 fNrectriggertracks = 0;
760 sprintf(branchname,"%sTriggerTrack",GetName());
761 branch = TreeT()->GetBranch(branchname);
762 if (branch) {
8c343c7c 763 AliInfo(Form("Branch %s is already in tree.",GetName()));
276c44b7 764 return ;
765 }
766 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
cba99c31 767 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
276c44b7 768 }
6309cf6e 769}
1eccde20 770//____________________________________________________________________________
771TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
772{
9140dcef 773 // Getting Raw Clusters
1eccde20 774 if (fRawClusters)
775 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
776 else
777 return NULL;
778}
6309cf6e 779//____________________________________________________________________________
276c44b7 780TClonesArray* AliMUONData::LocalTrigger()
781{
782 // Getting Local Trigger
783 if (fLocalTrigger)
784 return ( (TClonesArray*) fLocalTrigger );
785 else
786 return NULL;
787}
788//____________________________________________________________________________
789TClonesArray* AliMUONData::GlobalTrigger()
790{
791 // Getting Global Trigger
792 if (fGlobalTrigger)
793 return ( (TClonesArray*) fGlobalTrigger );
794 else
795 return NULL;
796}
797//____________________________________________________________________________
6309cf6e 798void AliMUONData::ResetDigits()
799{
800 //
801 // Reset number of digits and the digits array for this detector
802 //
803 if (fDigits == 0x0) return;
804 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
805 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
806 if (fNdigits) fNdigits[i]=0;
807 }
808}
d1775029 809//____________________________________________________________________________
810void AliMUONData::ResetSDigits()
811{
812 //
813 // Reset number of Sdigits and the Sdigits array for this detector
814 //
815 if (fSDigits == 0x0) return;
816 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
817 if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear();
818 if (fNSdigits) fNSdigits[i]=0;
819 }
820}
6309cf6e 821//______________________________________________________________________________
822void AliMUONData::ResetHits()
823{
824 // Reset number of clusters and the cluster array for this detector
825 fNhits = 0;
826 if (fHits) fHits->Clear();
827}
828//_______________________________________________________________________________
829void AliMUONData::ResetRawClusters()
830{
831 // Reset number of raw clusters and the raw clust array for this detector
832 //
833 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
834 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
835 if (fNrawclusters) fNrawclusters[i]=0;
836 }
837}
838//_______________________________________________________________________________
839void AliMUONData::ResetTrigger()
840{
841 // Reset Local and Global Trigger
842 fNglobaltrigger = 0;
843 if (fGlobalTrigger) fGlobalTrigger->Clear();
844 fNlocaltrigger = 0;
845 if (fLocalTrigger) fLocalTrigger->Clear();
846}
dcd2690d 847//____________________________________________________________________________
848void AliMUONData::ResetRecTracks()
849{
850 // Reset tracks information
851 fNrectracks = 0;
852 if (fRecTracks) fRecTracks->Clear();
853}
276c44b7 854//____________________________________________________________________________
855void AliMUONData::ResetRecTriggerTracks()
856{
857 // Reset tracks information
858 fNrectriggertracks = 0;
859 if (fRecTriggerTracks) fRecTriggerTracks->Clear();
860}
6309cf6e 861//_____________________________________________________________________________
ce3f5e87 862void AliMUONData::SetTreeAddress(Option_t* option)
6309cf6e 863{
9140dcef 864 //Setting Addresses to the events trees
ce3f5e87 865 const char *cH = strstr(option,"H");
866 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 867 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
ce3f5e87 868 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 869 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
870 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
dcd2690d 871 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 872 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
ce3f5e87 873 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
874
6309cf6e 875 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
876 char branchname[30];
877 TBranch * branch = 0x0;
878
879 //
880 // Branch address for hit tree
ce3f5e87 881 if ( TreeH() && cH ) {
88cf591d 882 if (fHits == 0x0) {
883 fHits = new TClonesArray("AliMUONHit",1000);
d1775029 884 // if (gAlice->GetMCApp())
885 // gAlice->GetMCApp()->AddHitList (fHits); Moved to AliMUON
88cf591d 886 }
6309cf6e 887 fNhits =0;
888 }
ce3f5e87 889 if (TreeH() && fHits && cH) {
6309cf6e 890 sprintf(branchname,"%sHits",GetName());
891 branch = TreeH()->GetBranch(branchname);
892 if (branch) {
d652f85c 893 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
6309cf6e 894 branch->SetAddress(&fHits);
895 }
896 else { //can be invoked before branch creation
8c343c7c 897 AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
6309cf6e 898 }
899 }
900
901 //
902 // Branch address for digit tree
95e68a13 903 if ( TreeD() ) {
904 if (fDigits == 0x0 && cD) {
6309cf6e 905 fDigits = new TObjArray(AliMUONConstants::NCh());
906 fNdigits= new Int_t[AliMUONConstants::NCh()];
907 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
908 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
909 fNdigits[i]=0;
910 }
911 }
ce3e25a8 912 if (fLocalTrigger == 0x0 && cGLT) {
913 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
914 }
915 if (fGlobalTrigger== 0x0 && cGLT) {
916 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
917 }
6309cf6e 918 }
919
ce3f5e87 920 if (TreeD() && fDigits && cD) {
6309cf6e 921 for (int i=0; i<AliMUONConstants::NCh(); i++) {
922 sprintf(branchname,"%sDigits%d",GetName(),i+1);
d652f85c 923 if (fDigits) {
924 branch = TreeD()->GetBranch(branchname);
925 TClonesArray * digits = Digits(i);
d1775029 926 if (branch) {
927 branch->SetAddress( &digits );
928 }
8c343c7c 929 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
d652f85c 930 }
6309cf6e 931 }
932 }
ce3e25a8 933 if ( TreeD() && fLocalTrigger && cGLT) {
934 sprintf(branchname,"%sLocalTrigger",GetName());
935 branch = TreeD()->GetBranch(branchname);
936 if (branch) branch->SetAddress(&fLocalTrigger);
8c343c7c 937 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
ce3e25a8 938 }
939 if ( TreeD() && fGlobalTrigger && cGLT) {
940 sprintf(branchname,"%sGlobalTrigger",GetName());
941 branch = TreeD()->GetBranch(branchname);
942 if (branch) branch->SetAddress(&fGlobalTrigger);
8c343c7c 943 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
ce3e25a8 944 }
945
d1775029 946 //
947 // Branch address for Sdigit tree
948 if ( TreeS() && cS) {
949 if (fSDigits == 0x0) {
950 fSDigits = new TObjArray(AliMUONConstants::NCh());
951 fNSdigits= new Int_t[AliMUONConstants::NCh()];
952 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
953 fSDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
954 fNSdigits[i]=0;
955 }
956 }
957 }
958
959 if (TreeS() && fSDigits && cS) {
960 for (int i=0; i<AliMUONConstants::NCh(); i++) {
961 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
962 if (fSDigits) {
963 branch = TreeS()->GetBranch(branchname);
30178c30 964 TClonesArray * sdigits = SDigits(i);
965 if (branch) branch->SetAddress( &sdigits );
8c343c7c 966 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
d1775029 967 }
968 }
969 }
6309cf6e 970
971 //
972 // Branch address for rawclusters, globaltrigger and local trigger tree
973 if (TreeR() ) {
ce3f5e87 974 if (fRawClusters == 0x0 && cRC) {
6309cf6e 975 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
976 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
977 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
978 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
979 fNrawclusters[i]=0;
980 }
981 }
ce3e25a8 982 if (fLocalTrigger == 0x0 && cTC) {
6309cf6e 983 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
984 }
ce3e25a8 985 if (fGlobalTrigger== 0x0 && cTC) {
6309cf6e 986 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
987 }
988
989 }
ce3f5e87 990 if ( TreeR() && fRawClusters && cRC) {
6309cf6e 991 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
992 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
993 if (fRawClusters) {
994 branch = TreeR()->GetBranch(branchname);
d652f85c 995 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
8c343c7c 996 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
6309cf6e 997 }
998 }
999 }
ce3e25a8 1000 if ( TreeR() && fLocalTrigger && cTC) {
6309cf6e 1001 sprintf(branchname,"%sLocalTrigger",GetName());
1002 branch = TreeR()->GetBranch(branchname);
1003 if (branch) branch->SetAddress(&fLocalTrigger);
8c343c7c 1004 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
6309cf6e 1005 }
ce3e25a8 1006 if ( TreeR() && fGlobalTrigger && cTC) {
6309cf6e 1007 sprintf(branchname,"%sGlobalTrigger",GetName());
1008 branch = TreeR()->GetBranch(branchname);
1009 if (branch) branch->SetAddress(&fGlobalTrigger);
8c343c7c 1010 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
6309cf6e 1011 }
dcd2690d 1012
8547965d 1013 if ( TreeT() ) {
61adb9bd 1014 if (fRecTracks == 0x0 && cRT) {
8547965d 1015 fRecTracks = new TClonesArray("AliMUONTrack",100);
1016 }
61adb9bd 1017
8547965d 1018 }
dcd2690d 1019 if ( TreeT() && fRecTracks && cRT ) {
1020 sprintf(branchname,"%sTrack",GetName());
1021 branch = TreeT()->GetBranch(branchname);
1022 if (branch) branch->SetAddress(&fRecTracks);
8c343c7c 1023 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
dcd2690d 1024 }
276c44b7 1025// trigger tracks
1026 if ( TreeT() ) {
1027 if (fRecTriggerTracks == 0x0 && cRL) {
1028 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
1029 }
1030
1031 }
1032 if ( TreeT() && fRecTriggerTracks && cRL ) {
1033 sprintf(branchname,"%sTriggerTrack",GetName());
1034 branch = TreeT()->GetBranch(branchname);
1035 if (branch) branch->SetAddress(&fRecTriggerTracks);
8c343c7c 1036 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
276c44b7 1037 }
1038
61adb9bd 1039
6309cf6e 1040}
1041//_____________________________________________________________________________