19 cout <<
"PndSttHitCorrector::CorrectHits" << endl;
30 cout <<
"Calculation for tube: " << actualTubeId << endl;
33 vector<vector<double> > angles;
40 for (
size_t j = 0; j <
fHitNeighbors[actualTubeId].size(); j++) {
44 cout <<
"NeighborTube: " << neighborTubeId <<
" : " << endl;
56 if (bestPhi.size() == 2) {
57 double absDiff = abs(*bestPhi.begin() - *(++bestPhi.begin()));
63 *(++bestPhi.begin())));
69 }
else if (bestPhi.size() == 1) {
73 cout <<
"Found no good combination of tangent angles for tube "
74 << actualTubeId << endl;
81 cout <<
"Search for special positioning of 3 active neighbors" << endl;
82 map<int, set<double> > tmpTangentAngles;
94 if (midNeighbor != 0) {
106 cout <<
"current tube: " << currentTube <<
", midNeighbor: "
107 << midNeighbor <<
", angles: "
108 << phi1 * TMath::RadToDeg() <<
", "
109 << phi2 * TMath::RadToDeg() << endl;
115 cout <<
"Initialization done. Current fTangentAngles: " << endl;
117 cout <<
"Adaption of angles: " << endl;
123 set<int> tubesToCheck;
125 for (
int i = 2;
i < 5; ++
i) {
131 tubesToCheck.insert(actualTubeId);
137 set<int> tmpTubesToCheck;
138 bool anglesChanged =
true;
141 while (anglesChanged) {
144 cout <<
"start loop - adaption of angles" << endl;
145 cout <<
"tubes to Check: " << tubesToCheck.size() << endl;
148 anglesChanged =
false;
149 tmpTubesToCheck.clear();
151 for (set<int>::iterator it = tubesToCheck.begin();
152 it != tubesToCheck.end(); ++it) {
158 int actualTubeId = *it;
163 cout <<
"currentTube: " << actualTubeId << endl;
166 if (straightNeighbors.first != 0) {
169 int unambiguousNeighbor = 0;
177 != straightNeighbors.first
179 != straightNeighbors.second)
188 straightNeighbors.first)) {
189 unambiguousNeighbor = straightNeighbors.first;
193 straightNeighbors.second)) {
194 unambiguousNeighbor = straightNeighbors.second;
203 unambiguousNeighbor = straightNeighbors.first;
206 straightNeighbors.second)) {
208 unambiguousNeighbor = straightNeighbors.second;
212 if (unambiguousNeighbor != 0) {
214 cout <<
"unambiguous neighbor: "
215 << unambiguousNeighbor << endl;
231 > secondNeigh->GetIsochrone()) {
238 <<
"isochrone is not the smallest one --> keep similar"
242 /
min(secondNeigh->GetIsochrone(),
252 cout <<
"nearly equal isochrones for tube "
253 << actualTubeId <<
": actual "
256 << secondNeigh->GetIsochrone()
259 <<
"--> keep similar" << endl;
265 int biggestNeigh, otherNeigh;
267 > secondNeigh->GetIsochrone()) {
268 biggestNeigh = straightNeighbors.first;
269 otherNeigh = straightNeighbors.second;
271 biggestNeigh = straightNeighbors.second;
272 otherNeigh = straightNeighbors.first;
276 cout <<
"Isochrones (actual, first, second): "
279 << secondNeigh->GetIsochrone() << endl;
281 <<
"isochrone is the smallest one, biggest neighbor: "
282 << biggestNeigh << endl;
285 if (unambiguousNeighbor == biggestNeigh) {
297 cout <<
"keep similar, change neighbor "
298 << otherNeigh <<
" to opposite"
301 double otherAngle = similarAngle
323 <<
"keep opposite, change neighbor "
324 << otherNeigh <<
" to similar"
337 anglesChanged =
true;
339 cout <<
"angles changed for " << actualTubeId
344 tmpTubesToCheck.insert(actualTubeId);
346 cout <<
"try " << actualTubeId <<
" in next loop"
357 cout <<
"handle zigzag for tube " << actualTubeId
362 int unambiguousNeighor = 0;
365 unambiguousNeighor = firstNeigh;
367 unambiguousNeighor = secondNeigh;
370 if (unambiguousNeighor != 0) {
371 double similarAngle =
380 similarAngle = (similarAngle +
TMath::Pi());
392 cout <<
"unambiguous neighbor: "
393 << unambiguousNeighor <<
", angle: "
395 * TMath::RadToDeg() <<
", similar: "
396 << similarAngle * TMath::RadToDeg()
397 <<
", keep:" << best * TMath::RadToDeg()
402 tmpTubesToCheck.insert(actualTubeId);
404 cout <<
"try " << actualTubeId <<
" in next loop"
409 cout <<
"found no straight neighbors" << endl;
414 tubesToCheck.clear();
415 tubesToCheck = tmpTubesToCheck;
418 cout <<
"new fTangentAngles: " << endl;
425 for (vector<FairHit*>::iterator it =
fHits.begin(); it !=
fHits.end();
440 cout <<
"Result:" << endl;
std::map< int, int > fMapTubeIdToHit
const PndSttStrawMap * fStrawMap
const PndSttGeometryMap * fGeometryMap
bool HasUnambiguousAngle(int tubeID)
double GetDiffBetweenAngles(double angle1, double angle2)
double GetBestFittingAngle(double angle, std::set< double > anglesToTest)
std::pair< int, int > GetStraightNeighbors(int tubeID)
int GetMiddleHitNeighbor(int tubeID)
void KeepBestAngle(int tubeID, double angle)
std::map< int, std::vector< int > > fSeparations
std::map< int, std::vector< int > > fHitNeighbors
std::vector< double > CalculateTangentAngles(PndSttHit *tube1, PndSttHit *tube2)
Double_t GetIsochrone() const
bool IsSkewedStraw(int strawindex) const
std::map< int, std::set< double > > fTangentAngles
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
bool AreHitNeihbors(int tubeID1, int tubeID2)
void PrintTangentAngles()
double GetAngleBetweenTubes(int tubeID1, int tubeID2) const
double fIsochroneEquality
double GetAverageOfAngles(double angle1, double angle2)
std::set< double > GetBestCombinatedPhi(const std::vector< std::vector< double > > &angles)
std::vector< FairHit * > fHits