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