00001
00002
00003
00004
00005
00006
00007
00008 #include "TSystem.h"
00009
00010
00011 #include "StEventTypes.h"
00012 #include "StL2_2008EmulatorMaker.h"
00013
00014
00015 #include "JanEvent.h"
00016 #include "StJanEventMaker.h"
00017
00018 ClassImp(StJanEventMaker)
00019
00020
00021
00022 Int_t StJanEventMaker::Init()
00023 {
00024 return StMaker::Init();
00025 }
00026
00027
00028 Int_t StJanEventMaker::InitRun(Int_t runNumber)
00029 {
00030 const Char_t* filename = Form("R%d.eve.bin", runNumber);
00031 if (gSystem->Getenv("JOBID"))
00032 filename = gSystem->ConcatFileName(gSystem->Getenv("SCRATCH"),
00033 Form("%s.%s", filename, gSystem->Getenv("JOBID")));
00034
00035 if (mFile.is_open()) mFile.close();
00036
00037 mFile.open(filename);
00038 mEventCounter = 0;
00039 return StMaker::InitRun(runNumber);
00040 }
00041
00042
00043 Int_t StJanEventMaker::Make()
00044 {
00045 StEvent* stEvent = (StEvent*)GetInputDS("StEvent");
00046 if (!stEvent) {
00047 gMessMgr->Warning("No StEvent");
00048 return kStWarn;
00049 }
00050 JanEvent janEvent;
00051
00052 StL2_2008EmulatorMaker *L2EmuMk=(StL2_2008EmulatorMaker*)GetChain()->GetMaker("L2Emul2008");
00053 assert(L2EmuMk);
00054
00055 unsigned short *btow=0, *etow=0;
00056 if(L2EmuMk->getBtowIn()) btow=L2EmuMk->getBtowBank();
00057 if(L2EmuMk->getEtowIn()) etow=L2EmuMk->getEtowBank();
00058
00059
00060
00061
00062
00063 fillJanEvent(triggerData(stEvent),btow,etow,janEvent);
00064
00065 mFile << janEvent;
00066 return kStOk;
00067 }
00068
00069
00070 Int_t StJanEventMaker::Finish()
00071 {
00072 mFile.close();
00073 return kStOk;
00074 }
00075
00076
00077
00078 Char_t* StJanEventMaker::triggerData(StEvent* event)
00079 {
00080 if (!event->triggerData()) {
00081 gMessMgr->Warning("No StTriggerData");
00082 return 0;
00083 }
00084 #if 0
00085 const UShort_t JPSI_MB_BITS = 0x0802;
00086 if (trgData->EvtDesc.DSMInput & JPSI_MB_BITS == JPSI_MB_BITS) {
00087 cout << "jpsi-mb bits on" << endl;
00088 }
00089 else {
00090 cout << "jpsi-mb bits off" << endl;
00091 }
00092 #endif
00093 return event->triggerData()->getTriggerStructure();
00094 }
00095
00096
00097
00098 void StJanEventMaker::fillJanEvent(Char_t* trgData, UShort_t* bemcData,
00099 UShort_t* eemcData, JanEvent& event)
00100 {
00101 Char_t* header = Form("Form2,ieve=%d,run=%d,id=%d,%d,%d,%d",
00102 ++mEventCounter, GetRunNumber(), GetEventNumber(),
00103 trgData != 0, bemcData != 0, eemcData != 0);
00104 event.setHeader(header);
00105 event.setTriggerData(trgData);
00106 event.setBemcData(bemcData);
00107 event.setEemcData(eemcData);
00108 }