20 #include "art_root_io/TFileService.h" 21 #include "art_root_io/TFileDirectory.h" 27 #include "lbne-raw-data/Overlays/TpcMilliSliceFragment.hh" 28 #include "artdaq-core/Data/Fragment.hh" 57 class NoiseCorrelation;
95 gStyle->SetOptStat(0);
99 fCorrelationHist = tfs->make<TH2F>(
"Correlation",
"Correlation;Online channel number;Online channel number;",2048,0,2048,2048,0,2048);
120 std::cerr <<
"Run: " << evt.
run()
121 <<
", SubRun: " << evt.
subRun()
122 <<
", Event: " << eventNumber
128 std::map < unsigned int, unsigned int > mapFragID;
129 for(
size_t fragIndex = 0; fragIndex < rawFragments->size(); fragIndex++){
130 const artdaq::Fragment &singleFragment = (*rawFragments)[fragIndex];
131 unsigned int fragmentID = singleFragment.fragmentID();
132 mapFragID.insert(std::pair<unsigned int, unsigned int>(fragmentID,fragIndex));
136 std::vector<std::vector<float> > correlationArray(2048,std::vector<float>(2048,0));
139 size_t numChannels = geometry->
Nchannels();
142 std::vector<std::vector<short> > adcVectors;
149 std::vector<short> adcvec;
150 if (mapFragID.find(fragmentID) != mapFragID.end()) {
151 unsigned int fragIndex = mapFragID[fragmentID];
152 const artdaq::Fragment &singleFragment = (*rawFragments)[fragIndex];
153 lbne::TpcMilliSliceFragment millisliceFragment(singleFragment);
154 auto numMicroSlices = millisliceFragment.microSliceCount();
155 for(
unsigned int i_micro = 0; i_micro < numMicroSlices; i_micro++) {
156 std::unique_ptr <const lbne::TpcMicroSlice> microSlice = millisliceFragment.microSlice(i_micro);
157 auto numNanoSlices = microSlice->nanoSliceCount();
158 for(
uint32_t i_nano = 0; i_nano < numNanoSlices; i_nano++){
160 bool success = microSlice->nanosliceSampleValue(i_nano, sample, val);
163 short adc = short(val - pedestal);
164 if ((adc & 0x3F) == 0x0 || (adc & 0x3F) == 0x3F)
165 adcvec.push_back(
short(-999));
167 adcvec.push_back(adc);
173 adcVectors.push_back(adcvec);
178 for (
size_t chan1 = 0; chan1 < numChannels; ++chan1) {
179 for (
size_t chan2 = chan1; chan2 < numChannels; ++chan2) {
185 std::vector<short> adcvec1 = adcVectors[chan1];
186 std::vector<short> adcvec2 = adcVectors[chan2];
194 size_t n1 = adcvec1.size(), n2 = adcvec2.size();
198 float sumxy = 0, sumx = 0, sumy = 0, sumx2 = 0, sumy2 = 0;
200 short adc1 = adcvec1[
tick], adc2 = adcvec2[
tick];
208 float denom = ( (n1*sumx2) - (sumx*sumx) ) * ( (n1*sumy2) - (sumy*sumy) );
209 if (n1 > 0 and denom > 0) {
210 fCorrelation = ( (n1*sumxy) - (sumx*sumy) ) / ( TMath::Sqrt( denom ) );
219 for (
unsigned int channel1 = 0; channel1 < correlationArray.size(); ++channel1)
220 for (
unsigned int channel2 = 0; channel2 < correlationArray.size(); ++channel2)
221 fCorrelationHist->SetBinContent(channel1, channel2, correlationArray[channel1][channel2]);
EventNumber_t event() const
unsigned int getNanoSliceSampleForChan(unsigned int channel)
Definition of basic raw digits.
EDAnalyzer(fhicl::ParameterSet const &pset)
NoiseCorrelation & operator=(NoiseCorrelation const &)=delete
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int getFragIDForChan(unsigned int channel)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#define DEFINE_ART_MODULE(klass)
void analyze(art::Event const &evt) override
Collect all the RawData header files together.
T get(std::string const &key) const
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
SubRunNumber_t subRun() const
static int max(int a, int b)
NoiseCorrelation(fhicl::ParameterSet const &pset)
void reconfigure(const fhicl::ParameterSet &pset)
const lariov::DetPedestalProvider & fPedestalRetrievalAlg
std::string fRawDataLabel
IDNumber_t< Level::Event > EventNumber_t
Interface for experiment-specific channel quality info provider.
virtual float PedMean(raw::ChannelID_t ch) const =0
Retrieve pedestal information.
Interface for experiment-specific service for channel quality info.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)