|
| 1 | +//////////////////////////////////////////////////////////////////////// |
| 2 | +// Class: TPCChannelIDAna |
| 3 | +// Plugin Type: analyzer |
| 4 | +// File: PDSMeanRMSLZ_tool.cc |
| 5 | +// Author: tjyang@fnal.gov |
| 6 | +// |
| 7 | +// Analyze channel ID data |
| 8 | +// |
| 9 | +//////////////////////////////////////////////////////////////////////// |
| 10 | +#include "art/Framework/Core/EDAnalyzer.h" |
| 11 | +#include "art/Framework/Core/ModuleMacros.h" |
| 12 | +#include "art/Framework/Principal/Event.h" |
| 13 | +#include "art/Framework/Principal/Handle.h" |
| 14 | +#include "art/Framework/Principal/Run.h" |
| 15 | +#include "art/Framework/Principal/SubRun.h" |
| 16 | +#include "canvas/Utilities/InputTag.h" |
| 17 | +#include "fhiclcpp/ParameterSet.h" |
| 18 | +#include "messagefacility/MessageLogger/MessageLogger.h" |
| 19 | +#include "art_root_io/TFileService.h" |
| 20 | + |
| 21 | +#include "lardataobj/RawData/RawDigit.h" |
| 22 | +#include "lardataobj/RawData/raw.h" |
| 23 | +#include "larcore/Geometry/Geometry.h" |
| 24 | + |
| 25 | +#include "sbndcode/ChannelMaps/TPC/TPCChannelMapService.h" |
| 26 | + |
| 27 | +#include "TTree.h" |
| 28 | + |
| 29 | +using namespace std; |
| 30 | + |
| 31 | +namespace sbnd { |
| 32 | + class TPCChannelIDAna; |
| 33 | +} |
| 34 | + |
| 35 | + |
| 36 | +class sbnd::TPCChannelIDAna : public art::EDAnalyzer { |
| 37 | +public: |
| 38 | + explicit TPCChannelIDAna(fhicl::ParameterSet const& p); |
| 39 | + // The compiler-generated destructor is fine for non-base |
| 40 | + // classes without bare pointers or other resource use. |
| 41 | + |
| 42 | + // Plugins should not be copied or assigned. |
| 43 | + TPCChannelIDAna(TPCChannelIDAna const&) = delete; |
| 44 | + TPCChannelIDAna(TPCChannelIDAna&&) = delete; |
| 45 | + TPCChannelIDAna& operator=(TPCChannelIDAna const&) = delete; |
| 46 | + TPCChannelIDAna& operator=(TPCChannelIDAna&&) = delete; |
| 47 | + |
| 48 | + // Required functions. |
| 49 | + void beginJob() override; |
| 50 | + void analyze(art::Event const& e) override; |
| 51 | + |
| 52 | +private: |
| 53 | + |
| 54 | + // Declare member data here. |
| 55 | + art::InputTag fRawDigitModuleLabel; |
| 56 | + TTree *chs; |
| 57 | + int ch; //offline channel |
| 58 | + int chid; //measurement from channel ID data |
| 59 | + int tpc; |
| 60 | + int plane; |
| 61 | + int wire; |
| 62 | + int wibcrate; |
| 63 | + int wib; |
| 64 | + int fembonwib; |
| 65 | + int fembch; |
| 66 | + int fembonwib_fromchid; |
| 67 | + int fembch_fromchid; |
| 68 | + int femcrate; |
| 69 | + int fem; |
| 70 | + int femch; |
| 71 | +}; |
| 72 | + |
| 73 | + |
| 74 | +sbnd::TPCChannelIDAna::TPCChannelIDAna(fhicl::ParameterSet const& p) |
| 75 | + : EDAnalyzer{p} |
| 76 | + , fRawDigitModuleLabel{p.get<art::InputTag>("RawDigitModuleLabel")} |
| 77 | + // More initializers here. |
| 78 | +{ |
| 79 | + // Call appropriate consumes<>() for any products to be retrieved by this module. |
| 80 | +} |
| 81 | + |
| 82 | +void sbnd::TPCChannelIDAna::beginJob(){ |
| 83 | + art::ServiceHandle<art::TFileService> tfs; |
| 84 | + chs = tfs->make<TTree>("chs","Channel information"); |
| 85 | + chs->Branch("ch", &ch, "ch/I"); |
| 86 | + chs->Branch("chid", &chid, "chid/I"); |
| 87 | + chs->Branch("tpc", &tpc, "tpc/I"); |
| 88 | + chs->Branch("plane", &plane, "plane/I"); |
| 89 | + chs->Branch("wire", &wire, "wire/I"); |
| 90 | + chs->Branch("wibcrate", &wibcrate, "wibcrate/I"); |
| 91 | + chs->Branch("wib", &wib, "wib/I"); |
| 92 | + chs->Branch("fembonwib", &fembonwib, "fembonwib/I"); |
| 93 | + chs->Branch("fembch", &fembch, "fembch/I"); |
| 94 | + chs->Branch("fembonwib_fromchid", &fembonwib_fromchid, "fembonwib_fromchid/I"); |
| 95 | + chs->Branch("fembch_fromchid", &fembch_fromchid, "fembch_fromchid/I"); |
| 96 | + chs->Branch("femcrate", &femcrate, "femcrate/I"); |
| 97 | + chs->Branch("fem", &fem, "fem/I"); |
| 98 | + chs->Branch("femch", &femch, "femch/I"); |
| 99 | +} |
| 100 | + |
| 101 | +void sbnd::TPCChannelIDAna::analyze(art::Event const& e) |
| 102 | +{ |
| 103 | + // Implementation of required member function here. |
| 104 | + |
| 105 | + art::ServiceHandle<geo::Geometry> geo; |
| 106 | + art::ServiceHandle<SBND::TPCChannelMapService> channelMap; |
| 107 | + |
| 108 | + // Get raw digits |
| 109 | + auto const& rawdigts = e.getProduct<std::vector<raw::RawDigit>>(fRawDigitModuleLabel); |
| 110 | + for (const auto & rd : rawdigts){ |
| 111 | + std::vector<short> rawadc; //UNCOMPRESSED ADC VALUES. |
| 112 | + rawadc.resize(rd.Samples()); |
| 113 | + raw::Uncompress(rd.ADCs(), rawadc, rd.GetPedestal(), rd.Compression()); |
| 114 | + //cout<<rd.Channel()<<" "<<rawadc[0]<<endl; |
| 115 | + ch = rd.Channel(); |
| 116 | + chid = rawadc[0]; |
| 117 | + auto const & chids = geo->ChannelToWire(ch); |
| 118 | + tpc = chids[0].TPC; |
| 119 | + plane = chids[0].Plane; |
| 120 | + wire = chids[0].Wire; |
| 121 | + auto const & chaninfo = channelMap->GetChanInfoFromOfflChan(ch); |
| 122 | + wibcrate = chaninfo.WIBCrate; |
| 123 | + wib = chaninfo.WIB; |
| 124 | + fembonwib = chaninfo.FEMBOnWIB; |
| 125 | + fembch = chaninfo.FEMBCh; |
| 126 | + femcrate = chaninfo.FEMCrate; |
| 127 | + fem = chaninfo.FEM; |
| 128 | + femch = chaninfo.FEMCh; |
| 129 | + fembonwib_fromchid = chid>>8; |
| 130 | + fembch_fromchid = chid&0xFF; |
| 131 | + chs->Fill(); |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +DEFINE_ART_MODULE(sbnd::TPCChannelIDAna) |
0 commit comments