-
Notifications
You must be signed in to change notification settings - Fork 0
/
EICutil.h
193 lines (126 loc) · 6.38 KB
/
EICutil.h
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* EICutil.h
*
* Created on: 11 maj 2023
* Author: Khaless
*/
#ifndef EICUTIL_H_
#define EICUTIL_H_
#include <vector>
#include <map>
#include "edm4hep/MCParticle.h"
#include "edm4hep/MCParticleData.h"
#include "edm4eic/CalorimeterHitData.h"
#include "edm4eic/CalorimeterHit.h"
#include "edm4hep/RawCalorimeterHitData.h"
#include "edm4hep/RawCalorimeterHit.h"
#include "edm4hep/SimCalorimeterHitData.h"
#include "edm4hep/SimCalorimeterHit.h"
using namespace std;
edm4hep::MCParticle GetMCParticle(edm4hep::MCParticleData mcpart_data);
int GetMCParentData(edm4hep::MCParticleData mcpart_data, vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCparents_data, vector<edm4hep::MCParticleData> *parents);
int GetMCDaughtersData(edm4hep::MCParticleData mcpart_data, vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCdaughters_data, vector<edm4hep::MCParticleData> *daughters);
edm4eic::CalorimeterHit GetCaloHit(edm4eic::CalorimeterHitData hitData);
edm4hep::RawCalorimeterHit GetCaloRawHit(edm4hep::RawCalorimeterHitData hitData);
edm4hep::SimCalorimeterHit GetCaloSimHit(edm4hep::SimCalorimeterHit hitData);
int GetCaloHitContributionsData(edm4hep::SimCalorimeterHitData hit_data, vector<edm4hep::CaloHitContributionData> *contribs_data, vector<podio::ObjectID> *relations_data, vector<edm4hep::CaloHitContributionData> *contributions);
edm4hep::CaloHitContribution GetCaloHitContribution(edm4hep::CaloHitContributionData calo_data);
int GetMCParticleDataFromCaloHitContributions(vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCparents_data, vector<edm4hep::MCParticleData> *parents);
int GetMCParticleIdFromCaloHitContributions(vector<podio::ObjectID> *MCparents_data, vector<unsigned> *parents);
int CreateMCParticleToCaloHitContributionMap(vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCparents_data, map<int, vector<int>> *map);
edm4hep::MCParticle GetMCParticle(edm4hep::MCParticleData mcpart_data)
{
edm4hep::MCParticle mcpart(mcpart_data.PDG, mcpart_data.generatorStatus, mcpart_data.simulatorStatus, mcpart_data.charge, mcpart_data.time, mcpart_data.mass, mcpart_data.vertex, mcpart_data.endpoint, mcpart_data.momentum, mcpart_data.momentumAtEndpoint, mcpart_data.spin, mcpart_data.colorFlow);
return mcpart;
}
int GetMCParentsData(edm4hep::MCParticleData mcpart_data, vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCparents_data, vector<edm4hep::MCParticleData> *parents)
{
for (int i = mcpart_data.parents_begin; i < mcpart_data.parents_end; ++i) {
unsigned parentID = MCparents_data->at(i).index;
edm4hep::MCParticleData mcpart_data_parent = MCParticles_data->at(parentID);
parents->push_back(mcpart_data_parent);
}
return 1.0;
}
int GetMCDaughtersData(edm4hep::MCParticleData mcpart_data, vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCdaughters_data, vector<edm4hep::MCParticleData> *daughters)
{
for (int i = mcpart_data.daughters_begin; i < mcpart_data.daughters_end; ++i) {
unsigned parentID = MCdaughters_data->at(i).index;
edm4hep::MCParticleData mcpart_data_daughter = MCParticles_data->at(parentID);
daughters->push_back(mcpart_data_daughter);
}
return 1.0;
}
edm4eic::CalorimeterHit GetCaloHit(edm4eic::CalorimeterHitData hitData)
{
edm4eic::CalorimeterHit hit(hitData.cellID, hitData.energy, hitData.energyError, hitData.time, hitData.timeError, hitData.position, hitData.dimension, hitData.sector, hitData.layer, hitData.local);
return hit;
}
edm4hep::RawCalorimeterHit GetCaloRecHit(edm4hep::RawCalorimeterHitData hitData)
{
edm4hep::RawCalorimeterHit hit(hitData.cellID, hitData.amplitude, hitData.timeStamp);
return hit;
}
edm4hep::SimCalorimeterHit GetCaloSimHit(edm4hep::SimCalorimeterHitData hitData)
{
edm4hep::SimCalorimeterHit hit(hitData.cellID, hitData.energy, hitData.position);
return hit;
}
int GetCaloHitContributionsData(edm4hep::SimCalorimeterHitData hit_data, vector<edm4hep::CaloHitContributionData> *contribs_data, vector<podio::ObjectID> *relations_data, vector<edm4hep::CaloHitContributionData> *contributions)
{
for (int i = hit_data.contributions_begin; i < hit_data.contributions_end; ++i) {
unsigned parentID = relations_data->at(i).index;
edm4hep::CaloHitContributionData contrib_data = contribs_data->at(parentID);
contributions->push_back(contrib_data);
}
return 1.0;
}
edm4hep::CaloHitContribution GetCaloHitContribution(edm4hep::CaloHitContributionData calo_data)
{
edm4hep::CaloHitContribution caloHitCont(calo_data.PDG, calo_data.energy, calo_data.time, calo_data.stepPosition);
return caloHitCont;
}
int GetMCParticleDataFromCaloHitContributions(vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCparents_data, vector<edm4hep::MCParticleData> *parents)
{
//for (int i = calo_data.parents_begin; i < calo_data.parents_end; ++i) {
for (int i = 0; i < MCparents_data->size(); ++i) {
unsigned parentID = MCparents_data->at(i).index;
edm4hep::MCParticleData mcpart_data_parent = MCParticles_data->at(parentID);
parents->push_back(mcpart_data_parent);
}
return 1.0;
}
int GetMCParticleIdFromCaloHitContributions(vector<podio::ObjectID> *MCparents_data, vector<unsigned> *parents)
{
//for (int i = calo_data.parents_begin; i < calo_data.parents_end; ++i) {
for (int i = 0; i < MCparents_data->size(); ++i) {
unsigned parentID = MCparents_data->at(i).index;
//edm4hep::MCParticleData mcpart_data_parent = MCParticles_data->at(parentID);
parents->push_back(parentID);
}
return 1.0;
}
int CreateMCParticleToCaloHitContributionMap(vector<edm4hep::MCParticleData> *MCParticles_data, vector<podio::ObjectID> *MCparents_data, map<int, vector<int>> *map_vec)
{
for (int i = 0; i < MCparents_data->size(); ++i) {
unsigned parentID = MCparents_data->at(i).index;
edm4hep::MCParticleData mcpart_data_parent = MCParticles_data->at(parentID);
map<int, vector<int>>::iterator it;
it = map_vec->find(parentID);
if (it != map_vec->end()) it->second.push_back(i);
else{
vector<int> vec = {i};
map_vec->insert(it, pair<int, vector<int>>(parentID, vec));
//cout<<"EICutil inserted = "<<parentID<<","<<i<<endl;
}
/*
it = map_vec->find(parentID);
cout<<"EICutil size[id="<<it->first<<"] ="<<it->second.size()<<endl;
for (int j = 0; j < it->second.size(); ++j) {
cout<<it->second[j]<<", ";
}
cout<<endl;*/
}
return 1.0;
}
#endif /* EICUTIL_H_ */