// ------------------------------------------------------------------------------------ // ----- MBSUnpack source file ----- // ----- Created 12/04/12 by P. Russotto ----- // ----- Modified by A. Le Fevre, 11/2012 (for ToF-Wall, CAMAC, and INFO branch) ----- // ------------------------------------------------------------------------------------ #include #include #include #include #include #include #include #include #include #include "MBSUnpack.h" #include "FairLogger.h" #include "TClonesArray.h" #include "FairRunAna.h" #include "FairRun.h" MBSUnpack::MBSUnpack() :FairTask() { } // ------------------------------------------------------------------------- MBSUnpack::MBSUnpack(const char* name, TString runlist, Int_t iVerbose) ///, FairRunAna* pippo : FairTask(name, iVerbose), fMyMbs(0), fMbsFileStatus(new Int_t), fIsLastEvent(0), fRootINFOEvent(0), // ALF, 11/2012 fRootINFOEventCopy(0), // ALF, 11/2012 fEvtBuffer(0), fEvtBufferClone(0) { frunlist=runlist; ///fpippo=pippo->Instance(); ///cout <<"this is pippo "<< pippo << endl; ///cout <<"this is fpippo "<< fpippo << endl; ///getchar(); } // ------------------------------------------------------------------------- MBSUnpack::~MBSUnpack() { } // ------------------------------------------------------------------------- InitStatus MBSUnpack::Init() { fLogger->Info(MESSAGE_ORIGIN," MBSUnpack::Init()------------------Start "); cout <<"runlist= "< to continue..."<< endl; getchar(); inputfile >> NFiles; inputfile >>InFile; fMyMbs= new MbsFile(InFile,fMbsFileStatus); fMyMbs->PrintFileHeader(); fEvtBuffer=new TEvtBuffer(); fRootINFOEvent = new TRootINFOEvent(); // general infos (run number, etc.) - ALF FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) Fatal("Init", "No FairRootManager"); ioman->Register("EVTBUFFER", "EVENT BUFFER", fEvtBuffer, kFALSE); fEvtBufferClone = new TClonesArray("TEvtBuffer"); fEvtBufferClone=(TClonesArray *)fEvtBuffer; ioman->Register("EVTBUFFERCLONE", "EVT BUFFER CLONE", fEvtBufferClone, kFALSE); ioman->Register("INFOEVENT", "INFO EVENT TREE", fRootINFOEvent, kFALSE); // ALF fRootINFOEventCopy = new TClonesArray("TRootINFOEvent"); // ALF fRootINFOEventCopy=(TClonesArray*)fRootINFOEvent; // ALF ioman->Register("INFOEVENTCLONE", "INFO EVENT TREE CLONE", fRootINFOEventCopy, kFALSE); // ALF // S. Kupny's structure - redundant with the previous one (INFOEVENT) => should be merged in the future fMbsInfo = new TMbsInfo(); fMbsInfoClone = new TClonesArray("TMbsInfo"); fMbsInfoClone = (TClonesArray *)fMbsInfo; ioman->Register("MBSINFO", "MBS INFO", fMbsInfo, kFALSE); ioman->Register("MBSINFOCLONE", "MBS INFO CLONE", fMbsInfoClone, kFALSE); fMbsInfo->SetRunNumber( fMyMbs->GetMbsRunNo() ); // ii=0; chievt=0; krattaevt=0; mbsevt=0; totevt=0; iFile=0; fLogger->Info(MESSAGE_ORIGIN," MBSUnpack::Init()------------------End "); cout << " ...return to continue..."<< endl; getchar(); } // ------------------------------------------------------------------------- void MBSUnpack::SetParTask() { } void MBSUnpack::PrintBuffer(TString Det, int * SubEvtPtr, int jmax) { for (int jj=0;jj=NFiles) { fLogger->Info(MESSAGE_ORIGIN," All events are completed........"); cout << " no more evt in infiles " << totevt<GetLMDProcessingStatus() << endl; FairRunAna::Instance()->StopProcessingLMD(); cout << " Value after: " << FairRunAna::Instance()->GetLMDProcessingStatus() << endl; } //getchar(); } // ------------------------------------------------------------------------- void MBSUnpack::Reset() // modified by SK - 12/2012 { cout << "[MBSUnpack::Reset]"<>InFile; fMyMbs= new MbsFile(InFile,fMbsFileStatus); fMyMbs->PrintFileHeader(); fMbsInfo->SetRunNumber( fMyMbs->GetMbsRunNo() ); totevt=totevt+ii; }else{ cout << "[MBSUnpack::Reset] That was last file."<Info(MESSAGE_ORIGIN," MBSUnpack::Exec(Option_t* opt) ");*/ int PrintEvtByEvt=0; fEvtBuffer->ClearBuffer(); //26092012 attenzione punto delicato bool CHIfound=false; bool CAMACfound=false; // ALF, 11/2012 bool MBallfound=false; bool KRATTAfound=false; bool ATOFfound=false; // ALF, 11/2012 bool MBSfound=false; bool LANDfound=false; bool TPattfound=false; Int_t* sebuflenght=new Int_t; Short_t* setype=new Short_t; Short_t* sesubtype=new Short_t; Char_t* sesubcrate=new Char_t; int CHITSs,CHITSm,CHITSh,MBSTSs,MBSTSm,MBSTSh; // time stamps - ALF, 11/2012 Int_t* SubEventDataPtr;//=new Int_t; // if(ii>3)Reset(); if(iFilePrintFileHeader(); if(!fIsLastEvent){ if(PrintEvtByEvt)cout << "############################# ii="<< ii << endl; if(ii%5000==0) cout<<"\033[7;34m|\033[7;0m"<GetEvent(); Int_t nrSubEvts =fMyMbs->GetNrSubEvent(); fMbsInfo->SetCamacEventNumber( fMyMbs->GetMbsEventNo() ); // SK for(Int_t j=1;j<=nrSubEvts;j++){ SubEventDataPtr=fMyMbs->GetSubEvent(j,sebuflenght,setype,sesubtype,sesubcrate); if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==256)){ CHIfound=fEvtBuffer->FillCHIBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("CHI 1st",SubEventDataPtr,4); CHITSs=*(SubEventDataPtr+1) & 0x0000ffff; // CHIMERA CHITSm=*(SubEventDataPtr+2) & 0x0000ffff; // time CHITSh=*(SubEventDataPtr+3) & 0x0000ffff; // stamp - ALF } if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==512)){ MBSfound=fEvtBuffer->FillMBSBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("MBS 1st",SubEventDataPtr,4); MBSTSs = *(SubEventDataPtr+1) & 0x0000ffff; // MBS MBSTSm = *(SubEventDataPtr+2) & 0x0000ffff; // time MBSTSh = *(SubEventDataPtr+3) & 0x0000ffff; // stamp - ALF } if((*setype==34) && (*sesubtype==1)){ // CAMAC subevent (ALF, 11/2012) CAMACfound=fEvtBuffer->FillCAMACBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("CAMAC (Stelzer) 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2700)){ MBallfound=fEvtBuffer->FillMBallBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("MicroBall 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==1)){ KRATTAfound=fEvtBuffer->FillKRATTABuf(SubEventDataPtr,*sebuflenght); // to activate when KRATTA libs debugged - ALF, 01/2013 if(PrintEvtByEvt)PrintBuffer("KRATTA 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2800)){ // SCALER subevent (ALF, 11/2012) TPattfound=fEvtBuffer->FillTPattBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("TrigPattern (scaler) 1st",SubEventDataPtr,4); // Add general info to tree - ALF, 11/2012 fRootINFOEvent->trigpat = *SubEventDataPtr; // trigger pattern } if((*setype==36) && (*sesubtype==9494)){ LANDfound=fEvtBuffer->FillLANDBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("LAND 1st",SubEventDataPtr,4); } if((*setype==32) && (*sesubtype==1130)){ // ALADiN ToF-Wall subevent (ALF, 11/2012) ATOFfound=fEvtBuffer->FillATOFBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("ToF-Wall 1st",SubEventDataPtr,4); //cout << "ATOFfound 1 [" << *sebuflenght << "]" << endl; } } if(ii==0 && CHIfound && !MBSfound){ cout << " 1st event of the file has to be an MBS events and not CHIMERA: skip this!"<FillMBSBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("MBS 1st-bis",SubEventDataPtr,4); MBSTSs = *(SubEventDataPtr+1) & 0x0000ffff; // MBS MBSTSm = *(SubEventDataPtr+2) & 0x0000ffff; // time MBSTSh = *(SubEventDataPtr+3) & 0x0000ffff; // stamp - ALF } if((*setype==34) && (*sesubtype==1)){ // CAMAC subevent (ALF, 11/2012) CAMACfound=fEvtBuffer->FillCAMACBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("CAMAC (Stelzer) 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2700)){ MBallfound=fEvtBuffer->FillMBallBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("MicroBall 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==1)){ KRATTAfound=fEvtBuffer->FillKRATTABuf(SubEventDataPtr,*sebuflenght); // to activate when KRATTA libs debugged - ALF, 01/2013 if(PrintEvtByEvt)PrintBuffer("KRATTA 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2800)){ // SCALER subevent (ALF, 11/2012) TPattfound=fEvtBuffer->FillTPattBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("TrigPattern (scaler) 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==9494)){ LANDfound=fEvtBuffer->FillLANDBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("LAND 1st-bis",SubEventDataPtr,4); } if((*setype==32) && (*sesubtype==1130)){ // ALADiN ToF-Wall subevent (ALF, 11/2012) ATOFfound=fEvtBuffer->FillATOFBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("ToF-Wall 1st-bis",SubEventDataPtr,4); } } } ii++; if(!fIsLastEvent) { if(PrintEvtByEvt)cout << "############################# ii="<< ii << endl; //if(ii%5000==0)cout << "############################# ii="<< ii << endl; if(ii%5000==0) cout<<"\033[7;34m|\033[7;0m"<GetEvent();// cout<< "Get Event qua"<GetNrSubEvent();//cout<< nrSubEvts<SetChimeraEventNumber( fMyMbs->GetMbsEventNo() ); // SK for(Int_t j=1;j<=nrSubEvts;j++){ SubEventDataPtr=fMyMbs->GetSubEvent(j,sebuflenght,setype,sesubtype,sesubcrate); if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==256)){ CHIfound=fEvtBuffer->FillCHIBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("CHIMERA 2nd",SubEventDataPtr,4); CHITSs=*(SubEventDataPtr+1) & 0x0000ffff; // CHIMERA CHITSm=*(SubEventDataPtr+2) & 0x0000ffff; // time CHITSh=*(SubEventDataPtr+3) & 0x0000ffff; // stamp - ALF } if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==512)){ MBSfound=fEvtBuffer->FillMBSBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("MBS 2nd",SubEventDataPtr,4); MBSTSs = *(SubEventDataPtr+1) & 0x0000ffff; // MBS MBSTSm = *(SubEventDataPtr+2) & 0x0000ffff; // time MBSTSh = *(SubEventDataPtr+3) & 0x0000ffff; // stamp - ALF } if((*setype==34) && (*sesubtype==1)){ // CAMAC subevent (ALF, 11/2012) CAMACfound=fEvtBuffer->FillCAMACBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("CAMAC (Stelzer) 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2700)){ MBallfound=fEvtBuffer->FillMBallBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("MicroBall 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==1)){ KRATTAfound=fEvtBuffer->FillKRATTABuf(SubEventDataPtr,*sebuflenght); // to activate when KRATTA libs debugged - ALF, 01/2013 //cout << "NEVER HAPPEN::: :) KRATTAfound [" << *sebuflenght_w << "]" << endl; if(PrintEvtByEvt)PrintBuffer("KRATTA 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2800)){ TPattfound=fEvtBuffer->FillTPattBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("TrigPattern (Stelzer) 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==9494)){ LANDfound=fEvtBuffer->FillLANDBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("LAND 2nd",SubEventDataPtr,4); } if((*setype==32) && (*sesubtype==1130)){ // ALADiN ToF-Wall subevent (ALF, 11/2012) ATOFfound=fEvtBuffer->FillATOFBuf(SubEventDataPtr,*sebuflenght); if(PrintEvtByEvt)PrintBuffer("ToF-Wall 2nd",SubEventDataPtr,4); } } ii++; // Write general informations in INFO tree branch - ALF, 11/2012 fRootINFOEvent->run = fMyMbs->GetMbsRunNo(); // run number fRootINFOEvent->ievt = fMyMbs->GetMbsEventNo(); // event number //printf("MBSUnpack: run=%d ievt=%d nrSubEvts=%d\n",fRootINFOEvent->run,fRootINFOEvent->ievt,nrSubEvts); fRootINFOEvent->time = (65536*(double(CHITSh)*65536+double(CHITSm))+double(CHITSs))/5e07; // time of the event in seconds (a time stamp unit for CHIMERA = 5 ns) - ALF, 11/2012 fRootINFOEvent->chitsh = CHITSh; // CHIMERA fRootINFOEvent->chitsm = CHITSm; // time fRootINFOEvent->chitss = CHITSs; // stamp fRootINFOEvent->mbstsh = MBSTSh; // MBS fRootINFOEvent->mbstsm = MBSTSm; // time fRootINFOEvent->mbstss = MBSTSs; // stamp fRootINFOEvent->time = (65536e0*(double(MBSTSh)*65536e0+double(MBSTSm))+double(MBSTSs))/5e07; // time of the event in seconds (a time stamp unit for CHIMERA = 5 ns) /*printf(" time=%e chitsh=%d chitsm=%d chitss=%d mbstsh=%d mbstsm=%d mbstss=%d\n ", fRootINFOEvent->time, fRootINFOEvent->chitsh = CHITSh, fRootINFOEvent->chitsm = CHITSm, fRootINFOEvent->chitss = CHITSs, fRootINFOEvent->mbstsh = MBSTSh, fRootINFOEvent->mbstsm = MBSTSm, fRootINFOEvent->mbstss = MBSTSs);*/ }else{ cout << "LAST event in file....N. "<< iFile<PrintCHIBuf(4); fEvtBuffer->PrintMBSBuf(4); fEvtBuffer->PrintMBallBuf(4); fEvtBuffer->PrintATOFBuf(4);*/ //cout <<"MBSUnpack::Exec*****************END***************"<