// ------------------------------------------------------------------------- // ----- MBSUnpackOld source file ----- // ----- Created 12/04/12 by P. Russotto ----- // ------------------------------------------------------------------------- #include "MBSUnpackOld.h" #include "FairLogger.h" #include "TClonesArray.h" #include "FairRunAna.h" #include "FairRun.h" MBSUnpackOld::MBSUnpackOld() :FairTask() { } // ------------------------------------------------------------------------- MBSUnpackOld::MBSUnpackOld(const char* name, TString runlist, Int_t iVerbose) ///, FairRunAna* pippo : FairTask(name, iVerbose), fMyMbs(0), fMbsFileStatus(new Int_t), fIsLastEvent(0), fEvtBuffer(0), fEvtBufferClone(0) { frunlist=runlist; ///fpippo=pippo->Instance(); ///cout <<"this is pippo "<< pippo << endl; ///cout <<"this is fpippo "<< fpippo << endl; ///getchar(); } // ------------------------------------------------------------------------- MBSUnpackOld::~MBSUnpackOld() { } // ------------------------------------------------------------------------- InitStatus MBSUnpackOld::Init() { fLogger->Info(MESSAGE_ORIGIN," MBSUnpackOld::Init()------------------Start "); cout <<"runlist= "<> NFiles; inputfile >>InFile; fMyMbs= new MbsFile(InFile,fMbsFileStatus); fMyMbs->PrintFileHeader(); fEvtBuffer=new TEvtBuffer(); 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); 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," MBSUnpackOld::Init()------------------End "); cout << " ...return to continue..."<< endl; getchar(); } // ------------------------------------------------------------------------- void MBSUnpackOld::SetParTask() { } void MBSUnpackOld::PrintBuffer(TString Det, int * SubEvtPtr, int jmax) { for (int jj=0;jj=NFiles) { fLogger->Info(MESSAGE_ORIGIN," Finish all events........"); cout << " no more evt in infiles " << totevt<GetLMDProcessingStatus() << endl; FairRunAna::Instance()->StopProcessingLMD(); cout << " Value after: " << FairRunAna::Instance()->GetLMDProcessingStatus() << endl; } //getchar(); } // ------------------------------------------------------------------------- void MBSUnpackOld::Reset() { cout << "[MBSUnpackOld::Reset]"<>InFile; fMyMbs= new MbsFile(InFile,fMbsFileStatus); fMyMbs->PrintFileHeader(); fMbsInfo->SetRunNumber( fMyMbs->GetMbsRunNo() ); totevt=totevt+ii; }else{ cout << "[MBSUnpackOld::Reset] That was last file."<Info(MESSAGE_ORIGIN," MBSUnpackOld::Exec(Option_t* opt) ");*/ int PrintEvtByEvt=0; fEvtBuffer->ClearBuffer(); //26092012 attenzione punto delicato bool CHIfound=false; bool MBallfound=false; bool KRATTAfound=false; bool ToFWallfound=false; bool MBSfound=false; bool LANDfound=false; bool TPattfound=false; Int_t* sebuflenght_w=new Int_t; Short_t* setype=new Short_t; Short_t* sesubtype=new Short_t; Char_t* sesubcrate=new Char_t; 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 << "############################# ii="<< ii << endl; fIsLastEvent =fMyMbs->GetEvent(); Int_t nrSubEvts =fMyMbs->GetNrSubEvent(); //fMyMbs->PrintFileHeader(); ///FOR DEBUGING ONLY //Int_t fMbsRunNo = fMyMbs->GetMbsRunNo(); cout << "[MBSUnpackOld:] e fMbsRunNo = " << fMbsRunNo << endl; //Int_t fMbsCamacEventNo = fMyMbs->GetMbsEventNo(); cout << "[MBSUnpackOld:] e fMbsCamacEventNo = " << fMbsCamacEventNo << endl; fMbsInfo->SetCamacEventNumber( fMyMbs->GetMbsEventNo() ); for(Int_t j=1;j<=nrSubEvts;j++){ SubEventDataPtr=fMyMbs->GetSubEvent(j,sebuflenght_w,setype,sesubtype,sesubcrate); if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==256)){ CHIfound=fEvtBuffer->FillCHIBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("CHI 1st",SubEventDataPtr,4); } if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==512)){ MBSfound=fEvtBuffer->FillMBSBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("MBS 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2700)){ MBallfound=fEvtBuffer->FillMBallBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("MicroBall 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==1)){ KRATTAfound=fEvtBuffer->FillKRATTABuf(SubEventDataPtr,*sebuflenght_w); //cout << "Event number" << fMbsInfo->GetCamacEventNumber() << endl; //cout << "KRATTAfound = "<< KRATTAfound<<" [" << *sebuflenght_w << "]" << endl; if(PrintEvtByEvt)PrintBuffer("Krratta 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2800)){ TPattfound=fEvtBuffer->FillTPattBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("TrigPattern 1st",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==9494)){ LANDfound=fEvtBuffer->FillLANDBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("LAND 1st",SubEventDataPtr,4); } /*if((*setype==32) && (*sesubtype==1130)){ ToFWallfound=fEvtBuffer->FillToFWallBuf(SubEventDataPtr,*sebuflenght_w); //if(PrintEvtByEvt)PrintBuffer("ToFwall",SubEventDataPtr,4); //cout << "ToFWallfound 1 [" << *sebuflenght_w << "]" << 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_w); if(PrintEvtByEvt)PrintBuffer("MBS 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2700)){ MBallfound=fEvtBuffer->FillMBallBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("MicroBall 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==1)){ KRATTAfound=fEvtBuffer->FillKRATTABuf(SubEventDataPtr,*sebuflenght_w); //cout << "Event number" << fMbsInfo->GetCamacEventNumber() << endl; //cout << "KRATTAfound = "<< KRATTAfound<<" [" << *sebuflenght_w << "]" << endl; if(PrintEvtByEvt)PrintBuffer("Krratta 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2800)){ TPattfound=fEvtBuffer->FillTPattBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("TrigPattern 1st-bis",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==9494)){ LANDfound=fEvtBuffer->FillLANDBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("LAND 1st-bis",SubEventDataPtr,4); } /*if((*setype==32) && (*sesubtype==1130)){ ToFWallfound=fEvtBuffer->FillToFWallBuf(SubEventDataPtr,*sebuflenght_w); //if(PrintEvtByEvt)PrintBuffer("Krratta",SubEventDataPtr,4); }*/ } } ii++; if(!fIsLastEvent) { if(PrintEvtByEvt)cout << "############################# ii="<< ii << endl; if(ii%5000==0)cout << "############################# ii="<< ii << endl; fIsLastEvent = fMyMbs->GetEvent();// cout<< "Get Event qua"<GetNrSubEvent();//cout<< nrSubEvts<GetMbsEventNo(); cout << "[MBSUnpackOld:] o fMbsChimeraEventNo = " << fMbsChimeraEventNo << endl; fMbsInfo->SetChimeraEventNumber( fMyMbs->GetMbsEventNo() ); for(Int_t j=1;j<=nrSubEvts;j++){ SubEventDataPtr=fMyMbs->GetSubEvent(j,sebuflenght_w,setype,sesubtype,sesubcrate); if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==256)){ CHIfound=fEvtBuffer->FillCHIBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("CHIMERA 2nd",SubEventDataPtr,4); } if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==512)){ MBSfound=fEvtBuffer->FillMBSBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("MBS 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2700)){ MBallfound=fEvtBuffer->FillMBallBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("MicroBall 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==1)){ KRATTAfound=fEvtBuffer->FillKRATTABuf(SubEventDataPtr,*sebuflenght_w); //cout << "NEVER HAPPEN::: :) KRATTAfound [" << *sebuflenght_w << "]" << endl; if(PrintEvtByEvt)PrintBuffer("Krratta 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==2800)){ TPattfound=fEvtBuffer->FillTPattBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("TrigPattern 2nd",SubEventDataPtr,4); } if((*setype==36) && (*sesubtype==9494)){ LANDfound=fEvtBuffer->FillLANDBuf(SubEventDataPtr,*sebuflenght_w); if(PrintEvtByEvt)PrintBuffer("LAND 2nd",SubEventDataPtr,4); } /*if((*setype==32) && (*sesubtype==1130)){ ToFWallfound=fEvtBuffer->FillToFWallBuf(SubEventDataPtr,*sebuflenght_w); //cout << "ToFWallfound 3 [" << *sebuflenght_w << "]" << endl; //if(PrintEvtByEvt)PrintBuffer("ToFWall",SubEventDataPtr,4); }*/ } ii++; }else{ cout << "LAST event in file....N. "<< iFile<PrintCHIBuf(4); fEvtBuffer->PrintMBSBuf(4); fEvtBuffer->PrintMBallBuf(4); fEvtBuffer->PrintToFWallBuf(4);*/ //cout <<"MBSUnpackOld::Exec*****************END***************"<