/// /// Example program for Trigger Check. /// /// Missing Spill Checking Program, Original is written by Kendoll.M /// Beam Data Access was added by Yano, basing on prototype of Beam Accessing Library. #include "IHandle.hxx" #include #include #include #include #include "IMidasBank.hxx" #include "IMidasFile.hxx" #include "IMidasBankProxyRegistry.hxx" #include "ICOMETRawEvent.hxx" // COMET software includes #include "IMidasBankProxy.hxx" #include "ICOMETRawEvent.hxx" #include "IRawDataHeader.hxx" // oaRawEvent includes #include "IMCMBank.hxx" #include #include /// ROOT stuff #include "TROOT.h" #include "TFile.h" #include "TTree.h" #include "IRawBeamData.hxx" Int_t Extract_RunNumber(char FileName[], UInt_t *RunNumber, UInt_t *SubRunNumber){ char ProcessRN[200]; if (strstr(FileName,".mid.gz")==NULL){ std::cout << "error" <" << std::endl; std::cerr << "this will generate spilllist.tmp.dat as list of good spills recorded in MIDAS" << std::endl; return(1); } else{ strcpy(FileName,argv[1]); } if (Extract_RunNumber(FileName,&RunNumber,&SubRunNumber)==0){ std::cerr << "Something wrong with Filename. It should be .root" << std::endl; return 0; } std::ofstream fout("spilllist.tmp.dat",std::ios::out); //yano --memo-- //Creating BeamData instance. //yano --memo-- COMET::IRawBeamData BeamData; /// Check that there are correct number of arguments // Open midas file COMETLog("Dumping MIDAS file: " << FileName << "\n"); COMET::IMidasFile mf; bool success = mf.Open(FileName); if (!success){ printf("Cannot open input file \"%s\"\n",FileName); exit(0); }else printf("Opening input file \"%s\"\n",FileName); /// Get Run Number /// --------------------------------------------------------- /// Main loop over events. bool firstEvent = true; UInt_t serNumber,failed; UInt_t nBeam=0,nCalib=0; UInt_t TrgId=0,nSpill; UInt_t missedspill=0; UInt_t lastnspill=0; bool firstspill=true; bool Fst_bsd=true; Int_t Fst_no=0; Int_t Fst_sec=0; bool Lst_bsd=true; Int_t Lst_no=0; Int_t Lst_sec=0; Int_t TrgSec=0; Int_t HdrSec=0; Int_t missedbeamspill=0; Int_t spillnum; Int_t good_spill_flag; Int_t good_gps_flag; Int_t run_type; Int_t count_normal_spill = 0; Double_t count_normal_pot = 0; Int_t count_good_spill = 0; Double_t count_good_pot = 0; Int_t count_total_spill = 0; Double_t count_total_pot = 0; Int_t trg_sec[3]; std::cout<<"-------------------- Check Start ----------------------"<PromoteMidasBanks(false); //re->ls(); serNumber = re->GetHeader().GetSeqNo(); if(firstEvent){ serNumber = -9999; // Sequence number for first event is wrong. firstEvent = false; continue; } /// MCM Bank COMET::IHandle mcmBank; while ( mcmBank = re->GetMidasBank("OMCM",mcmBank) ) { COMET::IMCMBank& mcm = re->UseMidasBank("OMCM"); TrgId = (mcm.GetTriggerWord()>>48) & 0xffff; nSpill = (mcm.GetTriggerWord()>>32) & 0xffff; TrgSec = (Int_t) mcmBank->GetUnixTimeTrig(); HdrSec = (Int_t) re->GetHeader().GetTimeStamp(); /* if(TrgId==1){ std::cout << nSpill <<" "<< lastnspill << std::endl; } */ if(firstspill){ lastnspill=nSpill-1; } if(TrgId==1){ if((nSpill==0&&lastnspill==65535)&&!firstspill){ lastnspill=-1; } if((nSpill!=lastnspill+1&&!firstspill)){ // check for missing spills int nMSpill=0; int missing_spill=0; while ((nSpill!=lastnspill+1+nMSpill)){ missing_spill= lastnspill+nMSpill+1; if (missing_spill>65535)missing_spill=missing_spill-65536; std::cerr<<"Missed a spill!"<