Skip to content

Commit

Permalink
Merge branch 'cvs'
Browse files Browse the repository at this point in the history
  • Loading branch information
plexoos committed Dec 19, 2017
2 parents 5e172ed + 42cdd05 commit eca18cc
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 57 deletions.
99 changes: 63 additions & 36 deletions StPicoDstMaker/StPicoDstMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@
#include "StPicoDstMaker/StPicoDst.h"


//_____________________________________________________________________________
//_________________
StPicoDstMaker::StPicoDstMaker(char const* name) : StMaker(name),
mMuDst(nullptr), mPicoDst(new StPicoDst()),
mEmcCollection(nullptr), mEmcPosition(nullptr),
mEmcGeom{}, mEmcIndex{},
mTpcVpdVzDiffCut(3),
mBField(0),
mVtxMode(PicoVtxMode::NotSet), // This should always be ::NotSet, do not change it, see ::Init()
mInputFileName(), mOutputFileName(), mOutputFile(nullptr),
Expand All @@ -87,19 +88,22 @@ StPicoDstMaker::StPicoDstMaker(char const* name) : StMaker(name),

std::fill_n(mStatusArrays, sizeof(mStatusArrays) / sizeof(mStatusArrays[0]), 1);
}
//_____________________________________________________________________________

//_________________
StPicoDstMaker::StPicoDstMaker(PicoIoMode ioMode, char const* fileName, char const* name) : StPicoDstMaker(name)
{
StMaker::m_Mode = ioMode;
mInputFileName = fileName;
}
//_____________________________________________________________________________

