StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StGammaSpinMaker.cxx
1 #include "StMuDSTMaker/COMMON/StMuDst.h"
2 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
3 #include "StMuDSTMaker/COMMON/StMuEvent.h"
4 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
5 #include "StEvent/StTriggerId.h"
6 
7 #include "StGammaEventMaker.h"
8 #include "StGammaEvent.h"
9 
10 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
11 
12 #include "StGammaSpinMaker.h"
13 
14 ClassImp(StGammaSpinMaker);
15 
17 // Constructor //
19 StGammaSpinMaker::StGammaSpinMaker(const Char_t *name): StMaker(name), mSpinDb(0)
20 {}
21 
23 // Destructor //
25 StGammaSpinMaker::~StGammaSpinMaker()
26 {}
27 
29 // Maker Make //
32 {
33 
34  StMuDst *mudst = (StMuDst*)GetDataSet("MuDst");
35  if(!mudst)
36  {
37  LOG_DEBUG << "Make() - No MuDst found!" << endm;
38  return kStFatal;
39  }
40 
41  StGammaEventMaker *mGammaEventMaker = dynamic_cast<StGammaEventMaker*>(GetMakerInheritsFrom("StGammaEventMaker"));
42  if(!mGammaEventMaker)
43  {
44  LOG_DEBUG << "Make() - No StGammaEventMaker found!" << endm;
45  return kStFatal;
46  }
47 
48  StGammaEvent *mGammaEvent = mGammaEventMaker->event();
49  if(!mGammaEvent)
50  {
51  LOG_DEBUG << "Make() - StGammaEventMaker contains no StGammaEvent!" << endm;
52  return kStFatal;
53  }
54 
55  // Retrieve BBC timebin information
56  mGammaEvent->SetDsmVertex( mudst->event()->bbcTriggerDetector().onlineTimeDifference() );
57 
58  mSpinDb = dynamic_cast<StSpinDbMaker*>(GetMakerInheritsFrom("StSpinDbMaker"));
59  if (!mSpinDb)
60  {
61  LOG_WARN << "Make() - No StSpinDbMaker found! No spin information will be stored." << endm;
62  return kStOK;
63  }
64 
65  if(!mSpinDb->isValid())
66  {
67  LOG_WARN << Form("++++ spindb reports invalid for run=%i event=%i", GetRunNumber(), GetEventNumber()) << endm;
68  }
69 
70 
71  // Populate StGammaTree with spin information
72  StMuEvent *event = mudst -> event();
73  StL0Trigger *trig =&(event->l0Trigger());
74 
75  StMuTriggerIdCollection tic = event -> triggerIdCollection();
76  StTriggerId l1trig = tic.l1();
77 
78  UShort_t bx48 = (UShort_t)trig->bunchCrossingId();
79  UShort_t bx7 = (UShort_t)trig->bunchCrossingId7bit( event->runNumber() );
80  UShort_t bxStar = (UShort_t)mSpinDb->BXyellowUsingBX48(bx48);
81 
82  // If bunch crossing is masked out skip event
83  if( mSpinDb->isMaskedUsingBX48(bx48) ) return kStOK;
84 
85  if( mSpinDb->offsetBX48minusBX7(bx48,bx7) != 0 )
86  {
87  LOG_WARN << " ++++ spindb indicates 7bit and 48bit bunch crossings are inconsistent... event invalid ++++" << endm;
88  return kStOK; // returns and leaves spin info in an "invalidated" state
89  }
90 
91  Int_t spin4 = mSpinDb->spin4usingBX48(bx48);
92 
93  // Finanlly, store the spin information
94  mGammaEvent->SetValidDb(true);
95  mGammaEvent->SetSpin4( (UShort_t)spin4 );
96  mGammaEvent->SetBunchCrossing7bit( (UShort_t)bx7 );
97  mGammaEvent->SetBunchCrossing48bit( (UShort_t)bx48 );
98  mGammaEvent->SetBunchCrossingStar( (UShort_t)bxStar );
99 
100  if( mSpinDb->isPolDirLong() ) mGammaEvent->SetPolarizationType( StGammaEvent::kLongLong );
101  if( mSpinDb->isPolDirTrans() ) mGammaEvent->SetPolarizationType( StGammaEvent::kTransTrans );
102 
103  return kStOK;
104 
105 }
106 
bool isPolDirTrans()
true if all needed DB tables were found
Definition: StSpinDbMaker.h:54
bool isValid()
dump spinDb content for current time stamp
Definition: StSpinDbMaker.h:53
int spin4usingBX48(int bx48)
8bit spin information
int BXyellowUsingBX48(int bx48)
4bit spin information
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Definition: Stypes.h:40
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
Collection of trigger ids as stored in MuDst.
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.
Definition: StSpinDbMaker.h:55