/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus * * MAUS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MAUS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MAUS. If not, see . * */ #include "gtest/gtest.h" #include "stdint.h" #include "src/common_cpp/Recon/SciFi/SciFiLookup.hh" #include "src/common_cpp/DataStructure/Spill.hh" #include "src/common_cpp/DataStructure/MCEvent.hh" #include "src/common_cpp/DataStructure/ReconEvent.hh" #include "src/common_cpp/DataStructure/Hit.hh" #include "src/common_cpp/DataStructure/SciFiChannelId.hh" #include "src/common_cpp/DataStructure/SciFiEvent.hh" #include "src/common_cpp/DataStructure/SciFiDigit.hh" #include "src/common_cpp/DataStructure/SciFiNoiseHit.hh" namespace MAUS { class SciFiLookupTest : public ::testing::Test { protected: SciFiLookupTest() {} virtual ~SciFiLookupTest() {} virtual void SetUp() {} virtual void TearDown() {} }; TEST_F(SciFiLookupTest, test_get_digit_id) { // Set up a digit with an expected id number of 100012023 uint64_t id = 100012023; int event_num = 100; int tracker = 0; int station = 1; int plane = 2; int channel = 23; SciFiDigit* dig = new SciFiDigit(); dig->set_event(event_num); dig->set_tracker(tracker); dig->set_station(station); dig->set_plane(plane); dig->set_channel(channel); // Check the lookup output SciFiLookup lu; EXPECT_EQ(id, lu.get_digit_id(dig)); delete dig; } TEST_F(SciFiLookupTest, test_make_maps) { // Set up a digit with an expected id number of 100012023 uint64_t id = 100012023; int event_num = 100; int tracker = 0; int station = 1; int plane = 2; int channel = 23; SciFiDigit* dig = new SciFiDigit(); dig->set_event(event_num); dig->set_tracker(tracker); dig->set_station(station); dig->set_plane(plane); dig->set_channel(channel); // Set up corresponding hits for the digit std::vector *hits = new std::vector; SciFiHit* hit1 = new SciFiHit(); SciFiHit* hit2 = new SciFiHit(); SciFiChannelId *sfid1 = new SciFiChannelId(); SciFiChannelId *sfid2 = new SciFiChannelId(); sfid1->SetID(static_cast(id)); sfid2->SetID(static_cast(id)); hit1->SetChannelId(sfid1); hit2->SetChannelId(sfid2); hits->push_back(*hit1); hits->push_back(*hit2); // Set up a corresponding noise hit for the digit std::vector *noise = new std::vector; SciFiNoiseHit* nhit1 = new SciFiNoiseHit(); nhit1->SetID(static_cast(id)); noise->push_back(*nhit1); // Set up the correspoding MCEvent std::vector *mcevts = new std::vector; MCEvent *mcevt = new MCEvent(); mcevt->SetSciFiHits(hits); mcevt->SetSciFiNoiseHits(noise); mcevts->push_back(mcevt); // Set up the correspoding SciFiEvent SciFiEvent *sfevt = new SciFiEvent(); sfevt->add_digit(dig); // Set up the correspoding ReconEvent std::vector *revts = new std::vector; ReconEvent *revt = new ReconEvent(); revt->SetSciFiEvent(sfevt); revts->push_back(revt); // Set up the correspoding Spill Spill* spill = new Spill(); spill->SetMCEvents(mcevts); spill->SetReconEvents(revts); // Run the Lookup for the hits SciFiLookup lu; lu.make_hits_map(mcevt); std::vector out_hits; bool success = lu.get_hits(dig, out_hits); // Check the hits results ASSERT_TRUE(success); EXPECT_EQ(2, static_cast(out_hits.size())); // Run the Lookup for the noise lu.make_noise_map(mcevt); std::vector out_noise; success = lu.get_noise(dig, out_noise); // Check the noise results ASSERT_TRUE(success); EXPECT_EQ(1, static_cast(out_noise.size())); // Clean up delete spill; } } // ~namespace MAUS