StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcTrigSimuMaker.cxx
1 //*-- Author : J.Balewski, R.Fatemi
2 //
3 // $Id: StEEmcTrigSimuMaker.cxx,v 1.8 2012/12/12 22:02:28 fisyak Exp $
4 // $Log: StEEmcTrigSimuMaker.cxx,v $
5 // Revision 1.8 2012/12/12 22:02:28 fisyak
6 // add sys/types.h include for APPLE
7 //
8 // Revision 1.7 2007/04/28 17:56:03 perev
9 // Redundant StChain.h removed
10 //
11 // Revision 1.6 2007/01/24 21:07:03 balewski
12 // 1) no cout or printf, only new Logger
13 // 2) EndcapMixer:
14 // - no assert()
15 // - locks out on first fatal error til the end of the job
16 //
17 // Revision 1.5 2003/09/02 17:57:55 perev
18 // gcc 3.2 updates + WarnOff
19 //
20 // Revision 1.4 2003/07/18 18:31:46 perev
21 // test for nonexistance of XXXReader added
22 //
23 // Revision 1.3 2003/04/30 20:36:37 perev
24 // Warnings cleanup. Modified lines marked VP
25 //
26 // Revision 1.2 2003/02/14 00:04:31 balewski
27 // remove few printouts
28 //
29 // Revision 1.1 2003/01/28 23:13:00 balewski
30 // star
31 //
32 
33 #ifdef __APPLE__
34 #include <sys/types.h>
35 #endif
36 #include <StMessMgr.h>
37 
38 #include "StEEmcTrigSimuMaker.h"
39 #include "St_DataSetIter.h"
40 
41 #include <Stiostream.h>
42 #include <math.h>
43 #include "TFile.h"
44 #include "TArrayF.h"
45 
46 #include "StMcEventMaker/StMcEventMaker.h"
47 #include "StMcEventTypes.hh"
48 #include "StEventTypes.h"
49 #include "StMcEvent.hh"
50 #include "StEvent.h"
51 
52 
53 ClassImp(StEEmcTrigSimuMaker)
54 StEEmcTrigSimuMaker::StEEmcTrigSimuMaker(const char *name):StMaker(name){
55  //
56 }
57 
58 
59 StEEmcTrigSimuMaker::~StEEmcTrigSimuMaker(){
60  //
61 }
62 
63 
64 //________________________________________________________
65 
66 Int_t StEEmcTrigSimuMaker::Init(){
67  // Create tables
68  // Create Histograms
69  return StMaker::Init();
70 }
71 
72 //____________________________________________________________
73 //____________________________________________________________
74 //____________________________________________________________
76 
77  StEvent* mEvent = (StEvent*)GetInputDS("StEvent");
78  assert(mEvent); // fix your chain
79  StEmcCollection* emcCollection = mEvent->emcCollection();
80  StEmcDetector* twB = emcCollection->detector(kBarrelEmcTowerId);
81 
82 
83  StEmcDetector* twE = emcCollection->detector(kEndcapEmcTowerId);
84  if(twE==0) {
85  LOG_WARN <<Form("%s found no E-EMC tower data in StEvent, skip event\n",GetName())<< endm;
86  return kStOK;
87  }
88 
89 
90  int i;
91 
92  if(twB) {
93  LOG_DEBUG<< Form(":: B_EMC Tower HITS ...\n");
94  for ( i = 1; i <= (int)twB->numberOfModules(); i++) { // The B-EMC modules
95  StSPtrVecEmcRawHit& emcTowerHits = twB->module(i)->hits();
96  uint j;
97  for ( j = 0; j < emcTowerHits.size(); j++) {
98  int adc= emcTowerHits[j]->adc();
99  int mod= emcTowerHits[j]->module();
100  int sub= emcTowerHits[j]->sub();
101  int eta= emcTowerHits[j]->eta();
102  float energy= emcTowerHits[j]->energy();
103  LOG_DEBUG<< Form("j=%d, mod=%d, sub=%d, eta=%d adc=%d ener=%f\n",j,mod,sub,eta,adc,energy);
104  }
105  }
106  LOG_DEBUG<<endm; // flush it now
107  }
108 
109  if(twE) {
110  LOG_DEBUG<< Form(":: E_EMC Tower HITS ... %d\n",twE->numberOfModules());
111  for ( i = 0; i < (int)twE->numberOfModules(); i++) { // The E-EMC modules
112  // printf("AAA %d\n",i);
113  StEmcModule* stmod = twE->module(i);
114  if(stmod==0) continue;
115  StSPtrVecEmcRawHit& emcTowerHits = stmod->hits();
116  uint j;
117  for ( j = 0; j < emcTowerHits.size(); j++) {
118  // printf("bbb=%d\n",j);
119  int adc= emcTowerHits[j]->adc();
120  int sec= emcTowerHits[j]->module()+1;
121  int sub= emcTowerHits[j]->sub()+'A';
122  int eta= emcTowerHits[j]->eta()+1;
123  float energy= emcTowerHits[j]->energy();
124  LOG_DEBUG<< Form("j=%d, sec=%d, sub=%c, eta=%d adc=%d ener=%f\n",j,sec,sub,eta,adc,energy);
125  }
126  }
127  LOG_DEBUG<<endm; // flush it now
128  }
129 
130  printE();
131 
132  return kStOK;
133 }
134 
135 
136 
137 //____________________________________________________________
138 //____________________________________________________________
139 //____________________________________________________________
141 
142  StEvent* mEvent = (StEvent*)GetInputDS("StEvent");
143  assert(mEvent); // fix your chain
144  StEmcCollection* emcC= mEvent->emcCollection();
145 
146  assert(emcC);
147  LOG_DEBUG<< Form("::printE() found EmcCollection\n")<<endm;
148  TString str1;
149  // aEEname[kEndcapEmcTowerId]="eeTower";
150  //aEEname[kEndcapEmcTowerId]="eeTower";
151 
152  for(int det = kEndcapEmcTowerId; det<= kEndcapSmdVStripId; det++){
153 
154  StDetectorId id = StDetectorId(det);
155  StEmcDetector* d = emcC->detector(id);
156  if(d==0) {
157  LOG_DEBUG<< Form("%s::printE() Found no sub-detector collection, skipping det=%d\n",GetName(),det)<<endm;
158  continue;
159  }
160 
161  str1=" i sec sub ieta energy ADC";
162  int nTot=0;
163  switch (det){
164  case kEndcapEmcTowerId:
165  LOG_DEBUG<< Form("Endcap Tower hits \n")<<endm; break;
166  case kEndcapEmcPreShowerId:
167  LOG_DEBUG<< Form("Endcap Preshower 1+2+post hits \n")<<endm; break;
168  case kEndcapSmdUStripId:
169  LOG_DEBUG<< Form("Endcap SMD-U hits \n")<<endm;
170  str1=" i sec strip energy ADC";
171  break;
172  case kEndcapSmdVStripId:
173  LOG_DEBUG<< Form("Endcap SMD-V hits \n")<<endm;
174  str1=" i sec strip energy ADC";
175  break;
176  default:
177  assert(1==2); // your event is corrupted
178  }
179 
180  if(d->numberOfModules() < 1) continue;
181 
182  LOG_DEBUG<< Form("%s\n",str1.Data())<<endm;
183 
184  for(unsigned int isec=0; isec<d->numberOfModules(); isec++){
185  int secID=isec+1;
186  StEmcModule* stmod = d->module(isec);
187  if(stmod==0) continue;
188 
189  StSPtrVecEmcRawHit & h = stmod->hits();
190  for(unsigned int j=0; j<h.size() ;j++){
191  nTot++;
192 
193  switch (det){
194  case kEndcapEmcTowerId:
195  case kEndcapEmcPreShowerId:
196  {
197  // printf("xxx secID=%d, id2=%d\n",secID,h[j]->module());
198  int sub='A'+h[j]->sub();
199  int keta=h[j]->eta()+1;
200  LOG_DEBUG<< Form("%3d %2.2d %c %2d %f %4d\n",nTot,secID,sub,keta,h[j]->energy(),h[j]->adc());
201  } break;
202  case kEndcapSmdUStripId:
203  case kEndcapSmdVStripId:
204  {
205  int strip=h[j]->eta()+1;
206  LOG_DEBUG<< Form("%3d %2.2d %3d %f %4d\n",nTot,secID,strip,h[j]->energy(),h[j]->adc());
207  } break;
208  default:
209  assert(1==2); // your event is corrupted
210  }// end of switch
211  }// loop over hits
212  LOG_DEBUG<<endm; // flush it now
213  }// loop over sectors==modules
214  }// looop over det
215 }
216 
217 
218 
219 
220 
221 
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:40
void printE()
Endcap hits in StEvent.