14#include "GaudiKernel/AlgFactory.h"
15#include "GaudiKernel/DataObject.h"
16#include "GaudiKernel/IEventProcessor.h"
18#include "GaudiKernel/Incident.h"
19#include "GaudiKernel/IIncidentSvc.h"
20#include "GaudiKernel/Memory.h"
25#include "GaudiKernel/ISvcLocator.h"
26#include "GaudiKernel/IDataProviderSvc.h"
27#include "GaudiKernel/Bootstrap.h"
28#include "GaudiKernel/RegistryEntry.h"
29#include "GaudiKernel/MsgStream.h"
40#include "GaudiKernel/SmartDataPtr.h"
47 Algorithm(name,pSvcLocator){
49 declareProperty(
"Dir_file", Dir_file =
"Cosmic_data_01.root");
50 declareProperty(
"TreeDigi", TreeDigi =
"t1");
51 declareProperty(
"CosmicRayDataSetID", CosmicRayDataSetID =
"CR201909");
59 MsgStream log(
msgSvc(), name());
60 log << MSG::INFO <<
"TestInputOutput initialize()" << endreq;
62 output =
new TFile(
"IOtest_histo.root",
"RECREATE");
66 hnhit_L1_x =
new TH1F(
"hnhit_L1_x",
"number of hits on layer 1, x srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
67 hnhit_L2_x =
new TH1F(
"hnhit_L2_x",
"number of hits on layer 2, x srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
68 hcharge_L1_x =
new TH1F(
"hcharge_L1_x",
"hcharge on layer 1, x srtips", 50, 0, 50);
69 hcharge_L2_x =
new TH1F(
"hcharge_L2_x",
"hcharge on layer 2, x strips", 50, 0, 50);
70 htime_L1_x =
new TH1F(
"htime_L1_x",
"htime_L1, x strips", 500, -300, 300);
71 htime_L2_x =
new TH1F(
"htime_L2_x",
"htime_L2, x strips", 500, -300, 300);
76 hnhit_L1_v =
new TH1F(
"hnhit_L1_v",
"number of hits on layer 1, v srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
77 hnhit_L2_v =
new TH1F(
"hnhit_L2_v",
"number of hits on layer 2, v srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
78 hcharge_L1_v =
new TH1F(
"hcharge_L1_v",
"hcharge on layer 1, v srtips", 50, 0, 50);
79 hcharge_L2_v =
new TH1F(
"hcharge_L2_v",
"hcharge on layer 2, v strips", 50, 0, 50);
80 htime_L1_v =
new TH1F(
"htime_L1_v",
"htime_L1, v strips", 500, -300, 300);
81 htime_L2_v =
new TH1F(
"htime_L2_v",
"htime_L2, v strips", 500, -300, 300);
87 hnhit_L1_x_GRAAL =
new TH1F(
"hnhit_L1_x_GRAAL",
"GRAAL: number of hits on layer 1, x srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
88 hnhit_L2_x_GRAAL =
new TH1F(
"hnhit_L2_x_GRAAL",
"GRAAL: number of hits on layer 2, x srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
89 hcharge_L1_x_GRAAL =
new TH1F(
"hcharge_L1_x_GRAAL",
"GRAAL: hcharge on layer 1, x srtips", 50, 0, 50);
90 hcharge_L2_x_GRAAL =
new TH1F(
"hcharge_L2_x_GRAAL",
"GRAAL: hcharge on layer 2, x strips", 50, 0, 50);
91 htime_L1_x_GRAAL =
new TH1F(
"htime_L1_x_GRAAL",
"GRAAL: htime_L1, x strips", 500, -300, 300);
92 htime_L2_x_GRAAL =
new TH1F(
"htime_L2_x_GRAAL",
"GRAAL: htime_L2, x strips", 500, -300, 300);
93 hstripid_L1_x_GRAAL =
new TH1F(
"hstripid_L1_x_GRAAL",
"GRAAL: strip IDs of hits on layer 1, x srtips",
95 hstripid_L2_x_GRAAL =
new TH1F(
"hstripid_L2_x_GRAAL",
"GRAAL: strip IDs of hits on layer 2, x srtips",
99 hnhit_L1_v_GRAAL =
new TH1F(
"hnhit_L1_v_GRAAL",
"GRAAL: number of hits on layer 1, v srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
100 hnhit_L2_v_GRAAL =
new TH1F(
"hnhit_L2_v_GRAAL",
"GRAAL: number of hits on layer 2, v srtips",
MAXNOFHITS, 0,
MAXNOFHITS);
101 hcharge_L1_v_GRAAL =
new TH1F(
"hcharge_L1_v_GRAAL",
"GRAAL: hcharge on layer 1, v srtips", 50, 0, 50);
102 hcharge_L2_v_GRAAL =
new TH1F(
"hcharge_L2_v_GRAAL",
"GRAAL: hcharge on layer 2, v strips", 50, 0, 50);
103 htime_L1_v_GRAAL =
new TH1F(
"htime_L1_v_GRAAL",
"GRAAL: htime_L1, v strips", 500, -300, 300);
104 htime_L2_v_GRAAL =
new TH1F(
"htime_L2_v_GRAAL",
"GRAAL: htime_L2, v strips", 500, -300, 300);
105 hstripid_L1_v_GRAAL =
new TH1F(
"hstripid_L1_v_GRAAL",
"GRAAL: strip IDs of hits on layer 1, v srtips",
107 hstripid_L2_v_GRAAL =
new TH1F(
"hstripid_L2_v_GRAAL",
"GRAAL: strip IDs of hits on layer 2, v srtips",
111 TString TDir_file(Dir_file);
112 f =
new TFile(TDir_file);
113 TString TTreeDigi(TreeDigi);
114 Tdigi = (TTree*)f->Get(TTreeDigi);
117 Tdigi->SetBranchAddress(
"nGemHit", &m_nGemHit);
119 Tdigi->SetBranchAddress(
"GemHit_plane", m_plane);
120 Tdigi->SetBranchAddress(
"GemHit_view", m_view);
121 Tdigi->SetBranchAddress(
"GemHit_strip", m_strip);
123 Tdigi->SetBranchAddress(
"GemHit_q", m_charge);
124 Tdigi->SetBranchAddress(
"GemHit_time", m_time);
128 return StatusCode::SUCCESS;
132 MsgStream log(
msgSvc(), name());
136 bool gotit = GetReferenceFromGRAAL();
138 cout<<
"Could not accesss Reference Histo!"<<endl;
142 ISvcLocator* svcLocator = Gaudi::svcLocator();
143 StatusCode sc=svcLocator->service(
"EventDataSvc", m_evtSvc);
145 cout<<
"Could not accesss EventDataSvc!"<<endl;
148 SmartDataPtr<CgemDigiCol> aDigiCol(m_evtSvc,
"/Event/Digi/CgemDigiCol");
150 cout<<
"Could not retrieve CGEM digi collection"<<endl;
152 int nhit = aDigiCol->size();
157 CgemDigiCol::iterator iDigiCol;
158 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
160 const Identifier ident = (*iDigiCol)->identify();
172 double charge = (*iDigiCol)->getCharge_fc();
173 double time = (*iDigiCol)->getTime_ns();
178 hcharge_L1_x->Fill(charge);
179 htime_L1_x->Fill(
time);
180 hstripid_L1_x->Fill(stripid);
183 else if(layerid == 1) {
184 hcharge_L2_x->Fill(charge);
185 htime_L2_x->Fill(
time);
186 hstripid_L2_x->Fill(stripid);
192 hcharge_L1_v->Fill(charge);
193 htime_L1_v->Fill(
time);
194 hstripid_L1_v->Fill(stripid);
197 else if(layerid == 1) {
198 hcharge_L2_v->Fill(charge);
199 htime_L2_v->Fill(
time);
200 hstripid_L2_v->Fill(stripid);
206 hnhit_L1_x->Fill(nhit_L1_x);
207 hnhit_L1_v->Fill(nhit_L1_v);
208 hnhit_L2_x->Fill(nhit_L2_x);
209 hnhit_L2_v->Fill(nhit_L2_v);
220 return StatusCode::SUCCESS;
224 MsgStream log(
msgSvc(),name());
225 log << MSG::INFO <<
"TestInputOutput finalize()" << endreq;
229 return StatusCode::SUCCESS;
233bool TestInputOutput::GetReferenceFromGRAAL(){
235 if(CosmicRayDataSetID ==
"CR201909") {
237 Tdigi->GetEntry(Ind_Entry_D);
246 for(
int ihit = 0; ihit < m_nGemHit; ihit++) {
248 if(m_view[ihit] == 2) {
249 if(m_plane[ihit] == 0) {
250 hcharge_L1_x_GRAAL->Fill(m_charge[ihit]);
251 htime_L1_x_GRAAL->Fill(m_time[ihit]);
252 hstripid_L1_x_GRAAL->Fill(m_strip[ihit]-1);
255 else if(m_plane[ihit] == 1 || m_plane[ihit] == 2) {
256 hcharge_L2_x_GRAAL->Fill(m_charge[ihit]);
257 htime_L2_x_GRAAL->Fill(m_time[ihit]);
263 else if(m_view[ihit] == 3) {
264 if(m_plane[ihit] == 0) {
265 hcharge_L1_v_GRAAL->Fill(m_charge[ihit]);
266 htime_L1_v_GRAAL->Fill(m_time[ihit]);
267 hstripid_L1_v_GRAAL->Fill(m_strip[ihit] -1);
270 else if(m_plane[ihit] == 1 || m_plane[ihit] == 2) {
271 hcharge_L2_v_GRAAL->Fill(m_charge[ihit]);
272 htime_L2_v_GRAAL->Fill(m_time[ihit]);
273 if(m_strip[ihit] == 539 || m_strip[ihit] == 1617) cout <<
"ERROR stripID " << m_strip[ihit] << endl;
277 else if(m_strip[ihit] > 1617) hstripid_L2_v_GRAAL->Fill(2*
CgemID::getVSTRIP_MAX(1) - m_strip[ihit] + 2);
283 hnhit_L1_x_GRAAL->Fill(nhit_L1_x);
284 hnhit_L2_x_GRAAL->Fill(nhit_L2_x);
285 hnhit_L1_v_GRAAL->Fill(nhit_L1_v);
286 hnhit_L2_v_GRAAL->Fill(nhit_L2_v);
289 if(CosmicRayDataSetID ==
"CR202001") {
291 Tdigi->GetEntry(Ind_Entry_D);
300 for(
int ihit = 0; ihit < m_nGemHit; ihit++) {
302 if(m_view[ihit] == 2) {
303 if(m_plane[ihit] == 0) {
304 hcharge_L1_x_GRAAL->Fill(m_charge[ihit]);
305 htime_L1_x_GRAAL->Fill(m_time[ihit]);
309 else if(m_plane[ihit] == 1 || m_plane[ihit] == 2) {
310 hcharge_L2_x_GRAAL->Fill(m_charge[ihit]);
311 htime_L2_x_GRAAL->Fill(m_time[ihit]);
317 else if(m_view[ihit] == 3) {
318 if(m_plane[ihit] == 0) {
319 hcharge_L1_v_GRAAL->Fill(m_charge[ihit]);
320 htime_L1_v_GRAAL->Fill(m_time[ihit]);
324 else if(m_plane[ihit] == 1 || m_plane[ihit] == 2) {
325 hcharge_L2_v_GRAAL->Fill(m_charge[ihit]);
326 htime_L2_v_GRAAL->Fill(m_time[ihit]);
334 hnhit_L1_x_GRAAL->Fill(nhit_L1_x);
335 hnhit_L2_x_GRAAL->Fill(nhit_L2_x);
336 hnhit_L1_v_GRAAL->Fill(nhit_L1_v);
337 hnhit_L2_v_GRAAL->Fill(nhit_L2_v);
348void TestInputOutput::CheckIO() {
351 cout <<
"tests: 1 = OK; 0 = WRONG" << endl;
352 cout <<
"1 - check entries" << endl;
354 cout <<
"nhit L1 x " << (hnhit_L1_x->GetEntries() == hnhit_L1_x_GRAAL->GetEntries() ) << endl;
355 cout <<
"nhit L2 x " << (hnhit_L2_x->GetEntries() == hnhit_L2_x_GRAAL->GetEntries() ) << endl;
356 cout <<
"nhit L1 v " << (hnhit_L1_v->GetEntries() == hnhit_L1_v_GRAAL->GetEntries() ) << endl;
357 cout <<
"nhit L2 v " << (hnhit_L2_v->GetEntries() == hnhit_L2_v_GRAAL->GetEntries() ) << endl;
360 cout <<
"stripid L1 x " << (hstripid_L1_x->GetEntries() == hstripid_L1_x_GRAAL->GetEntries() ) << endl;
361 cout <<
"stripid L2 x " << (hstripid_L2_x->GetEntries() == hstripid_L2_x_GRAAL->GetEntries() ) << endl;
362 cout <<
"stripid L1 v " << (hstripid_L1_v->GetEntries() == hstripid_L1_v_GRAAL->GetEntries() ) << endl;
363 cout <<
"stripid L2 v " << (hstripid_L2_v->GetEntries() == hstripid_L2_v_GRAAL->GetEntries() ) << endl;
366 cout <<
"time L1 x " << (htime_L1_x->GetEntries() == htime_L1_x_GRAAL->GetEntries() ) << endl;
367 cout <<
"time L2 x " << (htime_L2_x->GetEntries() == htime_L2_x_GRAAL->GetEntries() ) << endl;
368 cout <<
"time L1 v " << (htime_L1_v->GetEntries() == htime_L1_v_GRAAL->GetEntries() ) << endl;
369 cout <<
"time L2 v " << (htime_L2_v->GetEntries() == htime_L2_v_GRAAL->GetEntries() ) << endl;
372 cout <<
"charge L1 x " << (hcharge_L1_x->GetEntries() == hcharge_L1_x_GRAAL->GetEntries() ) << endl;
373 cout <<
"charge L2 x " << (hcharge_L2_x->GetEntries() == hcharge_L2_x_GRAAL->GetEntries() ) << endl;
374 cout <<
"charge L1 v " << (hcharge_L1_v->GetEntries() == hcharge_L1_v_GRAAL->GetEntries() ) << endl;
375 cout <<
"charge L2 v " << (hcharge_L2_v->GetEntries() == hcharge_L2_v_GRAAL->GetEntries() ) << endl;
377 cout <<
"2 - check mean values" << endl;
379 cout <<
"nhit L1 x " << (hnhit_L1_x->GetMean() == hnhit_L1_x_GRAAL->GetMean() ) << endl;
380 cout <<
"nhit L2 x " << (hnhit_L2_x->GetMean() == hnhit_L2_x_GRAAL->GetMean() ) << endl;
381 cout <<
"nhit L1 v " << (hnhit_L1_v->GetMean() == hnhit_L1_v_GRAAL->GetMean() ) << endl;
382 cout <<
"nhit L2 v " << (hnhit_L2_v->GetMean() == hnhit_L2_v_GRAAL->GetMean() ) << endl;
385 cout <<
"stripid L1 x " << (hstripid_L1_x->GetMean() == hstripid_L1_x_GRAAL->GetMean() ) << endl;
386 cout <<
"stripid L2 x " << (hstripid_L2_x->GetMean() == hstripid_L2_x_GRAAL->GetMean() ) << endl;
387 cout <<
"stripid L1 v " << (hstripid_L1_v->GetMean() == hstripid_L1_v_GRAAL->GetMean() ) << endl;
388 cout <<
"stripid L2 v " << (hstripid_L2_v->GetMean() == hstripid_L2_v_GRAAL->GetMean() ) << endl;
391 cout <<
"time L1 x " << (htime_L1_x->GetMean() == htime_L1_x_GRAAL->GetMean() ) << endl;
392 cout <<
"time L2 x " << (htime_L2_x->GetMean() == htime_L2_x_GRAAL->GetMean() ) << endl;
393 cout <<
"time L1 v " << (htime_L1_v->GetMean() == htime_L1_v_GRAAL->GetMean() ) << endl;
394 cout <<
"time L2 v " << (htime_L2_v->GetMean() == htime_L2_v_GRAAL->GetMean() ) << endl;
397 cout <<
"charge L1 x " << (hcharge_L1_x->GetMean() == hcharge_L1_x_GRAAL->GetMean() ) << endl;
398 cout <<
"charge L2 x " << (hcharge_L2_x->GetMean() == hcharge_L2_x_GRAAL->GetMean() ) << endl;
399 cout <<
"charge L1 v " << (hcharge_L1_v->GetMean() == hcharge_L1_v_GRAAL->GetMean() ) << endl;
400 cout <<
"charge L2 v " << (hcharge_L2_v->GetMean() == hcharge_L2_v_GRAAL->GetMean() ) << endl;
402 cout <<
"3 - check RMS values" << endl;
404 cout <<
"nhit L1 x " << (hnhit_L1_x->GetRMS() == hnhit_L1_x_GRAAL->GetRMS() ) << endl;
405 cout <<
"nhit L2 x " << (hnhit_L2_x->GetRMS() == hnhit_L2_x_GRAAL->GetRMS() ) << endl;
406 cout <<
"nhit L1 v " << (hnhit_L1_v->GetRMS() == hnhit_L1_v_GRAAL->GetRMS() ) << endl;
407 cout <<
"nhit L2 v " << (hnhit_L2_v->GetRMS() == hnhit_L2_v_GRAAL->GetRMS() ) << endl;
410 cout <<
"stripid L1 x " << (hstripid_L1_x->GetRMS() == hstripid_L1_x_GRAAL->GetRMS() ) << endl;
411 cout <<
"stripid L2 x " << (hstripid_L2_x->GetRMS() == hstripid_L2_x_GRAAL->GetRMS() ) << endl;
412 cout <<
"stripid L1 v " << (hstripid_L1_v->GetRMS() == hstripid_L1_v_GRAAL->GetRMS() ) << endl;
413 cout <<
"stripid L2 v " << (hstripid_L2_v->GetRMS() == hstripid_L2_v_GRAAL->GetRMS() ) << endl;
416 cout <<
"time L1 x " << (htime_L1_x->GetRMS() == htime_L1_x_GRAAL->GetRMS() ) << endl;
417 cout <<
"time L2 x " << (htime_L2_x->GetRMS() == htime_L2_x_GRAAL->GetRMS() ) << endl;
418 cout <<
"time L1 v " << (htime_L1_v->GetRMS() == htime_L1_v_GRAAL->GetRMS() ) << endl;
419 cout <<
"time L2 v " << (htime_L2_v->GetRMS() == htime_L2_v_GRAAL->GetRMS() ) << endl;
422 cout <<
"charge L1 x " << (hcharge_L1_x->GetRMS() == hcharge_L1_x_GRAAL->GetRMS() ) << endl;
423 cout <<
"charge L2 x " << (hcharge_L2_x->GetRMS() == hcharge_L2_x_GRAAL->GetRMS() ) << endl;
424 cout <<
"charge L1 v " << (hcharge_L1_v->GetRMS() == hcharge_L1_v_GRAAL->GetRMS() ) << endl;
425 cout <<
"charge L2 v " << (hcharge_L2_v->GetRMS() == hcharge_L2_v_GRAAL->GetRMS() ) << endl;
428 cout <<
"4 - check differences" << endl;
430 hnhit_L1_x->Add(hnhit_L1_x_GRAAL, -1);
431 hnhit_L2_x->Add(hnhit_L2_x_GRAAL, -1);
432 hnhit_L1_v->Add(hnhit_L1_v_GRAAL, -1);
433 hnhit_L2_v->Add(hnhit_L2_v_GRAAL, -1);
434 cout <<
"diff nhit L1 x: min= " << hnhit_L1_x->GetMinimum() <<
" max= " << hnhit_L1_x->GetMaximum() << endl;
435 cout <<
"diff nhit L2 x: min= " << hnhit_L2_x->GetMinimum() <<
" max= " << hnhit_L2_x->GetMaximum() << endl;
436 cout <<
"diff nhit L1 v: min= " << hnhit_L1_v->GetMinimum() <<
" max= " << hnhit_L1_v->GetMaximum() << endl;
437 cout <<
"diff nhit L2 v: min= " << hnhit_L2_v->GetMinimum() <<
" max= " << hnhit_L2_v->GetMaximum() << endl;
440 hstripid_L1_x->Add(hstripid_L1_x_GRAAL, -1);
441 hstripid_L2_x->Add(hstripid_L2_x_GRAAL, -1);
442 hstripid_L1_v->Add(hstripid_L1_v_GRAAL, -1);
443 hstripid_L2_v->Add(hstripid_L2_v_GRAAL, -1);
444 cout <<
"diff stripid L1 x: min= " << hstripid_L1_x->GetMinimum() <<
" max= " << hstripid_L1_x->GetMaximum() << endl;
445 cout <<
"diff stripid L2 x: min= " << hstripid_L2_x->GetMinimum() <<
" max= " << hstripid_L2_x->GetMaximum() << endl;
446 cout <<
"diff stripid L1 v: min= " << hstripid_L1_v->GetMinimum() <<
" max= " << hstripid_L1_v->GetMaximum() << endl;
447 cout <<
"diff stripid L2 v: min= " << hstripid_L2_v->GetMinimum() <<
" max= " << hstripid_L2_v->GetMaximum() << endl;
450 htime_L1_x->Add(htime_L1_x_GRAAL, -1);
451 htime_L2_x->Add(htime_L2_x_GRAAL, -1);
452 htime_L1_v->Add(htime_L1_v_GRAAL, -1);
453 htime_L2_v->Add(htime_L2_v_GRAAL, -1);
454 cout <<
"diff time L1 x: min= " << htime_L1_x->GetMinimum() <<
" max= " << htime_L1_x->GetMaximum() << endl;
455 cout <<
"diff time L2 x: min= " << htime_L2_x->GetMinimum() <<
" max= " << htime_L2_x->GetMaximum() << endl;
456 cout <<
"diff time L1 v: min= " << htime_L1_v->GetMinimum() <<
" max= " << htime_L1_v->GetMaximum() << endl;
457 cout <<
"diff time L2 v: min= " << htime_L2_v->GetMinimum() <<
" max= " << htime_L2_v->GetMaximum() << endl;
461 hcharge_L1_x->Add(hcharge_L1_x_GRAAL, -1);
462 hcharge_L2_x->Add(hcharge_L2_x_GRAAL, -1);
463 hcharge_L1_v->Add(hcharge_L1_v_GRAAL, -1);
464 hcharge_L2_v->Add(hcharge_L2_v_GRAAL, -1);
465 cout <<
"diff charge L1 x: min= " << hcharge_L1_x->GetMinimum() <<
" max= " << hcharge_L1_x->GetMaximum() << endl;
466 cout <<
"diff charge L2 x: min= " << hcharge_L2_x->GetMinimum() <<
" max= " << hcharge_L2_x->GetMaximum() << endl;
467 cout <<
"diff charge L1 v: min= " << hcharge_L1_v->GetMinimum() <<
" max= " << hcharge_L1_v->GetMaximum() << endl;
468 cout <<
"diff charge L2 v: min= " << hcharge_L2_v->GetMinimum() <<
" max= " << hcharge_L2_v->GetMaximum() << endl;
static int strip(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)