-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLargeBarrelMapping.cpp
More file actions
65 lines (64 loc) · 2.71 KB
/
LargeBarrelMapping.cpp
File metadata and controls
65 lines (64 loc) · 2.71 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
#include <algorithm>
#include "LargeBarrelMapping.h"
using namespace std;
const double degFullCircle = 360.;
LargeBarrelMapping::LargeBarrelMapping(){}
LargeBarrelMapping::~LargeBarrelMapping(){}
LargeBarrelMapping::LargeBarrelMapping(const JPetParamBank& paramBank){
buildMappings(paramBank);
}
int LargeBarrelMapping::getLayerNumber(const JPetLayer& layer) const{
return fRadiusToLayer.at(layer.getRadius());//??????? it's very strange thing
}
int LargeBarrelMapping::getNumberOfSlots(const JPetLayer& layer) const {
return fNumberOfSlotsInLayer.at(fRadiusToLayer.at(layer.getRadius()) - 1);//??????? it's very strange thing
}
int LargeBarrelMapping::getNumberOfSlots(int layerNumber) const {
return fNumberOfSlotsInLayer.at(layerNumber-1);
}
int LargeBarrelMapping::getSlotNumber(const JPetBarrelSlot& slot) const{
return fThetaToSlot[getLayerNumber(slot.getLayer())-1].at(slot.getTheta());
}
int LargeBarrelMapping::calcDeltaID(const JPetHit& hit1,const JPetHit& hit2) const{
if(hit1.getBarrelSlot().getLayer().getId()==hit2.getBarrelSlot().getLayer().getId()){
int delta_ID = abs(getSlotNumber(hit1.getBarrelSlot())-getSlotNumber(hit2.getBarrelSlot()));
int layer_size = getNumberOfSlots(hit1.getBarrelSlot().getLayer());
int half_layer_size = layer_size/2;
if( delta_ID > half_layer_size ) return layer_size-delta_ID;
return delta_ID;
}
return -1;//maybe throwing an exception would be a better solution?
}
void LargeBarrelMapping::buildMappings(const JPetParamBank& paramBank){
vector<double> layersRadii;
vector<vector<double> > slotsTheta;
for(auto & layer : paramBank.getLayers() ){
double radius = layer.second->getRadius();
layersRadii.push_back(radius);
fNumberOfSlotsInLayer.push_back(0);
map<double, int> slots_map;
fThetaToSlot.push_back(slots_map);
vector<double> slots_theta;
slotsTheta.push_back(slots_theta);
}
sort( layersRadii.begin(), layersRadii.end(),less<double>() );
int layer_counter = 1;
for(const auto & radius : layersRadii ){
fRadiusToLayer[ radius ] = layer_counter++;
}
for(const auto & slot : paramBank.getBarrelSlots()){
int layer_number = getLayerNumber( slot.second->getLayer() );
fNumberOfSlotsInLayer[layer_number-1]++;
slotsTheta[layer_number-1].push_back(slot.second->getTheta());
}
vector<int> slotCounters;
int layerNumber = 1;
for(auto & thetas : slotsTheta){
slotCounters.push_back(1);
sort( thetas.begin(), thetas.end(), less<double>() );
for(const double&theta : thetas){
fThetaToSlot[layerNumber-1][theta] = slotCounters[layerNumber-1]++;
}
layerNumber++;
}
}