]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSCPVModule.cxx
accumulated hits are now stored in TreeH
[u/mrichter/AliRoot.git] / PHOS / AliPHOSCPVModule.cxx
CommitLineData
61bc56b3 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$
7b84f7c1 18 Revision 1.1 2000/11/03 16:49:35 schutz
19 New class AliPHOSCPVModule
20
61bc56b3 21*/
22
23////////////////////////////////////////////////
24// Manager class for one CPV module //
25// //
26// Author: Yuri Kharlov, IHEP, Protvino //
27// e-mail: Yuri.Kharlov@cern.ch //
28// Last modified: 2 November 2000 //
29////////////////////////////////////////////////
30
31// --- ROOT system ---
32#include <TTree.h>
33
34// --- Standard library ---
35#include <stdio.h>
36#include <string.h>
37#include <stdlib.h>
7b84f7c1 38#include <iostream.h>
61bc56b3 39
40// --- galice header files ---
41#include "AliRun.h"
42#include "AliPHOSCPVModule.h"
43#include "AliPHOSCPVHit.h"
44
45//==============================================================================
46// AliPHOSCPVModule
47//==============================================================================
48
49ClassImp(AliPHOSCPVModule)
50
51//______________________________________________________________________________
52
7b84f7c1 53AliPHOSCPVModule::AliPHOSCPVModule(void)
54{
61bc56b3 55 //
56 // Allocate an array of hits
57 //
58
7b84f7c1 59 if ( NULL==(fHits =new TClonesArray("AliPHOSCPVHit",100)) ) {
60 Error("CPV","Can not create array of hits per track");
61bc56b3 61 exit(1);
62 }
63}
64
7b84f7c1 65//______________________________________________________________________________
66AliPHOSCPVModule::AliPHOSCPVModule(const AliPHOSCPVModule & module)
67{
68 // Copy constructor
69 module.Copy(*this);
70}
71
72//____________________________________________________________________________
73AliPHOSCPVModule & AliPHOSCPVModule::operator= (const AliPHOSCPVModule &module)
74{
75 module.Copy(*this);
76 return (*this);
77}
78
79//______________________________________________________________________________
80void AliPHOSCPVModule::Copy(AliPHOSCPVModule & module) const
81{
82 // Copy *this onto module
83 // It takes care about copying array of hits fHits
84
85 // Copy all first
86 if(this != &module) {
87 ((TObject*) this)->Copy((TObject&)module);
88 module.fHits = fHits;
89 }
90}
91
61bc56b3 92//______________________________________________________________________________
93
94AliPHOSCPVModule::~AliPHOSCPVModule(void)
95{
96 Clear();
97}
98
99//______________________________________________________________________________
100
101void AliPHOSCPVModule::Clear(Option_t *opt="")
102{
103// Clear hit information
104
7b84f7c1 105 fHits -> Clear(opt);
61bc56b3 106}
107
108//______________________________________________________________________________
109
110void AliPHOSCPVModule::AddHit(TLorentzVector p, Float_t *xy, Int_t ipart)
111{
112 //
113 // Add this hit to the hit list in CPV detector.
114 //
115
116 TClonesArray &lhits = *(TClonesArray *)fHits;
117 new(lhits[fHits->GetEntriesFast()]) AliPHOSCPVHit(p,xy,ipart);
118}
119
120//______________________________________________________________________________
121
122void AliPHOSCPVModule::Print(Option_t *opt)
123{
124 //
125 // Print AliPHOSCPVModule information.
126 // options: 'p' - print hits in the module
127 //
128
129 Int_t nhits,hit;
130 if (strcmp(opt,"p")==0) {
131 printf ("CPV module has %d hits\n",nhits=fHits->GetEntriesFast());
132 for (hit=0;hit<nhits;hit++) {
133 AliPHOSCPVHit *cpvHit = (AliPHOSCPVHit*)fHits->UncheckedAt(hit);
134 cpvHit->Print();
135 }
136 }
137}
138
139//______________________________________________________________________________
140
141void AliPHOSCPVModule::MakeBranch(Int_t i)
142{
143 //
144 // Create a new branch for a CPV module #i in the current Root Tree
145 //
146
147 char branchname[10];
148 sprintf(branchname,"CPV%d",i);
149 gAlice->TreeH()->Branch(branchname,&fHits, 1000);
150}
151
152//_____________________________________________________________________________
153void AliPHOSCPVModule::SetTreeAddress(Int_t i)
154{
155 //
156 // Set branch address for the Hits Tree for a CPV module #i
157 //
158
159 TBranch *branch;
160 char branchname[20];
161 TTree *treeH = gAlice->TreeH();
162 if (treeH){
163 sprintf(branchname,"CPV%d",i);
164 branch = treeH->GetBranch(branchname);
165 if (branch) branch->SetAddress(&fHits);
166 }
167}