]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSCPVModule.cxx
BuildGeometry of AliMUON for trigger chambers delegated to AliMUONSegmentationTrigger...
[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$
18*/
19
20////////////////////////////////////////////////
21// Manager class for one CPV module //
22// //
23// Author: Yuri Kharlov, IHEP, Protvino //
24// e-mail: Yuri.Kharlov@cern.ch //
25// Last modified: 2 November 2000 //
26////////////////////////////////////////////////
27
28// --- ROOT system ---
29#include <TTree.h>
30
31// --- Standard library ---
32#include <stdio.h>
33#include <string.h>
34#include <stdlib.h>
35
36// --- galice header files ---
37#include "AliRun.h"
38#include "AliPHOSCPVModule.h"
39#include "AliPHOSCPVHit.h"
40
41//==============================================================================
42// AliPHOSCPVModule
43//==============================================================================
44
45ClassImp(AliPHOSCPVModule)
46
47//______________________________________________________________________________
48
49AliPHOSCPVModule::AliPHOSCPVModule(void) {
50 //
51 // Allocate an array of hits
52 //
53
54 if ( NULL==(fHits=new TClonesArray("AliPHOSCPVHit",100)) ) {
55 Error("CPV","Can not create array of hits");
56 exit(1);
57 }
58}
59
60//______________________________________________________________________________
61
62AliPHOSCPVModule::~AliPHOSCPVModule(void)
63{
64 Clear();
65}
66
67//______________________________________________________________________________
68
69void AliPHOSCPVModule::Clear(Option_t *opt="")
70{
71// Clear hit information
72
73 fHits -> Clear(opt);
74}
75
76//______________________________________________________________________________
77
78void AliPHOSCPVModule::AddHit(TLorentzVector p, Float_t *xy, Int_t ipart)
79{
80 //
81 // Add this hit to the hit list in CPV detector.
82 //
83
84 TClonesArray &lhits = *(TClonesArray *)fHits;
85 new(lhits[fHits->GetEntriesFast()]) AliPHOSCPVHit(p,xy,ipart);
86}
87
88//______________________________________________________________________________
89
90void AliPHOSCPVModule::Print(Option_t *opt)
91{
92 //
93 // Print AliPHOSCPVModule information.
94 // options: 'p' - print hits in the module
95 //
96
97 Int_t nhits,hit;
98 if (strcmp(opt,"p")==0) {
99 printf ("CPV module has %d hits\n",nhits=fHits->GetEntriesFast());
100 for (hit=0;hit<nhits;hit++) {
101 AliPHOSCPVHit *cpvHit = (AliPHOSCPVHit*)fHits->UncheckedAt(hit);
102 cpvHit->Print();
103 }
104 }
105}
106
107//______________________________________________________________________________
108
109void AliPHOSCPVModule::MakeBranch(Int_t i)
110{
111 //
112 // Create a new branch for a CPV module #i in the current Root Tree
113 //
114
115 char branchname[10];
116 sprintf(branchname,"CPV%d",i);
117 gAlice->TreeH()->Branch(branchname,&fHits, 1000);
118}
119
120//_____________________________________________________________________________
121void AliPHOSCPVModule::SetTreeAddress(Int_t i)
122{
123 //
124 // Set branch address for the Hits Tree for a CPV module #i
125 //
126
127 TBranch *branch;
128 char branchname[20];
129 TTree *treeH = gAlice->TreeH();
130 if (treeH){
131 sprintf(branchname,"CPV%d",i);
132 branch = treeH->GetBranch(branchname);
133 if (branch) branch->SetAddress(&fHits);
134 }
135}