MpdFemtoAnalysis.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /**
  2. * \class MpdFemtoAnalsysis
  3. * \brief An example of the most basic (concrete) analysis.
  4. *
  5. * Most other analyses (e.g. MpdFemtoVertexAnalysis) inherit from this one.
  6. * Provides basic functionality for the analysis. To properly set up the
  7. * analysis the following steps should be taken:
  8. *
  9. * - create particle cuts and add them via setFirstParticleCut and
  10. * setSecondParticleCut. If one analyzes identical particle
  11. * correlations, the first particle cut must be also the second
  12. * particle cut.
  13. *
  14. * - create pair cuts and add them via setPairCut
  15. *
  16. * - create one or many correlation functions and add them via
  17. * addCorrFctn method.
  18. *
  19. * - specify how many events are to be strored in the mixing buffer for
  20. * background construction
  21. *
  22. * Then, when the analysis is run, for each event, the eventBegin is
  23. * called before any processing is done, then the ProcessEvent is called
  24. * which takes care of creating real and mixed pairs and sending them
  25. * to all the registered correlation functions. At the end of each event,
  26. * after all pairs are processed, eventEnd is called. After the whole
  27. * analysis finishes (there is no more events to process) finish() is
  28. * called.
  29. *
  30. * \author Grigory Nigmatkulov (NRNU MEPhI)
  31. * \date May 18, 2019
  32. * \email nigmatkulov@gmail.com
  33. */
  34. #ifndef MpdFemtoAnalysis_h
  35. #define MpdFemtoAnalysis_h
  36. // MpdFemtoMaker headers
  37. // Base classes
  38. #include "MpdFemtoBaseAnalysis.h"
  39. #include "MpdFemtoBasePairCut.h"
  40. #include "MpdFemtoBaseEventCut.h"
  41. #include "MpdFemtoBaseParticleCut.h"
  42. #include "MpdFemtoBaseCorrFctn.h"
  43. // Infrustructure classes
  44. #include "MpdFemtoCorrFctnCollection.h"
  45. #include "MpdFemtoPicoEventCollection.h"
  46. #include "MpdFemtoParticleCollection.h"
  47. #include "MpdFemtoPicoEvent.h"
  48. // ROOT headers
  49. #include "TList.h"
  50. // Forward declaration
  51. class MpdFemtoPicoEventCollectionVectorHideAway;
  52. //_________________
  53. class MpdFemtoAnalysis : public MpdFemtoBaseAnalysis {
  54. public:
  55. /// Construct with default parameters
  56. ///
  57. /// All pointer members are initialized to NULL except for the correlation
  58. /// function collection (mCorrFctnCollection) and the mixing buffer
  59. /// (mMixingBuffer) which are created with default parameters.
  60. MpdFemtoAnalysis();
  61. /// Copy parameters from another analysis.
  62. ///
  63. /// All parameters are copied and cuts & correlation functions are cloned.
  64. /// A new (empty) mixing buffer is created and the number of events processed
  65. /// (mNeventsProcessed) is set to 0. The EventCollectionHideAway is NOT
  66. /// copied, and it's up to the subclass to clone if neccessary.
  67. MpdFemtoAnalysis(const MpdFemtoAnalysis&);
  68. /// Copy constructor
  69. MpdFemtoAnalysis& operator=(const MpdFemtoAnalysis&);
  70. /// Default destructor
  71. virtual ~MpdFemtoAnalysis();
  72. //
  73. // Setters and getters
  74. //
  75. /// Return pointer to a pair cut
  76. virtual MpdFemtoBasePairCut* pairCut();
  77. /// Return pointer to an event cut
  78. virtual MpdFemtoBaseEventCut* eventCut();
  79. /// Return pointer to a first particle cut
  80. virtual MpdFemtoBaseParticleCut* firstParticleCut();
  81. /// Return pointer to a first particle cut
  82. virtual MpdFemtoBaseParticleCut* secondParticleCut();
  83. /// Return pointer to the correlation function collection
  84. MpdFemtoCorrFctnCollection* corrFctnCollection();
  85. /// Access to CFs within the collection
  86. virtual MpdFemtoBaseCorrFctn* corrFctn(int n);
  87. /// Add correlation function to the analysis
  88. void addCorrFctn(MpdFemtoBaseCorrFctn* cf) {
  89. mCorrFctnCollection->push_back(cf);
  90. cf->setAnalysis((MpdFemtoBaseAnalysis*)this);
  91. }
  92. /// Set pair cut
  93. void setPairCut(MpdFemtoBasePairCut* x) {
  94. mPairCut = x;
  95. x->setAnalysis((MpdFemtoBaseAnalysis*)this);
  96. }
  97. /// Set event cut
  98. void setEventCut(MpdFemtoBaseEventCut* x) {
  99. mEventCut = x;
  100. x->setAnalysis((MpdFemtoBaseAnalysis*)this);
  101. }
  102. /// Set first particle cut
  103. void setFirstParticleCut(MpdFemtoBaseParticleCut* x) {
  104. mFirstParticleCut = x;
  105. x->setAnalysis((MpdFemtoBaseAnalysis*)this);
  106. }
  107. /// Set second particle cut
  108. void setSecondParticleCut(MpdFemtoBaseParticleCut* x) {
  109. mSecondParticleCut = x;
  110. x->setAnalysis((MpdFemtoBaseAnalysis*)this);
  111. }
  112. /// Set minimal size of the particle collection
  113. void setMinSizePartCollection(unsigned int& minSize) {
  114. mMinSizePartCollection = minSize;
  115. }
  116. /// Set Reshuffling mode for particles
  117. /// \par 0 as is (do not swap of reshuffle particles)
  118. /// \par 1 swap particles from pair
  119. /// \par 2 reshuffle using Fisher Yates algorythm
  120. void setReshuffle(unsigned int type = 1);
  121. /// Set verbose mode
  122. void setVerboseMode(const bool& isVerbose) {
  123. mVerbose = isVerbose;
  124. }
  125. /// Return size of the event buffer to mix
  126. unsigned int numEventsToMix() {
  127. return mNumEventsToMix;
  128. }
  129. /// Set number of events to mix
  130. void setNumEventsToMix(const unsigned int& nmix) {
  131. mNumEventsToMix = nmix;
  132. }
  133. /// Return pointer ot the current event
  134. MpdFemtoPicoEvent* currentPicoEvent() {
  135. return mPicoEvent;
  136. }
  137. /// Return pointer to the current mixing buffer (particle collection)
  138. MpdFemtoPicoEventCollection* mixingBuffer() {
  139. return mMixingBuffer;
  140. }
  141. /// If mixing buffer is full
  142. bool mixingBufferFull() {
  143. return ( mMixingBuffer->size() >= mNumEventsToMix);
  144. }
  145. /// If first and second particle are identical
  146. bool analyzeIdenticalParticles() {
  147. return (mFirstParticleCut == mSecondParticleCut);
  148. }
  149. ///Returns particles reshuffling type
  150. char reshuffle() {
  151. return mReshuffle;
  152. }
  153. /// Returns report of reshuffle settings
  154. MpdFemtoString reshReport();
  155. /// Returns reports of all cuts applied and correlation functions being done
  156. virtual MpdFemtoString report();
  157. /// Return list of cut settings for the analysis
  158. virtual TList* listSettings();
  159. /// Return a TList of objects to be written as output
  160. virtual TList* getOutputList();
  161. /// Initialization code run at the beginning of processing an event
  162. ///
  163. /// This is implemented by calling EventBegin for each member cut
  164. /// and correlation function
  165. virtual void eventBegin(const MpdFemtoEvent*);
  166. /// Bulk of analysis code
  167. ///
  168. /// This functions begins by calling EventBegin. If the event passes the
  169. /// event cut, pairs are made from the particles passing their respective
  170. /// cuts. The pairs are passed to each correlation function's AddRealPair
  171. /// method. Pairs made between particles in this event and events in the
  172. /// mixing buffer, are passed to the correlation functions' AddMixedPair
  173. /// method. The event is then added to the mixing buffer. The EventEnd() is
  174. /// called exactly once upon exiting this function.
  175. virtual void processEvent(const MpdFemtoEvent*);
  176. /// Cleanup code after processing each event
  177. ///
  178. /// Calls EventEnd for each member cut and correlation function.
  179. virtual void eventEnd(const MpdFemtoEvent*);
  180. /// Returns number of events which have been passed to processEvent.
  181. int nEventsProcessed() {
  182. return mNeventsProcessed;
  183. }
  184. /// Finish the analysis
  185. virtual void finish();
  186. friend class MpdFemtoLikeSignAnalysis;
  187. protected:
  188. /// Increment fNeventsProcessed - is this method neccessary?
  189. void addEventProcessed();
  190. /// Build pairs, check pair cuts, and call CFs' AddRealPair() or
  191. /// AddMixedPair() methods. If no second particle collection is
  192. /// specfied, make pairs within first particle collection.
  193. ///
  194. /// \param type Either the string "real" or "mixed", specifying which method
  195. /// to call (AddRealPair or AddMixedPair)
  196. void makePairs(const char* type, MpdFemtoParticleCollection*, MpdFemtoParticleCollection* p2 = 0);
  197. /// Mixing Buffer used for Analyses which wrap this one
  198. MpdFemtoPicoEventCollectionVectorHideAway* mPicoEventCollectionVectorHideAway; //!
  199. /// Pair cut
  200. MpdFemtoBasePairCut* mPairCut;
  201. /// Correlation function collection
  202. MpdFemtoCorrFctnCollection* mCorrFctnCollection;
  203. /// Event cut
  204. MpdFemtoBaseEventCut* mEventCut;
  205. /// The first particle cut
  206. MpdFemtoBaseParticleCut* mFirstParticleCut;
  207. /// The second particle cut
  208. MpdFemtoBaseParticleCut* mSecondParticleCut;
  209. /// Event collection (mixing buffer)
  210. MpdFemtoPicoEventCollection* mMixingBuffer;
  211. /// Pointer to the event
  212. MpdFemtoPicoEvent* mPicoEvent; //!
  213. /// How many "previous" events get mixed with this one, to make background
  214. unsigned int mNumEventsToMix;
  215. /// Don't use event if it has fewer than this many particles passing ParticleCuts default 0
  216. unsigned int mNeventsProcessed;
  217. /// Minimum # particles in ParticleCollection
  218. unsigned int mMinSizePartCollection;
  219. /// Particles Reshuffling
  220. ///0 - no reshuffling
  221. ///1 - swapping particles in pairs
  222. ///2 - Fisher–Yates shuffling algorithm for particle collection
  223. /// default: mReshuffle=1
  224. char mReshuffle;
  225. /// Print info
  226. bool mVerbose;
  227. ClassDef(MpdFemtoAnalysis, 0)
  228. };
  229. //_________________
  230. inline MpdFemtoBasePairCut* MpdFemtoAnalysis::pairCut() {
  231. return mPairCut;
  232. }
  233. //_________________
  234. inline MpdFemtoBaseEventCut* MpdFemtoAnalysis::eventCut() {
  235. return mEventCut;
  236. }
  237. //_________________
  238. inline MpdFemtoBaseParticleCut* MpdFemtoAnalysis::firstParticleCut() {
  239. return mFirstParticleCut;
  240. }
  241. //_________________
  242. inline MpdFemtoBaseParticleCut* MpdFemtoAnalysis::secondParticleCut() {
  243. return mSecondParticleCut;
  244. }
  245. //_________________
  246. inline MpdFemtoCorrFctnCollection* MpdFemtoAnalysis::corrFctnCollection() {
  247. return mCorrFctnCollection;
  248. }
  249. #endif // #define MpdFemtoAnalysis_h