CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
ReadCosmicRayData-00-00-23/src/ReadCosmicRayData.cxx
Go to the documentation of this file.
1/**************************************************************************
2 * CgemBOSS (BESIII Offline Software System) *
3 * *
4 * Author: The BESII Collaboration *
5 * Contributors: Aiqiang Guo, Liangliang Wang, Lia Lavezzi *
6 * Date: Dec 10 2018 *
7 * *
8 **************************************************************************/
9/**************************************************************************
10 * Note for 01
11 * Change the reading method for vectorized data
12 * By: Aiqiang Guo
13 * Date: Dec 17 2018
14 **************************************************************************/
15/**************************************************************************
16 * Note for 02
17 * Add CC and mTPC for cluster object
18 * By: Aiqiang Guo
19 * Date: Dec 27 2018
20 **************************************************************************/
21
22// include system lib
23#include <iostream>
24#include <iomanip>
25#include <string>
26#include <cmath>
27
28// Include files
29#include "GaudiKernel/AlgFactory.h"
30#include "GaudiKernel/DataObject.h"
31#include "GaudiKernel/IEventProcessor.h"
32
33#include "GaudiKernel/Incident.h"
34#include "GaudiKernel/IIncidentSvc.h"
35#include "GaudiKernel/Memory.h"
36
37#include <csignal>
38
39// for save digit & cluster
40#include "GaudiKernel/ISvcLocator.h"
41#include "GaudiKernel/IDataProviderSvc.h"
42#include "GaudiKernel/Bootstrap.h"
43#include "GaudiKernel/RegistryEntry.h"
44#include "GaudiKernel/MsgStream.h"
45
46#include "CgemRawEvent/CgemDigi.h"
47#include "CgemRecEvent/RecCgemCluster.h"
48
49#include "Identifier/CgemID.h"
50
51#include "RawEvent/RawDataUtil.h"
52#include "RawEvent/DigiEvent.h"
53#include "ReconEvent/ReconEvent.h"
54#include "EventModel/EventHeader.h"
55#include "GaudiKernel/SmartDataPtr.h"
56
57#include "ReadCosmicRayData/ReadCosmicRayData.h"
58
59//using namespace std;
60ReadCosmicRayData::ReadCosmicRayData(const std::string& name, ISvcLocator* pSvcLocator):
61 Algorithm(name,pSvcLocator){
62
63 declareProperty("Dir_file", Dir_file = "input_file.txt");
64 declareProperty("TreeDigi", TreeDigi = "t1");
65 declareProperty("TreeCluster", TreeCluster = "t1");
66 declareProperty("ReadDigi", ReadDigi = true);
67 declareProperty("ReadCluster", ReadCluster = true);
68 declareProperty("DigiSheetID", DigiSheetID = 0);
69 declareProperty("Cut_on_tpc", Cut_on_tpc = false);
70 declareProperty("ClusterSheetID", ClusterSheetID = 0);
71 declareProperty("ClusterRecZ", ClusterRecZ = 0);
72 declareProperty("R_Cluster", R_Cluster = 1.0);
73 declareProperty("Shift_DigitLayerID", Shift_DigitLayerID = 0);
74 declareProperty("Shift_DigitSheetID", Shift_DigitSheetID = 0);
75 declareProperty("Shift_DigitXStripID", Shift_DigitXStripID = 0);
76 declareProperty("Shift_DigitVStripID", Shift_DigitVStripID = 0);
77 declareProperty("Shift_ClusterLayerID", Shift_ClusterLayerID = 0);
78 declareProperty("Shift_ClusterSheetID", Shift_ClusterSheetID = 0);
79 declareProperty("Shift_RecPhi", Shift_RecPhi = 0);
80 declareProperty("Shift_RecV", Shift_RecV = 0);
81 declareProperty("Shift_RecZ", Shift_RecZ = 0);
82 declareProperty("CosmicRayDataSetID", CosmicRayDataSetID = "CR201909");
83 declareProperty("runNo", m_runNo = 1);
84
85 // mapper = new StripMapper(CosmicRayDataSetID);
86}
87
89}
90
92 MsgStream log(msgSvc(), name());
93 log << MSG::INFO << "ReadCosmicRayData initialize()" << endreq;
94
95 // bool ismap = mapper->FillMap();
96
97 TString TDir_file(Dir_file);
98 if(ReadDigi)
99 {
100 TString TTreeDigi(TreeDigi);
101 Tdigi = new TChain(TTreeDigi);
102 TFileCollection* fc = new TFileCollection("mylist", "mylist",TDir_file);
103 Tdigi->AddFileInfoList((TCollection*)fc->GetList());
104
105 // Get Cgem digi tree
106 Tdigi->SetBranchAddress("Event", &m_Event_D); // event ID
107 Tdigi->SetBranchAddress("nGemHit", &m_nGemHit); // nof GEM hits
108 // Tdigi->SetBranchAddress("GemHit_nHit", &m_nGemHit); // nof GEM hits it is the same thing as before
109
110 // information on the IDs
111 Tdigi->SetBranchAddress("GemHit_channel", m_channel); // channel no. [0, 63]
112 Tdigi->SetBranchAddress("GemHit_ROC", m_ROC); // ROC no.
113 Tdigi->SetBranchAddress("GemHit_chip", m_chip); // chip no.
114 Tdigi->SetBranchAddress("GemHit_FEB", m_FEB); // FEB no.
115 Tdigi->SetBranchAddress("GemHit_plane", m_plane); // plane
116 Tdigi->SetBranchAddress("GemHit_sheet", m_sheet); // sheet
117 Tdigi->SetBranchAddress("GemHit_view", m_view); // view (axial or stereo strips)
118 Tdigi->SetBranchAddress("GemHit_strip", m_strip); // strip no.
119
120 // physical information
121 Tdigi->SetBranchAddress("GemHit_saturated", m_saturated); // is the ASIC channel saturated
122 Tdigi->SetBranchAddress("GemHit_q", m_charge); // charge (fC)
123 Tdigi->SetBranchAddress("GemHit_time", m_time); // time (ns)
124 // Tdigi->SetBranchAddress("GemHit_is_tpc", m_GemHit_is_tpc);
125
126 No_Entries_D = Tdigi->GetEntries();
127 cout<<"total Entry is "<<No_Entries_D<<endl;
128 Ind_Entry_D = 0;
129 }
130
131 /**
132 if(ReadCluster)
133 {
134 //Get Cgem cluster tree
135 TString TTreeCluster(TreeCluster);
136 Tcluster = (TTree*)f->Get(TTreeCluster);
137
138 Tcluster->SetBranchAddress("Event", &m_Event_C);
139 Tcluster->SetBranchAddress("GemCluster1d_nCluster", &m_nGemCluster);
140 Tcluster->SetBranchAddress("GemCluster1d_nHit", m_ClusternHit);
141 Tcluster->SetBranchAddress("GemCluster1d_HitIndex", m_ClusterHitIndex);
142 Tcluster->SetBranchAddress("GemCluster1d_plane", m_ClusterLayerID);
143 Tcluster->SetBranchAddress("GemCluster1d_view", m_Flag);
144 Tcluster->SetBranchAddress("GemCluster1d_q", m_EnergyDeposit);
145 Tcluster->SetBranchAddress("GemCluster1d_x", m_Cluster_x);
146 Tcluster->SetBranchAddress("GemCluster1d_z", m_Cluster_z);
147 Tcluster->SetBranchAddress("GemCluster1d_x_cc", m_Cluster_x_cc);
148 Tcluster->SetBranchAddress("GemCluster1d_x_tpc", m_Cluster_x_tpc);
149 Tcluster->SetBranchAddress("GemCluster1d_z_cc", m_Cluster_z_cc);
150 Tcluster->SetBranchAddress("GemCluster1d_z_tpc", m_Cluster_z_tpc);
151 //Tcluster->SetBranchAddress("ClusterSheetID", m_ClusterSheetID);
152 //Tcluster->SetBranchAddress("ClusterFlagB", m_ClusterFlagB);
153 //Tcluster->SetBranchAddress("ClusterFlagE", m_ClusterFlagE);
154 //Tcluster->SetBranchAddress("RecV", m_RecV);
155 //Tcluster->SetBranchAddress("RecZ", m_RecZ);
156
157 No_Entries_C = Tcluster->GetEntries();
158 Ind_Entry_C = 0;
159 }
160 **/
161
162 return StatusCode::SUCCESS;
163}
164
165
166int ReadCosmicRayData::TranslateDigitLayerID(int Input_LayerID)
167{
168 int ShiftValue = Shift_DigitLayerID;
169 return Input_LayerID+ShiftValue;
170}
171
172int ReadCosmicRayData::TranslateDigitSheetID(int Input_SheetID)
173{
174 int ShiftValue = Shift_DigitSheetID;
175 return Input_SheetID+ShiftValue;
176}
177
178int ReadCosmicRayData::TranslateDigitXStripID(int Input_StripID)
179{
180 int ShiftValue = Shift_DigitXStripID;
181 return Input_StripID+ShiftValue;
182}
183
184int ReadCosmicRayData::TranslateDigitVStripID(int Input_StripID)
185{
186 int ShiftValue = Shift_DigitVStripID;
187 return Input_StripID+ShiftValue;
188}
189
190int ReadCosmicRayData::TranslateDigitStripID(int Input_StripID, int StripType)
191{
192 int Output_StripID = -1;
193 if(StripType==0) Output_StripID = TranslateDigitXStripID(Input_StripID);
194 if(StripType==1) Output_StripID = TranslateDigitVStripID(Input_StripID);
195 return Output_StripID;
196}
197
198int ReadCosmicRayData::TranslateDigitStripType(int Input_StripType)
199{
200 return Input_StripType;
201}
202
203int ReadCosmicRayData::TranslateClusterLayerID(int Input_LayerID)
204{
205 int ShiftValue = Shift_ClusterLayerID;
206 return Input_LayerID+ShiftValue;
207}
208
209int ReadCosmicRayData::TranslateClusterSheetID(int Input_SheetID)
210{
211 int ShiftValue = Shift_ClusterSheetID;
212 return Input_SheetID+ShiftValue;
213}
214
215int ReadCosmicRayData::TranslateClusterFlag(int Input_Flag)
216{
217 return Input_Flag-2;
218}
219
220double ReadCosmicRayData::TranslateRecPhi(double Input_RecPhi)
221{
222 double ShiftValue = Shift_RecPhi;
223 return Input_RecPhi+ShiftValue;
224}
225
226double ReadCosmicRayData::TranslateRecV(double Input_RecV)
227{
228 double ShiftValue = Shift_RecV;
229 return Input_RecV+ShiftValue;
230}
231
232double ReadCosmicRayData::TranslateRecZ(double Input_RecZ)
233{
234 double ShiftValue = Shift_RecZ;
235 return Input_RecZ+ShiftValue;
236}
237
238void ReadCosmicRayData::ReadCgemDigits()
239{
240 //cout<<"Start to read the CgemDigits"<<endl;
241 Tdigi->GetEntry(Ind_Entry_D);
242 Ind_Entry_D++;
243}
244
245void ReadCosmicRayData::ReadCgemClusters()
246{
247 //cout<<"Start to read the CgemClusters"<<endl;
248 Tcluster->GetEntry(Ind_Entry_C);
249 Ind_Entry_C++;
250}
251
252bool ReadCosmicRayData::ConvertHitToDigi(int ihit, unsigned int &charge_channel, unsigned int &time_channel)
253{
254
255 if(CosmicRayDataSetID == "CR201909") {
256 // cout << "ReadCosmicRayData::ConvertGRAALToCgemBoss(), converting set " << CosmicRayDataSetID << endl;
257
258 // if(!m_GemHit_is_tpc[i]&&Cut_on_tpc) return false; // ??
259 charge_channel = 1;
260 time_channel = 1;
261
262 // from plane to LayerID
263 if(m_plane[ihit] == 0) m_LayerID[ihit] = 0; // LAYER1
264 else if(m_plane[ihit] == 1) m_LayerID[ihit] = 1; // LAYER2
265 else if(m_plane[ihit] == 2) m_LayerID[ihit] = 1; // LAYER2
266 else {
267 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown plane "<<m_plane[ihit]<<endl;
268 return false;
269 }
270
271 // from view to StripType
272 if(m_view[ihit] == 2) m_StripType[ihit] = 0; // x strip (phi)
273 else if(m_view[ihit] == 3) m_StripType[ihit] = 1; // v strip (stereo)
274 else {
275 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown view "<<m_view[ihit]<<endl;
276 return false;
277 }
278
279 //cout<<"layer "<<m_LayerID[ihit]<<", StripType "<<m_StripType[ihit]<<", original strip id: "<< m_strip[ihit]<<endl;
280 // sheet ID/strip ID
281 if(m_LayerID[ihit] == 0) { // LAYER 1
282 m_SheetID[ihit] = 0; // LAYER 1
283 m_StripID[ihit] = m_strip[ihit]-1;// strip ID starts from 0
284 if(m_StripType[ihit] == 0 && (m_StripID[ihit]<0||m_StripID[ihit]>=CgemID::getXSTRIP_MAX(m_LayerID[ihit]))) cout<<"ReadCosmicRayData::ConvertHitToDigi: X-strip ID out of range on layer1, sheet "<<m_SheetID[ihit]<<" : "<<m_StripID[ihit]<<endl;
285 if(m_StripType[ihit] == 1 && (m_StripID[ihit]<0||m_StripID[ihit]>=CgemID::getVSTRIP_MAX(m_LayerID[ihit]))) cout<<"ReadCosmicRayData::ConvertHitToDigi: V-strip ID out of range on layer1, sheet "<<m_SheetID[ihit]<<" : "<<m_StripID[ihit]<<endl;
286 }
287 if(m_LayerID[ihit] == 1) { // LAYER 2
288 m_SheetID[ihit] = 0;
289 if(m_StripType[ihit] == 0) // X strip
290 {
291
292 // sheet down --> sheet 1
293 if(m_strip[ihit] > CgemID::getXSTRIP_MAX(m_LayerID[ihit]))
294 {
295 m_SheetID[ihit] = 0;
296 m_StripID[ihit] = 2*CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];// strip ID starts from 0
297 }
298 else {
299 // sheet up --> sheet 2
300 m_StripID[ihit] = CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
301 m_SheetID[ihit] = 1;
302 }
303 if(m_StripID[ihit]<0||m_StripID[ihit]>=CgemID::getXSTRIP_MAX(m_LayerID[ihit])) cout<<"ReadCosmicRayData::ConvertHitToDigi: X-strip ID out of range on layer2, sheet "<<m_SheetID[ihit]<<" : "<<m_StripID[ihit]<<endl;
304 }
305 else if(m_StripType[ihit] == 1)// V strip with correction for the wrong mapping at strip 538 and 1617 in integration
306 {
307 if(m_strip[ihit] == 539 || m_strip[ihit] == 1617) {
308 cout<<"ReadCosmicRayData::ConvertHitToDigi: unexpated firing strip"<<m_strip[ihit]<<endl;
309 return false;
310 }
311 else if(m_strip[ihit] < 539) {
312 // sheet up --> sheet 2
313 m_StripID[ihit] = CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
314 m_SheetID[ihit] = 1;
315 }
316 else if(m_strip[ihit] < CgemID::getVSTRIP_MAX(m_LayerID[ihit]) + 2) {
317 // sheet up --> sheet 2
318 m_StripID[ihit] = CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit] + 1;
319 m_SheetID[ihit] = 1;
320 }
321 else if(m_strip[ihit] < 1617) {
322 // sheet down --> sheet 1
323 m_StripID[ihit] = 2*CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit] + 1;
324 m_SheetID[ihit] = 0;
325 }
326 else {
327 // sheet down --> sheet 1
328 m_StripID[ihit] = 2*CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit] + 2;
329 m_SheetID[ihit] = 0;
330 }
331 if(m_StripID[ihit]<0||m_StripID[ihit]>=CgemID::getVSTRIP_MAX(m_LayerID[ihit])) cout<<"ReadCosmicRayData::ConvertHitToDigi: V-strip ID out of range on layer2, sheet "<<m_SheetID[ihit]<<" : "<<m_StripID[ihit]<<endl;
332 }
333 }
334 return true;
335 }
336 else if(CosmicRayDataSetID == "CR202001") {
337 // cout << "ReadCosmicRayData::ConvertGRAALToCgemBoss(), converting set " << CosmicRayDataSetID << endl;
338
339 // if(!m_GemHit_is_tpc[i]&&Cut_on_tpc) return false; // ??
340 charge_channel = 1;
341 time_channel = 1;
342
343 // from plane to LayerID
344 if(m_plane[ihit] == 0) m_LayerID[ihit] = 0; // LAYER1
345 else if(m_plane[ihit] == 1) m_LayerID[ihit] = 1; // LAYER2
346 else if(m_plane[ihit] == 2) m_LayerID[ihit] = 1; // LAYER2
347 else {
348 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown plane "<<m_plane[ihit]<<endl;
349 return false;
350 }
351
352 // from view to StripType
353 if(m_view[ihit] == 2) m_StripType[ihit] = 0; // x strip (phi)
354 else if(m_view[ihit] == 3) m_StripType[ihit] = 1; // v strip (stereo)
355 else {
356 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown view "<<m_view[ihit]<<endl;
357 return false;
358 }
359
360 if(m_strip[ihit] < 0) return false;
361
362 // sheet ID/strip ID
363 m_SheetID[ihit] = 0;
364
365 if(m_StripType[ihit] == 0) // X strip
366 {
367 if(m_LayerID[ihit] == 0) { // LAYER 1
368 m_StripID[ihit] = CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
369 m_SheetID[ihit] = 0;
370 }
371 else if(m_LayerID[ihit] == 1) { // LAYER 2
372 // sheet down --> sheet 1
373 if(m_strip[ihit] > CgemID::getXSTRIP_MAX(m_LayerID[ihit]))
374 {
375 m_SheetID[ihit] = 0;
376 m_StripID[ihit] = 2*CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];// strip ID starts from 0
377 }
378 else {
379 // sheet up --> sheet 2
380 m_StripID[ihit] = CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
381 m_SheetID[ihit] = 1;
382 }
383 }
384 if(m_StripID[ihit]<0||m_StripID[ihit]>=CgemID::getXSTRIP_MAX(m_LayerID[ihit])) cout<<"ReadCosmicRayData::ConvertHitToDigi: X-strip ID out of range on layer2, sheet "<<m_SheetID[ihit]<<" : "<<m_StripID[ihit]<<endl;
385 }
386 else if(m_StripType[ihit] == 1)// V strip with correction for the wrong mapping at strip 538 and 1617 in integration
387 {
388 if(m_LayerID[ihit] == 0) { // LAYER 1
389 m_StripID[ihit] = CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
390 m_SheetID[ihit] = 0;
391 }
392 else if(m_LayerID[ihit] == 1) { // LAYER 2
393 // sheet down --> sheet 1
394 if(m_strip[ihit] > CgemID::getVSTRIP_MAX(m_LayerID[ihit]))
395 {
396 m_SheetID[ihit] = 0;
397 m_StripID[ihit] = 2*CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];// strip ID starts from 0
398 }
399 else {
400 // sheet up --> sheet 2
401 m_StripID[ihit] = CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
402 m_SheetID[ihit] = 1;
403 }
404 }
405 if(m_StripID[ihit]<0||m_StripID[ihit]>=CgemID::getVSTRIP_MAX(m_LayerID[ihit])) cout<<"ReadCosmicRayData::ConvertHitToDigi: V-strip ID out of range on layer2, sheet "<<m_SheetID[ihit]<<" : "<<m_StripID[ihit]<<endl;
406 }
407
408 // cout << "GRAAL " << m_strip[ihit] << " view " << m_view[ihit] << " plane " << m_plane[ihit] << endl;
409 // cout << "CGEMB " << m_StripID[ihit] << " view " << m_StripType[ihit] << " plane " << m_LayerID[ihit] << " sheet " << m_SheetID[ihit] << endl;
410
411
412 return true;
413 }
414 else if(CosmicRayDataSetID == "NEW202001") {
415
416 charge_channel = 1;
417 time_channel = 1;
418
419 // from plane to LayerID
420 if(m_plane[ihit] != 0 && m_plane[ihit] != 1) {
421 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown plane "<<m_plane[ihit]<<endl;
422 return false;
423 }
424 else m_LayerID[ihit] = m_plane[ihit] ;
425
426 // from view to StripType
427 if(m_view[ihit] == 2) m_StripType[ihit] = 0; // x strip (phi)
428 else if(m_view[ihit] == 3) m_StripType[ihit] = 1; // v strip (stereo)
429 else {
430 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown view "<<m_view[ihit]<<endl;
431 return false;
432 }
433
434 if(m_strip[ihit] < 0) return false;
435
436 // sheet
437 m_SheetID[ihit] = m_sheet[ihit] ;
438
439 // strip
440 m_StripID[ihit] = m_strip[ihit];
441
442 // some checks
443 if(m_StripType[ihit] == 0 && m_StripID[ihit] > CgemID::getXSTRIP_MAX(m_LayerID[ihit])) {
444 cout<<"ReadCosmicRayData::ConvertHitToDigi: X-strip ID out of range on layer " << m_LayerID[ihit] << ", sheet " << m_SheetID[ihit] << ": " << m_StripID[ihit] << endl;
445 }
446 else if(m_StripType[ihit] == 1 && m_StripID[ihit] > CgemID::getVSTRIP_MAX(m_LayerID[ihit])) {
447 cout<<"ReadCosmicRayData::ConvertHitToDigi: V-strip ID out of range on layer " << m_LayerID[ihit] << ", sheet " << m_SheetID[ihit] << ": " << m_StripID[ihit] << endl;
448 }
449
450 return true;
451 }
452
453
454 cout << "ERROR : ReadCosmicRayData::ConvertGRAALToCgemBoss(), the data set " << CosmicRayDataSetID << " is unknown! " << endl;
455 return false;
456
457}
458
459void ReadCosmicRayData::SaveCgemDigits()
460{
461
462 bool printFlag=false;
463 //cout<<"Start to save CgemDigi"<<endl;
464 // cgem digis collection defined in BOSS
465 CgemDigiCol* aCgemDigiCol = new CgemDigiCol;
466
467 //cout<<"nDigi : "<<m_nGemHit<<endl;
468 if (m_nGemHit > 0)
469 {
470 // push back cgem digits to CgemDigiCol in BOSS
471 for(int i=0;i<m_nGemHit;i++)
472 {
473 unsigned int charge_channel;
474 unsigned int time_channel;
475 bool is_converted = ConvertHitToDigi(i, charge_channel, time_channel);
476 if(!is_converted) {
477 cout<<"ReadCosmicRayData::SaveCgemDigits failed to convert hit "<<i<<" to digi in event "<<m_Event_D<<endl;
478 continue;
479 }
480 const Identifier ident = CgemID::strip_id(
481 TranslateDigitLayerID(m_LayerID[i]),
482 TranslateDigitSheetID(m_SheetID[i]),
483 TranslateDigitStripType(m_StripType[i]),
484 TranslateDigitStripID(m_StripID[i],TranslateDigitStripType(m_StripType[i])));
485
486 /**
487 cout << "graal strip " << m_strip[i]
488 << " graal view " << m_view[i]
489 << " stripid " << m_StripID[i]
490 << " striptype " << m_StripType[i]
491 << " strip " << TranslateDigitStripID(m_StripID[i],TranslateDigitStripType(m_StripType[i]))
492 << " identifier " << CgemID::getIntID(TranslateDigitLayerID(m_LayerID[i]),
493 TranslateDigitSheetID(m_SheetID[i]),
494 TranslateDigitStripType(m_StripType[i]),
495 TranslateDigitStripID(m_StripID[i],TranslateDigitStripType(m_StripType[i]))) << endl;;
496 **/
497
498 int layerid = CgemID::layer(ident);
499 int stripid = CgemID::strip(ident);
500 int sheetid = CgemID::sheet(ident);
501 bool is_xstrip = CgemID::is_xstrip(ident);
502
503 if(printFlag)
504 {
505 cout
506 << " digiID=" << ident.get_value()
507 << " layerID=" << CgemID::layer(ident)
508 << " sheetID=" << CgemID::sheet(ident)
509 << " isXstrip="<< CgemID::is_xstrip(ident)
510 << " stripID=" << CgemID::strip(ident)
511 << " time channel=" << time_channel
512 << " charge channel=" << charge_channel << endl;
513 }
514
515 CgemDigi* aCgemDigi = new CgemDigi(ident, time_channel, charge_channel);
516 aCgemDigi->setTime_ns(m_time[i]);
517 aCgemDigi->setCharge_fc(m_charge[i]);
518 aCgemDigiCol->push_back(aCgemDigi);
519
520 } // End of 'for(int i=0;i<nDigi;i++)'
521 } // End of 'if (nDigi > 0)'
522
523 // register CGEM digits collection to TDS
524 StatusCode scCgem = m_evtSvc->registerObject("/Event/Digi/CgemDigiCol", aCgemDigiCol);
525 if(scCgem!=StatusCode::SUCCESS)
526 {
527 cout << "ERROR : ReadCosmicRayData::SaveCgemDigits(), Could not register CGEM digi collection! " << endl;
528 }
529
530 //retrieve CGEM digits from TDS
531 /**
532 SmartDataPtr<CgemDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/CgemDigiCol");
533 if(!aDigiCol)
534 cout<<"Could not retrieve CGEM digi collection"<<endl;
535
536 CgemDigiCol::iterator iDigiCol;
537 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
538 {
539 const Identifier ident = (*iDigiCol)->identify();
540 cout<<" layer: "<<CgemID::layer(ident)
541 <<" sheet: "<<CgemID::sheet(ident)
542 <<" strip: "<<CgemID::strip(ident)
543 <<" charge: "<<(*iDigiCol)->getCharge_fc()
544 <<" time: "<<(*iDigiCol)->getTime_ns()<<endl;
545 }
546 cout<<"end of retrieve CGEM digi collection"<<endl;
547 **/
548}
549
550
551
552void ReadCosmicRayData::SaveCgemClusters()
553{
554
555 bool printFlag=false;
556 //cout<<"Start to save CgemCluster"<<endl;
557
558 // cgem digis collection defined in BOSS
559 RecCgemClusterCol* aRecCgemClusterCol = new RecCgemClusterCol;
560
561 int nCluster = m_nGemCluster; // the number of Clusters in one event
562 if (nCluster > 0)
563 {
564 // push back cgem clusters to RecCgemClusterCol in BOSS
565 for(int i=0;i<nCluster;i++)
566 {
567 RecCgemCluster* aRecCgemCluster = new RecCgemCluster();
568
569 aRecCgemCluster->setclusterid(i);
570 aRecCgemCluster->setlayerid(TranslateClusterLayerID(m_ClusterLayerID[i]));
571 aRecCgemCluster->setsheetid(ClusterSheetID);
572 aRecCgemCluster->setflag(TranslateClusterFlag(m_Flag[i]));
573 aRecCgemCluster->setenergydeposit(m_EnergyDeposit[i]);
574 if(TranslateClusterFlag(m_Flag[i])==0)
575 {
576 aRecCgemCluster->setrecphi(m_Cluster_x[i]);
577 aRecCgemCluster->setrecphi_CC(m_Cluster_x_cc[i]);
578 aRecCgemCluster->setrecphi_mTPC(m_Cluster_x_tpc[i]);
579 }
580 if(TranslateClusterFlag(m_Flag[i])==1)
581 {
582 aRecCgemCluster->setrecv(m_Cluster_x[i]);
583 aRecCgemCluster->setrecv_CC(m_Cluster_x_cc[i]);
584 aRecCgemCluster->setrecv_mTPC(m_Cluster_x_tpc[i]);
585 }
586 aRecCgemCluster->setRecZ(ClusterRecZ); //currently, no Z information is available
587 aRecCgemCluster->setRecZ_CC(ClusterRecZ);
588 aRecCgemCluster->setRecZ_mTPC(ClusterRecZ);
589 //aRecCgemCluster->setRecZ(m_Cluster_z[i]);
590 //aRecCgemCluster->setRecZ_CC(m_Cluster_z_cc[i]);
591 //aRecCgemCluster->setRecZ_mTPC(m_Cluster_z_tpc[i]);
592 aRecCgemCluster->setclusterflag(m_ClusterHitIndex[i][0],m_ClusterHitIndex[i][m_ClusternHit[i]-1]);
593
594 if(printFlag)
595 {
596 cout
597 << " clusterID=" << aRecCgemCluster->getclusterid()
598 << " clusterlayerID=" << aRecCgemCluster->getlayerid()
599 << " clustersheetID=" << aRecCgemCluster->getsheetid()
600 << " flag=" << aRecCgemCluster->getflag()
601 << " energydeposit=" << aRecCgemCluster->getenergydeposit()
602 << " recphi=" << aRecCgemCluster->getrecphi()
603 << " recv=" << aRecCgemCluster->getrecv()
604 << " recZ=" << aRecCgemCluster->getRecZ()
605 << " clusterflagb=" << aRecCgemCluster->getclusterflagb()
606 << " clusterflage=" << aRecCgemCluster->getclusterflage()<< endl;
607 }
608
609 aRecCgemClusterCol->push_back(aRecCgemCluster);
610
611 }
612 }
613
614
615 // register CGEM clusters collection to TDS
616 StatusCode scCgem = m_evtSvc->registerObject("/Event/Recon/RecCgemClusterCol", aRecCgemClusterCol); //Where should I put the vector?
617 if(scCgem!=StatusCode::SUCCESS)
618 {
619 cout << "ERROR : ReadCosmicRayData:::SaveCgemClusters(), Could not register CGEM cluster collection! " << endl;
620 }
621
622}
623
624
625StatusCode ReadCosmicRayData::execute(){
626
627 MsgStream log(msgSvc(), name());
628 if(ReadDigi&&!ReadCluster) log << MSG::INFO << "ReadCosmicRayData execute(): "<<Ind_Entry_D+1<<"/"<<No_Entries_D<<" events are finished !" << endreq;
629 if(!ReadDigi&&ReadCluster) log << MSG::INFO << "ReadCosmicRayData execute(): "<<Ind_Entry_C+1<<"/"<<No_Entries_C<<" events are finished !" << endreq;
630 if(ReadDigi&&ReadCluster) log << MSG::INFO << "ReadCosmicRayData execute(): "<<Ind_Entry_C+1<<"/"<<No_Entries_C<<" events are finished !" << endreq;
631
632
633 //interface to event data service
634 ISvcLocator* svcLocator = Gaudi::svcLocator();
635 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
636 if (sc.isFailure())
637 cout<<"Could not accesss EventDataSvc!"<<endl;
638
639 // set /Event/EventHeader
640 SmartDataPtr<Event::EventHeader> eventHeader(m_evtSvc,"/Event/EventHeader");
641 if (!eventHeader) {
642 Event::EventHeader *eventHeader = new Event::EventHeader;
643 StatusCode sc = m_evtSvc->registerObject("/Event/EventHeader",eventHeader);
644 }
645 eventHeader->setEventNumber(Ind_Entry_D);
646 eventHeader->setRunNumber( m_runNo);
647
648
649 if(ReadDigi)
650 {
651 DigiEvent* aDigiEvent = new DigiEvent;
652 sc = m_evtSvc->registerObject("/Event/Digi",aDigiEvent);
653 if(sc!=StatusCode::SUCCESS) {
654 cout<< "Could not register DigiEvent" <<endl;
655 }
656
657 ReadCgemDigits();
658 SaveCgemDigits();
659 //cout<<"Ind_Entry_D "<<Ind_Entry_D<<", Max_Ind_Entry_D "<<No_Entries_D<<endl;
660
661 if(Ind_Entry_D==No_Entries_D)
662 {
663 log << MSG::INFO << "scheduling a event processing stop...." << endreq;
664 SmartIF<IEventProcessor> ep(serviceLocator());
665 if (ep) ep->stopRun();
666 }
667
668 }
669 if(ReadCluster)
670 {
671 ReconEvent* aReconEvent = new ReconEvent;
672 sc = m_evtSvc->registerObject("/Event/Recon",aReconEvent);
673 if(sc!=StatusCode::SUCCESS) {
674 cout<< "Could not register ReconEvent" <<endl;
675 }
676
677 ReadCgemClusters();
678 SaveCgemClusters();
679 //cout<<"Ind_Entry_C "<<Ind_Entry_C<<", Max_Ind_Entry_C "<<No_Entries_C<<endl;
680 if(Ind_Entry_C==No_Entries_C)
681 {
682 // log << MSG::INFO << "scheduling a event processing stop...." << endreq;
683 SmartIF<IEventProcessor> ep(serviceLocator());
684 if (ep) ep->stopRun();
685 }
686 }
687 return StatusCode::SUCCESS;
688}
689
690StatusCode ReadCosmicRayData::finalize(){
691 MsgStream log(msgSvc(),name());
692 log << MSG::INFO << "ReadCosmicRayData finalize()" << endreq;
693
694 // DEBUG
695 /**
696 const int nlayer = 3; // CHECK hardcoded
697 const int nsheet[nlayer] = {1, 2, 2}; // CHECK hardcoded
698 const int nview = 2; // CHECK hardcoded
699 int nstrip[nlayer][nview] = {{856, 1173}, {630, 1077}, {832, 1395}}; // CHECK hardcoded
700
701 int layer=1;
702 int sheet=0;
703 int type=0;
704 for(int strip=0; strip<nstrip[layer][type]; strip++) {
705 cout << strip << " "
706 << mapper->GetGEMROC(strip, type, layer, sheet) << " "
707 << mapper->GetFEB(strip, type, layer, sheet) << " "
708 << mapper->GetTIGER(strip, type, layer, sheet)
709 << endl;
710 }
711 **/
712 // --------
713
714 return StatusCode::SUCCESS;
715}
716
717
718
ObjectVector< RecCgemCluster > RecCgemClusterCol
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static value_type getXSTRIP_MAX(unsigned int f_layer)
static int layer(const Identifier &id)
static value_type getVSTRIP_MAX(unsigned int f_layer)
static bool is_xstrip(const Identifier &id)
static Identifier strip_id(int f_layer, int f_sheet, int f_strip_type, int f_strip)
ReadCosmicRayData(const std::string &name, ISvcLocator *pSvcLocator)