12#include "GaudiKernel/AlgFactory.h"
13#include "GaudiKernel/DataObject.h"
14#include "GaudiKernel/IEventProcessor.h"
16#include "GaudiKernel/Incident.h"
17#include "GaudiKernel/IIncidentSvc.h"
18#include "GaudiKernel/Memory.h"
23#include "GaudiKernel/ISvcLocator.h"
24#include "GaudiKernel/IDataProviderSvc.h"
25#include "GaudiKernel/Bootstrap.h"
26#include "GaudiKernel/RegistryEntry.h"
27#include "GaudiKernel/MsgStream.h"
36#include "GaudiKernel/SmartDataPtr.h"
43 Algorithm(name,pSvcLocator){
45 declareProperty(
"LUTfile", lutfile =
"/bes3fs/cgemCosmic/data/CGEM_cosmic_look_up_table_from_17_to_17.root");
46 declareProperty(
"TimeMin", timemin = -8900);
47 declareProperty(
"TimeMax", timemax = -8500);
60 MsgStream log(
msgSvc(), name());
61 log << MSG::INFO <<
"TestHit initialize()" << endreq;
66 sc = service(
"CgemGeomSvc", m_geoSvc);
67 if(sc != StatusCode::SUCCESS) {
68 log << MSG::ERROR <<
"can not use CgemGeomSvc" << endreq;
69 return StatusCode::FAILURE;
74 output =
new TFile(
"hit.root",
"RECREATE");
75 tree =
new TTree(
"tree",
"hit info tree");
76 tree->Branch(
"event", &event,
"event/I");
77 tree->Branch(
"nhit", &nhit,
"nhit/I");
78 tree->Branch(
"nhit_L1_S1_x", &nhit_L1_S1_x,
"nhit_L1_S1_x/I");
79 tree->Branch(
"nhit_L2_S1_x", &nhit_L2_S1_x,
"nhit_L2_S1_x/I");
80 tree->Branch(
"nhit_L2_S2_x", &nhit_L2_S2_x,
"nhit_L2_S2_x/I");
81 tree->Branch(
"nhit_L1_S1_v", &nhit_L1_S1_v,
"nhit_L1_S1_v/I");
82 tree->Branch(
"nhit_L2_S1_v", &nhit_L2_S1_v,
"nhit_L2_S1_v/I");
83 tree->Branch(
"nhit_L2_S2_v", &nhit_L2_S2_v,
"nhit_L2_S2_v/I");
85 tree->Branch(
"ntwin_L1_S1_x", &ntwin_L1_S1_x,
"ntwin_L1_S1_x/I");
86 tree->Branch(
"ntwin_L2_S1_x", &ntwin_L2_S1_x,
"ntwin_L2_S1_x/I");
87 tree->Branch(
"ntwin_L2_S2_x", &ntwin_L2_S2_x,
"ntwin_L2_S2_x/I");
88 tree->Branch(
"ntwin_L1_S1_v", &ntwin_L1_S1_v,
"ntwin_L1_S1_v/I");
89 tree->Branch(
"ntwin_L2_S1_v", &ntwin_L2_S1_v,
"ntwin_L2_S1_v/I");
90 tree->Branch(
"ntwin_L2_S2_v", &ntwin_L2_S2_v,
"ntwin_L2_S2_v/I");
92 tree->Branch(
"hit_strip", &hit_strip,
"hit_strip[nhit]/I");
93 tree->Branch(
"hit_view", &hit_view,
"hit_view[nhit]/I");
94 tree->Branch(
"hit_layer", &hit_layer,
"hit_layer[nhit]/I");
95 tree->Branch(
"hit_sheet", &hit_sheet,
"hit_sheet[nhit]/I");
96 tree->Branch(
"hit_length", &hit_length,
"hit_length[nhit]/D");
98 tree->Branch(
"hit_channel", &hit_channel,
"hit_channel[nhit]/I");
99 tree->Branch(
"hit_roc", &hit_roc,
"hit_roc[nhit]/I");
100 tree->Branch(
"hit_feb", &hit_feb,
"hit_feb[nhit]/I");
101 tree->Branch(
"hit_tiger", &hit_tiger,
"hit_tiger[nhit]/I");
102 tree->Branch(
"hit_chip", &hit_chip,
"hit_chip[nhit]/I");
104 tree->Branch(
"hit_t", &hit_t,
"hit_t[nhit]/D");
105 tree->Branch(
"hit_q", &hit_q,
"hit_q[nhit]/D");
106 tree->Branch(
"hit_saturated", &hit_saturated,
"hit_saturated[nhit]/I");
107 tree->Branch(
"hit_quality", &hit_quality,
"hit_quality[nhit]/I");
113 return StatusCode::SUCCESS;
134 for(
int ihit = 0; ihit <
MAXNOFHIT; ihit++) {
135 hit_strip[ihit] = -1;
137 hit_layer[ihit] = -1;
138 hit_sheet[ihit] = -1;
139 hit_length[ihit] = 0.;
141 hit_channel[ihit] = -1;
144 hit_tiger[ihit] = -1;
146 hit_quality[ihit] = -1;
150 hit_saturated[ihit] = 0;
157 MsgStream log(
msgSvc(), name());
161 ISvcLocator* svcLocator = Gaudi::svcLocator();
162 StatusCode sc=svcLocator->service(
"EventDataSvc", m_evtSvc);
164 cout<<
"Could not accesss EventDataSvc!"<<endl;
185 SmartDataPtr<CgemDigiCol> aDigiCol(m_evtSvc,
"/Event/Digi/CgemDigiCol");
187 cout<<
"Could not retrieve CGEM digi collection"<<endl;
189 nhit = aDigiCol->size();
190 CgemDigiCol::iterator iDigiCol;
196 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
198 const Identifier ident = (*iDigiCol)->identify();
205 if(is_xstrip ==
true) view = 0;
206 double charge = (*iDigiCol)->getCharge_fc();
207 double time = (*iDigiCol)->getTime_ns();
209 hit_strip[ihit] = strip;
210 hit_layer[ihit] = layer;
211 hit_sheet[ihit] = sheet;
212 hit_view[ihit] = view;
216 else hit_length[ihit] = anode->
getLength();
218 hit_channel[ihit] = lutreader->
GetChannel(layer, sheet, view, strip);
219 hit_roc[ihit] = lutreader->
GetROC(layer, sheet, view, strip);
220 hit_feb[ihit] = lutreader->
GetFEB(layer, sheet, view, strip);
221 hit_tiger[ihit] = lutreader->
GetTIGER(layer, sheet, view, strip);
222 hit_chip[ihit] = lutreader->
GetChip(layer, sheet, view, strip);
223 hit_quality[ihit] = lutreader->
GetQuality(layer, sheet, view, strip);
228 hit_q[ihit] = charge;
229 hit_saturated[ihit] = 0;
231 if(is_xstrip ==
true) {
232 if(layer==0 && sheet==0) nhit_L1_S1_x++;
233 else if(layer==1 && sheet==0) nhit_L2_S1_x++;
234 else if(layer==1 && sheet==1) nhit_L2_S2_x++;
237 if(layer==0 && sheet==0) nhit_L1_S1_v++;
238 else if(layer==1 && sheet==0) nhit_L2_S1_v++;
239 else if(layer==1 && sheet==1) nhit_L2_S2_v++;
243 if(
time > timemin &&
time < timemax) {
244 if(is_xstrip ==
true) {
245 if(layer==0 && sheet==0) ntwin_L1_S1_x++;
246 else if(layer==1 && sheet==0) ntwin_L2_S1_x++;
247 else if(layer==1 && sheet==1) ntwin_L2_S2_x++;
250 if(layer==0 && sheet==0) ntwin_L1_S1_v++;
251 else if(layer==1 && sheet==0) ntwin_L2_S1_v++;
252 else if(layer==1 && sheet==1) ntwin_L2_S2_v++;
262 return StatusCode::SUCCESS;
267 MsgStream log(
msgSvc(),name());
268 log << MSG::INFO <<
"TestHit finalize()" << endreq;
272 return StatusCode::SUCCESS;
double getVStripLength(int V_ID) const
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static int layer(const Identifier &id)
static bool is_xstrip(const Identifier &id)
int GetChip(int ilayer, int isheet, int iview, int istrip)
int GetQuality(int ilayer, int isheet, int iview, int istrip)
int GetROC(int ilayer, int isheet, int iview, int istrip)
int GetChannel(int ilayer, int isheet, int iview, int istrip)
int GetTIGER(int ilayer, int isheet, int iview, int istrip)
int GetFEB(int ilayer, int isheet, int iview, int istrip)
virtual CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const =0
TestHit(const std::string &name, ISvcLocator *pSvcLocator)