#include "Stntuple/obj/TSiStripBlock.hh" #include #include ClassImp(TSiStripBlock) //_____________________________________________________________________________ TSiStripBlock::TSiStripBlock() : TStnDataBlock(), fNSiStrips(0), fSiStripList(NULL), fIndexFirstHit(NULL), fIndexLastHit(NULL), fBEState(NULL), fDtL1A(NULL), fMaxDigiCode(0), fNDigiCodes(0), fDigiCodes(NULL), fDigiCodeFirstHit(NULL), fDigiCodeLastHit(NULL), fDigiCodeBEState(NULL), fDigiCodeDtL1A(NULL), fStreamGeometryInfo(false), fInitialized(false) { fSiStripList = new TClonesArray("TStnSiStrip",1000); fSiStripList->BypassStreamer(kFALSE); fCollName = "GlobalSI_StripSet"; } //_____________________________________________________________________________ TSiStripBlock::~TSiStripBlock() { Clear(); fSiStripList->Delete(); delete fSiStripList; if (fMaxDigiCode>0) { delete []fIndexFirstHit; delete []fIndexLastHit; delete []fBEState; delete []fDtL1A; } } // Use custom streamer. // But we still need to puff up the hash table for hits on a given digicode. // Do it explicitly with InitEvent() void TSiStripBlock::Streamer(TBuffer &R__b){ if (R__b.IsReading()) { Version_t R__v = R__b.ReadVersion(); if (R__v) { } Clear(); R__b >> fNSiStrips; if (fNSiStrips > 0) { fSiStripList->Streamer(R__b); int n; R__b >> n; fNDigiCodes = n; if (n>0) { fDigiCodes = new UShort_t[n]; R__b.ReadFastArray(&fDigiCodes[0],n); fDigiCodeFirstHit = new Int_t[n]; R__b.ReadFastArray(&fDigiCodeFirstHit[0],n); fDigiCodeLastHit = new Int_t[n]; R__b.ReadFastArray(&fDigiCodeLastHit[0],n); fDigiCodeBEState = new Char_t[n]; if (R__v > 1) R__b.ReadFastArray(&fDigiCodeBEState[0],n); fDigiCodeDtL1A = new Short_t[n]; if (R__v > 1) R__b.ReadFastArray(&fDigiCodeDtL1A[0],n); } } } else { R__b.WriteVersion(TSiStripBlock::IsA()); R__b << fNSiStrips; if (fNSiStrips > 0) { fSiStripList->Streamer(R__b); int n=fNDigiCodes; R__b << n; if (n>0) { R__b.WriteFastArray(&fDigiCodes[0],n); R__b.WriteFastArray(&fDigiCodeFirstHit[0],n); R__b.WriteFastArray(&fDigiCodeLastHit[0],n); R__b.WriteFastArray(&fDigiCodeBEState[0],n); R__b.WriteFastArray(&fDigiCodeDtL1A[0],n); } } } } //_____________________________________________________________________________ Int_t TSiStripBlock::InitEvent(Int_t flag) { // Puff up the lookup table for hits in a given detector element // from the array fDigiCodes and its kin. // You must call this after you've read the block for the event. if (fInitialized) return 0; if (fNDigiCodes<=0) return -1; if (fMaxDigiCode==0) { // create lookup arrays TStnSiDigiCode digi(3,2,35,7,1); // 9125 fMaxDigiCode = digi.fDigiCode; fIndexFirstHit = new Int_t[fMaxDigiCode+1]; fIndexLastHit = new Int_t[fMaxDigiCode+1]; fBEState = new Short_t[fMaxDigiCode+1]; fDtL1A = new Short_t[fMaxDigiCode+1]; } if (fMaxDigiCode>0){ memset(fIndexFirstHit, -1, (fMaxDigiCode+1)*sizeof(Int_t)); memset(fIndexLastHit, -2, (fMaxDigiCode+1)*sizeof(Int_t)); memset(fBEState, -1, (fMaxDigiCode+1)*sizeof(Short_t)); memset(fDtL1A, -1, (fMaxDigiCode+1)*sizeof(Short_t)); } for (int i=0; ifStrip == stripnum) { stripindex = i; found = true; } } return stripindex; } //_____________________________________________________________________________ void TSiStripBlock::Clear(Option_t* opt) { fNSiStrips = 0; fSiStripList->Clear(opt); fNDigiCodes = 0; delete []fDigiCodes; fDigiCodes=NULL; delete []fDigiCodeFirstHit; fDigiCodeFirstHit=NULL; delete []fDigiCodeLastHit; fDigiCodeLastHit=NULL; delete []fDigiCodeBEState; fDigiCodeBEState=NULL; delete []fDigiCodeDtL1A; fDigiCodeDtL1A=NULL; fInitialized = false; } //------------------------------------------------------------------------------ void TSiStripBlock::Print(Option_t* opt) const { for (int i=0; iPrint(opt); std::cout << std::endl; } std::cout << "\nLinks from DigiCodes to SiStrips" << std::endl; for (int i=0; i