StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcPrint.cxx
1 //*-- Author : Wei-Ming Zhang
2 // $Id: StEEmcPrint.cxx,v 1.4 2012/12/12 22:05:30 fisyak Exp $
3 
4 #ifdef __APPLE__
5 #include <sys/types.h>
6 #endif
7 #include <iostream>
8 #include <StMessMgr.h>
9 
10 #include "StEEmcPrint.h"
11 #include "StEventTypes.h"
12 
13 ClassImp(StEEmcPrint);
15  mPrint = 15;
16 }
17 StEEmcPrint::~StEEmcPrint(){ }
18 
19 //______________________________________________________________________
20 //______________________________________________________________________
21 void
22 StEEmcPrint::print(StEmcCollection * emcCol) {
23  LOG_DEBUG << "mPrint = " << mPrint << endm;
24  int detBit[4] = {1, 2, 4, 8};
25  char uv = 'U';
26 
27  for(int iDet = kEndcapEmcTowerId; iDet<= kEndcapSmdVStripId; iDet++){
28  if(!(mPrint & detBit[iDet - kEndcapEmcTowerId])) continue;
29  if(iDet == kEndcapSmdVStripId) uv++;
30  if(iDet == kEndcapEmcTowerId) {
31  LOG_DEBUG << "EEmc Tower" << endm;
32  }
33  else if(iDet == kEndcapEmcPreShowerId) {
34  LOG_DEBUG << "EEmc Pre/Post" << endm;
35  }
36  else {
37  LOG_DEBUG << "EEmc SMD-" << uv << endm;
38  }
39 
40  StDetectorId detId = StDetectorId(iDet);
41  StEmcDetector* StEEmcDet = emcCol->detector(detId);
42 
43  if(StEEmcDet !=0) {
44  for(unsigned int sec = 1; sec <= StEEmcDet->numberOfModules(); sec++){
45  StEmcModule* StEEmcMod = StEEmcDet->module(sec);
46  LOG_DEBUG << "Sector = " << sec << endm;
47 
48  if(StEEmcMod != 0) {
49  StSPtrVecEmcRawHit & EEmcRawHits = StEEmcMod->hits();
50  LOG_DEBUG << "Number of Hits = " << EEmcRawHits.size() << endm;
51 
52  for(unsigned int i=0; i<EEmcRawHits.size() ;i++){
53  int sub = EEmcRawHits[i]->sub();
54  int eta = EEmcRawHits[i]->eta();
55  float e = EEmcRawHits[i]->energy();
56  int adc = EEmcRawHits[i]->adc();
57 
58  if(iDet == kEndcapEmcTowerId) {
59  LOG_DEBUG <<Form("i=%d Tower %2.2dT%c%2.2d: energy=%f adc=%d",i,sec,sub+'A'-1,eta,e,adc )<< endm;
60  }
61  else if(iDet == kEndcapEmcPreShowerId) {
62  int psub = (sub%5 == 0) ? 5:sub%5;
63  int pre = (sub-1)/5 + 1;
64  LOG_DEBUG <<Form("i=%d pre/post(%d) %2.2d%c%c%2.2d : energy=%f adc=%d",i,pre,sec,pre+'P'-1,psub+'A'-1,eta,e,adc)<< endm;
65  }
66  else {
67  LOG_DEBUG <<Form("SMD-%c %2.2d%c%3.3d : energy=%f adc=%d",uv,sec,uv,eta,e,adc)<< endm;
68  }
69  }
70  }
71  }
72  }
73  }
74 
75 }
76 
77 
78 //______________________________________________________________________
79 //______________________________________________________________________
80 void
81 StEEmcPrint::printChange(StEmcCollection * emcCol,StEmcCollection * emcColB,char *comm){
82  //For towers & ecolB zero ADC values are assumed to not match to ecolA
83 
84  LOG_DEBUG << comm<<" mPrint mode= " << mPrint << endm;
85  int detBit[4] = {1, 2, 4, 8};
86  char uv = 'U';
87 
88  for(int iDet = kEndcapEmcTowerId; iDet<= kEndcapSmdVStripId; iDet++){
89  if(!(mPrint & detBit[iDet - kEndcapEmcTowerId])) continue;
90  if(iDet == kEndcapSmdVStripId) uv++;
91  if(iDet == kEndcapEmcTowerId) {
92  LOG_DEBUG << "EEmc Tower" << endm;
93  }
94  else if(iDet == kEndcapEmcPreShowerId) {
95  LOG_DEBUG << "EEmc Pre/Post" << endm;
96  }
97  else {
98  LOG_DEBUG << "EEmc SMD-" << uv << endm;
99  }
100 
101  StDetectorId detId = StDetectorId(iDet);
102  StEmcDetector* StEEmcDet = emcCol->detector(detId);
103  StEmcDetector* StEEmcDetB = emcColB->detector(detId);
104 
105  if(StEEmcDet ==0) continue;
106  if(StEEmcDetB==0) {
107  LOG_DEBUG << " colB has no data for above sub-detector"<<endm;
108  continue;
109  }
110 
111  for(unsigned int sec = 1; sec <= StEEmcDet->numberOfModules(); sec++){
112  StEmcModule* StEEmcMod = StEEmcDet->module(sec);
113  if(StEEmcMod == 0) continue;
114 
115  StEmcModule* StEEmcModB = StEEmcDetB->module(sec);
116  LOG_DEBUG << "Sector = " << sec <<endm ;
117 
118  assert(StEEmcModB);//tmp
119 
120  StSPtrVecEmcRawHit & EEmcRawHits = StEEmcMod->hits();
121  StSPtrVecEmcRawHit & EEmcRawHitsB = StEEmcModB->hits();
122  LOG_DEBUG << " Number of HitsA = " << EEmcRawHits.size() << ", HitsB="<<EEmcRawHitsB.size()<<endm;
123 
124  for(unsigned int i=0; i<EEmcRawHits.size() ;i++){
125  int sub = EEmcRawHits[i]->sub();
126  uint eta = EEmcRawHits[i]->eta();
127  float e = EEmcRawHits[i]->energy();
128  int adc = EEmcRawHits[i]->adc();
129 
130  int adcB=-99999;
131  bool match=false;
132  for(unsigned int j=0; j<EEmcRawHitsB.size() ;j++){
133  if(sub != EEmcRawHitsB[j]->sub()) continue;
134  if(eta != EEmcRawHitsB[j]->eta()) continue;
135  adcB= EEmcRawHitsB[j]->adc();
136  if(iDet == kEndcapEmcTowerId && adcB==0) continue;
137  match=true;
138  break;
139  }
140 
141  if(!match) continue;
142 
143  if(iDet == kEndcapEmcTowerId) {
144  LOG_DEBUG << Form("\ti=%d ecolA: Tower %2.2dT%c%2.2d: energy=%f adc=%d <--> %d=adc old in ecolB",i,sec,sub+'A'-1,eta,e,adc, adcB)<<endm;
145  } else if(iDet == kEndcapEmcPreShowerId) {
146  int psub = (sub%5 == 0) ? 5:sub%5;
147  int pre = (sub-1)/5 + 1;
148  LOG_DEBUG << Form("\ti=%d ecolA: pre/post(%d) %2.2d%c%c%2.2d : energy=%f adc=%d<--> %d=adc old in ecolB",i,pre,sec,pre+'P'-1,psub+'A'-1,eta,e,adc,adcB)<<endm;
149  }
150  else {
151  LOG_DEBUG << Form("\tSMD-%c %2.2d%c%3.3d : energy=%f adc=%d <--> %d=adc old in ecolB",uv,sec,uv,eta,e,adc, adcB)<<endm;
152  }
153  }
154  }
155  }
156 }
157 
StEEmcPrint()
print mode
Definition: StEEmcPrint.cxx:14