//_________________
StPicoDstMaker::~StPicoDstMaker()
{
delete mChain;
delete mPicoDst;
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::clearArrays()
{
for (int i = 0; i < StPicoArrays::NAllPicoArrays; ++i)
Expand Down Expand Up @@ -138,7 +142,8 @@ void StPicoDstMaker::SetStatus(char const* branchNameRegex, int enable)
if (StMaker::m_Mode == PicoIoMode::IoRead)
setBranchAddresses(mChain);
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::setBranchAddresses(TChain* chain)
{
if (!chain) return;
Expand All @@ -162,7 +167,8 @@ void StPicoDstMaker::setBranchAddresses(TChain* chain)
}
mTTree = mChain->GetTree();
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::streamerOff()
{
// This is to to save space on the file. No need for TObject bits for this structure.
Expand All @@ -181,7 +187,8 @@ void StPicoDstMaker::streamerOff()
StPicoBEmcPidTraits::Class()->IgnoreTObjectStreamer();
StPicoMtdPidTraits::Class()->IgnoreTObjectStreamer();
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::createArrays()
{
for (int i = 0; i < StPicoArrays::NAllPicoArrays; ++i)
Expand All @@ -191,7 +198,8 @@ void StPicoDstMaker::createArrays()

mPicoDst->set(mPicoArrays);
}
//_____________________________________________________________________________

//_________________
Int_t StPicoDstMaker::Init()
{
switch (StMaker::m_Mode)
Expand Down Expand Up @@ -240,22 +248,24 @@ Int_t StPicoDstMaker::Init()
return kStOK;
}


//_________________
int StPicoDstMaker::setVtxModeAttr()
{
if (strcmp(SAttr("PicoVtxMode"), "PicoVtxDefault") == 0)
mTpcVpdVzDiffCut = DAttr("TpcVpdVzDiffCut"); //Read the Tpc-Vpd cut from the input

if (strcasecmp(SAttr("PicoVtxMode"), "PicoVtxDefault") == 0)
{
setVtxMode(PicoVtxMode::Default);
LOG_INFO << " PicoVtxDefault is being used " << endm;
return kStOK;
}
else if (strcmp(SAttr("PicoVtxMode"), "PicoVtxVpd") == 0)
else if (strcasecmp(SAttr("PicoVtxMode"), "PicoVtxVpd") == 0)
{
setVtxMode(PicoVtxMode::Vpd);
LOG_INFO << " PicoVtxVpd is being used " << endm;
return kStOK;
}
else if (strcmp(SAttr("PicoVtxMode"), "PicoVtxVpdOrDefault") == 0)
else if (strcasecmp(SAttr("PicoVtxMode"), "PicoVtxVpdOrDefault") == 0)
{
setVtxMode(PicoVtxMode::VpdOrDefault);
LOG_INFO << " PicoVtxVpdOrDefault is being used " << endm;
Expand All @@ -265,7 +275,7 @@ int StPicoDstMaker::setVtxModeAttr()
return kStErr;
}

//_____________________________________________________________________________
//_________________
Int_t StPicoDstMaker::InitRun(Int_t const runnumber)
{
if (StMaker::m_Mode == PicoIoMode::IoWrite)
Expand All @@ -279,7 +289,7 @@ Int_t StPicoDstMaker::InitRun(Int_t const runnumber)
return kStOK;
}

//_____________________________________________________________________________
//_________________
Bool_t StPicoDstMaker::initMtd(Int_t const runnumber)
{
// Oct. 1st (approx. 273rd day) is the start of a new running year
Expand Down Expand Up @@ -396,7 +406,7 @@ Bool_t StPicoDstMaker::initMtd(Int_t const runnumber)
return kTRUE;
}

//_____________________________________________________________________________
//_________________
Int_t StPicoDstMaker::Finish()
{
if (StMaker::m_Mode == PicoIoMode::IoRead)
Expand All @@ -410,7 +420,8 @@ Int_t StPicoDstMaker::Finish()
}
return kStOK;
}
//_____________________________________________________________________________

//_________________
Int_t StPicoDstMaker::openRead()
{
if (!mChain) mChain = new TChain("PicoDst");
Expand Down Expand Up @@ -465,7 +476,8 @@ Int_t StPicoDstMaker::openRead()

return kStOK;
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::openWrite()
{

Expand All @@ -487,7 +499,8 @@ void StPicoDstMaker::openWrite()
mTTree->Branch(StPicoArrays::picoArrayNames[i], &mPicoArrays[i], bufsize, mSplit);
}
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::initEmc()
{
mEmcPosition = new StEmcPosition();
Expand All @@ -497,7 +510,8 @@ void StPicoDstMaker::initEmc()
mEmcGeom[i] = StEmcGeom::getEmcGeom(detname[i].Data());
}
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::buildEmcIndex()
{
StEmcDetector* mEmcDet = mMuDst->emcCollection()->detector(kBarrelEmcTowerId);
Expand All @@ -520,28 +534,32 @@ void StPicoDstMaker::buildEmcIndex()
}
}
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::finishEmc()
{
delete mEmcPosition;
mEmcPosition = nullptr;

std::fill_n(mEmcGeom, 4, nullptr);
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::Clear(char const*)
{
if (StMaker::m_Mode == PicoIoMode::IoRead)
return;
clearArrays();
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::closeRead()
{
delete mChain;
mChain = nullptr;
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::closeWrite()
{
if (StMaker::m_Mode == PicoIoMode::IoWrite)
Expand All @@ -553,7 +571,8 @@ void StPicoDstMaker::closeWrite()
}
}
}
//_____________________________________________________________________________

//_________________
int StPicoDstMaker::Make()
{
int returnStarCode = kStOK;
Expand All @@ -567,7 +586,8 @@ int StPicoDstMaker::Make()

return returnStarCode;
}
//_____________________________________________________________________________

//_________________
Int_t StPicoDstMaker::MakeRead()
{
if (!mChain)
Expand All @@ -594,7 +614,8 @@ Int_t StPicoDstMaker::MakeRead()

return kStOK;
}
//_____________________________________________________________________________

//_________________
Int_t StPicoDstMaker::MakeWrite()
{
StMaker::WhiteBoard("muDst", &mMuDst);
Expand Down Expand Up @@ -660,6 +681,7 @@ Int_t StPicoDstMaker::MakeWrite()
return kStOK;
}

//_________________
void StPicoDstMaker::fillEventHeader() const
{
StPicoEvent* event=StPicoDst::event();
Expand All @@ -672,7 +694,7 @@ void StPicoDstMaker::fillEventHeader() const
header->SetGMTime( (UInt_t) (event->time()) );
}

//_____________________________________________________________________________
//_________________
void StPicoDstMaker::fillTracks()
{
// We save primary tracks associated with the selected primary vertex only
Expand Down Expand Up @@ -748,7 +770,7 @@ void StPicoDstMaker::fillTracks()
}
}

//_____________________________________________________________________________
//_________________
bool StPicoDstMaker::getBEMC(const StMuTrack* t, int* id, int* adc, float* ene, float* d, int* nep, int* towid)
{
*id = -1;
Expand Down Expand Up @@ -926,13 +948,15 @@ bool StPicoDstMaker::getBEMC(const StMuTrack* t, int* id, int* adc, float* ene,

return kTRUE;
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::fillEvent()
{
int counter = mPicoArrays[StPicoArrays::Event]->GetEntries();
new((*(mPicoArrays[StPicoArrays::Event]))[counter]) StPicoEvent(*mMuDst);
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::fillEmcTrigger()
{

Expand Down Expand Up @@ -1018,15 +1042,14 @@ void StPicoDstMaker::fillEmcTrigger()
}
}

//_____________________________________________________________________________
//_________________
void StPicoDstMaker::fillMtdTrigger()
{
int counter = mPicoArrays[StPicoArrays::MtdTrigger]->GetEntries();
new((*(mPicoArrays[StPicoArrays::MtdTrigger]))[counter]) StPicoMtdTrigger(*mMuDst, mQTtoModule, mQTSlewBinEdge, mQTSlewCorr);
}


//_____________________________________________________________________________
//_________________
void StPicoDstMaker::fillBTowHits()
{
for (int i = 0; i < 4800; ++i)
Expand All @@ -1043,7 +1066,8 @@ void StPicoDstMaker::fillBTowHits()
new((*(mPicoArrays[StPicoArrays::BTowHit]))[counter]) StPicoBTowHit(softId, adc, energy);
}
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::fillBTofHits()
{
for (unsigned int i = 0; i < mMuDst->numberOfBTofHit(); ++i)
Expand All @@ -1056,7 +1080,8 @@ void StPicoDstMaker::fillBTofHits()
new((*(mPicoArrays[StPicoArrays::BTofHit]))[counter]) StPicoBTofHit(cellId);
}
}
//_____________________________________________________________________________

//_________________
void StPicoDstMaker::fillMtdHits()
{
// fill MTD hits
Expand Down Expand Up @@ -1173,6 +1198,7 @@ void StPicoDstMaker::fillMtdHits()
*
* Returns `false` otherwise.
*/
//_________________
bool StPicoDstMaker::selectVertex()
{
StMuPrimaryVertex* selectedVertex = nullptr;
Expand All @@ -1188,6 +1214,7 @@ bool StPicoDstMaker::selectVertex()
if(mVtxMode == PicoVtxMode::VpdOrDefault)
{
mMuDst->setVertexIndex(0);
selectedVertex = mMuDst->primaryVertex();
}

StBTofHeader const* mBTofHeader = mMuDst->btofHeader();
Expand All @@ -1201,7 +1228,7 @@ bool StPicoDstMaker::selectVertex()
StMuPrimaryVertex* vtx = mMuDst->primaryVertex(iVtx);
if (!vtx) continue;

if (fabs(vzVpd - vtx->position().z()) < 3.)
if (fabs(vzVpd - vtx->position().z()) < mTpcVpdVzDiffCut)
{
mMuDst->setVertexIndex(iVtx);
selectedVertex = mMuDst->primaryVertex();
Expand Down
1 change: 1 addition & 0 deletions StPicoDstMaker/StPicoDstMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class StPicoDstMaker : public StMaker
/// Selects a primary vertex from `muDst` vertex collection according to the
/// vertex selection mode `mVtxMode` specified by the user.
bool selectVertex();
Float_t mTpcVpdVzDiffCut;

/// A pointer to the main input source containing all muDst `TObjArray`s
/// filled from corresponding muDst branches
Expand Down
Loading

0 comments on commit eca18cc

Please sign in to comment.