//----------------------------------------------------------------------------- // Jan 10 2001 P.Murat: CMP data block: CSPD and CMPD //----------------------------------------------------------------------------- #include "TBuffer.h" #include #include #include ClassImp(TCmpDataBlock) //______________________________________________________________________________ void TCmpDataBlock::Streamer(TBuffer &R__b) { // Stream an object of class TCmpDataBlock. if (R__b.IsReading()) { Clear(); Version_t R__v = R__b.ReadVersion(); if (R__v) { } fCspd.Streamer(R__b); fCmpd.Streamer(R__b); InitTdcChannels(); } else { R__b.WriteVersion(TCmpDataBlock::IsA()); fCspd.Streamer(R__b); fCmpd.Streamer(R__b); } } //_____________________________________________________________________________ Int_t TCmpDataBlock::InitTdcChannels() { // update transient data members // int old = -1; int nw, loc, nw_total, itdc; // TCspCounter* counter; fNCspHits = 0; fNCmpdHits = 0; nw_total = fCspd.NDataWords(); itdc = 0; loc = 0; while (loc < nw_total) { fCspTdc[itdc++].SetData(fCspd.GetArray()+loc); TCspTdcHeader header = (TCspTdcHeader) fCspd[loc]; // number of data words for given TDC int ir = header.Region(); nw = header.NDataWords(); fNCspHits += nw; // int id = header.ModuleId(); // fCspTdc[id].SetData(fCspd.GetArray()+loc); // for (int iw=0; iwChannelId(); // if (ich != old) { // old = ich; // // side here is west(0)/east(1) // int is = hit->Side(); // int ic = hit->Counter(); // counter = cmp->Side(ir)->CspCounter(ic); // counter->SetData(fCspd+loc+1+iw); // } // counter->IncrementNHits(); // } // n(data words) + header loc += nw+1; } nw_total = fCmpd.NDataWords(); loc = 0; itdc = 0; while (loc < nw_total) { fCmpTdc[itdc++].SetData(fCmpd.GetArray()+loc); TCmpTdcHeader header = (TCmpTdcHeader) fCmpd[loc]; nw = header.NDataWords(); fNCmpdHits += nw; // int id = header.ModuleId(); // fCspTdc[id].SetData(fCspd.GetArray()+loc); // for (int iw=0; iwChannelId(); // if (ich != old) { // old = ich; // // side here is west(0)/east(1) // int is = hit->Side(); // int ic = hit->Counter(); // counter = cmp->Side(ir)->CspCounter(ic); // counter->SetData(fCspd+loc+1+iw); // } // counter->IncrementNHits(); // } // n(data words) + header loc += nw+1; } return 0; } //_____________________________________________________________________________ TCmpDataBlock::TCmpDataBlock() : fCspd(100), fCmpd(100) { // default version of the calibration // constants // fCalibVersion = 0; // fCalibRun = -1; // fCalibDone = 0; // initialize transient part to allow // fast I/O. Reserve 100 data words // for each of CSP and CMP data to // minimize number of subsequent // reallocations, though it is not // critical anyway } //_____________________________________________________________________________ TCmpDataBlock::~TCmpDataBlock() { } //_____________________________________________________________________________ void TCmpDataBlock::Clear(Option_t* opt) { // make the data block looking like there is no data in it // reset CSP TDS's fCspd.Clear(); for (int i=0; iCmpTdc(itdc); int nhits = tdc.NDataWords(); if (nhits > 0) { printf(" %3i %7i\n",itdc, nhits); TCmpTdcHeader* header = (TCmpTdcHeader*) tdc.Header(); for (int i=0; iLeadingEdge(), data->Width(), data->First(), data->ChannelId(), header->TdcNumber(), header->Region(), data->Layer(), data->Stack()); } } } PRINT_CSP_HITS:; if (NCspHits() == 0) goto END; printf(" ------------------------ CSP:\n"); printf(" TDC N(hits) Hit# LeadingEdge Width First ChannelID "); printf(" Region Counter Side\n"); for (int itdc=0; itdcCspTdc(itdc); int nhits = tdc.NDataWords(); if (nhits > 0) { printf(" %3i %7i\n",itdc, nhits); TCspTdcHeader* header = (TCspTdcHeader*) tdc.Header(); for (int i=0; iLeadingEdge(), data->Width(), data->First(), data->ChannelId(), header->Region(), data->Counter(), data->Side()); } } } END:; } //_____________________________________________________________________________ int TCmpDataBlock::ReadCalibrations(int run_number) { // first implementation: read a given file // if ( (fCalibRun == run_number) && fCalibDone) return 0; return 0; }