/*! \file \version $Id: TATdatRaw.cxx,v 1.12 2003/06/09 18:41:17 mueller Exp $ \brief Implementation of TATOFdatRaw. */ #include #include #include #include #include "TString.h" #include "TATOFdatRaw.h" /*! \class TATOFdatRaw TATOFdatRaw.hxx "TATOFdatRaw.hxx" \brief Mapping and Geometry parameters for Tof wall. ** */ Int_t fiNAdc; // Int_t fiNTdc; // Int_t fiNDrop; // vector fHitList; // make them global vector fHitIndex; // for AsyEOSRoot ClassImp(TATOFrawHit); //------------------------------------------+----------------------------------- //! Destructor. TATOFrawHit::~TATOFrawHit() {} //------------------------------------------+----------------------------------- //! Setup values. void TATOFrawHit::SetData(Int_t i_type, Bool_t b_ran, Int_t i_val) { Int_t i_data = i_val; if (b_ran) i_data |= 0x1000; // ??? param flag bit switch(i_type) { case 1: fiStatus |= BIT(0); fiAdct = i_data; break; case 2: fiStatus |= BIT(1); fiAdcb = i_data; break; case 3: fiStatus |= BIT(2); fiTdct = i_data; break; case 4: fiStatus |= BIT(3); fiTdcb = i_data; break; default: break; } } //############################################################################## ClassImp(TATOFdatRaw); //------------------------------------------+----------------------------------- //! Default constructor. TATOFdatRaw::TATOFdatRaw() { fHitIndex.reserve(256); // ??? parametrize default reserve } //------------------------------------------+----------------------------------- //! Destructor. TATOFdatRaw::~TATOFdatRaw() {} //------------------------------------------+----------------------------------- //! Setup mapping data for a single slat. void TATOFdatRaw::SetHitData(Int_t i_slat, Int_t i_type, Bool_t b_ran, Int_t i_val) { if (i_slat >= (Int_t) fHitIndex.size()) fHitIndex.resize(i_slat+1, -1); Int_t i_ind = fHitIndex[i_slat]; if (i_ind == -1) { i_ind = (Int_t) fHitList.size(); fHitIndex[i_slat] = i_ind; fHitList.push_back(TATOFrawHit(i_slat)); } fHitList[i_ind].SetData(i_type, b_ran, i_val); return; } /*------------------------------------------+---------------------------------*/ //! Set statistics counters. void TATOFdatRaw::SetCounter(Int_t i_nadc, Int_t i_ntdc, Int_t i_ndrop) { fiNAdc = i_nadc; fiNTdc = i_ntdc; fiNDrop = i_ndrop; return; } /*------------------------------------------+---------------------------------*/ //! helper to define hit sorting order by increasing slat number inline bool less_by_slat(const TATOFrawHit& lhs, const TATOFrawHit& rhs) { return lhs.Slat() < rhs.Slat(); } /*------------------------------------------+---------------------------------*/ //! Sort by slat number. void TATOFdatRaw::SortBySlat() { sort(fHitList.begin(), fHitList.end(), less_by_slat); for (Int_t i = 0; i < NHit(); i++) fHitIndex[Hit(i).Slat()] = i; return; } //------------------------------------------+----------------------------------- //! Returns hit index for slat. Int_t TATOFdatRaw::IndexFromSlat(Int_t i_slat) const { if (i_slat <= 0 || i_slat >= (Int_t)fHitIndex.size()) return -1; return fHitIndex[i_slat]; } //------------------------------------------+----------------------------------- //! Clear event. void TATOFdatRaw::Clear() // ALF, 01/2013 //void TATOFdatRaw::Clear(Option_t*) // does not work in AsyEOSRoot - ALF, 01/2013 { //TATOFdata::Clear(); // does not work in AsyEOSRoot - ALF, 01/2013 for (Int_t i = 0; i < NHit(); i++) fHitIndex[Hit(i).Slat()] = -1; fHitList.clear(); return; } /*------------------------------------------+---------------------------------*/ //! helper to format one converter value static void print_value(ostream& os, Int_t i_val) { char c_ran = (i_val & 0x1000) ? 'h' : 'l'; os << Form("%4d", i_val & 0x0fff, "d", 4) << " " << c_ran; return; } /*------------------------------------------+---------------------------------*/ //! ostream insertion. void TATOFdatRaw::ToStream(ostream& os, Option_t* option) const { os << "TATOFdatRaw " << GetName() << Form(" nhit=%3d", NHit()) << Form(" nadc=%3d", NAdc()) << Form(" ntdc=%3d", NTdc()) << Form(" ndrop=%3d", NDrop()) << endl; os << "slat stat adct adcb tdct tdcb" << endl; for (Int_t i = 0; i < NHit(); i++) { const TATOFrawHit& hit = Hit(i); os << Form("%4d", hit.Slat()); os << " " << bitset<4>(hit.Status()); os << " "; print_value(os, hit.AdctRaw()); os << " "; print_value(os, hit.AdcbRaw()); os << " "; print_value(os, hit.TdctRaw()); os << " "; print_value(os, hit.TdcbRaw()); os << endl; } return; }