StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSpinInfoMaker.cxx
1 
10 #include "StRoot/StMuDSTMaker/COMMON/StMuDst.h"
11 #include "StRoot/StMuDSTMaker/COMMON/StMuEvent.h"
12 #include "StRoot/StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
13 
14 #include "StSpinInfoMaker.h"
15 
17  int ierr = kStOK;
18 
19  StMuDst *mudst = (StMuDst*)GetDataSet("MuDst");
20  if(!mudst) {
21  LOG_FATAL << "StSpinInfoMaker_t::Init(), no MuDst found!" << endm;
22  ierr = kStFatal;
23  };
24 
25  return ierr;
26 };
27 
29  //
30  // COPY DETAILS FROM MuDst
31  //
32 
33  StMuDst *mudst = (StMuDst*)GetDataSet("MuDst");
34  if(!mudst) {
35  LOG_FATAL << "StSpinInfoMaker_t::Make(), no MuDst found!" << endm;
36  return kStFatal;
37  };
38 
39  StMuEvent *event = mudst->event();
40  if( !event ){
41  LOG_FATAL << "Cannot get 'StEvent' pointer from MuDst" << endm;
42  return kStFatal;
43  };
44 
45  mSpinInfo.setDsmVertex( event->bbcTriggerDetector().onlineTimeDifference() );
46 
47  //
48  // COPY DETAILS FROM StSpinDb
49  //
50 
51  StSpinDbMaker *spinDB = dynamic_cast<StSpinDbMaker*>(GetMakerInheritsFrom("StSpinDbMaker"));
52  if (!spinDB) {
53  LOG_FATAL << "StSpinInfoMaker_t::Make(), no StSpinDbMaker found!" << endm;
54  return kStFatal;
55  };
56 
57  if( !spinDB->isValid()) {
58  LOG_WARN << "StSpinInfoMaker_t::Make(), SpinDB reports invalid for run " << GetRunNumber() << ", " << GetEventNumber() << "." << endm;
59  };
60 
61  StL0Trigger *trig =&(event->l0Trigger());
62  if( !trig ){
63  LOG_FATAL << "Cannot get 'StL0Trigger' pointer from MuDst" << endm;
64  return kStFatal;
65  };
66 
67  UShort_t bx48 = static_cast< UShort_t >( trig->bunchCrossingId() );
68  UShort_t bx7 = static_cast< UShort_t >( trig->bunchCrossingId7bit( event->runNumber() ));
69  UShort_t bxStar = static_cast< UShort_t >( spinDB->BXyellowUsingBX48(bx48) );
70 
71  mSpinInfo.setbXingIsMaskedInSpinDB( spinDB->isMaskedUsingBX48(bx48) );
72  mSpinInfo.setValidDB( spinDB->isValid() );
73  mSpinInfo.setBunchCrossing7bit( bx7 );
74  mSpinInfo.setBunchCrossing48bit( bx48 );
75  mSpinInfo.setBunchCrossingStar( bxStar );
76 
77  //
78  // SPIN PART
79  //
80 
81  mSpinInfo.setSpin4( -1 );
82  if( !spinDB->isMaskedUsingBX48(bx48) ){
83 
84  if( spinDB->offsetBX48minusBX7(bx48,bx7) != 0 ) {
85  LOG_WARN << " ++++ spindb indicates 7bit and 48bit bunch crossings are inconsistent... event invalid ++++" << endm;
86  return kStOK; // returns and leaves spin info in an "invalidated" state
87  }
88 
89  // Finanlly, store the spin information
90  Int_t spin4 = spinDB->spin4usingBX48(bx48);
91 
92  mSpinInfo.setSpin4( static_cast< UShort_t >( spin4 ) );
93 
94  if( spinDB->isPolDirLong() )
95  mSpinInfo.setPolarizationType( StSpinInfo_t::LONG_LONG_POLARIZATION );
96 
97  if( spinDB->isPolDirTrans() )
98  mSpinInfo.setPolarizationType( StSpinInfo_t::TRANS_TRANS_POLARIZATION );
99  };
100 
101  return kStOK;
102 };
103 
105 void StSpinInfoMaker_t::Clear(Option_t *opts){
106  mSpinInfo.clear();
107 };
108 
109 
110 ClassImp( StSpinInfoMaker_t );
111 
112 /*
113  * $Id: StSpinInfoMaker.cxx,v 1.2 2013/02/21 21:58:14 sgliske Exp $
114  * $Log: StSpinInfoMaker.cxx,v $
115  * Revision 1.2 2013/02/21 21:58:14 sgliske
116  * added mask field, cleaned up comments, and adjusted the logic
117  *
118  * Revision 1.1 2012/11/26 19:06:11 sgliske
119  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcTreeMaker to StRoot/StEEmcPool/StEEmcTreeMaker
120  *
121  *
122  */
void Clear(Option_t *opts="")
Clear for next event.
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
void clear()
Clear function.
Definition: StSpinInfo.cxx:18
Int_t Make()
Fill the spin info class.
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
Int_t Init()
Initialize.
Include StRoot headers.
void setValidDB(Bool_t ValidDB)
Modifiers.
Definition: StSpinInfo.h:42
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.
Definition: StSpinDbMaker.h:55