HbtFitter.cxx 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644
  1. #include "HbtFitter.h"
  2. #include <TMath.h>
  3. #include <TString.h>
  4. #include <iostream>
  5. Double_t R_GAUS_TO_EXPO = 1./TMath::Sqrt( TMath::Pi() );
  6. Double_t hBar = 0.1973269718;
  7. //_________________
  8. HbtFitter* HbtFitter::objHbtFitter=0;
  9. //_________________
  10. HbtFitter::HbtFitter(Int_t PartType, Int_t SourceForm,
  11. Int_t NonFemtoForm, Bool_t ExcludePoints) {
  12. //Set basic parameters
  13. SetPartType(PartType);
  14. SetSourceForm(SourceForm);
  15. SetNonFemtoForm(NonFemtoForm);
  16. SetExcludeFromFit(ExcludePoints);
  17. SetFitMethod(0);
  18. //Correct on MC or not
  19. mCorrectOnMc = false;
  20. //Project by bins or by vals
  21. mProjectionType = false;
  22. //Number of femtoscopic parameters: lambda, R
  23. mFemto1DParNum = 2;
  24. mFemto3DParNum = 7;
  25. //Fixed parameter vector initialization
  26. if(!mFixParameters1D.empty()) {
  27. mFixParameters1D.clear();
  28. }
  29. if(!mFixParameters3D.empty()) {
  30. mFixParameters3D.clear();
  31. }
  32. //Initialize fit parameters
  33. mQinvVal[0] = 0.; mQinvVal[1] = 1.;
  34. mQoutVal[0] = 0.; mQoutVal[1] = 1.;
  35. mQsideVal[0] = 0.; mQsideVal[1] = 1.;
  36. mQlongVal[0] = 0.; mQlongVal[1] = 1.;
  37. //Number of Q bins
  38. mQinvNbins = 50;
  39. mQoutNbins = 50;
  40. mQsideNbins = 50;
  41. mQlongNbins = 50;
  42. //Projection ranges (in bins and in vals)
  43. mOutProjBins[0] = 1; mOutProjBins[1] = 6;
  44. mSideProjBins[0] = 1; mSideProjBins[1] = 6;
  45. mLongProjBins[0] = 1; mLongProjBins[1] = 6;
  46. mOutProjVals[0] = 0.; mOutProjVals[1] = 0.05;
  47. mSideProjVals[0] = 0.; mSideProjVals[1] = 0.05;
  48. mLongProjVals[0] = 0.; mLongProjVals[1] = 0.05;
  49. //Clean fit parameters
  50. if(!mFemto1DVal.empty()) {
  51. mFemto1DVal.clear();
  52. }
  53. if(!mFemto1DValErr.empty()) {
  54. mFemto1DValErr.clear();
  55. }
  56. if(!mNonFemto1DVal.empty()) {
  57. mNonFemto1DVal.clear();
  58. }
  59. if(!mNonFemto1DValErr.empty()) {
  60. mNonFemto1DValErr.clear();
  61. }
  62. if(!mFemto3DVal.empty()) {
  63. mFemto3DVal.clear();
  64. }
  65. if(!mFemto3DValErr.empty()) {
  66. mFemto3DValErr.clear();
  67. }
  68. if(!mNonFemto3DVal.empty()) {
  69. mNonFemto3DVal.clear();
  70. }
  71. if(!mNonFemto3DValErr.empty()) {
  72. mNonFemto3DValErr.clear();
  73. }
  74. //Use Coulomb correction if it is not set
  75. mUseCoulombCorrection = true;
  76. //Initialize 1D non-femto parameters
  77. for(Int_t iIter=0; iIter<3; iIter++) {
  78. mNonFemto1DParArr[iIter] = 0;
  79. mNonFemto1DParErrArr[iIter] = 0;
  80. }
  81. //Initialize 3D non-femto parameters
  82. for(Int_t iIter1=0; iIter1<3; iIter1++) { //Out,Side,Long
  83. //iIter1 corresponds to out,side,long
  84. for(Int_t iIter2=0; iIter2<3; iIter2++) {
  85. //iIter2 corresponds to the mNonFemtoParNum
  86. mNonFemto3DParArr[iIter1][iIter2] = 0;
  87. mNonFemto3DParErrArr[iIter1][iIter2] = 0;
  88. }
  89. }
  90. //Set null pointers to the histograms
  91. h1dNumer = NULL;
  92. h1dDenom = NULL;
  93. h1dCorrFctn = NULL;
  94. h1dMcNumer = NULL;
  95. h1dMcDenom = NULL;
  96. h1dMcCorrFctn = NULL;
  97. h3dNumer = NULL;
  98. h3dDenom = NULL;
  99. h3dCorrFctn = NULL;
  100. h3dCoulombWeight = NULL;
  101. h3dMcNumer = NULL;
  102. h3dMcDenom = NULL;
  103. h3dMcCorrFctn = NULL;
  104. //3D fit numerator
  105. h3dFitNumerator = NULL;
  106. h3dFitQoutProj = NULL;
  107. h3dFitQsideProj = NULL;
  108. h3dFitQlongProj = NULL;
  109. //3D correlation function and 3D fit projections
  110. h3dQoutProjNum = NULL;
  111. h3dQoutProjDen = NULL;
  112. h3dMcQoutProjNum = NULL;
  113. h3dMcQoutProjDen = NULL;
  114. h3dQsideProjNum = NULL;
  115. h3dQsideProjDen = NULL;
  116. h3dMcQsideProjNum = NULL;
  117. h3dMcQsideProjDen = NULL;
  118. h3dQlongProjNum = NULL;
  119. h3dQlongProjDen = NULL;
  120. h3dMcQlongProjNum = NULL;
  121. h3dMcQlongProjDen = NULL;
  122. h3dCorrFctnOutProj = NULL;
  123. h3dCorrFctnFitOutProj = NULL;
  124. h3dCorrFctnSideProj = NULL;
  125. h3dCorrFctnFitSideProj = NULL;
  126. h3dCorrFctnLongProj = NULL;
  127. h3dCorrFctnFitLongProj = NULL;
  128. //Pointer to the current object
  129. SetObject(this);
  130. }
  131. //_________________
  132. HbtFitter::~HbtFitter() {
  133. //Cleaning 1D histograms
  134. if(h1dNumer) delete h1dNumer; h1dNumer=NULL;
  135. if(h1dDenom) delete h1dDenom; h1dDenom=NULL;
  136. if(h1dCorrFctn) delete h1dCorrFctn; h1dCorrFctn=NULL;
  137. if(h1dMcNumer) delete h1dMcNumer; h1dMcNumer=NULL;
  138. if(h1dMcDenom) delete h1dMcDenom; h1dMcDenom=NULL;
  139. if(h1dMcCorrFctn) delete h1dMcCorrFctn; h1dMcCorrFctn=NULL;
  140. if(h1dFitNumerator) delete h1dFitNumerator; h1dFitNumerator=NULL;
  141. //Cleaning 3D histograms
  142. if(h3dNumer) delete h3dNumer; h3dNumer=NULL;
  143. if(h3dDenom) delete h3dDenom; h3dDenom=NULL;
  144. if(h3dCorrFctn) delete h3dCorrFctn; h3dCorrFctn=NULL;
  145. if(h3dCoulombWeight) delete h3dCoulombWeight; h3dCoulombWeight=NULL;
  146. if(h3dMcNumer) delete h3dMcNumer; h3dMcNumer=NULL;
  147. if(h3dMcDenom) delete h3dMcDenom; h3dMcDenom=NULL;
  148. if(h3dMcCorrFctn) delete h3dMcCorrFctn; h3dMcCorrFctn=NULL;
  149. if(h3dFitNumerator) delete h3dFitNumerator; h3dFitNumerator=NULL;
  150. //Cleaning fit projection histograms
  151. if(h3dFitQoutProj) delete h3dFitQoutProj; h3dFitQoutProj=NULL;
  152. if(h3dFitQsideProj) delete h3dFitQsideProj; h3dFitQsideProj=NULL;
  153. if(h3dFitQlongProj) delete h3dFitQlongProj; h3dFitQlongProj=NULL;
  154. //Cleaning outward projections
  155. if(h3dQoutProjNum) delete h3dQoutProjNum; h3dQoutProjNum=NULL;
  156. if(h3dQoutProjDen) delete h3dQoutProjDen; h3dQoutProjDen=NULL;
  157. if(h3dMcQoutProjNum) delete h3dMcQoutProjNum; h3dMcQoutProjNum=NULL;
  158. if(h3dMcQoutProjDen) delete h3dMcQoutProjDen; h3dMcQoutProjDen=NULL;
  159. //Cleaning sideward projections
  160. if(h3dQsideProjNum) delete h3dQsideProjNum; h3dQsideProjNum=NULL;
  161. if(h3dQsideProjDen) delete h3dQsideProjDen; h3dQsideProjDen=NULL;
  162. if(h3dMcQsideProjNum) delete h3dMcQsideProjNum; h3dMcQsideProjNum=NULL;
  163. if(h3dMcQsideProjDen) delete h3dMcQsideProjDen; h3dMcQsideProjDen=NULL;
  164. //Cleaning longitudinal projections
  165. if(h3dQlongProjNum) delete h3dQlongProjNum; h3dQlongProjNum=NULL;
  166. if(h3dQlongProjDen) delete h3dQlongProjDen; h3dQlongProjDen=NULL;
  167. if(h3dMcQlongProjNum) delete h3dMcQlongProjNum; h3dMcQlongProjNum=NULL;
  168. if(h3dMcQlongProjDen) delete h3dMcQlongProjDen; h3dMcQlongProjDen=NULL;
  169. //Clean correlation function projections
  170. if(h3dCorrFctnOutProj) delete h3dCorrFctnOutProj; h3dCorrFctnOutProj=NULL;
  171. if(h3dMcCorrFctnOutProj) delete h3dMcCorrFctnOutProj; h3dMcCorrFctnOutProj=NULL;
  172. if(h3dCorrFctnFitOutProj) delete h3dCorrFctnFitOutProj; h3dCorrFctnFitOutProj=NULL;
  173. if(h3dCorrFctnSideProj) delete h3dCorrFctnSideProj; h3dCorrFctnSideProj=NULL;
  174. if(h3dMcCorrFctnSideProj) delete h3dMcCorrFctnSideProj; h3dMcCorrFctnSideProj=NULL;
  175. if(h3dCorrFctnFitSideProj) delete h3dCorrFctnFitSideProj; h3dCorrFctnFitSideProj=NULL;
  176. if(h3dCorrFctnLongProj) delete h3dCorrFctnLongProj; h3dCorrFctnLongProj=NULL;
  177. if(h3dMcCorrFctnLongProj) delete h3dMcCorrFctnLongProj; h3dMcCorrFctnLongProj=NULL;
  178. if(h3dCorrFctnFitLongProj) delete h3dCorrFctnFitLongProj; h3dCorrFctnFitLongProj=NULL;
  179. }
  180. //_________________
  181. void HbtFitter::Clear() {
  182. std::cout << "Clearing histograms...";
  183. if(h3dCorrFctn) delete h3dCorrFctn; h3dCorrFctn=NULL;
  184. if(h3dFitNumerator) delete h3dFitNumerator; h3dFitNumerator=NULL;
  185. //Cleaning fit projection histograms
  186. if(h3dFitQoutProj) delete h3dFitQoutProj; h3dFitQoutProj=NULL;
  187. if(h3dFitQsideProj) delete h3dFitQsideProj; h3dFitQsideProj=NULL;
  188. if(h3dFitQlongProj) delete h3dFitQlongProj; h3dFitQlongProj=NULL;
  189. //Cleaning outward projections
  190. if(h3dQoutProjNum) delete h3dQoutProjNum; h3dQoutProjNum=NULL;
  191. if(h3dQoutProjDen) delete h3dQoutProjDen; h3dQoutProjDen=NULL;
  192. if(h3dMcQoutProjNum) delete h3dMcQoutProjNum; h3dMcQoutProjNum=NULL;
  193. if(h3dMcQoutProjDen) delete h3dMcQoutProjDen; h3dMcQoutProjDen=NULL;
  194. //Cleaning sideward projections
  195. if(h3dQsideProjNum) delete h3dQsideProjNum; h3dQsideProjNum=NULL;
  196. if(h3dQsideProjDen) delete h3dQsideProjDen; h3dQsideProjDen=NULL;
  197. if(h3dMcQsideProjNum) delete h3dMcQsideProjNum; h3dMcQsideProjNum=NULL;
  198. if(h3dMcQsideProjDen) delete h3dMcQsideProjDen; h3dMcQsideProjDen=NULL;
  199. //Cleaning longitudinal projections
  200. if(h3dQlongProjNum) delete h3dQlongProjNum; h3dQlongProjNum=NULL;
  201. if(h3dQlongProjDen) delete h3dQlongProjDen; h3dQlongProjDen=NULL;
  202. if(h3dMcQlongProjNum) delete h3dMcQlongProjNum; h3dMcQlongProjNum=NULL;
  203. if(h3dMcQlongProjDen) delete h3dMcQlongProjDen; h3dMcQlongProjDen=NULL;
  204. //Clean correlation function projections
  205. if(h3dCorrFctnOutProj) delete h3dCorrFctnOutProj; h3dCorrFctnOutProj=NULL;
  206. if(h3dMcCorrFctnOutProj) delete h3dMcCorrFctnOutProj; h3dMcCorrFctnOutProj=NULL;
  207. if(h3dCorrFctnFitOutProj) delete h3dCorrFctnFitOutProj; h3dCorrFctnFitOutProj=NULL;
  208. if(h3dCorrFctnSideProj) delete h3dCorrFctnSideProj; h3dCorrFctnSideProj=NULL;
  209. if(h3dMcCorrFctnSideProj) delete h3dMcCorrFctnSideProj; h3dMcCorrFctnSideProj=NULL;
  210. if(h3dCorrFctnFitSideProj) delete h3dCorrFctnFitSideProj; h3dCorrFctnFitSideProj=NULL;
  211. if(h3dCorrFctnLongProj) delete h3dCorrFctnLongProj; h3dCorrFctnLongProj=NULL;
  212. if(h3dMcCorrFctnLongProj) delete h3dMcCorrFctnLongProj; h3dMcCorrFctnLongProj=NULL;
  213. if(h3dCorrFctnFitLongProj) delete h3dCorrFctnFitLongProj; h3dCorrFctnFitLongProj=NULL;
  214. if(!mFixParameters1D.empty()) {
  215. mFixParameters1D.clear();
  216. }
  217. if(!mFixParameters3D.empty()) {
  218. mFixParameters3D.clear();
  219. }
  220. if(!mFemto1DVal.empty()) {
  221. mFemto1DVal.clear();
  222. mFemto1DValErr.clear();
  223. }
  224. if(!mNonFemto1DVal.empty()) {
  225. mNonFemto1DVal.clear();
  226. mNonFemto1DValErr.clear();
  227. }
  228. if(!mFemto3DVal.empty()) {
  229. mFemto3DVal.clear();
  230. mFemto3DValErr.clear();
  231. }
  232. if(!mNonFemto3DVal.empty()) {
  233. mNonFemto3DVal.clear();
  234. mNonFemto3DValErr.clear();
  235. }
  236. std::cout << "\t[DONE]" << std::endl;
  237. }
  238. //_________________
  239. void HbtFitter::SetCorrectOnMc(Bool_t corr) {
  240. mCorrectOnMc = corr;
  241. std::cout << "HbtFitter::SetCorrectOnMc : " << mCorrectOnMc << std::endl;
  242. }
  243. //_________________
  244. void HbtFitter::SetSourceForm(Int_t SourceForm) {
  245. mSourceForm = SourceForm;
  246. std::cout << "HbtFitter::SetSourceForm : " << mSourceForm << std::endl;
  247. }
  248. //_________________
  249. void HbtFitter::SetNonFemtoForm(Int_t form) {
  250. /*
  251. Non-femtoscopic forms:
  252. 0 - constant
  253. 1 - linear
  254. 2 - 2nd oreder polynomial
  255. 3 - sqrt(1 + a x^2 + b x^4) (sqrt tail)
  256. 4 - a ( 1 + e^{b x^2}) (Gaussian tail)
  257. 5 - a / (1 + b x^2) (hyperbolic tail)
  258. */
  259. mNonFemtoForm = form;
  260. switch(mNonFemtoForm) {
  261. case 0 :
  262. mNonFemto1DParNum = 1;
  263. mNonFemto3DParNum = 1;
  264. break;
  265. case 1 :
  266. mNonFemto1DParNum = 2;
  267. mNonFemto3DParNum = 4;
  268. break;
  269. case 2 :
  270. mNonFemto1DParNum = 3;
  271. mNonFemto3DParNum = 7;
  272. break;
  273. case 3 :
  274. mNonFemto1DParNum = 3;
  275. mNonFemto3DParNum = 7;
  276. break;
  277. case 4 :
  278. mNonFemto1DParNum = 2;
  279. mNonFemto3DParNum =4;
  280. break;
  281. case 5 :
  282. mNonFemto1DParNum = 2;
  283. mNonFemto3DParNum = 4;
  284. break;
  285. default:
  286. std::cout << "SetNonFemtoForm: Unknown non-femtoscopic form" << std::cout;
  287. mNonFemto1DParNum = 1;
  288. mNonFemto3DParNum = 1;
  289. break;
  290. }
  291. std::cout << "HbtFitter::SetNonFemtoForm : " << mNonFemtoForm << std::endl;
  292. }
  293. //_________________
  294. void HbtFitter::SetFitMethod(Int_t method) {
  295. switch(method) {
  296. case 0: //ChiSquare
  297. mFitMethod = 0;
  298. std::cout << "HbtFitter::FitMethod : ChiSquare" << std::endl;
  299. break;
  300. case 1: //Log-likelihood
  301. mFitMethod = 1;
  302. std::cout << "HbtFitter::FitMethod : Log-Likelihood" << std::endl;
  303. break;
  304. default: //ChiSquare
  305. mFitMethod = 0;
  306. std::cout << "HbtFitter::FitMethod : [WARNING] - unknown fit method"
  307. << "\nReset to ChiSquare" << std::endl;
  308. break;
  309. }
  310. }
  311. //_________________
  312. void HbtFitter::Set1DFitRange(Double_t qLo, Double_t qHi) {
  313. mQinvFitRange[0] = qLo;
  314. mQinvFitRange[1] = qHi;
  315. if(h1dNumer) {
  316. mQinvFitRangeBin[0] = h1dNumer->GetXaxis()->FindBin(mQinvFitRange[0]);
  317. mQinvFitRangeBin[1] = h1dNumer->GetXaxis()->FindBin(mQinvFitRange[1]);
  318. }
  319. else {
  320. std::cout << "HbtFitter::Set1DFitRange [WARNING] Fit range is set to default values" << std::endl;
  321. mQinvFitRangeBin[0] = 1;
  322. mQinvFitRangeBin[1] = mQinvNbins;
  323. }
  324. }
  325. //_________________
  326. void HbtFitter::Set3DFitRange(Double_t qOutLo, Double_t qOutHi,
  327. Double_t qSideLo, Double_t qSideHi,
  328. Double_t qLongLo, Double_t qLongHi) {
  329. mQoutFitRange[0] = qOutLo; mQoutFitRange[1] = qOutHi;
  330. mQsideFitRange[0] = qSideLo; mQsideFitRange[1] = qSideHi;
  331. mQlongFitRange[0] = qLongLo; mQlongFitRange[1] = qLongHi;
  332. if(h3dNumer) {
  333. mQoutFitRangeBin[0] = h3dNumer->GetXaxis()->FindBin(mQoutFitRange[0]);
  334. mQoutFitRangeBin[1] = h3dNumer->GetXaxis()->FindBin(mQoutFitRange[1]);
  335. mQsideFitRangeBin[0] = h3dNumer->GetXaxis()->FindBin(mQsideFitRange[0]);
  336. mQsideFitRangeBin[1] = h3dNumer->GetXaxis()->FindBin(mQsideFitRange[1]);
  337. mQlongFitRangeBin[0] = h3dNumer->GetXaxis()->FindBin(mQlongFitRange[0]);
  338. mQlongFitRangeBin[1] = h3dNumer->GetXaxis()->FindBin(mQlongFitRange[1]);
  339. }
  340. else {
  341. std::cout << "HbtFitter::Set3DFitRange [WARNING] Fit range is set to default values" << std::endl;
  342. mQoutFitRangeBin[0] = 1; mQoutFitRangeBin[1] = mQoutNbins;
  343. mQsideFitRangeBin[0] = 1; mQsideFitRangeBin[1] = mQsideNbins;
  344. mQlongFitRangeBin[0] = 1; mQlongFitRangeBin[1] = mQlongNbins;
  345. }
  346. std::cout << "Fit ranges: " << std::endl
  347. << "Qout : " << mQoutFitRange[0] << "<=Qout<=" << mQoutFitRange[1]
  348. << " " << mQoutFitRangeBin[0] << "<=QoutBin<=" << mQoutFitRangeBin[1] << std::endl
  349. << "Qside : " << mQsideFitRange[0] << "<=Qside<=" << mQsideFitRange[1]
  350. << " " << mQsideFitRangeBin[0] << "<=QsideBin<=" << mQsideFitRangeBin[1] << std::endl
  351. << "Qlong : " << mQlongFitRange[0] << "<=Qlong<=" << mQlongFitRange[1]
  352. << " " << mQlongFitRangeBin[0] << "<=QlongBin<=" << mQlongFitRangeBin[1] << std::endl;
  353. }
  354. //_________________
  355. void HbtFitter::Fit1D() {
  356. //Double check if the points were really exluded
  357. /*
  358. if(mExcludeRange == 1) {
  359. if(x[0] > mExcludedVal[0] && x[0]<mExcludedVal[1]) {
  360. TF1::RejectPoint();
  361. return 0;
  362. }
  363. }
  364. */
  365. Double_t mAutoParVal[5] = {0.5, 5., 1., 0., 0.};
  366. Double_t mAutoParValErr[5] = {0.01, 0.01, 0.01, 0.01, 0.01};
  367. TString mParNames[5] = {"#lambda", "R_{inv}", "N", "a", "b"};
  368. Int_t mFitParNum = mFemto1DParNum + mNonFemto1DParNum;
  369. //From Victor M. Perevozchikov
  370. SetObject(this);
  371. TMinuit mFit(mFitParNum);
  372. switch(mFitMethod) {
  373. case 0:
  374. std::cout << "Fit1D: ChiSquare method has been initialized" << std::endl;
  375. mFit.SetFCN(HbtFitter::FitFunc1DChiSquare);
  376. break;
  377. case 1:
  378. std::cout << "Fit1D: Log-likelihood method has been initialized" << std::endl;
  379. mFit.SetFCN(HbtFitter::FitFunc1DLogLike);
  380. break;
  381. default:
  382. std::cout << "Fit1D: Default method has been initialized" << std::endl;
  383. mFit.SetFCN(HbtFitter::FitFunc1DChiSquare);
  384. break;
  385. }
  386. Double_t mInitParVal[mFitParNum];
  387. Double_t mInitParValErr[mFitParNum];
  388. TString mInitParName[mFitParNum];
  389. for(Int_t iIter=0; iIter<mFitParNum; iIter++) {
  390. mInitParVal[iIter] = mAutoParVal[iIter];
  391. mInitParValErr[iIter] = mAutoParValErr[iIter];
  392. mInitParName[iIter] = mParNames[iIter];
  393. mFit.DefineParameter(iIter,mInitParName[iIter].Data(),mInitParVal[iIter],mInitParValErr[iIter], 0, 0);
  394. }
  395. //Fix fit parameters
  396. if(!mFixParameters1D.empty()) {
  397. for(UInt_t iIter=0; iIter<mFixParameters1D.size(); iIter++) {
  398. mFit.FixParameter(mFixParameters1D.at(iIter));
  399. }
  400. }
  401. Double_t mArgList[mFitParNum];
  402. Int_t ierflag = 0;
  403. Int_t mNFitCycles = 0;
  404. do {
  405. mNFitCycles++;
  406. std::cout << "********** Fit loop " <<mNFitCycles << std::endl;
  407. //mFit.mnexcm("SIMPLEX", mArgList, 0, ierflag);
  408. mFit.mnexcm("MIGRAD", mArgList, 0, ierflag);
  409. } while( (ierflag!=0) && (mNFitCycles!=50) );
  410. Double_t mFitVal, mFitValErr;
  411. //Return femtoscopic fit parameters
  412. for(Int_t iIter=0; iIter<mFemto1DParNum; iIter++) {
  413. mFitVal=0.; mFitValErr=0.;
  414. mFit.GetParameter(iIter, mFitVal, mFitValErr);
  415. mFemto1DVal.push_back(mFitVal);
  416. mFemto1DValErr.push_back(mFitValErr);
  417. std::cout << Form("%s = %3.2f +- %3.2f", mParNames[iIter].Data(),
  418. mFitVal, mFitValErr) << std::endl;
  419. }
  420. //Return non-femtoscopic fit parameters
  421. for(Int_t iIter=mFemto1DParNum; iIter<mFitParNum; iIter++) {
  422. mFitVal=0.; mFitValErr=0.;
  423. mFit.GetParameter(iIter, mFitVal, mFitValErr);
  424. mNonFemto1DVal.push_back(mFitVal);
  425. mNonFemto1DValErr.push_back(mFitValErr);
  426. std::cout << Form("%s = %3.2f +- %3.2f", mParNames[iIter].Data(),
  427. mFitVal, mFitValErr) << std::endl;
  428. }
  429. }
  430. //_________________
  431. void HbtFitter::Fit3D() {
  432. //Initial values: L Ro Rs Rl Ros Rol Rsl
  433. // N ao as al bo bs bl
  434. Double_t mAutoParVal[14] = {0.3, 4., 4., 4., 0., 0., 0.,
  435. 0.3, 0., 0., 0., 0., 0., 0.};
  436. // L Ro Rs Rl Ros Rol Rsl
  437. // N ao as al bo bs bl
  438. Double_t mAutoParValErr[14] = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
  439. 0.001, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01};
  440. // L Ro Rs Rl Ros Rol Rsl
  441. // N ao as al bo bs bl
  442. Double_t mAutoParValLo[14] = {0., 0., 0., 0., 0., 0., 0.,
  443. 0., -5., -5., -5., -2., -2., -2.};
  444. // L Ro Rs Rl Ros Rol Rsl
  445. // N ao as al bo bs bl
  446. Double_t mAutoParValHi[14] = {1.05, 60., 60., 60., 60., 60., 60.,
  447. 5., 5., 5., 5., 2., 2., 2.};
  448. TString mParNames[14] = {"Lambda", "R_{out}", "R_{side}", "R_{long}",
  449. "R_{out-side}", "R_{out-long}", "R_{side-long}",
  450. "Norm", "A_{out}", "A_{side}", "A_{long}",
  451. "B_{out}", "B_{side}", "B_{long}"};
  452. Int_t mFitParNum = mFemto3DParNum + mNonFemto3DParNum;
  453. TMinuit mFit(mFitParNum);
  454. switch(mFitMethod) {
  455. case 0:
  456. std::cout << "Fit3D: ChiSquare method has been initialized" << std::endl;
  457. mFit.SetFCN(HbtFitter::FitFunc3DChiSquare);
  458. break;
  459. case 1:
  460. std::cout << "Fit3D: Log-likelihood method has been initialized" << std::endl;
  461. mFit.SetFCN(HbtFitter::FitFunc3DLogLike);
  462. break;
  463. default:
  464. std::cout << "Fit3D: Default method has been initialized" << std::endl;
  465. mFit.SetFCN(HbtFitter::FitFunc3DLogLike);
  466. break;
  467. }
  468. Double_t mInitParVal[mFitParNum];
  469. Double_t mInitParValErr[mFitParNum];
  470. Double_t mInitParValLo[mFitParNum];
  471. Double_t mInitParValHi[mFitParNum];
  472. TString mInitParName[mFitParNum];
  473. for(Int_t iIter=0; iIter<mFitParNum; iIter++) {
  474. mInitParVal[iIter] = mAutoParVal[iIter];
  475. mInitParValErr[iIter] = mAutoParValErr[iIter];
  476. mInitParValLo[iIter] = mAutoParValLo[iIter];
  477. mInitParValHi[iIter] = mAutoParValHi[iIter];
  478. mInitParName[iIter] = mParNames[iIter];
  479. mFit.DefineParameter(iIter, mInitParName[iIter].Data(),
  480. mInitParVal[iIter], mInitParValErr[iIter],
  481. mInitParValLo[iIter], mInitParValHi[iIter]);
  482. }
  483. //Fix fit parameters
  484. if(!mFixParameters3D.empty()) {
  485. for(UInt_t iIter=0; iIter<mFixParameters3D.size(); iIter++) {
  486. mFit.FixParameter(mFixParameters3D.at(iIter));
  487. }
  488. }
  489. mFit.SetErrorDef(0.5); //Log-likelihood minimization
  490. Double_t mArgList[mFitParNum];
  491. Int_t ierflag = 0;
  492. Int_t mNFitCycles = 0;
  493. std::cout << "Start 3D fit" << std::endl;
  494. do {
  495. mNFitCycles++;
  496. std::cout << "********** Fit loop " <<mNFitCycles << std::endl;
  497. mFit.mnexcm("MIGRAD", mArgList, 0, ierflag);
  498. } while( (ierflag!=0) && (mNFitCycles!=50) );
  499. std::cout << "The 3D fit has been finished" << std::endl;
  500. Double_t mFitVal, mFitValErr;
  501. //Return femtoscopic fit parameters
  502. for(Int_t iIter=0; iIter<mFemto3DParNum; iIter++) {
  503. mFitVal=0.; mFitValErr=0.;
  504. mFit.GetParameter(iIter, mFitVal, mFitValErr);
  505. mFemto3DVal.push_back(mFitVal);
  506. mFemto3DValErr.push_back(mFitValErr);
  507. }
  508. //Return non-femtoscopic fit parameters
  509. for(Int_t iIter=mFemto3DParNum; iIter<mFitParNum; iIter++) {
  510. mFitVal=0.; mFitValErr=0.;
  511. mFit.GetParameter(iIter, mFitVal, mFitValErr);
  512. mNonFemto3DVal.push_back(mFitVal);
  513. mNonFemto3DValErr.push_back(mFitValErr);
  514. }
  515. if(!h3dCorrFctn) {
  516. h3dCorrFctn = new TH3F("h3dCorrFctn","h3dCorrFctn",
  517. mQoutNbins,mQoutVal[0],mQoutVal[1],
  518. mQsideNbins,mQsideVal[0],mQsideVal[1],
  519. mQlongNbins,mQlongVal[0],mQlongVal[1]);
  520. h3dCorrFctn->Divide(h3dNumer,h3dDenom);
  521. }
  522. }
  523. //_________________
  524. void HbtFitter::Set3DBinsNum(Int_t OutNBins, Int_t SideNBins, Int_t LongNBins) {
  525. mQoutNbins = OutNBins;
  526. mQsideNbins = SideNBins;
  527. mQlongNbins = LongNBins;
  528. }
  529. //_________________
  530. void HbtFitter::Set3DHistoRange(Double_t outLo, Double_t outHi,
  531. Double_t sideLo, Double_t sideHi,
  532. Double_t longLo, Double_t longHi) {
  533. mQoutVal[0] = outLo; mQoutVal[1] = outHi;
  534. mQsideVal[0] = sideLo; mQsideVal[1] = sideHi;
  535. mQlongVal[0] = longLo; mQlongVal[1] = longHi;
  536. }
  537. //_________________
  538. void HbtFitter::Set1DNonFemtoParameters(vector<double> par) {
  539. for(UInt_t i=0; i<par.size(); i++) {
  540. mNonFemto1DParArr[i] = par.at(i);
  541. }
  542. }
  543. //_________________
  544. void HbtFitter::Set3DNonFemtoParameters(vector<double> parOut,
  545. vector<double> parSide,
  546. vector<double> parLong) {
  547. //Assuming the same amount of parameters
  548. //for out, side and long components
  549. for(UInt_t i=0; i<parOut.size(); i++) {
  550. mNonFemto3DParArr[0][i] = parOut.at(i);
  551. mNonFemto3DParArr[1][i] = parSide.at(i);
  552. mNonFemto3DParArr[2][i] = parLong.at(i);
  553. }
  554. }
  555. //_________________
  556. void HbtFitter::SetExcludeRange(Double_t qInvLo, Double_t qInvHi) {
  557. //Exlude range from the fit
  558. mExcludedVal[0] = qInvLo;
  559. mExcludedVal[1] = qInvHi;
  560. }
  561. //_________________
  562. Double_t HbtFitter::Coulomb1D(Int_t qInvBin) {
  563. Double_t coulombVal;
  564. switch(mPartType) {
  565. case 3:
  566. coulombVal = PI_LONG[qInvBin-1];
  567. break;
  568. case 4:
  569. coulombVal = KK_LONG[qInvBin-1];
  570. break;
  571. default:
  572. std::cout << "Coulomb1D: Unknown particle type" << std::endl;
  573. coulombVal = 1.;
  574. break;
  575. }
  576. return coulombVal;
  577. }
  578. //_________________
  579. Double_t HbtFitter::Coulomb3D(Int_t qOutBin, Int_t qSideBin, Int_t qLongBin) {
  580. Double_t coulombVal;
  581. if(!h3dCoulombWeight) { //If coulomb qInv weight function is not set
  582. std::cout << "Coulomb3D: The histogram with Coulomb weights is not set" << std::endl;
  583. coulombVal = 1.;
  584. }
  585. else { //If 3D qInv weight function is set
  586. //Obtain qInv weight from 3D
  587. Double_t qInvWeight = h3dCoulombWeight->GetBinContent(qOutBin, qSideBin, qLongBin);
  588. //Calculation of the Coulomb bin correction
  589. Int_t qBins = mQoutNbins;
  590. Double_t qHi = mQoutVal[1];
  591. Double_t qLow = h3dCoulombWeight->GetXaxis()->GetBinLowEdge(1);
  592. Double_t qStep = (qHi-qLow)/qBins;
  593. Int_t qCoulBin = (Int_t)(qInvWeight/qStep);
  594. //Obtain 1D Coulomb correction
  595. switch(mPartType) {
  596. case 3:
  597. coulombVal = PI_LONG[qCoulBin];
  598. break;
  599. case 4:
  600. coulombVal = KK_LONG[qCoulBin];
  601. break;
  602. default:
  603. std::cout << "Coulomb3D: Unknown particle type" << std::endl;
  604. coulombVal = 1.;
  605. break;
  606. }
  607. if(coulombVal<0.0001) {
  608. coulombVal=1.;
  609. }
  610. /*
  611. std::cout << Form("Coulomb3D: oBin=%2d sBin=%2d lBin=%2d cVal=%4.3f",
  612. qOutBin, qSideBin, qLongBin, coulombVal) << std::endl;
  613. */
  614. }
  615. return coulombVal;
  616. }
  617. //_________________
  618. Double_t HbtFitter::TheorCorrFctn1D(Double_t *par, Int_t qInvBin) {
  619. Double_t mArg = 0;
  620. Double_t mTheory = 0;
  621. Double_t mNonFemto = 0;
  622. Double_t qInv = h1dNumer->GetBinCenter(qInvBin);
  623. Double_t qCoul;
  624. if(mUseCoulombCorrection==0) {
  625. qCoul = 1.;
  626. }
  627. else {
  628. qCoul = Coulomb1D(qInvBin);
  629. }
  630. switch(mSourceForm) {
  631. case 0: //Gaussian source
  632. mArg = qInv*qInv*par[1]*par[1];
  633. mArg /= -1.*hBar*hBar;
  634. break;
  635. case 1: //Exponential source
  636. mArg = qInv*par[1];
  637. mArg /= -1.*hBar*hBar;
  638. mArg /= R_GAUS_TO_EXPO; //Scale from expo to gauss
  639. break;
  640. default:
  641. std::cout << "TheorCorrFctn1D: Unknown source form" << std::endl;
  642. mArg = qInv*qInv*par[1]*par[1];
  643. break;
  644. }
  645. mTheory = (1 - par[0]) + par[0]*qCoul*(1+TMath::Exp(mArg)) *
  646. NonFemto1D(&par[2], qInv); //Ideal * NonFemto
  647. return mTheory;
  648. }
  649. //_________________
  650. Double_t HbtFitter::TheorCorrFctn3D(Double_t *par, Int_t qOutBin, Int_t qSideBin, Int_t qLongBin) {
  651. Double_t mArg = 0.;
  652. Double_t mTheory = 0.;
  653. Double_t mNonFemto = 0.;
  654. Double_t qOut = h3dNumer->GetXaxis()->GetBinCenter(qOutBin);
  655. Double_t qSide = h3dNumer->GetYaxis()->GetBinCenter(qSideBin);
  656. Double_t qLong = h3dNumer->GetZaxis()->GetBinCenter(qLongBin);
  657. Double_t qCoul;
  658. if(mUseCoulombCorrection == 0) {
  659. qCoul = 1.;
  660. }
  661. else {
  662. qCoul = Coulomb3D(qOutBin, qSideBin, qLongBin);
  663. }
  664. switch(mSourceForm) {
  665. case 0: //Gaussian source
  666. mArg = par[1]*par[1]*qOut*qOut; //Out^2
  667. mArg += par[2]*par[2]*qSide*qSide; //Side^2
  668. mArg += par[3]*par[3]*qLong*qLong; //Long^2
  669. mArg += 2*par[4]*par[4]*qOut*qSide; //Out*Side
  670. mArg += 2*par[5]*par[5]*qOut*qLong; //Out*Long
  671. mArg += 2*par[6]*par[6]*qSide*qLong; //Side*Long
  672. mArg /= -1.*hBar*hBar;
  673. break;
  674. case 1: //Exponential source. Note that the cross-terms should not present in fit
  675. mArg = TMath::Abs(par[1]*par[1]*qOut*qOut); //Out
  676. mArg += TMath::Abs(par[2]*par[2]*qSide*qSide); //Side
  677. mArg += TMath::Abs(par[3]*par[3]*qLong*qLong); //Long
  678. mArg += 2*par[4]*qOut*qSide; //Out*Side
  679. mArg += 2*par[5]*qOut*qLong; //Out*Long
  680. mArg += 2*par[6]*qSide*qLong; //Side*Long
  681. mArg /= -1.*hBar*hBar;
  682. mArg /= R_GAUS_TO_EXPO; //Scale from expo to gaus
  683. break;
  684. }
  685. mTheory = (1 - par[0] + par[0]*qCoul*(1+TMath::Exp(mArg))) *
  686. NonFemto3D(&par[7], qOut, qSide, qLong); //Ideal*NonFemto
  687. return mTheory;
  688. }
  689. //_________________
  690. Double_t HbtFitter::NonFemto1D(Double_t *par, Double_t qInv) {
  691. Double_t nonFemtoVal = 0;
  692. switch(mNonFemtoForm) {
  693. case 0: //Constant
  694. nonFemtoVal = par[0];
  695. break;
  696. case 1: //Linear
  697. nonFemtoVal = par[0]*(1 + par[1]*qInv);
  698. break;
  699. case 2: //Second oreder polynomial
  700. nonFemtoVal = par[0]*(1 + par[1]*qInv + par[2]*qInv*qInv);
  701. break;
  702. case 3: //Sqrt(pol4)
  703. nonFemtoVal = par[0]*TMath::Sqrt(1 + par[1]*qInv*qInv + par[2]*qInv*qInv*qInv*qInv);
  704. break;
  705. case 4: //Gaussian-like
  706. nonFemtoVal = par[0]*(1 + TMath::Exp(-par[1]*qInv*qInv));
  707. break;
  708. case 5: //Hyperbolic
  709. nonFemtoVal = par[0] / (1 + par[1]*qInv*qInv);
  710. break;
  711. default:
  712. nonFemtoVal = par[0];
  713. break;
  714. }
  715. return nonFemtoVal;
  716. }
  717. //_________________
  718. Double_t HbtFitter::NonFemto3D(Double_t *par, Double_t qOut, Double_t qSide, Double_t qLong) {
  719. Double_t nonFemtoVal = 0;
  720. Double_t mArg;
  721. switch(mNonFemtoForm) {
  722. case 0: //Constant
  723. nonFemtoVal = par[0];
  724. break;
  725. case 1: //Linear
  726. nonFemtoVal = 1;
  727. nonFemtoVal += par[1]*qOut;
  728. nonFemtoVal += par[2]*qSide;
  729. nonFemtoVal += par[3]*qLong;
  730. nonFemtoVal *= par[0];
  731. break;
  732. case 2: //Second order polynomial
  733. nonFemtoVal = 1;
  734. nonFemtoVal += par[1]*qOut;
  735. nonFemtoVal += par[2]*qSide;
  736. nonFemtoVal += par[3]*qLong;
  737. nonFemtoVal += par[4]*qOut*qOut;
  738. nonFemtoVal += par[5]*qSide*qSide;
  739. nonFemtoVal += par[6]*qLong*qLong;
  740. nonFemtoVal *= par[0];
  741. break;
  742. case 3: //Sqrt(Pol4)
  743. mArg = 1;
  744. mArg += par[1]*qOut*qOut;
  745. mArg += par[2]*qSide*qSide;
  746. mArg += par[3]*qLong*qLong;
  747. mArg += par[4]*qOut*qOut*qOut*qOut;
  748. mArg += par[5]*qSide*qSide*qSide*qSide;
  749. mArg += par[6]*qLong*qLong*qLong*qLong;
  750. nonFemtoVal = TMath::Sqrt(mArg);
  751. nonFemtoVal *= par[0];
  752. break;
  753. case 4: //Gaussian-like
  754. nonFemtoVal = 1;
  755. nonFemtoVal += TMath::Exp(-1.*par[1]*qOut*qOut);
  756. nonFemtoVal += TMath::Exp(-1.*par[2]*qSide*qSide);
  757. nonFemtoVal += TMath::Exp(-1.*par[3]*qLong*qLong);
  758. nonFemtoVal *= par[0];
  759. break;
  760. case 5: //Hyperbolic
  761. nonFemtoVal = par[0];
  762. mArg = 1;
  763. mArg += par[1]*qOut*qOut;
  764. mArg += par[2]*qSide*qSide;
  765. mArg += par[3]*qLong*qLong;
  766. nonFemtoVal /= mArg;
  767. break;
  768. default:
  769. nonFemtoVal = par[0];
  770. break;
  771. }
  772. return nonFemtoVal;
  773. }
  774. //_________________
  775. Double_t HbtFitter::CorrFctn1DChiSqr(Int_t &npar, Double_t *gin, Double_t &f,
  776. Double_t *par, Int_t iflag) {
  777. f = 0.;
  778. Double_t mChisq = 0;
  779. Double_t mDelta;
  780. Double_t mQinvErr, A, B, C;
  781. Double_t mcA, mcB;
  782. Int_t mNQinvBins = mQinvNbins;
  783. Double_t mNonFemtoCorrFactor = 1.;
  784. TH1F hCorrectedOnMc("hCorrectedOnMc","hCorrectedOnMc",mQinvNbins, mQinvVal[0], mQinvVal[1]);
  785. if(mCorrectOnMc) {
  786. hCorrectedOnMc.Divide(h1dCorrFctn,h1dMcCorrFctn);
  787. }
  788. //Calculating overall chi2
  789. for(Int_t iQbin = mQinvFitRangeBin[1]; iQbin>=mQinvFitRangeBin[0]; iQbin--) {
  790. mQinvErr = h1dCorrFctn->GetBinError(iQbin);
  791. A = h1dNumer->GetBinContent(iQbin);
  792. B = h1dDenom->GetBinContent(iQbin);
  793. C = A/B;
  794. //If divide on MC CorrFctn
  795. if(mCorrectOnMc) {
  796. mNonFemtoCorrFactor = h1dMcCorrFctn->GetBinContent(iQbin);
  797. C /= mNonFemtoCorrFactor;
  798. mQinvErr = hCorrectedOnMc.GetBinError(iQbin);
  799. }
  800. if( (A>=0.0001) && (B>=0.0001)) {
  801. mDelta = (C - TheorCorrFctn1D(par, iQbin))/mQinvErr;
  802. mChisq += mDelta*mDelta;
  803. }
  804. }
  805. f = mChisq;
  806. return f;
  807. }
  808. //_________________
  809. Double_t HbtFitter::CorrFctn1DLogLike(Int_t &npar, Double_t *gin, Double_t &f,
  810. Double_t *par, Int_t iflag) {
  811. f = 0.;
  812. Double_t mChisq = 0;
  813. Double_t mDelta;
  814. Double_t A, B, C, mcA, mcB;
  815. Int_t mNQinvBins = mQinvNbins;
  816. Double_t mNonFemtoCorrFactor;
  817. //Calculating of the log-likelihood chi2
  818. for(Int_t iQbin = mQinvFitRangeBin[1]; iQbin>=mQinvFitRangeBin[0]; iQbin--) {
  819. A = h1dNumer->GetBinContent(iQbin);
  820. B = h1dDenom->GetBinContent(iQbin);
  821. if(mCorrectOnMc) {
  822. mcA = h1dMcNumer->GetBinContent(iQbin);
  823. mcB = h1dMcDenom->GetBinContent(iQbin);
  824. A *= mcB;
  825. B *= mcA;
  826. }
  827. if( (A>=0.0001) && (B>=0.0001) ) {
  828. C = TheorCorrFctn1D(par, iQbin);
  829. mDelta = -2* ( A * TMath::Log( (C/A)*((A+B)/(C+1)) ) +
  830. B * TMath::Log( (A+B)/(B*(C+1)) ) );
  831. mChisq += mDelta;
  832. }
  833. } //for(Int_t iQbin = 1; iQbin<=mNQinvBins; iQbin++)
  834. f = mChisq;
  835. return f;
  836. }
  837. //_________________
  838. Double_t HbtFitter::CorrFctn3DChiSqr(Int_t &npar, Double_t *gin, Double_t &f,
  839. Double_t *par, Int_t iflag) {
  840. f = 0.;
  841. Double_t mChisq = 0;
  842. Double_t mDelta = 0;
  843. Double_t A, B, C, mQcorrErr, mcA, mcB, mNonFemtoCorrFactor;
  844. Int_t mNqOutBins = mQoutNbins;
  845. Int_t mNqSideBins = mQsideNbins;
  846. Int_t mNqLongBins = mQlongNbins;
  847. mNonFemtoCorrFactor = 1.;
  848. TH3F hCorrectedOnMc("hCorrectedOnMc","hCorrectedOnMc",
  849. mQoutNbins,mQoutVal[0],mQoutVal[1],
  850. mQsideNbins,mQsideVal[0],mQsideVal[1],
  851. mQlongNbins,mQlongVal[0],mQlongVal[1]);
  852. if(mCorrectOnMc) {
  853. hCorrectedOnMc.Divide(h3dCorrFctn,h3dMcCorrFctn);
  854. }
  855. for(Int_t iOutBin=mQoutFitRangeBin[1]; iOutBin>=mQoutFitRangeBin[0]; iOutBin--) {
  856. for(Int_t iSideBin=mQsideFitRangeBin[1]; iSideBin>=mQsideFitRangeBin[0]; iSideBin--) {
  857. for(Int_t iLongBin=mQlongFitRangeBin[1]; iLongBin>=mQlongFitRangeBin[0]; iLongBin--) {
  858. mQcorrErr = h3dCorrFctn->GetBinError(iOutBin, iSideBin, iLongBin);
  859. if(mQcorrErr<=0.0) continue;
  860. A = h3dNumer->GetBinContent(iOutBin, iSideBin, iLongBin);
  861. B = h3dDenom->GetBinContent(iOutBin, iSideBin, iLongBin);
  862. C = A/B;
  863. //If divide on MC CorrFctn
  864. if(mCorrectOnMc) {
  865. mNonFemtoCorrFactor = h3dMcCorrFctn->GetBinContent(iOutBin, iSideBin, iLongBin);
  866. C /= mNonFemtoCorrFactor;
  867. mQcorrErr = hCorrectedOnMc.GetBinError(iOutBin, iSideBin, iLongBin);
  868. }
  869. if( (A>=0.0001) && (B>=0.0001)) {
  870. mDelta = (C - TheorCorrFctn3D(par, iOutBin, iSideBin, iLongBin))/mQcorrErr;
  871. mChisq += mDelta*mDelta;
  872. }
  873. } //for(Int_t iLongBin=1; iLongBin<=mNqLongBins; iLongBin++)
  874. } //for(Int_t iSideBin=1; iSideBin<=mNqSideBins; iSideBin++)
  875. } //for(Int_t iOutBin=1; iOutBin<=mNqOutBins; iOutBin++)
  876. f = mChisq;
  877. return f;
  878. }
  879. //_________________
  880. Double_t HbtFitter::CorrFctn3DLogLike(Int_t &npar, Double_t *gin, Double_t &f,
  881. Double_t *par, Int_t iflag) {
  882. f = 0.;
  883. Double_t mChisq = 0;
  884. Double_t mDelta = 0;
  885. Double_t A, B, C, mcA, mcB;
  886. Int_t mNqOutBins = mQoutNbins;
  887. Int_t mNqSideBins = mQsideNbins;
  888. Int_t mNqLongBins = mQlongNbins;
  889. //Calculation of the log-likelihood chi2
  890. for(Int_t iOutBin=mQoutFitRangeBin[1]; iOutBin>=mQoutFitRangeBin[0]; iOutBin--) {
  891. for(Int_t iSideBin=mQsideFitRangeBin[1]; iSideBin>=mQsideFitRangeBin[0]; iSideBin--) {
  892. for(Int_t iLongBin=mQlongFitRangeBin[1]; iLongBin>=mQlongFitRangeBin[0]; iLongBin--) {
  893. A = h3dNumer->GetBinContent(iOutBin, iSideBin, iLongBin);
  894. B = h3dDenom->GetBinContent(iOutBin, iSideBin, iLongBin);
  895. if( (A>=0.0001) && (B>=0.0001) ) {
  896. C = TheorCorrFctn3D(par, iOutBin, iSideBin, iLongBin);
  897. if(mCorrectOnMc) {
  898. mcA = h3dMcNumer->GetBinContent(iOutBin, iSideBin, iLongBin);
  899. mcB = h3dMcDenom->GetBinContent(iOutBin, iSideBin, iLongBin);
  900. C *= mcA;
  901. C /= mcB;
  902. }
  903. mDelta = -2. * ( A * TMath::Log( (C/A) * ((A+B)/(C+1)) ) +
  904. B * TMath::Log( (1.0/B) * ((A+B)/(C+1))) );
  905. mChisq += mDelta;
  906. }
  907. } //for(Int_t iLongBin=1; iLongBin<=mNqLongBins; iLongBin++)
  908. } //for(Int_t iSideBin=1; iSideBin<=mNqSideBins; iSideBin++)
  909. } //for(Int_t iOutBin=1; iOutBin<=mNqOutBins; iOutBin++)
  910. f = mChisq;
  911. return f;
  912. }
  913. //_________________
  914. void HbtFitter::FitFunc1DChiSquare(Int_t &npar, Double_t *gin, Double_t &f,
  915. Double_t *par, Int_t iflag) {
  916. f = objHbtFitter->CorrFctn1DChiSqr(npar, gin, f, par, iflag);
  917. }
  918. //_________________
  919. void HbtFitter::FitFunc1DLogLike(Int_t &npar, Double_t *gin, Double_t &f,
  920. Double_t *par, Int_t iflag) {
  921. f = objHbtFitter->CorrFctn1DLogLike(npar, gin, f, par, iflag);
  922. }
  923. //_________________
  924. void HbtFitter::FitFunc3DChiSquare(Int_t &npar, Double_t *gin, Double_t &f,
  925. Double_t *par, Int_t iflag) {
  926. f = objHbtFitter->CorrFctn3DChiSqr(npar, gin, f, par, iflag);
  927. }
  928. //_________________
  929. void HbtFitter::FitFunc3DLogLike(Int_t &npar, Double_t *gin, Double_t &f,
  930. Double_t *par, Int_t iflag) {
  931. f = objHbtFitter->CorrFctn3DLogLike(npar, gin, f, par, iflag);
  932. }
  933. //_________________
  934. void HbtFitter::MakeProjections() {
  935. std::cout << "Start making projections";
  936. //Experimental Q distribution projections
  937. MakeExpProjections();
  938. if(mCorrectOnMc) {
  939. //MC Q distribution projections
  940. MakeMcProjections();
  941. //Correct projections
  942. h3dCorrFctnOutProj->Divide(h3dMcCorrFctnOutProj);
  943. h3dCorrFctnSideProj->Divide(h3dMcCorrFctnSideProj);
  944. h3dCorrFctnLongProj->Divide(h3dMcCorrFctnLongProj);
  945. }
  946. //Calculate 3D fit projections
  947. MakeFitProjections();
  948. //Scale distributions
  949. Double_t mScale = 1./mNonFemto3DVal.at(0);
  950. h3dCorrFctn->Scale(mScale);
  951. h3dFitNumerator->Divide(h3dDenom);
  952. h3dFitNumerator->Scale(mScale);
  953. Calculate3DChi2();
  954. //Correlation function scale
  955. h3dCorrFctnOutProj->Scale(mScale);
  956. h3dCorrFctnSideProj->Scale(mScale);
  957. h3dCorrFctnLongProj->Scale(mScale);
  958. //Fit function scale
  959. h3dCorrFctnFitOutProj->Scale(mScale);
  960. h3dCorrFctnFitSideProj->Scale(mScale);
  961. h3dCorrFctnFitLongProj->Scale(mScale);
  962. std::cout << "\t[DONE]" << std::endl;
  963. }
  964. //_________________
  965. void HbtFitter::Calculate3DChi2() {
  966. mChi2PerNDF = 0.;
  967. mChi2 = 0;
  968. double mNBinsNDF = 0;
  969. double mError;
  970. double mCorrFctnVal, mFitFctnVal, mDelta;
  971. for(Int_t iOutBin=mQoutFitRangeBin[1]; iOutBin>=mQoutFitRangeBin[0]; iOutBin--) {
  972. for(Int_t iSideBin=mQsideFitRangeBin[1]; iSideBin>=mQsideFitRangeBin[0]; iSideBin--) {
  973. for(Int_t iLongBin=mQlongFitRangeBin[1]; iLongBin>=mQlongFitRangeBin[0]; iLongBin--) {
  974. mError = h3dCorrFctn->GetBinError(iOutBin,iSideBin,iLongBin);
  975. if(mError<=0) continue;
  976. mNBinsNDF++;
  977. mCorrFctnVal = h3dCorrFctn->GetBinContent(iOutBin,iSideBin,iLongBin);
  978. mFitFctnVal = h3dFitNumerator->GetBinContent(iOutBin,iSideBin,iLongBin);
  979. mDelta = (mCorrFctnVal - mFitFctnVal)/mError;
  980. mChi2 += (mDelta*mDelta);
  981. }
  982. }
  983. }
  984. mNDF = mNBinsNDF - (mFemto3DParNum+mNonFemto3DParNum) + mFixParameters3D.size();
  985. mChi2PerNDF = mChi2/mNDF;
  986. }
  987. //_________________
  988. void HbtFitter::MakeFitProjections() {
  989. //Make fit numerator
  990. MakeFitNumerator();
  991. if(!h3dFitQoutProj || !h3dQoutProjDen) {
  992. std::cout << "MakeFitProjections: Out projections are empty" << std::endl;
  993. std::cout << "Fit out proj numerator address: " << h3dFitQoutProj
  994. << " Fit out proj denominator address: " << h3dQoutProjDen << std::endl;
  995. return;
  996. }
  997. if(!h3dFitQsideProj || !h3dQsideProjDen) {
  998. std::cout << "MakeFitProjections: Side projections are empty" << std::endl;
  999. std::cout << "Fit side proj numerator address: " << h3dFitQsideProj
  1000. << " Fit side proj denominator address: " << h3dQsideProjDen << std::endl;
  1001. return;
  1002. }
  1003. if(!h3dFitQlongProj || !h3dQlongProjDen) {
  1004. std::cout << "MakeFitProjections: Long projections are empty" << std::endl;
  1005. std::cout << "Fit long proj numerator address: " << h3dFitQlongProj
  1006. << " Fit long proj denominator address: " << h3dQlongProjDen << std::endl;
  1007. return;
  1008. }
  1009. //TString name, title;
  1010. //Out
  1011. TH1F* hCorrOut = new TH1F(*h3dFitQoutProj);
  1012. /*
  1013. name=""; title="";
  1014. name = hCorrOut->GetName();
  1015. title = hCorrOut->GetTitle();
  1016. name += "_fit";
  1017. title += " fit";
  1018. */
  1019. hCorrOut->Divide(h3dQoutProjDen);
  1020. for(Int_t iBin=1; iBin<=(hCorrOut->GetNbinsX()); iBin++) {
  1021. if(hCorrOut->GetBinContent(iBin) != 0) {
  1022. hCorrOut->SetBinError(iBin, 0.);
  1023. }
  1024. }
  1025. h3dCorrFctnFitOutProj = hCorrOut;
  1026. //h3dCorrFctnFitOutProj->Scale(1./mNonFemto3DVal.at(0));
  1027. //Side
  1028. TH1F* hCorrSide = new TH1F(*h3dFitQsideProj);
  1029. /*
  1030. name=""; title="";
  1031. name = hCorrSide->GetName();
  1032. title = hCorrSide->GetTitle();
  1033. name += "_fit";
  1034. title += " fit";
  1035. */
  1036. hCorrSide->Divide(h3dQsideProjDen);
  1037. for(Int_t iBin=1; iBin<=(hCorrSide->GetNbinsX()); iBin++) {
  1038. if(hCorrSide->GetBinContent(iBin) != 0) {
  1039. hCorrSide->SetBinError(iBin, 0.);
  1040. }
  1041. }
  1042. h3dCorrFctnFitSideProj = hCorrSide;
  1043. //h3dCorrFctnFitSideProj->Scale(1./mNonFemto3DVal.at(0));
  1044. //Long
  1045. TH1F* hCorrLong = new TH1F(*h3dFitQlongProj);
  1046. /*
  1047. name=""; title="";
  1048. name = hCorrLong->GetName();
  1049. title = hCorrLong->GetTitle();
  1050. name += "_fit";
  1051. title += " fit";
  1052. */
  1053. hCorrLong->Divide(h3dQlongProjDen);
  1054. for(Int_t iBin=1; iBin<=(hCorrLong->GetNbinsX()); iBin++) {
  1055. if(hCorrLong->GetBinContent(iBin) != 0) {
  1056. hCorrLong->SetBinError(iBin, 0.);
  1057. }
  1058. }
  1059. h3dCorrFctnFitLongProj = hCorrLong;
  1060. //h3dCorrFctnFitLongProj->Scale(1./mNonFemto3DVal.at(0));
  1061. }
  1062. //_________________
  1063. void HbtFitter::Make1DFunctions() {
  1064. Make1DCorrFctn();
  1065. Make1DFitFunction();
  1066. }
  1067. //_________________
  1068. void HbtFitter::Make1DCorrFctn() {
  1069. double norm = mNonFemto1DVal.at(0);
  1070. h1dCorrFctn->Divide(h1dNumer,h1dDenom);
  1071. h1dCorrFctn->Scale(1./norm);
  1072. }
  1073. //_________________
  1074. void HbtFitter::Make1DFitFunction() {
  1075. Double_t fitPar[mFemto1DParNum+mNonFemto1DParNum];
  1076. for(Int_t iIter=0; iIter<mFemto1DParNum; iIter++) {
  1077. fitPar[iIter] = mFemto1DVal.at(iIter);
  1078. }
  1079. for(Int_t iIter=0; iIter<mNonFemto1DParNum; iIter++) {
  1080. fitPar[iIter] = mNonFemto1DVal.at(iIter);
  1081. }
  1082. h1dFitNumerator = new TH1F("h1dFitNumerator","h1dFitNumerator",
  1083. mQinvNbins, mQinvVal[0], mQinvVal[1]);
  1084. Double_t wTheor, wFitNum;
  1085. for(Int_t iBin=mQinvFitRangeBin[0]; iBin<=mQinvFitRangeBin[1]; iBin++) {
  1086. wTheor = TheorCorrFctn1D(fitPar, iBin);
  1087. h1dFitNumerator->SetBinContent(iBin, wTheor);
  1088. h1dFitNumerator->SetBinError(iBin,0.);
  1089. }
  1090. //IMPORTANT: Correct on the denominator here
  1091. h1dFitNumerator->Divide(h1dDenom);
  1092. }
  1093. //_________________
  1094. void HbtFitter::MakeFitNumerator() {
  1095. //Obtain fit parameters
  1096. Double_t fitPar[mFemto3DParNum+mNonFemto3DParNum];
  1097. for(Int_t iIter=0; iIter<mFemto3DParNum; iIter++) {
  1098. fitPar[iIter] = mFemto3DVal.at(iIter);
  1099. }
  1100. for(Int_t iIter=0; iIter<mNonFemto3DParNum; iIter++) {
  1101. fitPar[mFemto3DParNum+iIter] = mNonFemto3DVal.at(iIter);
  1102. }
  1103. h3dFitNumerator = new TH3F("h3dFitNumerator","h3dFitNumerator",
  1104. mQoutNbins, mQoutVal[0],mQoutVal[1],
  1105. mQsideNbins, mQsideVal[0],mQsideVal[1],
  1106. mQlongNbins, mQlongVal[0],mQlongVal[1]);
  1107. Double_t mNonFemtoCorrFactor = 1.;
  1108. Double_t wTheor, wFitNum;
  1109. //Bin-by-bin loop
  1110. /*
  1111. for(Int_t iOutBin=1; iOutBin<=mQoutNbins; iOutBin++) {
  1112. for(Int_t iSideBin=1; iSideBin<=mQsideNbins; iSideBin++) {
  1113. for(Int_t iLongBin=1; iLongBin<=mQlongNbins; iLongBin++) {
  1114. */
  1115. for(Int_t iOutBin=mQoutFitRangeBin[0]; iOutBin<=mQoutFitRangeBin[1]; iOutBin++) {
  1116. for(Int_t iSideBin=mQsideFitRangeBin[0]; iSideBin<=mQsideFitRangeBin[1]; iSideBin++) {
  1117. for(Int_t iLongBin=mQlongFitRangeBin[0]; iLongBin<=mQlongFitRangeBin[1]; iLongBin++) {
  1118. wTheor = TheorCorrFctn3D(fitPar, iOutBin, iSideBin, iLongBin);
  1119. if(mCorrectOnMc) {
  1120. mNonFemtoCorrFactor = h3dMcCorrFctn->GetBinContent(iOutBin, iSideBin, iLongBin);
  1121. wTheor *= mNonFemtoCorrFactor;
  1122. }
  1123. wFitNum = wTheor * h3dDenom->GetBinContent(iOutBin, iSideBin, iLongBin);
  1124. h3dFitNumerator->SetBinContent(iOutBin, iSideBin, iLongBin, wFitNum);
  1125. h3dFitNumerator->SetBinError(iOutBin, iSideBin, iLongBin, 0.);
  1126. } //for(Int_t iLongBin=1; iLongBin<=mQlongNbins; iLongBin++)
  1127. } //for(Int_t iSideBin=1; iSideBin<=mQsideNbins, iSideBin++)
  1128. } //for(Int_t iOutBin=1; iOutBin<=mQoutNbins, iOutBin++)
  1129. if(mProjectionType == 0) { //By bins
  1130. Project3DDistribution(h3dFitNumerator,
  1131. h3dFitQoutProj, h3dFitQsideProj, h3dFitQlongProj,
  1132. mOutProjBins[0], mOutProjBins[1],
  1133. mSideProjBins[0], mSideProjBins[1],
  1134. mLongProjBins[0], mLongProjBins[1]);
  1135. }
  1136. else { //By values
  1137. Project3DDistribution(h3dFitNumerator,
  1138. h3dFitQoutProj, h3dFitQsideProj, h3dFitQlongProj,
  1139. mOutProjVals[0], mOutProjVals[1],
  1140. mSideProjVals[0], mSideProjVals[1],
  1141. mLongProjVals[0], mLongProjVals[1]);
  1142. }
  1143. }
  1144. //_________________
  1145. void HbtFitter::MakeExpProjections() {
  1146. if(!h3dNumer) {
  1147. std::cout << "MakeExpProjections: 3D numerator is not set" << std::endl;
  1148. return;
  1149. }
  1150. if(!h3dDenom) {
  1151. std::cout << "MakeExpProjections: 3D denominator is not set" << std::endl;
  1152. return;
  1153. }
  1154. //h3dNumer->Draw();
  1155. if(mProjectionType == 0) { //By bins
  1156. Project3DCorrFctn(h3dNumer, h3dDenom,
  1157. h3dQoutProjNum, h3dQsideProjNum, h3dQlongProjNum,
  1158. h3dQoutProjDen, h3dQsideProjDen, h3dQlongProjDen,
  1159. mOutProjBins[0], mOutProjBins[1],
  1160. mSideProjBins[0], mSideProjBins[1],
  1161. mLongProjBins[0], mLongProjBins[1]);
  1162. }
  1163. else { //By values
  1164. Project3DCorrFctn(h3dNumer, h3dDenom,
  1165. h3dQoutProjNum, h3dQsideProjNum, h3dQlongProjNum,
  1166. h3dQoutProjDen, h3dQsideProjDen, h3dQlongProjDen,
  1167. mOutProjVals[0], mOutProjVals[1],
  1168. mSideProjVals[0], mSideProjVals[1],
  1169. mLongProjVals[0], mLongProjVals[1]);
  1170. }
  1171. if(!h3dQoutProjNum || !h3dQsideProjNum || !h3dQlongProjNum) {
  1172. std::cout << "MakeExpProjections: Numerator projections are not defined" << std::endl;
  1173. std::cout << "Out proj address: " << h3dQoutProjNum
  1174. << " Side proj address: " << h3dQsideProjNum
  1175. << " Long proj address: " << h3dQlongProjNum << std::endl;
  1176. return;
  1177. }
  1178. if(!h3dQoutProjDen || !h3dQsideProjDen || !h3dQlongProjDen) {
  1179. std::cout << "MakeExpProjections: Denominator projections are not defined" << std::endl;
  1180. std::cout << "Out proj address: " << h3dQoutProjDen
  1181. << " Side proj address: " << h3dQsideProjDen
  1182. << " Long proj address: " << h3dQlongProjDen << std::endl;
  1183. return;
  1184. }
  1185. //Out
  1186. TH1F* hCorrOut = new TH1F(*h3dQoutProjNum);
  1187. hCorrOut->Divide(h3dQoutProjDen);
  1188. h3dCorrFctnOutProj = hCorrOut;
  1189. //Side
  1190. TH1F* hCorrSide = new TH1F(*h3dQsideProjNum);
  1191. hCorrSide->Divide(h3dQsideProjDen);
  1192. h3dCorrFctnSideProj = hCorrSide;
  1193. //Long
  1194. TH1F* hCorrLong = new TH1F(*h3dQlongProjNum);
  1195. hCorrLong->Divide(h3dQlongProjDen);
  1196. h3dCorrFctnLongProj = hCorrLong;
  1197. }
  1198. //_________________
  1199. void HbtFitter::MakeMcProjections() {
  1200. if(!h3dMcNumer) {
  1201. std::cout << "MakeMcProjections: 3D numerator is not set" << std::endl;
  1202. return;
  1203. }
  1204. if(!h3dMcDenom) {
  1205. std::cout << "MakeMcProjections: 3D denominator is not set" << std::endl;
  1206. return;
  1207. }
  1208. if(mProjectionType == 0) { //By bins
  1209. Project3DCorrFctn(h3dMcNumer, h3dMcDenom,
  1210. h3dMcQoutProjNum, h3dMcQsideProjNum, h3dMcQlongProjNum,
  1211. h3dMcQoutProjDen, h3dMcQsideProjDen, h3dMcQlongProjDen,
  1212. mOutProjBins[0], mOutProjBins[1],
  1213. mSideProjBins[0], mSideProjBins[1],
  1214. mLongProjBins[0], mLongProjBins[1]);
  1215. }
  1216. else { //By values
  1217. Project3DCorrFctn(h3dMcNumer, h3dMcDenom,
  1218. h3dMcQoutProjNum, h3dMcQsideProjNum, h3dMcQlongProjNum,
  1219. h3dMcQoutProjDen, h3dMcQsideProjDen, h3dMcQlongProjDen,
  1220. mOutProjVals[0], mOutProjVals[1],
  1221. mSideProjVals[0], mSideProjVals[1],
  1222. mLongProjVals[0], mLongProjVals[1]);
  1223. }
  1224. if(!h3dMcQoutProjNum || !h3dMcQsideProjNum || !h3dMcQlongProjNum) {
  1225. std::cout << "MakeMcProjections: Numerator projections are not defined" << std::endl;
  1226. std::cout << "Out proj address: " << h3dMcQoutProjNum
  1227. << " Side proj address: " << h3dMcQsideProjNum
  1228. << " Long proj address: " << h3dMcQlongProjNum << std::endl;
  1229. return;
  1230. }
  1231. if(!h3dMcQoutProjDen || !h3dMcQsideProjDen || !h3dMcQlongProjDen) {
  1232. std::cout << "MakeMcProjections: Denominator projections are not defined" << std::endl;
  1233. std::cout << "Out proj address: " << h3dMcQoutProjDen
  1234. << " Side proj address: " << h3dMcQsideProjDen
  1235. << " Long proj address: " << h3dMcQlongProjDen << std::endl;
  1236. return;
  1237. }
  1238. //Out
  1239. TH1F* hCorrOut = new TH1F(*h3dMcQoutProjNum);
  1240. hCorrOut->Divide(h3dMcQoutProjDen);
  1241. h3dMcCorrFctnOutProj = hCorrOut;
  1242. //Side
  1243. TH1F* hCorrSide = new TH1F(*h3dMcQsideProjNum);
  1244. hCorrSide->Divide(h3dMcQsideProjDen);
  1245. h3dMcCorrFctnSideProj = hCorrSide;
  1246. //Long
  1247. TH1F* hCorrLong = new TH1F(*h3dMcQlongProjNum);
  1248. hCorrLong->Divide(h3dMcQlongProjDen);
  1249. h3dMcCorrFctnLongProj = hCorrLong;
  1250. }
  1251. //_________________
  1252. void HbtFitter::Project3DCorrFctn(TH3F* hNumer, TH3F* hDenom,
  1253. TH1F *&hOutProjNum, TH1F *&hSideProjNum,
  1254. TH1F *&hLongProjNum,
  1255. TH1F *&hOutProjDen, TH1F *&hSideProjDen,
  1256. TH1F *&hLongProjDen,
  1257. Int_t mOutBinLow, Int_t mOutBinHi,
  1258. Int_t mSideBinLow, Int_t mSideBinHi,
  1259. Int_t mLongBinLow, Int_t mLongBinHi) {
  1260. Project3DDistribution(hNumer, hOutProjNum, hSideProjNum, hLongProjNum,
  1261. mOutBinLow, mOutBinHi,
  1262. mSideBinLow, mSideBinHi,
  1263. mLongBinLow, mLongBinHi);
  1264. if(!hOutProjNum || !hSideProjNum || !hLongProjNum) {
  1265. std::cout << "Project3DCorrFctn: One of the numerator projections is not set" << std::endl;
  1266. }
  1267. Project3DDistribution(hDenom, hOutProjDen, hSideProjDen, hLongProjDen,
  1268. mOutBinLow, mOutBinHi,
  1269. mSideBinLow, mSideBinHi,
  1270. mLongBinLow, mLongBinHi);
  1271. if(!hOutProjDen || !hSideProjDen || !hLongProjDen) {
  1272. std::cout << "Project3DCorrFctn: One of the denominator projections is not set" << std::endl;
  1273. }
  1274. }
  1275. //_________________
  1276. void HbtFitter::Project3DCorrFctn(TH3F* hNumer, TH3F* hDenom,
  1277. TH1F *&hOutProjNum, TH1F *&hSideProjNum,
  1278. TH1F *&hLongProjNum,
  1279. TH1F *&hOutProjDen, TH1F *&hSideProjDen,
  1280. TH1F *&hLongProjDen,
  1281. Double_t mQoutLow, Double_t mQoutHi,
  1282. Double_t mQsideLow, Double_t mQsideHi,
  1283. Double_t mQlongLow, Double_t mQlongHi) {
  1284. Project3DDistribution(hNumer,
  1285. hOutProjNum, hSideProjNum, hLongProjNum,
  1286. mQoutLow, mQoutHi,
  1287. mQsideLow, mQsideHi,
  1288. mQlongLow, mQlongHi);
  1289. if(!hOutProjNum || !hSideProjNum || !hLongProjNum) {
  1290. std::cout << "Project3DCorrFctn: One of the numerator projections is not set" << std::endl;
  1291. }
  1292. Project3DDistribution(hDenom,
  1293. hOutProjDen, hSideProjDen, hLongProjDen,
  1294. mQoutLow, mQoutHi,
  1295. mQsideLow, mQsideHi,
  1296. mQlongLow, mQlongHi);
  1297. if(!hOutProjDen || !hSideProjDen || !hLongProjDen) {
  1298. std::cout << "Project3DCorrFctn: One of the denominator projections is not set" << std::endl;
  1299. }
  1300. }
  1301. //_________________
  1302. void HbtFitter::Project3DDistribution(TH3F* hQdist,
  1303. TH1F *&hQoutProj, TH1F *&hQsideProj, TH1F *&hQlongProj,
  1304. Int_t mOutBinLow, Int_t mOutBinHi,
  1305. Int_t mSideBinLow, Int_t mSideBinHi,
  1306. Int_t mLongBinLow, Int_t mLongBinHi) {
  1307. if(!hQdist) {
  1308. std::cout << "Project3DDistribution: 3D histogram is not set" << std::endl;
  1309. return;
  1310. }
  1311. //hQdist->Draw();
  1312. //Obtaining number of bins in each axis
  1313. Int_t mNbinsX = hQdist->GetNbinsX();
  1314. Int_t mNbinsY = hQdist->GetNbinsY();
  1315. Int_t mNbinsZ = hQdist->GetNbinsZ();
  1316. if(!mNbinsX || !mNbinsY || !mNbinsZ) {
  1317. std::cout << "Project3DDistribution: 3D distribution is empty" << std::endl;
  1318. return;
  1319. }
  1320. TH1F* hXproj;
  1321. TH1F* hYproj;
  1322. TH1F* hZproj;
  1323. TString name, title;
  1324. //Project 3D histogram using number of bins
  1325. //Out
  1326. name = hQdist->GetName();
  1327. title = hQdist->GetTitle();
  1328. name += "_out";
  1329. title += " out projection";
  1330. hXproj = (TH1F*)hQdist->ProjectionX("hQoutProj",
  1331. mSideBinLow, mSideBinHi,
  1332. mLongBinLow, mLongBinHi);
  1333. hXproj->SetNameTitle(name.Data(), title.Data());
  1334. //Side
  1335. name = hQdist->GetName();
  1336. title = hQdist->GetTitle();
  1337. name += "_side";
  1338. title += " side projection";
  1339. hYproj = (TH1F*)hQdist->ProjectionY("hQsideProj",
  1340. mOutBinLow, mOutBinHi,
  1341. mLongBinLow, mLongBinHi);
  1342. hYproj->SetNameTitle(name.Data(), title.Data());
  1343. //Long
  1344. name = hQdist->GetName();
  1345. title = hQdist->GetTitle();
  1346. name += "_long";
  1347. title += " long projection";
  1348. hZproj = (TH1F*)hQdist->ProjectionZ("hQlongProj",
  1349. mOutBinLow, mOutBinHi,
  1350. mSideBinLow, mSideBinHi);
  1351. hZproj->SetNameTitle(name.Data(), title.Data());
  1352. hQoutProj = hXproj;
  1353. hQsideProj = hYproj;
  1354. hQlongProj = hZproj;
  1355. }
  1356. //_________________
  1357. void HbtFitter::Project3DDistribution(TH3F* hQdist,
  1358. TH1F *&hQoutProj, TH1F *&hQsideProj, TH1F *&hQlongProj,
  1359. Double_t mQoutLow, Double_t mQoutHi,
  1360. Double_t mQsideLow, Double_t mQsideHi,
  1361. Double_t mQlongLow, Double_t mQlongHi) {
  1362. if(!hQdist) {
  1363. std::cout << "Project3DDistribution: 3D histogram is not set" << std::endl;
  1364. return;
  1365. }
  1366. //hQdist->Draw();
  1367. //Obtaining number of bins in each axis
  1368. Int_t mNbinsX = hQdist->GetNbinsX();
  1369. Int_t mNbinsY = hQdist->GetNbinsY();
  1370. Int_t mNbinsZ = hQdist->GetNbinsZ();
  1371. if(!mNbinsX || !mNbinsY || !mNbinsZ) {
  1372. std::cout << "Project3DDistribution: 3D distribution has no bins" << std::endl;
  1373. return;
  1374. }
  1375. //Obtaining the ranges
  1376. Double_t xLow = hQdist->GetXaxis()->GetXmin();
  1377. Double_t xHi = hQdist->GetXaxis()->GetXmax();
  1378. Double_t yLow = hQdist->GetYaxis()->GetXmin();
  1379. Double_t yHi = hQdist->GetYaxis()->GetXmax();
  1380. Double_t zLow = hQdist->GetZaxis()->GetXmin();
  1381. Double_t zHi = hQdist->GetZaxis()->GetXmax();
  1382. TH1F* hXproj;
  1383. TH1F* hYproj;
  1384. TH1F* hZproj;
  1385. TString name, title;
  1386. //Project 3D histogram using the ranges
  1387. //Out
  1388. name = hQdist->GetName();
  1389. title = hQdist->GetTitle();
  1390. name += "_out";
  1391. title += " out projection";
  1392. hQdist->SetAxisRange(xLow, xHi, "x");
  1393. hQdist->SetAxisRange(mQsideLow, mQsideHi, "y");
  1394. hQdist->SetAxisRange(mQlongLow, mQlongHi, "z");
  1395. hXproj = (TH1F*)hQdist->Project3D("xe");
  1396. hXproj->SetNameTitle(name.Data(), title.Data());;
  1397. //Side
  1398. name = hQdist->GetName();
  1399. title = hQdist->GetTitle();
  1400. name += "_side";
  1401. title += " side projection";
  1402. hQdist->SetAxisRange(mQoutLow, mQoutHi, "x");
  1403. hQdist->SetAxisRange(yLow, yHi, "y");
  1404. hQdist->SetAxisRange(mQlongLow, mQlongHi, "z");
  1405. hYproj = (TH1F*)hQdist->Project3D("ye");
  1406. hYproj->SetNameTitle(name.Data(), title.Data());
  1407. //Long
  1408. name = hQdist->GetName();
  1409. title = hQdist->GetTitle();
  1410. name += "_long";
  1411. title += " long projection";
  1412. hQdist->SetAxisRange(mQoutLow, mQoutHi, "x");
  1413. hQdist->SetAxisRange(mQsideLow, mQsideHi, "y");
  1414. hQdist->SetAxisRange(zLow, zHi, "z");
  1415. hZproj = (TH1F*)hQdist->Project3D("ze");
  1416. hZproj->SetNameTitle(name.Data(), title.Data());
  1417. hQoutProj = hXproj;
  1418. hQsideProj = hYproj;
  1419. hQlongProj = hZproj;
  1420. }