CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_ReadCosmicRayData-00-00-12/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 = "Cosmic_data_01.root");
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 f = new TFile(TDir_file);
99 if(ReadDigi)
100 {
101 TString TTreeDigi(TreeDigi);
102 Tdigi = (TTree*)f->Get(TTreeDigi);
103
104 // Get Cgem digi tree
105 Tdigi->SetBranchAddress("Event", &m_Event_D); // event ID
106 Tdigi->SetBranchAddress("nGemHit", &m_nGemHit); // nof GEM hits
107 // Tdigi->SetBranchAddress("GemHit_nHit", &m_nGemHit); // nof GEM hits it is the same thing as before
108
109 // information on the IDs
110 Tdigi->SetBranchAddress("GemHit_channel", m_channel); // channel no. [0, 63]
111 Tdigi->SetBranchAddress("GemHit_ROC", m_ROC); // ROC no.
112 Tdigi->SetBranchAddress("GemHit_chip", m_chip); // chip no.
113 Tdigi->SetBranchAddress("GemHit_FEB", m_FEB); // FEB no.
114 Tdigi->SetBranchAddress("GemHit_plane", m_plane); // plane
115 Tdigi->SetBranchAddress("GemHit_view", m_view); // view (axial or stereo strips)
116 Tdigi->SetBranchAddress("GemHit_strip", m_strip); // strip no.
117
118 // physical information
119 Tdigi->SetBranchAddress("GemHit_saturated", m_saturated); // is the ASIC channel saturated
120 Tdigi->SetBranchAddress("GemHit_q", m_charge); // charge (fC)
121 Tdigi->SetBranchAddress("GemHit_time", m_time); // time (ns)
122 // Tdigi->SetBranchAddress("GemHit_is_tpc", m_GemHit_is_tpc);
123
124 No_Entries_D = Tdigi->GetEntries();
125 Ind_Entry_D = 0;
126 }
127
128 /**
129 if(ReadCluster)
130 {
131 //Get Cgem cluster tree
132 TString TTreeCluster(TreeCluster);
133 Tcluster = (TTree*)f->Get(TTreeCluster);
134
135 Tcluster->SetBranchAddress("Event", &m_Event_C);
136 Tcluster->SetBranchAddress("GemCluster1d_nCluster", &m_nGemCluster);
137 Tcluster->SetBranchAddress("GemCluster1d_nHit", m_ClusternHit);
138 Tcluster->SetBranchAddress("GemCluster1d_HitIndex", m_ClusterHitIndex);
139 Tcluster->SetBranchAddress("GemCluster1d_plane", m_ClusterLayerID);
140 Tcluster->SetBranchAddress("GemCluster1d_view", m_Flag);
141 Tcluster->SetBranchAddress("GemCluster1d_q", m_EnergyDeposit);
142 Tcluster->SetBranchAddress("GemCluster1d_x", m_Cluster_x);
143 Tcluster->SetBranchAddress("GemCluster1d_z", m_Cluster_z);
144 Tcluster->SetBranchAddress("GemCluster1d_x_cc", m_Cluster_x_cc);
145 Tcluster->SetBranchAddress("GemCluster1d_x_tpc", m_Cluster_x_tpc);
146 Tcluster->SetBranchAddress("GemCluster1d_z_cc", m_Cluster_z_cc);
147 Tcluster->SetBranchAddress("GemCluster1d_z_tpc", m_Cluster_z_tpc);
148 //Tcluster->SetBranchAddress("ClusterSheetID", m_ClusterSheetID);
149 //Tcluster->SetBranchAddress("ClusterFlagB", m_ClusterFlagB);
150 //Tcluster->SetBranchAddress("ClusterFlagE", m_ClusterFlagE);
151 //Tcluster->SetBranchAddress("RecV", m_RecV);
152 //Tcluster->SetBranchAddress("RecZ", m_RecZ);
153
154 No_Entries_C = Tcluster->GetEntries();
155 Ind_Entry_C = 0;
156 }
157 **/
158
159 return StatusCode::SUCCESS;
160}
161
162
163int ReadCosmicRayData::TranslateDigitLayerID(int Input_LayerID)
164{
165 int ShiftValue = Shift_DigitLayerID;
166 return Input_LayerID+ShiftValue;
167}
168
169int ReadCosmicRayData::TranslateDigitSheetID(int Input_SheetID)
170{
171 int ShiftValue = Shift_DigitSheetID;
172 return Input_SheetID+ShiftValue;
173}
174
175int ReadCosmicRayData::TranslateDigitXStripID(int Input_StripID)
176{
177 int ShiftValue = Shift_DigitXStripID;
178 return Input_StripID+ShiftValue;
179}
180
181int ReadCosmicRayData::TranslateDigitVStripID(int Input_StripID)
182{
183 int ShiftValue = Shift_DigitVStripID;
184 return Input_StripID+ShiftValue;
185}
186
187int ReadCosmicRayData::TranslateDigitStripID(int Input_StripID, int StripType)
188{
189 int Output_StripID = -1;
190 if(StripType==0) Output_StripID = TranslateDigitXStripID(Input_StripID);
191 if(StripType==1) Output_StripID = TranslateDigitVStripID(Input_StripID);
192 return Output_StripID;
193}
194
195int ReadCosmicRayData::TranslateDigitStripType(int Input_StripType)
196{
197 return Input_StripType;
198}
199
200int ReadCosmicRayData::TranslateClusterLayerID(int Input_LayerID)
201{
202 int ShiftValue = Shift_ClusterLayerID;
203 return Input_LayerID+ShiftValue;
204}
205
206int ReadCosmicRayData::TranslateClusterSheetID(int Input_SheetID)
207{
208 int ShiftValue = Shift_ClusterSheetID;
209 return Input_SheetID+ShiftValue;
210}
211
212int ReadCosmicRayData::TranslateClusterFlag(int Input_Flag)
213{
214 return Input_Flag-2;
215}
216
217double ReadCosmicRayData::TranslateRecPhi(double Input_RecPhi)
218{
219 double ShiftValue = Shift_RecPhi;
220 return Input_RecPhi+ShiftValue;
221}
222
223double ReadCosmicRayData::TranslateRecV(double Input_RecV)
224{
225 double ShiftValue = Shift_RecV;
226 return Input_RecV+ShiftValue;
227}
228
229double ReadCosmicRayData::TranslateRecZ(double Input_RecZ)
230{
231 double ShiftValue = Shift_RecZ;
232 return Input_RecZ+ShiftValue;
233}
234
235void ReadCosmicRayData::ReadCgemDigits()
236{
237 //cout<<"Start to read the CgemDigits"<<endl;
238 Tdigi->GetEntry(Ind_Entry_D);
239 Ind_Entry_D++;
240}
241
242void ReadCosmicRayData::ReadCgemClusters()
243{
244 //cout<<"Start to read the CgemClusters"<<endl;
245 Tcluster->GetEntry(Ind_Entry_C);
246 Ind_Entry_C++;
247}
248
249bool ReadCosmicRayData::ConvertHitToDigi(int ihit, unsigned int &charge_channel, unsigned int &time_channel)
250{
251
252 if(CosmicRayDataSetID == "CR201909") {
253 // cout << "ReadCosmicRayData::ConvertGRAALToCgemBoss(), converting set " << CosmicRayDataSetID << endl;
254
255 // if(!m_GemHit_is_tpc[i]&&Cut_on_tpc) return false; // ??
256 charge_channel = 1;
257 time_channel = 1;
258
259 // from plane to LayerID
260 if(m_plane[ihit] == 0) m_LayerID[ihit] = 0; // LAYER1
261 else if(m_plane[ihit] == 1) m_LayerID[ihit] = 1; // LAYER2
262 else if(m_plane[ihit] == 2) m_LayerID[ihit] = 1; // LAYER2
263 else {
264 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown plane "<<m_plane[ihit]<<endl;
265 return false;
266 }
267
268 // from view to StripType
269 if(m_view[ihit] == 2) m_StripType[ihit] = 0; // x strip (phi)
270 else if(m_view[ihit] == 3) m_StripType[ihit] = 1; // v strip (stereo)
271 else {
272 cout<<"ReadCosmicRayData::ConvertHitToDigi: unknown view "<<m_view[ihit]<<endl;
273 return false;
274 }
275
276 //cout<<"layer "<<m_LayerID[ihit]<<", StripType "<<m_StripType[ihit]<<", original strip id: "<< m_strip[ihit]<<endl;
277 // sheet ID/strip ID
278 if(m_LayerID[ihit] == 0) { // LAYER 1
279 m_SheetID[ihit] = 0; // LAYER 1
280 m_StripID[ihit] = m_strip[ihit]-1;// strip ID starts from 0
281 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;
282 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;
283 }
284 if(m_LayerID[ihit] == 1) { // LAYER 2
285 m_SheetID[ihit] = 0;
286 if(m_StripType[ihit] == 0) // X strip
287 {
288
289 // sheet down --> sheet 1
290 if(m_strip[ihit] > CgemID::getXSTRIP_MAX(m_LayerID[ihit]))
291 {
292 m_SheetID[ihit] = 0;
293 m_StripID[ihit] = 2*CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];// strip ID starts from 0
294 }
295 else {
296 // sheet up --> sheet 2
297 m_StripID[ihit] = CgemID::getXSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
298 m_SheetID[ihit] = 1;
299 }
300 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;
301 }
302 else if(m_StripType[ihit] == 1)// V strip with correction for the wrong mapping at strip 538 and 1617 in integration
303 {
304 if(m_strip[ihit] == 539 || m_strip[ihit] == 1617) return false;
305 else if(m_strip[ihit] < 539) {
306 // sheet up --> sheet 2
307 m_StripID[ihit] = CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit];
308 m_SheetID[ihit] = 1;
309 }
310 else if(m_strip[ihit] < CgemID::getVSTRIP_MAX(m_LayerID[ihit]) + 2) {
311 // sheet up --> sheet 2
312 m_StripID[ihit] = CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit] + 1;
313 m_SheetID[ihit] = 1;
314 }
315 else if(m_strip[ihit] < 1617) {
316 // sheet down --> sheet 1
317 m_StripID[ihit] = 2*CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit] + 1;
318 m_SheetID[ihit] = 0;
319 }
320 else {
321 // sheet down --> sheet 1
322 m_StripID[ihit] = 2*CgemID::getVSTRIP_MAX(m_LayerID[ihit]) - m_strip[ihit] + 2;
323 m_SheetID[ihit] = 0;
324 }
325 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;
326 }
327 }
328
329 // cout << "GRAAL " << m_strip[ihit] << " view " << m_view[ihit] << " plane " << m_plane[ihit] << endl;
330 // cout << "CGEMB " << m_StripID[ihit] << " view " << m_StripType[ihit] << " plane " << m_LayerID[ihit] << " sheet " << m_SheetID[ihit] << endl;
331
332
333 return true;
334 }
335
336 cout << "ERROR : ReadCosmicRayData::ConvertGRAALToCgemBoss(), the data set " << CosmicRayDataSetID << " is unknown! " << endl;
337 return false;
338
339}
340
341void ReadCosmicRayData::SaveCgemDigits()
342{
343
344 bool printFlag=false;
345 //cout<<"Start to save CgemDigi"<<endl;
346 // cgem digis collection defined in BOSS
347 CgemDigiCol* aCgemDigiCol = new CgemDigiCol;
348
349 //cout<<"nDigi : "<<m_nGemHit<<endl;
350 if (m_nGemHit > 0)
351 {
352 // push back cgem digits to CgemDigiCol in BOSS
353 for(int i=0;i<m_nGemHit;i++)
354 {
355 unsigned int charge_channel;
356 unsigned int time_channel;
357 bool is_converted = ConvertHitToDigi(i, charge_channel, time_channel);
358 if(!is_converted) {
359 cout<<"ReadCosmicRayData::SaveCgemDigits failed to convert hit "<<i<<" to digi in event "<<m_Event_D<<endl;
360 continue;
361 }
362 const Identifier ident = CgemID::strip_id(
363 TranslateDigitLayerID(m_LayerID[i]),
364 TranslateDigitSheetID(m_SheetID[i]),
365 TranslateDigitStripType(m_StripType[i]),
366 TranslateDigitStripID(m_StripID[i],TranslateDigitStripType(m_StripType[i])));
367
368 /**
369 cout << "graal strip " << m_strip[i]
370 << " graal view " << m_view[i]
371 << " stripid " << m_StripID[i]
372 << " striptype " << m_StripType[i]
373 << " strip " << TranslateDigitStripID(m_StripID[i],TranslateDigitStripType(m_StripType[i]))
374 << " identifier " << CgemID::getIntID(TranslateDigitLayerID(m_LayerID[i]),
375 TranslateDigitSheetID(m_SheetID[i]),
376 TranslateDigitStripType(m_StripType[i]),
377 TranslateDigitStripID(m_StripID[i],TranslateDigitStripType(m_StripType[i]))) << endl;;
378 **/
379
380 int layerid = CgemID::layer(ident);
381 int stripid = CgemID::strip(ident);
382 int sheetid = CgemID::sheet(ident);
383 bool is_xstrip = CgemID::is_xstrip(ident);
384
385 if(printFlag)
386 {
387 cout
388 << " digiID=" << ident.get_value()
389 << " layerID=" << CgemID::layer(ident)
390 << " sheetID=" << CgemID::sheet(ident)
391 << " isXstrip="<< CgemID::is_xstrip(ident)
392 << " stripID=" << CgemID::strip(ident)
393 << " time channel=" << time_channel
394 << " charge channel=" << charge_channel << endl;
395 }
396
397 CgemDigi* aCgemDigi = new CgemDigi(ident, time_channel, charge_channel);
398 aCgemDigi->setTime_ns(m_time[i]);
399 aCgemDigi->setCharge_fc(m_charge[i]);
400 aCgemDigiCol->push_back(aCgemDigi);
401
402 } // End of 'for(int i=0;i<nDigi;i++)'
403 } // End of 'if (nDigi > 0)'
404
405 // register CGEM digits collection to TDS
406 StatusCode scCgem = m_evtSvc->registerObject("/Event/Digi/CgemDigiCol", aCgemDigiCol);
407 if(scCgem!=StatusCode::SUCCESS)
408 {
409 cout << "ERROR : ReadCosmicRayData::SaveCgemDigits(), Could not register CGEM digi collection! " << endl;
410 }
411
412 //retrieve CGEM digits from TDS
413 /**
414 SmartDataPtr<CgemDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/CgemDigiCol");
415 if(!aDigiCol)
416 cout<<"Could not retrieve CGEM digi collection"<<endl;
417
418 CgemDigiCol::iterator iDigiCol;
419 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
420 {
421 const Identifier ident = (*iDigiCol)->identify();
422 cout<<" layer: "<<CgemID::layer(ident)
423 <<" sheet: "<<CgemID::sheet(ident)
424 <<" strip: "<<CgemID::strip(ident)
425 <<" charge: "<<(*iDigiCol)->getCharge_fc()
426 <<" time: "<<(*iDigiCol)->getTime_ns()<<endl;
427 }
428 cout<<"end of retrieve CGEM digi collection"<<endl;
429 **/
430}
431
432
433
434void ReadCosmicRayData::SaveCgemClusters()
435{
436
437 bool printFlag=false;
438 //cout<<"Start to save CgemCluster"<<endl;
439
440 // cgem digis collection defined in BOSS
441 RecCgemClusterCol* aRecCgemClusterCol = new RecCgemClusterCol;
442
443 int nCluster = m_nGemCluster; // the number of Clusters in one event
444 if (nCluster > 0)
445 {
446 // push back cgem clusters to RecCgemClusterCol in BOSS
447 for(int i=0;i<nCluster;i++)
448 {
449 RecCgemCluster* aRecCgemCluster = new RecCgemCluster();
450
451 aRecCgemCluster->setclusterid(i);
452 aRecCgemCluster->setlayerid(TranslateClusterLayerID(m_ClusterLayerID[i]));
453 aRecCgemCluster->setsheetid(ClusterSheetID);
454 aRecCgemCluster->setflag(TranslateClusterFlag(m_Flag[i]));
455 aRecCgemCluster->setenergydeposit(m_EnergyDeposit[i]);
456 if(TranslateClusterFlag(m_Flag[i])==0)
457 {
458 aRecCgemCluster->setrecphi(m_Cluster_x[i]);
459 aRecCgemCluster->setrecphi_CC(m_Cluster_x_cc[i]);
460 aRecCgemCluster->setrecphi_mTPC(m_Cluster_x_tpc[i]);
461 }
462 if(TranslateClusterFlag(m_Flag[i])==1)
463 {
464 aRecCgemCluster->setrecv(m_Cluster_x[i]);
465 aRecCgemCluster->setrecv_CC(m_Cluster_x_cc[i]);
466 aRecCgemCluster->setrecv_mTPC(m_Cluster_x_tpc[i]);
467 }
468 aRecCgemCluster->setRecZ(ClusterRecZ); //currently, no Z information is available
469 aRecCgemCluster->setRecZ_CC(ClusterRecZ);
470 aRecCgemCluster->setRecZ_mTPC(ClusterRecZ);
471 //aRecCgemCluster->setRecZ(m_Cluster_z[i]);
472 //aRecCgemCluster->setRecZ_CC(m_Cluster_z_cc[i]);
473 //aRecCgemCluster->setRecZ_mTPC(m_Cluster_z_tpc[i]);
474 aRecCgemCluster->setclusterflag(m_ClusterHitIndex[i][0],m_ClusterHitIndex[i][m_ClusternHit[i]-1]);
475
476 if(printFlag)
477 {
478 cout
479 << " clusterID=" << aRecCgemCluster->getclusterid()
480 << " clusterlayerID=" << aRecCgemCluster->getlayerid()
481 << " clustersheetID=" << aRecCgemCluster->getsheetid()
482 << " flag=" << aRecCgemCluster->getflag()
483 << " energydeposit=" << aRecCgemCluster->getenergydeposit()
484 << " recphi=" << aRecCgemCluster->getrecphi()
485 << " recv=" << aRecCgemCluster->getrecv()
486 << " recZ=" << aRecCgemCluster->getRecZ()
487 << " clusterflagb=" << aRecCgemCluster->getclusterflagb()
488 << " clusterflage=" << aRecCgemCluster->getclusterflage()<< endl;
489 }
490
491 aRecCgemClusterCol->push_back(aRecCgemCluster);
492
493 }
494 }
495
496
497 // register CGEM clusters collection to TDS
498 StatusCode scCgem = m_evtSvc->registerObject("/Event/Recon/RecCgemClusterCol", aRecCgemClusterCol); //Where should I put the vector?
499 if(scCgem!=StatusCode::SUCCESS)
500 {
501 cout << "ERROR : ReadCosmicRayData:::SaveCgemClusters(), Could not register CGEM cluster collection! " << endl;
502 }
503
504}
505
506
507StatusCode ReadCosmicRayData::execute(){
508
509 MsgStream log(msgSvc(), name());
510 if(ReadDigi&&!ReadCluster) log << MSG::INFO << "ReadCosmicRayData execute(): "<<Ind_Entry_D+1<<"/"<<No_Entries_D<<" events are finished !" << endreq;
511 if(!ReadDigi&&ReadCluster) log << MSG::INFO << "ReadCosmicRayData execute(): "<<Ind_Entry_C+1<<"/"<<No_Entries_C<<" events are finished !" << endreq;
512 if(ReadDigi&&ReadCluster) log << MSG::INFO << "ReadCosmicRayData execute(): "<<Ind_Entry_C+1<<"/"<<No_Entries_C<<" events are finished !" << endreq;
513
514
515 //interface to event data service
516 ISvcLocator* svcLocator = Gaudi::svcLocator();
517 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
518 if (sc.isFailure())
519 cout<<"Could not accesss EventDataSvc!"<<endl;
520
521 // set /Event/EventHeader
522 SmartDataPtr<Event::EventHeader> eventHeader(m_evtSvc,"/Event/EventHeader");
523 if (!eventHeader) {
524 Event::EventHeader *eventHeader = new Event::EventHeader;
525 StatusCode sc = m_evtSvc->registerObject("/Event/EventHeader",eventHeader);
526 }
527 eventHeader->setEventNumber(Ind_Entry_D);
528 eventHeader->setRunNumber( m_runNo);
529
530
531 if(ReadDigi)
532 {
533 DigiEvent* aDigiEvent = new DigiEvent;
534 sc = m_evtSvc->registerObject("/Event/Digi",aDigiEvent);
535 if(sc!=StatusCode::SUCCESS) {
536 cout<< "Could not register DigiEvent" <<endl;
537 }
538
539 ReadCgemDigits();
540 SaveCgemDigits();
541 //cout<<"Ind_Entry_D "<<Ind_Entry_D<<", Max_Ind_Entry_D "<<No_Entries_D<<endl;
542
543 if(Ind_Entry_D==No_Entries_D)
544 {
545 log << MSG::INFO << "scheduling a event processing stop...." << endreq;
546 SmartIF<IEventProcessor> ep(serviceLocator());
547 if (ep) ep->stopRun();
548 }
549
550 }
551 if(ReadCluster)
552 {
553 ReconEvent* aReconEvent = new ReconEvent;
554 sc = m_evtSvc->registerObject("/Event/Recon",aReconEvent);
555 if(sc!=StatusCode::SUCCESS) {
556 cout<< "Could not register ReconEvent" <<endl;
557 }
558
559 ReadCgemClusters();
560 SaveCgemClusters();
561 //cout<<"Ind_Entry_C "<<Ind_Entry_C<<", Max_Ind_Entry_C "<<No_Entries_C<<endl;
562 if(Ind_Entry_C==No_Entries_C)
563 {
564 // log << MSG::INFO << "scheduling a event processing stop...." << endreq;
565 SmartIF<IEventProcessor> ep(serviceLocator());
566 if (ep) ep->stopRun();
567 }
568 }
569 return StatusCode::SUCCESS;
570}
571
572StatusCode ReadCosmicRayData::finalize(){
573 MsgStream log(msgSvc(),name());
574 log << MSG::INFO << "ReadCosmicRayData finalize()" << endreq;
575
576 // DEBUG
577 /**
578 const int nlayer = 3; // CHECK hardcoded
579 const int nsheet[nlayer] = {1, 2, 2}; // CHECK hardcoded
580 const int nview = 2; // CHECK hardcoded
581 int nstrip[nlayer][nview] = {{856, 1173}, {630, 1077}, {832, 1395}}; // CHECK hardcoded
582
583 int layer=1;
584 int sheet=0;
585 int type=0;
586 for(int strip=0; strip<nstrip[layer][type]; strip++) {
587 cout << strip << " "
588 << mapper->GetGEMROC(strip, type, layer, sheet) << " "
589 << mapper->GetFEB(strip, type, layer, sheet) << " "
590 << mapper->GetTIGER(strip, type, layer, sheet)
591 << endl;
592 }
593 **/
594 // --------
595
596 return StatusCode::SUCCESS;
597}
598
599
600
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)