MpdFemtoVertexAnalysis.cxx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // Femtoscopic analysis which mixes events with vertex z-binning
  3. //
  4. // MpdFemtoMaker headers
  5. // Base
  6. #include "MpdFemtoBaseTrackCut.h"
  7. #include "MpdFemtoBaseV0Cut.h"
  8. #include "MpdFemtoBaseKinkCut.h"
  9. // Infrastructure
  10. #include "MpdFemtoVertexAnalysis.h"
  11. #include "MpdFemtoParticleCollection.h"
  12. #include "MpdFemtoPicoEventCollectionVector.h"
  13. #include "MpdFemtoPicoEventCollectionVectorHideAway.h"
  14. ClassImp(MpdFemtoVertexAnalysis)
  15. //_________________
  16. MpdFemtoVertexAnalysis::MpdFemtoVertexAnalysis(unsigned int bins, float zMin, float zMax) :
  17. MpdFemtoAnalysis(),
  18. mVertexBins(bins),
  19. mOverFlow(0),
  20. mUnderFlow(0) {
  21. // Parametrized constructor
  22. mVertexZ[0] = zMin;
  23. mVertexZ[1] = zMax;
  24. if (mMixingBuffer) {
  25. delete mMixingBuffer;
  26. mMixingBuffer = nullptr;
  27. }
  28. mPicoEventCollectionVectorHideAway =
  29. new MpdFemtoPicoEventCollectionVectorHideAway(mVertexBins, mVertexZ[0], mVertexZ[1]);
  30. }
  31. //_________________
  32. MpdFemtoVertexAnalysis::MpdFemtoVertexAnalysis(const MpdFemtoVertexAnalysis& a) :
  33. MpdFemtoAnalysis(a),
  34. mVertexBins(a.mVertexBins),
  35. mOverFlow(0),
  36. mUnderFlow(0) {
  37. // Copy constructor
  38. mVertexZ[0] = a.mVertexZ[0];
  39. mVertexZ[1] = a.mVertexZ[1];
  40. if (mMixingBuffer) {
  41. delete mMixingBuffer;
  42. mMixingBuffer = nullptr;
  43. } // if (mMixingBuffer)
  44. mPicoEventCollectionVectorHideAway =
  45. new MpdFemtoPicoEventCollectionVectorHideAway(mVertexBins, mVertexZ[0], mVertexZ[1]);
  46. if (mVerbose) {
  47. std::cout << " MpdFemtoVertexAnalysis::MpdFemtoVertexAnalysis(const MpdFemtoVertexAnalysis& a) - analysis copied "
  48. << std::endl;
  49. } // if (mVerbose)
  50. }
  51. //_________________
  52. MpdFemtoVertexAnalysis& MpdFemtoVertexAnalysis::operator=(const MpdFemtoVertexAnalysis& a) {
  53. // Assignment operator
  54. if (this != &a) {
  55. MpdFemtoAnalysis::operator=(a);
  56. mVertexBins = a.mVertexBins;
  57. mVertexZ[0] = a.mVertexZ[0];
  58. mVertexZ[1] = a.mVertexZ[1];
  59. mUnderFlow = 0;
  60. mOverFlow = 0;
  61. if (mMixingBuffer) {
  62. delete mMixingBuffer;
  63. mMixingBuffer = nullptr;
  64. }
  65. mPicoEventCollectionVectorHideAway =
  66. new MpdFemtoPicoEventCollectionVectorHideAway(mVertexBins, mVertexZ[0], mVertexZ[1]);
  67. } // if ( this != &a )
  68. return *this;
  69. }
  70. //_________________
  71. MpdFemtoVertexAnalysis::~MpdFemtoVertexAnalysis() {
  72. // Now delete every PicoEvent in the EventMixingBuffer and then the Buffer itself
  73. delete mPicoEventCollectionVectorHideAway;
  74. }
  75. //_________________
  76. MpdFemtoString MpdFemtoVertexAnalysis::report() {
  77. // Prepare report fromt the execution
  78. if (mVerbose) {
  79. std::cout << "MpdFemtoVertexAnalysis - constructing report..." << std::endl;
  80. }
  81. TString report("-----------\nMpdFemtoVertexAnalysis report:\n");
  82. report += TString::Format("Events are mixed in %d bins in the range %E cm to %E cm.\n",
  83. mVertexBins, mVertexZ[0], mVertexZ[1])
  84. + TString::Format("Events underflowing: %d\n", mUnderFlow)
  85. + TString::Format("Events overflowing: %d\n", mOverFlow)
  86. + TString::Format("Now adding MpdFemtoAnalysis(base) report\n");
  87. report += MpdFemtoAnalysis::report();
  88. return MpdFemtoString((const char *) report);
  89. }
  90. //_________________
  91. void MpdFemtoVertexAnalysis::processEvent(const MpdFemtoEvent* hbtEvent) {
  92. if (mVerbose) {
  93. std::cout << " MpdFemtoVertexAnalysis::processEvent(const MpdFemtoEvent* hbtEvent) " << std::endl;
  94. }
  95. // Get right mixing buffer
  96. double vertexZ = hbtEvent->primaryVertex().Z();
  97. mMixingBuffer = mPicoEventCollectionVectorHideAway->picoEventCollection(vertexZ);
  98. if (!mMixingBuffer) {
  99. if (vertexZ < mVertexZ[0]) mUnderFlow++;
  100. if (vertexZ > mVertexZ[1]) mOverFlow++;
  101. return;
  102. }
  103. // Call processEvent() from MpdFemtoAnalysis-base
  104. MpdFemtoAnalysis::processEvent(hbtEvent);
  105. // NULL out the mixing buffer after event processed
  106. mMixingBuffer = nullptr;
  107. }
  108. //_________________
  109. TList* MpdFemtoVertexAnalysis::listSettings() {
  110. TList *settings = MpdFemtoAnalysis::listSettings();
  111. settings->AddVector(new TObjString(TString::Format("MpdFemtoVertexAnalysis.vertex_z.bins=%d", mVertexBins)),
  112. new TObjString(TString::Format("MpdFemtoVertexAnalysis.vertex_z.min=%f", mVertexZ[0])),
  113. new TObjString(TString::Format("MpdFemtoVertexAnalysis.vertex_z.max=%f", mVertexZ[1])),
  114. NULL);
  115. return settings;
  116. }
  117. //_________________________
  118. TList* MpdFemtoVertexAnalysis::getOutputList() {
  119. // Collect the list of output objects to be written
  120. TList *tOutputList = new TList();
  121. TList *p1Cut = mFirstParticleCut->getOutputList();
  122. TListIter nextp1(p1Cut);
  123. while (TObject * obj = nextp1.Next()) {
  124. tOutputList->Add(obj);
  125. }
  126. delete p1Cut;
  127. if (mSecondParticleCut != mFirstParticleCut) {
  128. TList *p2Cut = mSecondParticleCut->getOutputList();
  129. TIter nextp2(p2Cut);
  130. while (TObject * obj = nextp2()) {
  131. tOutputList->Add(obj);
  132. }
  133. delete p2Cut;
  134. } //if (fSecondParticleCut != fFirstParticleCut)
  135. TList *pairCut = mPairCut->getOutputList();
  136. TIter nextpair(pairCut);
  137. while (TObject * obj = nextpair()) {
  138. tOutputList->Add(obj);
  139. }
  140. delete pairCut;
  141. TList *eventCut = mEventCut->getOutputList();
  142. TIter nextevent(eventCut);
  143. while (TObject * obj = nextevent()) {
  144. tOutputList->Add(obj);
  145. }
  146. delete eventCut;
  147. for (auto &cf : *mCorrFctnCollection) {
  148. TList *tListCf = cf->getOutputList();
  149. TIter nextListCf(tListCf);
  150. while (TObject * obj = nextListCf()) {
  151. tOutputList->Add(obj);
  152. }
  153. delete tListCf;
  154. }
  155. return tOutputList;
  156. }