-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathpixel.cpp
More file actions
71 lines (58 loc) · 1.81 KB
/
pixel.cpp
File metadata and controls
71 lines (58 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// read csv
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <sstream>
// dependence
#include "pixel.h"
#include "edm4hep/RawTimeSeriesCollection.h"
// root
#include <TFile.h>
#include <TTree.h>
DECLARE_COMPONENT(PixelWrite)
PixelWrite::PixelWrite(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc)
{
declareProperty("RawTimeSeriesOut", m_hitCol);
}
StatusCode PixelWrite::initialize()
{
info() << "begin initialize PixelWrite" << endmsg;
// get file path
tree_file = new TFile("/afs/ihep.ac.cn/users/l/lishuqi/public/TB/AllSameTimeHitsLoose2_9.root", "READ");
if (!tree_file->IsOpen()) {
info() << "failed open file" << endmsg;
}
tree = (TTree*)tree_file->Get("TimeInfo");
tree->SetBranchAddress("timeChip", &timeChip);
tree->SetBranchAddress("planeID", &planeID);
tree->SetBranchAddress("row", &row);
tree->SetBranchAddress("col", &col);
info() << "Total Number of Events = " << tree->GetEntries() << endmsg;
return GaudiAlgorithm::initialize();
}
StatusCode PixelWrite::execute()
{
info() << "Executing Event " << eventid << endmsg;
tree->GetEntry(eventid);
auto hits = m_hitCol.createAndPut();
hits->setID(eventid);
int event_size = timeChip->size();
for (int i=0; i < event_size; i++){
auto hit = hits->create();
hit.setTime(timeChip->at(i));
// planeID:8,row:12,col:12
dd4hep::rec::CellID ncellid;
m_decoder.set(ncellid, "planeID", planeID->at(i));
m_decoder.set(ncellid, "row", row->at(i));
m_decoder.set(ncellid, "col", col->at(i));
hit.setCellID(ncellid);
}
eventid += 1;
return StatusCode::SUCCESS;
}
StatusCode PixelWrite::finalize()
{
info() << "finalize PixelWrite" << endmsg;
return GaudiAlgorithm::finalize();
}