GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
AlphanumericHelper.cxx
Go to the documentation of this file.
2
4{
5 // get the channel map and loop over it, building a map of array number to channel address
6 // the NOLINT is there to keep clang-tidy from wrongly complaining that these variables need to be initialized
7 std::unordered_map<unsigned int, TChannel*>* channelMap = TChannel::GetChannelMap(); // NOLINT(cppcoreguidelines-init-variables)
8 std::cout << "Got " << channelMap->size() << " channels" << std::endl;
9 std::map<int, unsigned int> address; // NOLINT(cppcoreguidelines-init-variables)
10
11 for(auto channel : *channelMap) {
12 // use only GRIFFIN channels
13 if(channel.second->GetClassType() == TGriffin::Class()) {
14 // use only the "A" channel, not the "B" channel
15 if(channel.second->GetMnemonic()->OutputSensor() == TMnemonic::EMnemonic::kA) {
16 address[4 * (channel.second->GetDetectorNumber() - 1) + channel.second->GetCrystalNumber() + 1] = channel.second->GetAddress();
17 }
18 }
19 }
20
21 std::cout << "x-axis: " << address.rbegin()->first - address.begin()->first + 1 << " bins from " << address.begin()->first << " to " << address.rbegin()->first + 1 << std::endl;
22
23 // Define Histograms
24 fH2[slot]["EnergyVsChannel"] = new TH2D("EnergyVsChannel", "#gamma singles energy vs. channel", address.rbegin()->first - address.begin()->first + 1, address.begin()->first, address.rbegin()->first + 1, 4000, 0, 2000);
25 fH2[slot]["ChargeVsChannel"] = new TH2D("ChargeVsChannel", "#gamma singles charge vs. channel", address.rbegin()->first - address.begin()->first + 1, address.begin()->first, address.rbegin()->first + 1, 4000, 0, 4000);
26
27 for(int bin = 1; bin <= fH2[slot]["EnergyVsChannel"]->GetNbinsX(); ++bin) {
28 if(address.find(bin) == address.end()) {
29 std::cout << "Couldn't find array number " << bin << " in address map" << std::endl;
30 continue;
31 }
32 fH2[slot]["EnergyVsChannel"]->GetXaxis()->SetBinLabel(bin, Form("0x%x", address.at(bin)));
33 fH2[slot]["ChargeVsChannel"]->GetXaxis()->SetBinLabel(bin, Form("0x%x", address.at(bin)));
34 }
35}
36
37void AlphanumericHelper::Exec(unsigned int slot, TGriffin& grif)
38{
39 // Loop over all Griffin Hits
40 for(auto i = 0; i < grif.GetMultiplicity(); ++i) {
41 auto grif1 = grif.GetGriffinHit(i);
42 fH2[slot].at("EnergyVsChannel")->Fill(grif1->GetArrayNumber(), grif1->GetEnergy());
43 fH2[slot].at("ChargeVsChannel")->Fill(grif1->GetArrayNumber(), grif1->GetCharge());
44 }
45}
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
void Exec(unsigned int slot, TGriffin &grif)
static std::unordered_map< unsigned int, TChannel * > * GetChannelMap()
Definition TChannel.h:72
std::vector< TGRSIMap< std::string, TH2 * > > fH2
Definition TGRSIHelper.h:49
Short_t GetMultiplicity() const override
Definition TGriffin.h:52
TGriffinHit * GetGriffinHit(const int &i)
!
Definition TGriffin.h:47