StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEeventDst.cxx
1 // $Id: EEeventDst.cxx,v 1.9 2007/05/30 02:38:48 balewski Exp $
2 
3 #include <cassert>
4 #include <TClonesArray.h>
5 #include <StMessMgr.h>
6 
7 #include "EEsectorDst.h"
8 #include "EEeventDst.h"
9 
10 ClassImp(EEeventDst)
11 //--------------------------------------------------
12 //--------------------------------------------------
13 //--------------------------------------------------
15  // printf("EEeventDst() constructed\n");
16  Sec= new TClonesArray("EEsectorDst",1000);
17  clear();
18 }
19 
20 //--------------------------------------------------
21 //--------------------------------------------------
22 //--------------------------------------------------
23 EEeventDst::~EEeventDst()
24 {
25  delete Sec; Sec = 0;
26 }
27 
28 //--------------------------------------------------
29 //--------------------------------------------------
30 //--------------------------------------------------
31 int EEeventDst::getNSectors(){return Sec->GetEntries();}
32 
33 //--------------------------------------------------
34 //--------------------------------------------------
35 //--------------------------------------------------
36 void EEeventDst::clear(){ // only content of sectors, leave sectors
37  // printf("EEvent Dst-hits cleared in %d sectors\n",Sec->GetEntries());
38 
39  ID=-999;
40  type=kUnknown;
41  token=-2;
42  timeStamp=0;
43  Sec->Delete();
44 }
45 //--------------------------------------------------
46 //--------------------------------------------------
47 //--------------------------------------------------
48 void EEeventDst::Clear(const char*){ clear();}
49 
50 //-------------------------------------------------
51 //-------------------------------------------------
52 //-------------------------------------------------
53 void EEeventDst::print(int k){
54  LOG_INFO<<Form("Event ID=%d, type=%d token=%d nSect=%d time stamp= %d\n",ID,type,token,Sec->GetEntries(),timeStamp)<<endm;
55  int is;
56  for(is=0;is<Sec->GetEntriesFast();is++) {
57  EEsectorDst *sec=(EEsectorDst*)Sec->At(is);
58  sec->print(k-1);
59  }
60 
61 }
62 
63 
64 //-------------------------------------------------
65 //-------------------------------------------------
66 //-------------------------------------------------
67 EEsectorDst * EEeventDst::addSectorDst(int IDx) {
68  // To avoid calling the very time consuming operator new for each track,
69  // the standard but not well know C++ operator "new with placement"
70  // is called. If tracks[i] is 0, a new Track object will be created
71  // otherwise the previous Track[i] will be overwritten.
72 
73  TClonesArray &SEC1 = *Sec;
74  int nSec=SEC1.GetEntriesFast();
75  EEsectorDst *sec= new(SEC1[nSec]) EEsectorDst(IDx);;
76  sec->clear();
77  //printf("Dst-hits add sector %d Array \n",IDx);
78  //sec->print();
79 
80  return sec;
81 }
82 
83 //---------------------------------------------------
84 //---------------------------------------------------
85 //---------------------------------------------------
86 EEsectorDst* EEeventDst::getSec(int secID, int create){
87  int is;
88  //printf("EEeventDst::getSec(%d), nSec=%d\n",secID,Sec->GetEntries());
89  for(is=0;is<Sec->GetEntries();is++) {
90  EEsectorDst *sec=(EEsectorDst*)Sec->At(is);
91  if(sec->getID()==secID) return sec;
92  }
93  //printf("EEeventDst() : sector ID=%d not found\n",secID);
94  if(create==0) return 0;
95  return addSectorDst(secID);
96 }
97 
98 
99 //---------------------------------------------------
100 //---------------------------------------------------
101 //---------------------------------------------------
102 void EEeventDst:: sumRawMC(EEeventDst* eveOut,float minE) {
103  assert(eveOut);
104  eveOut->clear();
105  eveOut->ID=ID;
106  eveOut->type=kTrigMC;
107 
108  int is;
109  for(is=0;is<Sec->GetEntries();is++) {
110 
111  // access In & Out sectors with the same ID
112 
113  EEsectorDst *secIN=(EEsectorDst*)Sec->At(is);
114  int secID=secIN->getID();
115  EEsectorDst *secOut=eveOut->getSec(secID);
116  if(secOut==0) { // add new sector if needed
117  secOut= eveOut->addSectorDst(secID);
118  }
119 
120  secIN->sumRawMC(secOut,minE);
121  }
122 
123 }
124 
125 
126 // $Log: EEeventDst.cxx,v $
127 // Revision 1.9 2007/05/30 02:38:48 balewski
128 // replace printf -->LOG_XXX
129 //
130 // Revision 1.8 2004/04/08 21:34:17 perev
131 // Leak off
132 //
133 // Revision 1.7 2004/04/07 18:54:47 perev
134 // Cleanup delete in destructor added
135 //
136 // Revision 1.6 2003/11/12 19:59:06 balewski
137 // I forgot what has changed
138 //
139 // Revision 1.5 2003/10/02 20:52:45 balewski
140 // more functionality for print()
141 //
142 // Revision 1.4 2003/09/11 19:40:56 zolnie
143 // updates for gcc3.2
144 //
145 // Revision 1.3 2003/07/01 14:13:13 balewski
146 // no clue
147 //
148 // Revision 1.2 2003/02/21 22:21:47 balewski
149 // time stamp added
150 //
151 // Revision 1.1 2003/02/20 05:15:14 balewski
152 // reorganization
153 //
154 // Revision 1.1 2003/01/28 23:16:06 balewski
155 // start
156 //
157 // Revision 1.8 2002/11/30 20:03:15 balewski
158 // consistent with FeeRawTTree
159 //
160 // Revision 1.7 2002/11/12 20:08:29 balewski
161 // some cleanup
162 //
163 // Revision 1.6 2002/11/11 21:22:48 balewski
164 // EEMC added to StEvent
165 //
166 // Revision 1.5 2002/10/01 06:03:15 balewski
167 // added smd & pre2 to TTree, tof removed
168 //
169 // Revision 1.4 2002/09/26 14:48:28 balewski
170 // biger buffer
171 //
172 // Revision 1.3 2002/09/25 16:47:55 balewski
173 // cleanup , cut in geant time for twoer-like detectors
174 //
175 // Revision 1.2 2002/09/20 21:58:13 balewski
176 // sum of MC hits over activ detectors
177 // produce total tower energy with weight 1 1 1 1
178 //
179 // Revision 1.1.1.1 2002/09/19 18:58:54 zolnie
180 // Imported sources
181 //
182 // Revision 1.1.1.1 2002/08/29 19:32:01 zolnie
183 // imported sources
184 //
185 // Revision 1.2 2002/08/28 01:43:42 zolnie
186 // version alpha - 2
187 //
188 // Revision 1.1 2002/08/26 19:46:12 zolnie
189 // Initial revision
190 //
191