///////////////////////////////////////////////////////////////////////////// // // MRawEvtData // // Storage container to store the raw FADC values. // // MArrayS fHiGainPixId // --------------------- // Array of Pixel Numbers for their high voltage channel in the order the // FADC values are stored in fHiGainFadcSamples // // MArrayB fHiGainFadcSaples // ------------------------- // FADC samples (hi gain) of all pixels // // MArrayS fLoGainPixId // -------------------- // see fHiGainPixId // // MArrayB fLoGainFadcSamples // -------------------------- // see fHiGainFadcSaples // ///////////////////////////////////////////////////////////////////////////// #include "MRawEvtData.h" #include #include #include #include #include #include "MLog.h" #include "MArrayS.h" #include "MArrayB.h" #include "MRawRunHeader.h" ClassImp(MRawEvtData) MRawEvtData::MRawEvtData(const char *name, const char *title) { *fName = name ? name : "MRawEvtData"; *fTitle = title ? title : "Raw Event Data Information"; InitArrays(); } MRawEvtData::~MRawEvtData() { DeleteArrays(); } void MRawEvtData::Clear(Option_t *) { // // reset all arrays // /* FIXME: Is Reset (set all entries to zero) what you want to do or Set(0) (delete the array) */ fHiGainPixId->Reset(); fLoGainPixId->Reset(); fHiGainFadcSamples->Reset(); fLoGainFadcSamples->Reset(); } Byte_t MRawEvtData::GetNumHiGainSamples() const { return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/fHiGainPixId->GetSize() : 0; } Byte_t MRawEvtData::GetNumLoGainSamples() const { return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/fLoGainPixId->GetSize() : 0; } Byte_t MRawEvtData::GetNumPixels() const { return fHiGainPixId->GetSize(); } void MRawEvtData::Print(Option_t *opt) { // // print fadc inforation to screen // Possible Options: // - DEC: Print values decimal instead of hexadecimal (default) // const Byte_t nHiSamp = GetNumHiGainSamples(); const Byte_t nLoSamp = GetNumLoGainSamples(); const UShort_t nHiPix = fHiGainPixId->GetSize();; const UShort_t nLoPix = fLoGainPixId->GetSize();; fLog->unsetf(ios::showbase); *fLog << dec; *fLog << "HiGain: " << nHiPix << " Pixels with " << (Int_t)nHiSamp << " Samples" << endl; *fLog << "LoGain: " << nLoPix << " Pixels with " << (Int_t)nLoSamp << " Samples";; TString str(opt); Int_t manip = str.Contains("dec", TString::kIgnoreCase); Int_t l=0; for (int i=0; i5) sscanf(&str[5], "%d", &num); if (num>=GetNumPixels()) num= GetNumPixels(); *fLog << "Drawing Graph of Pixel " << num << endl; const Int_t n = GetNumHiGainSamples(); Float_t *x = new Float_t[n]; Float_t *y = new Float_t[n]; for (int i=0; iSetMaximum (256) ; graph->SetMinimum (0) ; graph->Draw("AC*"); return; } if (str.BeginsWith("HIST", TString::kIgnoreCase)) { *fLog << "Length: " << str.Length() << endl; if (str.Length()>4) sscanf(&str[4], "%d", &num); if (num>=GetNumPixels()) num= GetNumPixels(); *fLog << "Drawing Histogram of Pixel " << num << endl; const Int_t n = GetNumHiGainSamples(); char *name = new char[16]; sprintf(name, "Pixel No.%d", (*fHiGainPixId)[num]); TH1F *hist = new TH1F(name, "Hi Gain Samples FADC", n, 0, n); for (int i=0; iFill(0.5+i, (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]); hist->Draw(); return; } *fLog << "MRawEvtData::Draw: Warning: You must specify either 'GRAPH' or 'HIST'" << endl; } void MRawEvtData::DeletePixels(Bool_t flag) { // // Deletes all arrays describing the pixel Id and Samples in pixels // DeleteArrays(); InitArrays(flag); } void MRawEvtData::DeleteArrays() { delete fHiGainPixId; delete fLoGainPixId; delete fHiGainFadcSamples; delete fLoGainFadcSamples; } void MRawEvtData::InitArrays(Bool_t flag) { // const int npix = !flag ? 0 : fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate(); fHiGainPixId = new MArrayS(0);//npix); fLoGainPixId = new MArrayS(0);//npix); fHiGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesHiGain()); fLoGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesLoGain()); } void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag) { // // This is to fill the data of one pixel to the MRawEvtHeader Class. // The parameters are the pixelnumber and the FADC_SLICES values of ADCs // Add to lo gains if lflag = 1 // MArrayS *arrpix = lflag ? fLoGainPixId : fHiGainPixId; MArrayB *arrsam = lflag ? fLoGainFadcSamples : fHiGainFadcSamples; // // check whether we got the right number of new samples // if there are no samples already stored: this is the new number of samples // const Byte_t ns = data->GetSize(); const Byte_t nSamp = lflag ? GetNumLoGainSamples() : GetNumHiGainSamples(); if (nSamp && ns!=nSamp) { *fLog << "RawEvtData::FillPixel: Error, number of samples in "; *fLog << "TArrayC doesn't match actual number" << endl; return; } // // enhance pixel array by one // arrpix->Set(arrpix->GetSize()+1); // // add the number of the new pixel to the array as last entry // arrpix->AddAt(nOfPixel, arrpix->GetSize()-1); // // enhance the array by the number of new samples // arrsam->Set(arrsam->GetSize()+ns); // // add the new slices as last entries to array // arrsam->AddAt((Byte_t*)data->GetArray(), arrsam->GetSize()-ns, ns); } void MRawEvtData::ReadEvt(istream &fin) { // // Fills members with information from a magic binary file. // WARNING: you have to use Init() before you can do this // const UShort_t nlo = fRunHeader->GetNumSamplesLoGain(); const UShort_t nhi = fRunHeader->GetNumSamplesHiGain(); const UShort_t npic = fRunHeader->GetNumPixInCrate(); // // Enhance array by the size which we'll read now // Byte_t lo[nlo]; Byte_t hi[nhi]; const int npixhi = fHiGainPixId->GetSize(); const int npixlo = fLoGainPixId->GetSize(); fHiGainPixId->Set(npixhi+npic); fLoGainPixId->Set(npixlo+npic); const int nsamhi = fHiGainFadcSamples->GetSize(); const int nsamlo = fLoGainFadcSamples->GetSize(); fHiGainFadcSamples->Set(nsamhi+nhi*npic); fLoGainFadcSamples->Set(nsamlo+nlo*npic); for (int i=0; iGetPixAssignment(i); // // This is to fill the data of one pixel to the MRawEvtHeader Class. // The parameters are the pixelnumber and the FADC_SLICES values of ADCs // Add to lo gains if lflag = 1 // fin.read(hi, nhi); fHiGainPixId->AddAt(npix, npixhi+i); fHiGainFadcSamples->AddAt(hi, nsamhi+i*nhi, nhi); // FIXME: Not implemented in the raw files yet //if (IsLoGainOn(i, j)) //{ fin.read(lo, nlo); fLoGainPixId->AddAt(npix, npixlo+i); fLoGainFadcSamples->AddAt(lo, nsamlo+i*nlo, nlo); //} } }