#include "MapsSensor.hh" #include #include #include #include #include #include #include #include "TFile.h" #include "TH2F.h" #include "TRandom2.h" void printSensor(MapsSensor* s) { std::cout << *s << "\n"; } void isDead(MapsSensor* s, std::pair input) { if (s->isDeadArea(input)) std::cout << "Sensor " << s->id() << " reports area dead.\n"; else std::cout << "Sensor " << s->id() << " reports area alive.\n"; } struct testArea : public std::binary_function, bool> { bool operator()(MapsSensor* s, std::pair p) const { //std::cout << *s << ":\t dead at " << p << "?\t"; if (s->isDeadArea(p)) { //std::cout << "Yes.\n"; s->registerTrackMiss(0, p, 0); } //else //std::cout << "No.\n"; return s->isDeadArea(p); } }; int main() { std::cout << "Wilkommen to ze RotationTest\n"; double pi = 3.14159265358979323846; std::vector sensors; MapsSensor* s0 = new MapsSensor(0, 0, 0); MapsSensor* s90 = new MapsSensor(1, 10, pi/2.0); MapsSensor* s180 = new MapsSensor(2, 20, pi); MapsSensor* s270 = new MapsSensor(3, 30, 1.5*pi); sensors.push_back(s0); sensors.push_back(s90); sensors.push_back(s180); sensors.push_back(s270); std::pair testC1(167, 0); std::cout << "Each sensor takes " << testC1 << " to...\n"; for(std::vector::iterator it = sensors.begin(); it != sensors.end(); ++it) { std::pair transform; MapsSensor* s = *it; s->convertHitToPhysical(testC1, transform); std::cout << *s << "\t ---> " << transform << "\n"; } //test zero degree case first std::cout << "Testing zero degree case...\n"; std::pair input(2.40, 3.0); bool isDead0 = s0->isDeadArea(input); std::cout << *s0 << " reports " << input<< " is dead?\t" << isDead0 << "\n"; std::for_each(sensors.begin(), sensors.end(), printSensor); std::for_each(sensors.begin(), sensors.end(), std::mem_fun(&MapsSensor::id)); int howMany = std::count_if(sensors.begin(), sensors.end(), std::bind2nd( testArea(), input)); std::cout << "Hoy many have sensors report dead areas for that hit?:\t" << howMany << "\n"; TFile* f = new TFile("RotationTest.root", "recreate"); TH2F hExclusion("hExclusion", "Mutual exclusion areas", 1000, -5.0, 5.0, 1000, -5.0, 5.0); TRandom2 rand; std::pair place; for (unsigned u(0); u < 100000; ++u) { place.first = rand.Uniform(10.0) - 5.0; place.second = rand.Uniform(10.0) - 5.0; int deathCount = std::count_if(sensors.begin(), sensors.end(), std::bind2nd(testArea(), place)); if (deathCount > 0) hExclusion.Fill(place.first, place.second); } TH2F s0x("hS0XMapping", "hS0XMapping", 168, 0, 168, 1000, -5.0, 5.0); TH2F s90x("hS90XMapping", "hS90XMapping", 168, 0, 168, 1000, -5.0, 5.0); TH2F s0y("hS0YMapping", "hS0YMapping", 168, 0, 168, 1000, -5.0, 5.0); TH2F s90y("hS90YMapping", "hS90YMapping", 168, 0, 168, 1000, -5.0, 5.0); for (unsigned k(0); k < 168; ++k) { std::pair h(k, k); std::pair p; s0->convertHitToPhysical(h, p); s0x.Fill(h.first, p.first); s0y.Fill(h.second, p.second); s90->convertHitToPhysical(h, p); s90x.Fill(h.first, p.first); s90y.Fill(h.second, p.second); } s0y.Write(); s90y.Write(); s0x.Write(); s90x.Write(); TH2F a, b, c, d; s0->getInefficiencyXYPlot(a, true); s90->getInefficiencyXYPlot(b, true); s180->getInefficiencyXYPlot(c, true); s270->getInefficiencyXYPlot(d, true); a.Write(); b.Write(); c.Write(); d.Write(); hExclusion.Write(); f->Write(); f->Close(); }