120 std::cerr <<
"Run: " <<
evt.
run()
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]);
unsigned int getNanoSliceSampleForChan(unsigned int channel)
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int getFragIDForChan(unsigned int channel)
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
static int max(int a, int b)
const lariov::DetPedestalProvider & fPedestalRetrievalAlg
std::string fRawDataLabel
IDNumber_t< Level::Event > EventNumber_t
virtual float PedMean(raw::ChannelID_t ch) const =0
Retrieve pedestal information.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)