00001 #include "StMuDSTMaker/COMMON/StMuDst.h"
00002 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00003 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00004 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
00005 #include "StEvent/StTriggerId.h"
00006
00007 #include "StGammaEventMaker.h"
00008 #include "StGammaEvent.h"
00009
00010 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
00011
00012 #include "StGammaSpinMaker.h"
00013
00014 ClassImp(StGammaSpinMaker);
00015
00017
00019 StGammaSpinMaker::StGammaSpinMaker(const Char_t *name): StMaker(name), mSpinDb(0)
00020 {}
00021
00023
00025 StGammaSpinMaker::~StGammaSpinMaker()
00026 {}
00027
00029
00031 Int_t StGammaSpinMaker::Make()
00032 {
00033
00034 StMuDst *mudst = (StMuDst*)GetDataSet("MuDst");
00035 if(!mudst)
00036 {
00037 LOG_DEBUG << "Make() - No MuDst found!" << endm;
00038 return kStFatal;
00039 }
00040
00041 StGammaEventMaker *mGammaEventMaker = dynamic_cast<StGammaEventMaker*>(GetMakerInheritsFrom("StGammaEventMaker"));
00042 if(!mGammaEventMaker)
00043 {
00044 LOG_DEBUG << "Make() - No StGammaEventMaker found!" << endm;
00045 return kStFatal;
00046 }
00047
00048 StGammaEvent *mGammaEvent = mGammaEventMaker->event();
00049 if(!mGammaEvent)
00050 {
00051 LOG_DEBUG << "Make() - StGammaEventMaker contains no StGammaEvent!" << endm;
00052 return kStFatal;
00053 }
00054
00055
00056 mGammaEvent->SetDsmVertex( mudst->event()->bbcTriggerDetector().onlineTimeDifference() );
00057
00058 mSpinDb = dynamic_cast<StSpinDbMaker*>(GetMakerInheritsFrom("StSpinDbMaker"));
00059 if (!mSpinDb)
00060 {
00061 LOG_WARN << "Make() - No StSpinDbMaker found! No spin information will be stored." << endm;
00062 return kStOK;
00063 }
00064
00065 if(!mSpinDb->isValid())
00066 {
00067 LOG_WARN << Form("++++ spindb reports invalid for run=%i event=%i", GetRunNumber(), GetEventNumber()) << endm;
00068 }
00069
00070
00071
00072 StMuEvent *event = mudst -> event();
00073 StL0Trigger *trig =&(event->l0Trigger());
00074
00075 StMuTriggerIdCollection tic = event -> triggerIdCollection();
00076 StTriggerId l1trig = tic.l1();
00077
00078 UShort_t bx48 = (UShort_t)trig->bunchCrossingId();
00079 UShort_t bx7 = (UShort_t)trig->bunchCrossingId7bit( event->runNumber() );
00080 UShort_t bxStar = (UShort_t)mSpinDb->BXyellowUsingBX48(bx48);
00081
00082
00083 if( mSpinDb->isMaskedUsingBX48(bx48) ) return kStOK;
00084
00085 if( mSpinDb->offsetBX48minusBX7(bx48,bx7) != 0 )
00086 {
00087 LOG_WARN << " ++++ spindb indicates 7bit and 48bit bunch crossings are inconsistent... event invalid ++++" << endm;
00088 return kStOK;
00089 }
00090
00091 Int_t spin4 = mSpinDb->spin4usingBX48(bx48);
00092
00093
00094 mGammaEvent->SetValidDb(true);
00095 mGammaEvent->SetSpin4( (UShort_t)spin4 );
00096 mGammaEvent->SetBunchCrossing7bit( (UShort_t)bx7 );
00097 mGammaEvent->SetBunchCrossing48bit( (UShort_t)bx48 );
00098 mGammaEvent->SetBunchCrossingStar( (UShort_t)bxStar );
00099
00100 if( mSpinDb->isPolDirLong() ) mGammaEvent->SetPolarizationType( StGammaEvent::kLongLong );
00101 if( mSpinDb->isPolDirTrans() ) mGammaEvent->SetPolarizationType( StGammaEvent::kTransTrans );
00102
00103 return kStOK;
00104
00105 }
00106