16 #include "FairRootManager.h"
17 #include "FairRunAna.h"
18 #include "FairRuntimeDb.h"
20 #include "TClonesArray.h"
60 display =
new TCanvas(
"display",
"display", 0, 0, 800, 800);
62 hxy =
new TH2F(
"hxy",
"xy plane", 130, -65, 65, 130, -65, 65);
63 hxy1 =
new TH2F(
"hxy1",
"xy plane 1", 76, -38, 38, 76, -38, 38);
64 hxy2 =
new TH2F(
"hxy2",
"xy plane 2", 94, -47, 47, 94, -47, 47);
65 hxy3 =
new TH2F(
"hxy3",
"xy plane 3", 130, -65, 65, 130, -65, 65);
71 std::map< int, bool > hitTousability;
74 cerr <<
"PndTrkGemCombinatorial::CombinatorialSuppression youwant evaluate performances but you did not set the mc TCA!" << endl;
75 return hitTousability;
78 if(
fVerbose) cout <<
"---------------------- " << endl;
79 double distlimit = 999;
83 std::map< int, int > hitidTopos;
84 std::multimap< int, int > posTohitid;
85 std::multimap< int, int > posTohitid1;
86 std::multimap< int, int > posTohitid2;
96 for(
int ihit = 0; ihit <
fGemHitArray->GetEntriesFast(); ihit++) {
100 if(hit->GetRefIndex() == -1)
nunasso++;
111 int posid = (sensid + 2 * (statid - 1)) - 1;
114 hitidTopos[ihit] = posid;
115 posTohitid.insert(std::pair<int, int>(posid, ihit));
118 if(sensid == 1) posTohitid1.insert(std::pair<int, int>(posid, ihit));
119 else posTohitid2.insert(std::pair<int, int>(posid, ihit));
146 std::multimap< int, int >::iterator it1;
147 std::multimap< int, int >::iterator it2;
149 std::multimap< int, std::pair< int, double > > hit1Topairhit2_distance;
150 std::multimap< int, std::pair< int, double > > hit2Topairhit1_distance;
151 std::vector< int > alone1;
152 std::vector< int > alone2;
154 for (it1 = posTohitid1.begin(); it1 != posTohitid1.end(); ++it1) {
155 int posid1 = (*it1).first;
156 int posid2 = posid1 + 1;
157 int hitid1 = (*it1).second;
161 std::pair < std::multimap < int, int >::iterator, std::multimap< int, int >::iterator > ret;
162 ret = posTohitid2.equal_range(posid2);
164 for (it2 = ret.first; it2 != ret.second; ++it2) {
167 int hitid2 = (*it2).second;
168 if(hitid1 == hitid2)
continue;
170 TVector2 pos2 = hit2->GetPosition().XYvector();
173 double distancexy = (pos2 - pos1).Mod();
174 std::pair< int, double > hit2_distance(hitid2, distancexy);
175 hit1Topairhit2_distance.insert(std::pair<
int, std::pair< int, double > > (hitid1, hit2_distance));
176 std::pair< int, double > hit1_distance(hitid1, distancexy);
177 hit2Topairhit1_distance.insert(std::pair<
int, std::pair< int, double > > (hitid2, hit1_distance));
180 if(hit1Topairhit2_distance.count(hitid1) == 0) alone1.push_back(hitid1);
181 if(
fVerbose) cout <<
"---> pos 1 hit " << hitid1 <<
" has counts " << hit1Topairhit2_distance.count(hitid1) << endl;
184 for(
size_t ihit = 0; ihit < alone1.size(); ihit++) {
186 if(
fVerbose) cout <<
"**********alone1 " << alone1[ihit] <<
" " << hit1->GetRefIndex() << endl;
189 for (it2 = posTohitid2.begin(); it2 != posTohitid2.end(); ++it2) {
190 int hitid2 = (*it2).second;
191 if(hit2Topairhit1_distance.count(hitid2) == 0) alone2.push_back(hitid2);
192 if(
fVerbose) cout <<
"---> pos 2 hit " << hitid2 <<
" has counts " << hit2Topairhit1_distance.count(hitid2) << endl;
195 for(
size_t ihit = 0; ihit < alone2.size(); ihit++) {
197 if(
fVerbose) cout <<
"**********alone2 " << alone2[ihit] <<
" " << hit2->GetRefIndex() << endl;
202 std::multimap< int, std::pair< int, double > >::iterator iter;
206 int tmpdigi1[2] = {-1, -1};
207 int tmpdigi2[2] = {-1, -1};
209 double tmpdistance = 1000;
210 std::map< int, std::pair< int, double > > chosenmap;
211 std::multimap< int, int > digiTohitid1;
212 std::multimap< int, int > digiTohitid2;
213 for (iter = hit1Topairhit2_distance.begin(); iter != hit1Topairhit2_distance.end(); ++iter) {
215 int hitid1 = (*iter).first;
216 int hitid2 = ((*iter).second).first;
217 double distance = ((*iter).second).second;
218 if(
fVerbose) cout <<
"hit1: " << hitid1 <<
" associated to hit2: " << hitid2 <<
" with dist " << distance << endl;
220 if(tmphitid1 == -1) tmphitid1 = hitid1;
222 if(hitid1 == tmphitid1) {
223 if(distance < tmpdistance) {
224 tmpdistance = distance;
230 tmpdigi2[0] = hit2->GetDigiNr(0);
231 tmpdigi2[1] = hit2->GetDigiNr(1);
235 if(tmpdistance < distlimit) {
236 if(
fVerbose) cout <<
"chosen " << tmphitid1 <<
" " << tmphitid2 <<
" " << tmpdistance << endl;
237 chosenmap[tmphitid1] = std::pair< int, double >(tmphitid2, tmpdistance);
238 chosenmap[tmphitid2] = std::pair< int, double >(tmphitid1, tmpdistance);
242 digiTohitid1.insert(std::pair< int, int >(tmpdigi1[0], tmphitid1));
243 digiTohitid1.insert(std::pair< int, int >(tmpdigi1[1], tmphitid1));
244 digiTohitid2.insert(std::pair< int, int >(tmpdigi2[0], tmphitid2));
245 digiTohitid2.insert(std::pair< int, int >(tmpdigi2[1], tmphitid2));
247 tmpdistance = distance;
254 tmpdigi2[0] = hit2->GetDigiNr(0);
255 tmpdigi2[1] = hit2->GetDigiNr(1);
262 if(tmpdistance < distlimit) {
263 if(
fVerbose) cout <<
"chosen " << tmphitid1 <<
" " << tmphitid2 <<
" " << tmpdistance << endl;
264 chosenmap[tmphitid1] = std::pair< int, double >(tmphitid2, tmpdistance);
265 chosenmap[tmphitid2] = std::pair< int, double >(tmphitid1, tmpdistance);
269 digiTohitid1.insert(std::pair< int, int >(tmpdigi1[0], tmphitid1));
270 digiTohitid1.insert(std::pair< int, int >(tmpdigi1[1], tmphitid1));
271 digiTohitid2.insert(std::pair< int, int >(tmpdigi2[0], tmphitid2));
272 digiTohitid2.insert(std::pair< int, int >(tmpdigi2[1], tmphitid2));
275 std::map< int, int >::iterator ditr;
278 std::map< int, std::pair< int, double > > chosenmap2;
279 for (ditr = digiTohitid1.begin(); ditr != digiTohitid1.end(); ++ditr) {
280 int digiid = (*ditr).first;
281 if(digiid == tmpdigiid)
continue;
284 int ntimes = digiTohitid1.count(digiid);
286 std::pair < std::multimap< int, int >::iterator, std::multimap< int, int >::iterator > ret2;
287 ret2 = digiTohitid1.equal_range(digiid);
288 std::multimap< int, int >::iterator itr3;
290 int tmphit1 = -1, tmphit2 = -1 ;
291 double tmpdist = 1000;
292 for (itr3 = ret2.first; itr3 != ret2.second; ++itr3) {
293 int hitid1 = (*itr3).second;
294 int hitid2 = chosenmap[hitid1].first;
295 double distance = chosenmap[hitid1].second;
296 if(distance < tmpdist) {
303 chosenmap2[tmphit1] = std::pair< int, double >(tmphit2, tmpdist);
304 chosenmap2[tmphit2] = std::pair< int, double >(tmphit1, tmpdist);
307 int hitid1 = (*ditr).second;
308 int hitid2 = chosenmap[hitid1].first;
309 double distance = chosenmap[hitid1].second;
310 chosenmap2[hitid1] = std::pair< int, double >(hitid2, distance);
311 chosenmap2[hitid2] = std::pair< int, double >(hitid1, distance);
317 std::map< int, std::pair < int, double > >::iterator citr;
318 for (citr = chosenmap2.begin(); citr != chosenmap2.end(); ++citr) {
319 if(
fVerbose) cout << (*citr).first <<
" finally associated to " << ((*citr).second).first <<
" with dist " << ((*citr).second).second << endl;
336 std::vector< int > dontuse;
337 for(
int ihit = 0; ihit <
fGemHitArray->GetEntriesFast(); ihit++) {
338 hitTousability[ihit] =
true;
339 if(chosenmap2.count(ihit) > 0)
continue;
340 dontuse.push_back(ihit);
341 hitTousability[ihit] =
false;
345 for(
size_t ihit = 0; ihit < dontuse.size(); ihit++) {
347 if(
fVerbose) cout <<
"dontuse " << dontuse[ihit] <<
" " << hit->GetRefIndex() << endl;
357 mrk->SetMarkerColor(kRed);
376 cout <<
"TOTAL HITS " <<
nhits <<
" TOTAL MC POINTS " <<
npoints << endl;
377 cout <<
"ASSO " <<
nasso <<
" UN-ASSO " <<
nunasso << endl;
385 cout <<
"TOTAL number of hits = " <<
nhits <<
" of which " << 100. *
nasso/
nhits <<
"% TRUE, " << 100. *
nunasso/
nhits <<
"% FAKE" << endl;
396 return hitTousability;
401 if(
hxy == NULL)
hxy =
new TH2F(
"hxy",
"xy plane", 110, -55, 55, 110, -55, 55);
403 if(
hxy1 == NULL)
hxy1 =
new TH2F(
"hxy1",
"xy plane 1", 110, -55, 55, 110, -55, 55);
405 if(
hxy2 == NULL)
hxy2 =
new TH2F(
"hxy2",
"xy plane 2", 110, -55, 55, 110, -55, 55);
407 if(
hxy3 == NULL)
hxy3 =
new TH2F(
"hxy3",
"xy plane 3", 110, -55, 55, 110, -55, 55);
410 hxy1->SetStats(kFALSE);
413 hxy2->SetStats(kFALSE);
416 hxy3->SetStats(kFALSE);
419 hxy->SetStats(kFALSE);
428 for(
int ipnt = 0; ipnt <
fGemPointArray->GetEntriesFast(); ipnt++) {
434 if(sensid == 273 || sensid == 289) statid = 1;
435 else if(sensid == 529 || sensid == 545) statid = 2;
436 if(sensid == 785 || sensid == 801) statid = 3;
439 point->Position(pos);
440 TMarker *mrk =
new TMarker(pos.X(), pos.Y(), 3);
442 mrk->SetMarkerColor(kBlue);
TClonesArray * fGemHitArray
TClonesArray * fGemPointArray
~PndTrkGemCombinatorial()
Int_t GetSensorNr() const
std::map< int, bool > CombinatorialSuppression()
Int_t GetSensorId() const
Int_t GetStationNr() const
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
TVector3 GetPosition() const
Int_t GetDigiNr(Int_t iside) const