StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJanEventMaker.cxx
1 //
2 // Pibero Djawotho <pibero@iucf.indiana.edu>
3 // Indiana University
4 // Mar 1, 2006
5 //
6 
7 // ROOT
8 #include "TSystem.h"
9 
10 // STAR
11 #include "StEventTypes.h"
12 #include "StL2_2008EmulatorMaker.h"
13 
14 // Local
15 #include "JanEvent.h"
16 #include "StJanEventMaker.h"
17 
18 ClassImp(StJanEventMaker)
19 
20 
21 //==========================================
22 Int_t StJanEventMaker::Init()
23 {
24  return StMaker::Init();
25 }
26 
27 //==========================================
28 Int_t StJanEventMaker::InitRun(Int_t runNumber)
29 {
30  const Char_t* filename = Form("R%d.eve.bin", runNumber);
31  if (gSystem->Getenv("JOBID"))
32  filename = gSystem->ConcatFileName(gSystem->Getenv("SCRATCH"),
33  Form("%s.%s", filename, gSystem->Getenv("JOBID")));
34 
35  if (mFile.is_open()) mFile.close();
36  // mFile.open(filename, ios_base::app);
37  mFile.open(filename);// no append
38  mEventCounter = 0;
39  return StMaker::InitRun(runNumber);
40 }
41 
42 //==========================================
44 {
45  StEvent* stEvent = (StEvent*)GetInputDS("StEvent");
46  if (!stEvent) {
47  gMessMgr->Warning("No StEvent");
48  return kStWarn;
49  }
50  JanEvent janEvent;
51 
52  StL2_2008EmulatorMaker *L2EmuMk=(StL2_2008EmulatorMaker*)GetChain()->GetMaker("L2Emul2008"); // tmp, should have year dependent switch
53  assert(L2EmuMk);
54 
55  unsigned short *btow=0, *etow=0;
56  if(L2EmuMk->getBtowIn()) btow=L2EmuMk->getBtowBank();
57  if(L2EmuMk->getEtowIn()) etow=L2EmuMk->getEtowBank();
58 
59  // printf("i BB=%d EE=%d \n",L2EmuMk->getBtowIn(),L2EmuMk->getEtowIn());
60  // printf("a BB=%p EE=%p \n",btow=L2EmuMk->getBtowBank(),btow=L2EmuMk->getEtowBank());
61 
62  // Char_t* trig=(Char_t*)L2EmuMk->mTrigData;
63  fillJanEvent(triggerData(stEvent),btow,etow,janEvent);
64 
65  mFile << janEvent;
66  return kStOk;
67 }
68 
69 //==========================================
71 {
72  mFile.close();
73  return kStOk;
74 }
75 
76 
77 //==========================================
78 Char_t* StJanEventMaker::triggerData(StEvent* event)
79 {
80  if (!event->triggerData()) {
81  gMessMgr->Warning("No StTriggerData");
82  return 0;
83  }
84 #if 0
85  const UShort_t JPSI_MB_BITS = 0x0802;
86  if (trgData->EvtDesc.DSMInput & JPSI_MB_BITS == JPSI_MB_BITS) {
87  cout << "jpsi-mb bits on" << endl;
88  }
89  else {
90  cout << "jpsi-mb bits off" << endl;
91  }
92 #endif
93  return event->triggerData()->getTriggerStructure();
94 }
95 
96 
97 //==========================================
98 void StJanEventMaker::fillJanEvent(Char_t* trgData, UShort_t* bemcData,
99  UShort_t* eemcData, JanEvent& event)
100 {
101  Char_t* header = Form("Form2,ieve=%d,run=%d,id=%d,%d,%d,%d",
102  ++mEventCounter, GetRunNumber(), GetEventNumber(),
103  trgData != 0, bemcData != 0, eemcData != 0);
104  event.setHeader(header);
105  event.setTriggerData(trgData);
106  event.setBemcData(bemcData);
107  event.setEemcData(eemcData);
108 }
Definition: Stypes.h:42
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
Definition: Stypes.h:41