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