GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
AlphanumericSelector.C
Go to the documentation of this file.
1#define AlphanumericSelector_cxx
2// The class definition in AlphanumericSelector.h has been generated automatically
4
6{
7 // get the channel map and loop over it, building a map of array number to channel address
8 std::unordered_map<unsigned int, TChannel*>* channelMap = TChannel::GetChannelMap();
9 std::cout << "Got " << channelMap->size() << " channels" << std::endl;
10 std::map<int, unsigned int> address;
11
12 for(auto channel : *channelMap) {
13 // use only GRIFFIN channels
14 if(channel.second->GetClassType() == TGriffin::Class()) {
15 // use only the "A" channel, not the "B" channel
16 if(channel.second->GetMnemonic()->OutputSensor() == TMnemonic::EMnemonic::kA) {
17 address[4 * (channel.second->GetDetectorNumber() - 1) + channel.second->GetCrystalNumber() + 1] = channel.second->GetAddress();
18 }
19 }
20 }
21
22 std::cout << "x-axis: " << address.rbegin()->first - address.begin()->first + 1 << " bins from " << address.begin()->first << " to " << address.rbegin()->first + 1 << std::endl;
23
24 // Define Histograms
25 fH2["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);
26 fH2["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);
27
28 for(int bin = 1; bin <= fH2["EnergyVsChannel"]->GetNbinsX(); ++bin) {
29 if(address.find(bin) == address.end()) {
30 std::cout << "Couldn't find array number " << bin << " in address map" << std::endl;
31 continue;
32 }
33 fH2["EnergyVsChannel"]->GetXaxis()->SetBinLabel(bin, Form("0x%x", address.at(bin)));
34 fH2["ChargeVsChannel"]->GetXaxis()->SetBinLabel(bin, Form("0x%x", address.at(bin)));
35 }
36
37 // Send histograms to Output list to be added and written.
38 for(auto it : fH1) {
39 GetOutputList()->Add(it.second);
40 }
41 for(auto it : fH2) {
42 GetOutputList()->Add(it.second);
43 }
44 for(auto it : fHSparse) {
45 GetOutputList()->Add(it.second);
46 }
47}
48
50{
51 // Loop over all Griffin Hits
52 for(auto i = 0; i < fGrif->GetMultiplicity(); ++i) {
53 auto grif = fGrif->GetGriffinHit(i);
54 fH2.at("EnergyVsChannel")->Fill(grif->GetArrayNumber(), grif->GetEnergy());
55 fH2.at("ChargeVsChannel")->Fill(grif->GetArrayNumber(), grif->GetCharge());
56 }
57}
static std::unordered_map< unsigned int, TChannel * > * GetChannelMap()
Definition TChannel.h:72
TGRSIMap< std::string, TH1 * > fH1
TGRSIMap< std::string, TH2 * > fH2
TGRSIMap< std::string, THnSparseF * > fHSparse
TList * GetOutputList() const override
this does the same as TSelector::GetOutputList()
Short_t GetMultiplicity() const override
Definition TGriffin.h:52
TGriffinHit * GetGriffinHit(const int &i)
!
Definition TGriffin.h:47