MpdFemtoVertexMultAnalysis.cxx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. //
  2. // Perform femtoscopic analysis using z- and multiplicity binnings
  3. //
  4. // C++ headers
  5. #include <iostream>
  6. // MpdFemtoMaker headers
  7. // Base
  8. #include "MpdFemtoBaseTrackCut.h"
  9. #include "MpdFemtoBaseV0Cut.h"
  10. #include "MpdFemtoBaseKinkCut.h"
  11. #include "MpdFemtoBaseXiCut.h"
  12. // Infrastructure
  13. #include "MpdFemtoVertexMultAnalysis.h"
  14. #include "MpdFemtoParticleCollection.h"
  15. #include "MpdFemtoPicoEventCollectionVector.h"
  16. #include "MpdFemtoPicoEventCollectionVectorHideAway.h"
  17. // ROOT headers
  18. #include "TString.h"
  19. ClassImp(MpdFemtoVertexMultAnalysis)
  20. //_________________
  21. MpdFemtoVertexMultAnalysis::MpdFemtoVertexMultAnalysis(unsigned int binsVertex,
  22. double minVertex,
  23. double maxVertex,
  24. unsigned int binsMult,
  25. double minMult,
  26. double maxMult) :
  27. MpdFemtoAnalysis(),
  28. mVertexZBins(binsVertex),
  29. mOverFlowVertexZ(0),
  30. mUnderFlowVertexZ(0),
  31. mMultBins(binsMult),
  32. mOverFlowMult(0),
  33. mUnderFlowMult(0) {
  34. // Constructor
  35. mVertexZ[0] = minVertex;
  36. mVertexZ[1] = maxVertex;
  37. mMult[0] = minMult;
  38. mMult[1] = maxMult;
  39. // Print out warnings, will help user to fix these bugs
  40. if (minVertex >= maxVertex) {
  41. std::cout << "[WARNING] MpdFemtoVertexMultAnalysis - wrong z-vertex positions ("
  42. << minVertex << " >= " << maxVertex << "). No events are expected to pass."
  43. << std::endl;
  44. }
  45. if (minMult >= maxMult) {
  46. std::cout << "[WARNING] MpdFemtoVertexMultAnalysis - wrong multiplicity intervals ("
  47. << minMult << " >= " << maxMult << "). No events are expected to pass."
  48. << std::endl;
  49. }
  50. if (!mCorrFctnCollection) {
  51. mCorrFctnCollection = new MpdFemtoCorrFctnCollection;
  52. }
  53. // If the event collection was already create (it should NOT be) delete
  54. // before we allocate a new one
  55. if (mMixingBuffer) {
  56. delete mMixingBuffer;
  57. mMixingBuffer = nullptr;
  58. }
  59. mPicoEventCollectionVectorHideAway =
  60. new MpdFemtoPicoEventCollectionVectorHideAway(mVertexZBins, mVertexZ[0], mVertexZ[1],
  61. mMultBins, mMult[0], mMult[1]);
  62. }
  63. //_________________
  64. MpdFemtoVertexMultAnalysis::MpdFemtoVertexMultAnalysis(const MpdFemtoVertexMultAnalysis& a) :
  65. MpdFemtoAnalysis(a),
  66. mVertexZBins(a.mVertexZBins),
  67. mOverFlowVertexZ(0),
  68. mUnderFlowVertexZ(0),
  69. mMultBins(a.mMultBins),
  70. mOverFlowMult(0),
  71. mUnderFlowMult(0) {
  72. // Copy constructor
  73. mVertexZ[0] = a.mVertexZ[0];
  74. mVertexZ[1] = a.mVertexZ[1];
  75. mMult[0] = a.mMult[0];
  76. mMult[1] = a.mMult[1];
  77. if (mMixingBuffer) {
  78. delete mMixingBuffer;
  79. mMixingBuffer = nullptr;
  80. }
  81. if (mPicoEventCollectionVectorHideAway) {
  82. delete mPicoEventCollectionVectorHideAway;
  83. }
  84. mPicoEventCollectionVectorHideAway =
  85. new MpdFemtoPicoEventCollectionVectorHideAway(mVertexZBins, mVertexZ[0], mVertexZ[1],
  86. mMultBins, mMult[0], mMult[1]);
  87. if (mVerbose) {
  88. std::cout << "MpdFemtoVertexMultAnalysis::MpdFemtoVertexMultAnalysis(const MpdFemtoVertexMultAnalysis& a) - "
  89. << "analysis copied" << std::endl;
  90. } // if (mVerbose)
  91. }
  92. //_________________
  93. MpdFemtoVertexMultAnalysis& MpdFemtoVertexMultAnalysis::operator=(const MpdFemtoVertexMultAnalysis& a) {
  94. // Assignement operator
  95. if (this != &a) {
  96. // Allow parent class to copy the cuts and correlation functions
  97. MpdFemtoAnalysis::operator=(a);
  98. mVertexZBins = a.mVertexZBins;
  99. mMultBins = a.mMultBins;
  100. mVertexZ[0] = a.mVertexZ[0];
  101. mVertexZ[1] = a.mVertexZ[1];
  102. mUnderFlowVertexZ = 0;
  103. mOverFlowVertexZ = 0;
  104. mMult[0] = a.mMult[0];
  105. mMult[1] = a.mMult[1];
  106. mUnderFlowMult = 0;
  107. mOverFlowMult = 0;
  108. if (mMixingBuffer) {
  109. delete mMixingBuffer;
  110. mMixingBuffer = nullptr;
  111. }
  112. delete mPicoEventCollectionVectorHideAway;
  113. mPicoEventCollectionVectorHideAway =
  114. new MpdFemtoPicoEventCollectionVectorHideAway(mVertexZBins, mVertexZ[0], mVertexZ[1],
  115. mMultBins, mMult[0], mMult[1]);
  116. } // if ( this != &a)
  117. return *this;
  118. }
  119. //_________________
  120. MpdFemtoVertexMultAnalysis::~MpdFemtoVertexMultAnalysis() {
  121. // Destructor
  122. // Now delete every PicoEvent in the EventMixingBuffer and
  123. // then the Buffer itself
  124. delete mPicoEventCollectionVectorHideAway;
  125. }
  126. //_________________
  127. MpdFemtoString MpdFemtoVertexMultAnalysis::report() {
  128. // Prepare a report of the execution
  129. if (mVerbose) {
  130. std::cout << "MpdFemtoVertexMultAnalysis - constructing report..." << std::endl;
  131. }
  132. TString report("-----------\nHbt MpdFemtoVertexMultAnalysis Report:\n");
  133. report += TString::Format("Events are mixed in %d VertexZ bins in the range %E cm to %E cm.\n",
  134. mVertexZBins, mVertexZ[0], mVertexZ[1])
  135. + TString::Format("Events underflowing: %d\n", mUnderFlowVertexZ)
  136. + TString::Format("Events overflowing: %d\n", mOverFlowVertexZ)
  137. + TString::Format("Events are mixed in %d Mult bins in the range %E cm to %E cm.\n",
  138. mMultBins, mMult[0], mMult[1])
  139. + TString::Format("Events underflowing: %d\n", mUnderFlowMult)
  140. + TString::Format("Events overflowing: %d\n", mOverFlowMult)
  141. + TString::Format("Now adding MpdFemtoAnalysis(base) report\n")
  142. + MpdFemtoAnalysis::report();
  143. return MpdFemtoString((const char *) report);
  144. }
  145. //_________________
  146. TList* MpdFemtoVertexMultAnalysis::listSettings() {
  147. TList *settings = MpdFemtoAnalysis::listSettings();
  148. settings->AddVector(new TObjString(TString::Format("MpdFemtoVertexMultAnalysis.vertex_z.bins=%d", mVertexZBins)),
  149. new TObjString(TString::Format("MpdFemtoVertexMultAnalysis.vertex_z.min=%f", mVertexZ[0])),
  150. new TObjString(TString::Format("MpdFemtoVertexMultAnalysis.vertex_z.max=%f", mVertexZ[1])),
  151. new TObjString(TString::Format("MpdFemtoVertexMultAnalysis.multiplicity.bins=%d", mMultBins)),
  152. new TObjString(TString::Format("MpdFemtoVertexMultAnalysis.multiplicity.min=%f", mMult[0])),
  153. new TObjString(TString::Format("MpdFemtoVertexMultAnalysis.multiplicity.max=%f", mMult[1])),
  154. NULL);
  155. return settings;
  156. }
  157. //_________________________
  158. TList* MpdFemtoVertexMultAnalysis::getOutputList() {
  159. // Collect the list of output objects to be written
  160. TList *tOutputList = new TList();
  161. TList *p1Cut = mFirstParticleCut->getOutputList();
  162. TListIter nextp1(p1Cut);
  163. while (TObject * obj = nextp1.Next()) {
  164. tOutputList->Add(obj);
  165. }
  166. delete p1Cut;
  167. if (mSecondParticleCut != mFirstParticleCut) {
  168. TList *p2Cut = mSecondParticleCut->getOutputList();
  169. TIter nextp2(p2Cut);
  170. while (TObject * obj = nextp2()) {
  171. tOutputList->Add(obj);
  172. }
  173. delete p2Cut;
  174. } //if (fSecondParticleCut != fFirstParticleCut)
  175. TList *pairCut = mPairCut->getOutputList();
  176. TIter nextpair(pairCut);
  177. while (TObject * obj = nextpair()) {
  178. tOutputList->Add(obj);
  179. }
  180. delete pairCut;
  181. TList *eventCut = mEventCut->getOutputList();
  182. TIter nextevent(eventCut);
  183. while (TObject * obj = nextevent()) {
  184. tOutputList->Add(obj);
  185. }
  186. delete eventCut;
  187. for (auto &cf : *mCorrFctnCollection) {
  188. TList *tListCf = cf->getOutputList();
  189. TIter nextListCf(tListCf);
  190. while (TObject * obj = nextListCf()) {
  191. tOutputList->Add(obj);
  192. }
  193. delete tListCf;
  194. }
  195. return tOutputList;
  196. }
  197. //_________________
  198. void MpdFemtoVertexMultAnalysis::processEvent(const MpdFemtoEvent* hbtEvent) {
  199. // Perform event processing in bins of z vertex and multiplicity
  200. // Find the correct mixing buffer
  201. double vertexZ = hbtEvent->primaryVertex().Z();
  202. double mult = hbtEvent->refMult();
  203. mMixingBuffer = mPicoEventCollectionVectorHideAway->picoEventCollection(vertexZ, mult);
  204. if (!mMixingBuffer) {
  205. if (vertexZ < mVertexZ[0]) mUnderFlowVertexZ++;
  206. if (vertexZ > mVertexZ[1]) mOverFlowVertexZ++;
  207. if (mult < mMult[0]) mUnderFlowMult++;
  208. if (mult > mMult[1]) mOverFlowMult++;
  209. return;
  210. }
  211. // Call ProcessEvent() from MpdFemtoAnalysis-base
  212. MpdFemtoAnalysis::processEvent(hbtEvent);
  213. // NULL out the mixing buffer after event processed
  214. mMixingBuffer = nullptr;
  215. }