// ----------------------------------------------------------------------------- // ----- ----- // ----- KRATUnpack2 ----- // ----- Created 17.05.2013 by S.Kupny ----- // ----- ----- // ---- Based on: ----- // ---- https://subversion.gsi.de/trac/fairroot/browser/r3broot/trunk/unpack/land/R3BLandUnpack.cxx ----- // ----------------------------------------------------------------------------- #include #include "FairRootManager.h" #include "KRATUnpack2.h" using namespace std; //______________________________________________________________________ //KRATUnpack2::KRATUnpack2(const char *strMappingFile, Int_t type, \ Int_t subType, Int_t iVerbose) // Fairroot version: v-13.05 KRATUnpack2::KRATUnpack2(const char *strMappingFile, Short_t type, Short_t subType, Short_t procId, Short_t subCrate, Short_t control, Int_t iVerbose) // Fairroot version: v-13.12 : FairUnpack(type, subType, procId, subCrate, control), fKrattaMapping(0), fKratRaw_evt(0), fKratRaw_evtCopy(0), fFileWithMapping(strMappingFile), fWriteOutputDataToFile(kFALSE), fDebugModeLvl( iVerbose ) ///by default: for 0 - no debug outputs { if ( fDebugModeLvl > 1 ){ cout << "[KRATUnpack2::KRATUnpack2]: Launched with: "; cout << "type = " << type << ", subType = " << subType << endl; } } //______________________________________________________________________ KRATUnpack2::~KRATUnpack2() { if ( fDebugModeLvl > 1 ){ cout << "[KRATUnpack2::~KRATUnpack2]" << endl; } delete fKrattaMapping; delete fKratRaw_evt; delete fKratRaw_evtCopy; } //______________________________________________________________________ Bool_t KRATUnpack2::Init() { if ( fDebugModeLvl > 1 ){ cout << "[KRATUnpack2::Init]" << endl; } //fLogger->Info(MESSAGE_ORIGIN," KrattaUnpack::Init()--------Start "); ///Initialization and configuration TString dir=gSystem->Getenv("VMCWORKDIR"); fKratRaw_evt = new TKRATRawEvent(); fKrattaMapping = new TKRATMapping(); ///Use the default location of mapping file when input param is empty if (fFileWithMapping.Length() == 0 ){ fFileWithMapping = dir + "/calfiles/KRATTA/Asyeos_Kratta_Mapping.conf"; } fKrattaMapping -> Init( fFileWithMapping ); if ( fDebugModeLvl > 0 ){ fKrattaMapping -> PrintMapping(); } fKratRaw_evt->SetDebugMode( fDebugModeLvl ); ///Init and register new data container in fairroot fKratRaw_evtCopy = new TClonesArray("TKRATRawEvent"); fKratRaw_evtCopy =(TClonesArray*)fKratRaw_evt; Register(); ///Get access to fairroot data source (how it looks in first unpacker) //ffBufferClone =(TClonesArray*) ioman->GetObject("EVTBUFFERCLONE"); //ffBuffer = (TEvtBuffer*)ffBufferClone; //fLogger->Info(MESSAGE_ORIGIN," KrattaUnpack::Init()----------End "); return kTRUE; } //______________________________________________________________________ Bool_t KRATUnpack2::DoUnpack(Int_t *data, Int_t size) { //eKrattaRawEvent->SetId( i ); //if( fDebugModeLvl > 2 ) cout << "[KRATUnpack:Debug.2] Kratta subevent found (KRATTAnrw=" << ffBuffer->KRATTA_nrlw << ", Buffer addr=" << ffBuffer->KRATTABuffer << ")" << endl; //fKratRaw_evt->ProcessCurrentEventMBS ( ffBuffer->KRATTABuffer, ffBuffer->KRATTA_nrlw, *fKrattaMapping); if( fDebugModeLvl > 2 ) cout << "[KRATUnpack2:Debug.2] Kratta subevent found (KRATTAnrw=" << size << ", Buffer addr=" << data << ")" << endl; Int_t SIZE_AFTER_CORR = size/2; ///TODO: Explain that again. For the default value it crashed again fKratRaw_evt->ProcessCurrentEventMBS ( data, SIZE_AFTER_CORR, *fKrattaMapping); //fKratRaw_evt->SetId( fEventIndex ); fEventIndex++; ///Print some logs: //cout << "General info about Kratta event:" << endl; //cout << fKratRaw_evt->ToString() << endl; //cout << "Detail info about Kratta event" << endl; //cout << fKratRaw_evt->ToStringPhotodiode() << endl; /* Instruction: How to get access to table with pulse shape for each detector's Photodiode [0 - 105] for (Int_t iPhotodiode = 0; iPhotodiode < gKRATTANumberOfPhotodiodes; iPhotodiode++ ) { if( fKratRaw_evt->ContainSignalFromPh(iPhotodiode) ) { cout << "Photodiode " << iPhotodiode << ": ["; for (Int_t ii = 0; ii < fKratRaw_evt->GetSignalArraySize( iPhotodiode );ii++ ) { cout << (fKratRaw_evt->GetSignalArray( iPhotodiode ))[ii]<<","; } cout << "] " << endl; } } */ return kTRUE; } //______________________________________________________________________ void KRATUnpack2::Register() { if ( fDebugModeLvl > 1 ){ cout << "[KRATUnpack2::Register]" << endl; } FairRootManager *fMan = FairRootManager::Instance(); if(! fMan) { return; } fMan->Register("KRATTARAWEVENT", "KRATTA RAW EVENT TREE", fKratRaw_evt, kFALSE); fMan->Register("KRATTARAWEVENTCLONE", "KRATTA RAW EVENT TREE CLONE",fKratRaw_evtCopy, fWriteOutputDataToFile); } //______________________________________________________________________ void KRATUnpack2::Reset() { if ( fDebugModeLvl > 1 ){ cout << "[KRATUnpack2::Reset()]" << endl; } fKratRaw_evtCopy->Clear(); } //______________________________________________________________________ void KRATUnpack2::Finish() { if ( fDebugModeLvl > 1 ){ cout << "[KRATUnpack2::Finish():] Calculated " << fEventIndex << endl; } } //______________________________________________________________________ void KRATUnpack2::SetDebugLevel(Int_t iNewDebugLvl) { fDebugModeLvl = iNewDebugLvl; } ClassImp(KRATUnpack2)