FemtoDstAnalyzer_FlowChargedHadrons.C 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530
  1. /**
  2. * \brief Example of how to read a file (list of files) using StFemtoEvent classes
  3. *
  4. * RunFemtoDstAnalyzer.C is an example of reading FemtoDst format.
  5. * One can use either FemtoDst file or a list of femtoDst files (inFile.lis or
  6. * inFile.list) as an input, and preform physics analysis
  7. *
  8. * \author Grigory Nigmatkulov
  9. * \date May 29, 2018
  10. */
  11. // This is needed for calling standalone classes
  12. #define _VANILLA_ROOT_
  13. // C++ headers
  14. #include <iostream>
  15. #include <vector>
  16. #include <map>
  17. // ROOT headers
  18. #include "TROOT.h"
  19. #include "TFile.h"
  20. #include "TChain.h"
  21. #include "TVector2.h"
  22. #include "TVector3.h"
  23. #include "TTree.h"
  24. #include "TSystem.h"
  25. #include "TH1.h"
  26. #include "TH2.h"
  27. #include "TMath.h"
  28. #include "TProfile2D.h"
  29. #include "TStopwatch.h"
  30. // FemtoDst headers
  31. #include "StFemtoDstReader.h"
  32. #include "StFemtoDst.h"
  33. #include "StFemtoEvent.h"
  34. #include "StFemtoTrack.h"
  35. // Load libraries (for ROOT_VERSTION_CODE >= 393215)
  36. #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 0, 0)
  37. R__LOAD_LIBRARY(/ mnt / pool / rhic / 4 / parfenovpeter / STAR / build / libStFemtoDst.so)
  38. #endif
  39. #include "Constants.h"
  40. // inFile - is a name of name.FemtoDst.root file or a name
  41. // of a name.lis(t) files, that contains a list of
  42. // name1.FemtoDst.root, name2.FemtoDst.root, ... files
  43. //Used functions (see them below)
  44. Bool_t isGoodEvent(StFemtoEvent *const &event);
  45. Bool_t isGoodTrack(StFemtoTrack *const &track, Float_t _energy, TVector3 pVtx);
  46. Bool_t isGoodTrackFlow(StFemtoTrack *const &track, Float_t _energy, TVector3 pVtx);
  47. Double_t GetWeight(StFemtoTrack *const &track);
  48. TVector2 CalcQvector(StFemtoTrack *const &track, Int_t _harm);
  49. Double_t AngleShift(Double_t Psi, Double_t order);
  50. Int_t GetVzBin(Double_t vtxZ);
  51. Float_t BBC_GetPhi(const Int_t eastWest, const Int_t tileId);
  52. Bool_t isBadRun(StFemtoEvent *const &event);
  53. Double_t GetZDCPosition(Int_t eastwest, Int_t verthori, Int_t strip);
  54. //_________________
  55. void FemtoDstAnalyzer_FlowChargedHadrons(const Char_t *inFile = "st_physics_12150008_raw_4030001.femtoDst.root",
  56. const Char_t *outFile = "./oShiftTest.root",
  57. const Char_t *reCentFile = "",
  58. const Char_t *shiftFile = "",
  59. const Char_t *resFile = "",
  60. const Char_t *gainBBC = "",
  61. const Char_t *reCentFileBBC = "",
  62. const Char_t *shiftFileBBC = "",
  63. const Char_t *reCentFileZDC = "",
  64. const Char_t *shiftFileZDC = "",
  65. const Char_t *resFitFile = "")
  66. {
  67. std::cout << "Hi! Lets do some physics, Master!" << std::endl;
  68. TStopwatch timer;
  69. timer.Start();
  70. #if ROOT_VERSION_CODE < ROOT_VERSION(6, 0, 0)
  71. gSystem->Load("../libStFemtoDst.so");
  72. #endif
  73. StFemtoDstReader *femtoReader = new StFemtoDstReader(inFile);
  74. femtoReader->Init();
  75. // This is a way if you want to spead up IO
  76. std::cout << "Explicit read status for some branches" << std::endl;
  77. femtoReader->SetStatus("*", 0);
  78. femtoReader->SetStatus("Event", 1);
  79. femtoReader->SetStatus("Track", 1);
  80. std::cout << "Status has been set" << std::endl;
  81. std::cout << "Now I know what to read, Master!" << std::endl;
  82. if (!femtoReader->chain())
  83. {
  84. std::cout << "No chain has been found." << std::endl;
  85. }
  86. Long64_t eventsInTree = femtoReader->tree()->GetEntries();
  87. std::cout << "eventsInTree: " << eventsInTree << std::endl;
  88. Long64_t events2read = femtoReader->chain()->GetEntries();
  89. std::cout << "Number of events to read: " << events2read << std::endl;
  90. //Read ReCentering <Q> vectors
  91. TFile *fiReCent = new TFile(reCentFile, "read");
  92. std::map<Double_t, Double_t> p_Qx_FULL_EP[fNharmonics][fArraySize][fNCent];
  93. std::map<Double_t, Double_t> p_Qy_FULL_EP[fNharmonics][fArraySize][fNCent];
  94. std::map<Double_t, Double_t> p_Qx_FULL_SP[fNharmonics][fArraySize][fNCent];
  95. std::map<Double_t, Double_t> p_Qy_FULL_SP[fNharmonics][fArraySize][fNCent];
  96. std::map<Double_t, Double_t> p_Qx_EAST_EP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  97. std::map<Double_t, Double_t> p_Qy_EAST_EP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  98. std::map<Double_t, Double_t> p_Qx_EAST_SP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  99. std::map<Double_t, Double_t> p_Qy_EAST_SP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  100. std::map<Double_t, Double_t> p_Qx_WEST_EP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  101. std::map<Double_t, Double_t> p_Qy_WEST_EP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  102. std::map<Double_t, Double_t> p_Qx_WEST_SP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  103. std::map<Double_t, Double_t> p_Qy_WEST_SP[fNharmonics][fArraySize][fNCent][NEtaGaps];
  104. TProfile2D *prof;
  105. double binCont;
  106. std::cout << "Reading file for TPC recentering..." << std::endl;
  107. for (int iHarm = 0; iHarm < fNharmonics; iHarm++)
  108. {
  109. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  110. {
  111. std::cout << "iHarm: " << iHarm << " iVtx: " << iVtx << std::endl;
  112. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%ix_FULL_EP%i", iHarm, iVtx));
  113. for (int i = 0; i < fNBins; i++)
  114. {
  115. for (int iCent = 0; iCent < fNCent; iCent++)
  116. {
  117. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  118. if (binCont == 0.)
  119. continue;
  120. p_Qx_FULL_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  121. }
  122. }
  123. delete prof;
  124. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%iy_FULL_EP%i", iHarm, iVtx));
  125. for (int i = 0; i < fNBins; i++)
  126. {
  127. for (int iCent = 0; iCent < fNCent; iCent++)
  128. {
  129. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  130. if (binCont == 0.)
  131. continue;
  132. p_Qy_FULL_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  133. }
  134. }
  135. delete prof;
  136. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%ix_FULL_SP%i", iHarm, iVtx));
  137. for (int i = 0; i < fNBins; i++)
  138. {
  139. for (int iCent = 0; iCent < fNCent; iCent++)
  140. {
  141. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  142. if (binCont == 0.)
  143. continue;
  144. p_Qx_FULL_SP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  145. }
  146. }
  147. delete prof;
  148. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%iy_FULL_SP%i", iHarm, iVtx));
  149. for (int i = 0; i < fNBins; i++)
  150. {
  151. for (int iCent = 0; iCent < fNCent; iCent++)
  152. {
  153. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  154. if (binCont == 0.)
  155. continue;
  156. p_Qy_FULL_SP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  157. }
  158. }
  159. delete prof;
  160. for (int iEtaGap = 0; iEtaGap < NEtaGaps; iEtaGap++)
  161. {
  162. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%ix_EAST_EP%i_gap%i", iHarm, iVtx, iEtaGap));
  163. for (int i = 0; i < fNBins; i++)
  164. {
  165. for (int iCent = 0; iCent < fNCent; iCent++)
  166. {
  167. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  168. if (binCont == 0.)
  169. continue;
  170. p_Qx_EAST_EP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  171. }
  172. }
  173. delete prof;
  174. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%iy_EAST_EP%i_gap%i", iHarm, iVtx, iEtaGap));
  175. for (int i = 0; i < fNBins; i++)
  176. {
  177. for (int iCent = 0; iCent < fNCent; iCent++)
  178. {
  179. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  180. if (binCont == 0.)
  181. continue;
  182. p_Qy_EAST_EP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  183. }
  184. }
  185. delete prof;
  186. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%ix_EAST_SP%i_gap%i", iHarm, iVtx, iEtaGap));
  187. for (int i = 0; i < fNBins; i++)
  188. {
  189. for (int iCent = 0; iCent < fNCent; iCent++)
  190. {
  191. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  192. if (binCont == 0.)
  193. continue;
  194. p_Qx_EAST_SP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  195. }
  196. }
  197. delete prof;
  198. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%iy_EAST_SP%i_gap%i", iHarm, iVtx, iEtaGap));
  199. for (int i = 0; i < fNBins; i++)
  200. {
  201. for (int iCent = 0; iCent < fNCent; iCent++)
  202. {
  203. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  204. if (binCont == 0.)
  205. continue;
  206. p_Qy_EAST_SP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  207. }
  208. }
  209. delete prof;
  210. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%ix_WEST_EP%i_gap%i", iHarm, iVtx, iEtaGap));
  211. for (int i = 0; i < fNBins; i++)
  212. {
  213. for (int iCent = 0; iCent < fNCent; iCent++)
  214. {
  215. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  216. if (binCont == 0.)
  217. continue;
  218. p_Qx_WEST_EP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  219. }
  220. }
  221. delete prof;
  222. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%iy_WEST_EP%i_gap%i", iHarm, iVtx, iEtaGap));
  223. for (int i = 0; i < fNBins; i++)
  224. {
  225. for (int iCent = 0; iCent < fNCent; iCent++)
  226. {
  227. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  228. if (binCont == 0.)
  229. continue;
  230. p_Qy_WEST_EP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  231. }
  232. }
  233. delete prof;
  234. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%ix_WEST_SP%i_gap%i", iHarm, iVtx, iEtaGap));
  235. for (int i = 0; i < fNBins; i++)
  236. {
  237. for (int iCent = 0; iCent < fNCent; iCent++)
  238. {
  239. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  240. if (binCont == 0.)
  241. continue;
  242. p_Qx_WEST_SP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  243. }
  244. }
  245. delete prof;
  246. prof = (TProfile2D *)fiReCent->Get(Form("p_Q%iy_WEST_SP%i_gap%i", iHarm, iVtx, iEtaGap));
  247. for (int i = 0; i < fNBins; i++)
  248. {
  249. for (int iCent = 0; iCent < fNCent; iCent++)
  250. {
  251. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  252. if (binCont == 0.)
  253. continue;
  254. p_Qy_WEST_SP[iHarm][iVtx][iCent][iEtaGap][(Double_t)(runId_min + i)] = binCont;
  255. }
  256. }
  257. delete prof;
  258. }
  259. }
  260. }
  261. //Read Shift coefficients
  262. TFile *fiShift = new TFile(shiftFile, "read");
  263. std::map<Double_t, Double_t> p_Cos2_FULL_EP[fArraySize][NShiftOrderMax][fNCent];
  264. std::map<Double_t, Double_t> p_Sin2_FULL_EP[fArraySize][NShiftOrderMax][fNCent];
  265. std::map<Double_t, Double_t> p_Cos2_FULL_SP[fArraySize][NShiftOrderMax][fNCent];
  266. std::map<Double_t, Double_t> p_Sin2_FULL_SP[fArraySize][NShiftOrderMax][fNCent];
  267. std::map<Double_t, Double_t> p_Cos2_EAST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  268. std::map<Double_t, Double_t> p_Sin2_EAST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  269. std::map<Double_t, Double_t> p_Cos2_EAST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  270. std::map<Double_t, Double_t> p_Sin2_EAST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  271. std::map<Double_t, Double_t> p_Cos2_WEST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  272. std::map<Double_t, Double_t> p_Sin2_WEST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  273. std::map<Double_t, Double_t> p_Cos2_WEST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  274. std::map<Double_t, Double_t> p_Sin2_WEST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  275. std::map<Double_t, Double_t> p_Cos3_FULL_EP[fArraySize][NShiftOrderMax][fNCent];
  276. std::map<Double_t, Double_t> p_Sin3_FULL_EP[fArraySize][NShiftOrderMax][fNCent];
  277. std::map<Double_t, Double_t> p_Cos3_FULL_SP[fArraySize][NShiftOrderMax][fNCent];
  278. std::map<Double_t, Double_t> p_Sin3_FULL_SP[fArraySize][NShiftOrderMax][fNCent];
  279. std::map<Double_t, Double_t> p_Cos3_EAST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  280. std::map<Double_t, Double_t> p_Sin3_EAST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  281. std::map<Double_t, Double_t> p_Cos3_EAST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  282. std::map<Double_t, Double_t> p_Sin3_EAST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  283. std::map<Double_t, Double_t> p_Cos3_WEST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  284. std::map<Double_t, Double_t> p_Sin3_WEST_EP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  285. std::map<Double_t, Double_t> p_Cos3_WEST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  286. std::map<Double_t, Double_t> p_Sin3_WEST_SP[fArraySize][NShiftOrderMax][fNCent][NEtaGaps];
  287. std::cout << "Reading file for TPC flattening..." << std::endl;
  288. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  289. {
  290. for (int iShift = 0; iShift < NShiftOrderMax; iShift++)
  291. {
  292. std::cout << "iVtx: " << iVtx << " iShiftOrder: " << iShift << std::endl;
  293. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_FULL_EP%i_shiftOrder_%i", 2, iVtx, iShift));
  294. for (int i = 0; i < fNBins; i++)
  295. {
  296. for (int iCent = 0; iCent < fNCent; iCent++)
  297. {
  298. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  299. if (binCont == 0.)
  300. continue;
  301. p_Cos2_FULL_EP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  302. }
  303. }
  304. delete prof;
  305. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_FULL_EP%i_shiftOrder_%i", 2, iVtx, iShift));
  306. for (int i = 0; i < fNBins; i++)
  307. {
  308. for (int iCent = 0; iCent < fNCent; iCent++)
  309. {
  310. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  311. if (binCont == 0.)
  312. continue;
  313. p_Sin2_FULL_EP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  314. }
  315. }
  316. delete prof;
  317. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_FULL_SP%i_shiftOrder_%i", 2, iVtx, iShift));
  318. for (int i = 0; i < fNBins; i++)
  319. {
  320. for (int iCent = 0; iCent < fNCent; iCent++)
  321. {
  322. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  323. if (binCont == 0.)
  324. continue;
  325. p_Cos2_FULL_SP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  326. }
  327. }
  328. delete prof;
  329. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_FULL_SP%i_shiftOrder_%i", 2, iVtx, iShift));
  330. for (int i = 0; i < fNBins; i++)
  331. {
  332. for (int iCent = 0; iCent < fNCent; iCent++)
  333. {
  334. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  335. if (binCont == 0.)
  336. continue;
  337. p_Sin2_FULL_SP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  338. }
  339. }
  340. delete prof;
  341. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_FULL_EP%i_shiftOrder_%i", 3, iVtx, iShift));
  342. for (int i = 0; i < fNBins; i++)
  343. {
  344. for (int iCent = 0; iCent < fNCent; iCent++)
  345. {
  346. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  347. if (binCont == 0.)
  348. continue;
  349. p_Cos3_FULL_EP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  350. }
  351. }
  352. delete prof;
  353. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_FULL_EP%i_shiftOrder_%i", 3, iVtx, iShift));
  354. for (int i = 0; i < fNBins; i++)
  355. {
  356. for (int iCent = 0; iCent < fNCent; iCent++)
  357. {
  358. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  359. if (binCont == 0.)
  360. continue;
  361. p_Sin3_FULL_EP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  362. }
  363. }
  364. delete prof;
  365. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_FULL_SP%i_shiftOrder_%i", 3, iVtx, iShift));
  366. for (int i = 0; i < fNBins; i++)
  367. {
  368. for (int iCent = 0; iCent < fNCent; iCent++)
  369. {
  370. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  371. if (binCont == 0.)
  372. continue;
  373. p_Cos3_FULL_SP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  374. }
  375. }
  376. delete prof;
  377. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_FULL_SP%i_shiftOrder_%i", 3, iVtx, iShift));
  378. for (int i = 0; i < fNBins; i++)
  379. {
  380. for (int iCent = 0; iCent < fNCent; iCent++)
  381. {
  382. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  383. if (binCont == 0.)
  384. continue;
  385. p_Sin3_FULL_SP[iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  386. }
  387. }
  388. delete prof;
  389. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  390. {
  391. // for 2nd harmonics
  392. // EAST
  393. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_EAST_EP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  394. for (int i = 0; i < fNBins; i++)
  395. {
  396. for (int iCent = 0; iCent < fNCent; iCent++)
  397. {
  398. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  399. if (binCont == 0.)
  400. continue;
  401. p_Cos2_EAST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  402. }
  403. }
  404. delete prof;
  405. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_EAST_EP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  406. for (int i = 0; i < fNBins; i++)
  407. {
  408. for (int iCent = 0; iCent < fNCent; iCent++)
  409. {
  410. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  411. if (binCont == 0.)
  412. continue;
  413. p_Sin2_EAST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  414. }
  415. }
  416. delete prof;
  417. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_EAST_SP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  418. for (int i = 0; i < fNBins; i++)
  419. {
  420. for (int iCent = 0; iCent < fNCent; iCent++)
  421. {
  422. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  423. if (binCont == 0.)
  424. continue;
  425. p_Cos2_EAST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  426. }
  427. }
  428. delete prof;
  429. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_EAST_SP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  430. for (int i = 0; i < fNBins; i++)
  431. {
  432. for (int iCent = 0; iCent < fNCent; iCent++)
  433. {
  434. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  435. if (binCont == 0.)
  436. continue;
  437. p_Sin2_EAST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  438. }
  439. }
  440. delete prof;
  441. // WEST
  442. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_WEST_EP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  443. for (int i = 0; i < fNBins; i++)
  444. {
  445. for (int iCent = 0; iCent < fNCent; iCent++)
  446. {
  447. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  448. if (binCont == 0.)
  449. continue;
  450. p_Cos2_WEST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  451. }
  452. }
  453. delete prof;
  454. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_WEST_EP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  455. for (int i = 0; i < fNBins; i++)
  456. {
  457. for (int iCent = 0; iCent < fNCent; iCent++)
  458. {
  459. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  460. if (binCont == 0.)
  461. continue;
  462. p_Sin2_WEST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  463. }
  464. }
  465. delete prof;
  466. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_WEST_SP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  467. for (int i = 0; i < fNBins; i++)
  468. {
  469. for (int iCent = 0; iCent < fNCent; iCent++)
  470. {
  471. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  472. if (binCont == 0.)
  473. continue;
  474. p_Cos2_WEST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  475. }
  476. }
  477. delete prof;
  478. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_WEST_SP%i_shiftOrder_%i_gap%i", 2, iVtx, iShift, iGap));
  479. for (int i = 0; i < fNBins; i++)
  480. {
  481. for (int iCent = 0; iCent < fNCent; iCent++)
  482. {
  483. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  484. if (binCont == 0.)
  485. continue;
  486. p_Sin2_WEST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  487. }
  488. }
  489. delete prof;
  490. // for 3rd harmonics
  491. // EAST
  492. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_EAST_EP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  493. for (int i = 0; i < fNBins; i++)
  494. {
  495. for (int iCent = 0; iCent < fNCent; iCent++)
  496. {
  497. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  498. if (binCont == 0.)
  499. continue;
  500. p_Cos3_EAST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  501. }
  502. }
  503. delete prof;
  504. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_EAST_EP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  505. for (int i = 0; i < fNBins; i++)
  506. {
  507. for (int iCent = 0; iCent < fNCent; iCent++)
  508. {
  509. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  510. if (binCont == 0.)
  511. continue;
  512. p_Sin3_EAST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  513. }
  514. }
  515. delete prof;
  516. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_EAST_SP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  517. for (int i = 0; i < fNBins; i++)
  518. {
  519. for (int iCent = 0; iCent < fNCent; iCent++)
  520. {
  521. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  522. if (binCont == 0.)
  523. continue;
  524. p_Cos3_EAST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  525. }
  526. }
  527. delete prof;
  528. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_EAST_SP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  529. for (int i = 0; i < fNBins; i++)
  530. {
  531. for (int iCent = 0; iCent < fNCent; iCent++)
  532. {
  533. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  534. if (binCont == 0.)
  535. continue;
  536. p_Sin3_EAST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  537. }
  538. }
  539. delete prof;
  540. // WEST
  541. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_WEST_EP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  542. for (int i = 0; i < fNBins; i++)
  543. {
  544. for (int iCent = 0; iCent < fNCent; iCent++)
  545. {
  546. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  547. if (binCont == 0.)
  548. continue;
  549. p_Cos3_WEST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  550. }
  551. }
  552. delete prof;
  553. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_WEST_EP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  554. for (int i = 0; i < fNBins; i++)
  555. {
  556. for (int iCent = 0; iCent < fNCent; iCent++)
  557. {
  558. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  559. if (binCont == 0.)
  560. continue;
  561. p_Sin3_WEST_EP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  562. }
  563. }
  564. delete prof;
  565. prof = (TProfile2D *)fiShift->Get(Form("p_Cos%i_WEST_SP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  566. for (int i = 0; i < fNBins; i++)
  567. {
  568. for (int iCent = 0; iCent < fNCent; iCent++)
  569. {
  570. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  571. if (binCont == 0.)
  572. continue;
  573. p_Cos3_WEST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  574. }
  575. }
  576. delete prof;
  577. prof = (TProfile2D *)fiShift->Get(Form("p_Sin%i_WEST_SP%i_shiftOrder_%i_gap%i", 3, iVtx, iShift, iGap));
  578. for (int i = 0; i < fNBins; i++)
  579. {
  580. for (int iCent = 0; iCent < fNCent; iCent++)
  581. {
  582. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  583. if (binCont == 0.)
  584. continue;
  585. p_Sin3_WEST_SP[iVtx][iShift][iCent][iGap][(Double_t)(runId_min + i)] = binCont;
  586. }
  587. }
  588. delete prof;
  589. }
  590. }
  591. }
  592. //Read resolution
  593. TFile *fiRes = new TFile(resFile, "read");
  594. TProfile *p_res2_EP[NEtaGaps];
  595. TProfile *p_res3_EP[NEtaGaps];
  596. TProfile *p_res2_SP[NEtaGaps];
  597. TProfile *p_res3_SP[NEtaGaps];
  598. // TProfile *p_resBBC_EP[fNharmonics+1];
  599. TProfile *p_res2_EP_3sub_AB;
  600. TProfile *p_res2_EP_3sub_AC;
  601. TProfile *p_res2_EP_3sub_BC;
  602. p_res2_EP_3sub_AB = (TProfile *)fiRes->Get("p_res2_EP_3sub_AB");
  603. p_res2_EP_3sub_AC = (TProfile *)fiRes->Get("p_res2_EP_3sub_AC");
  604. p_res2_EP_3sub_BC = (TProfile *)fiRes->Get("p_res2_EP_3sub_BC");
  605. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  606. {
  607. p_res2_EP[iGap] = (TProfile *)fiRes->Get(Form("p_res2_EP_gap%i", iGap));
  608. p_res3_EP[iGap] = (TProfile *)fiRes->Get(Form("p_res3_EP_gap%i", iGap));
  609. p_res2_SP[iGap] = (TProfile *)fiRes->Get(Form("p_res2_SP_gap%i", iGap));
  610. p_res3_SP[iGap] = (TProfile *)fiRes->Get(Form("p_res3_SP_gap%i", iGap));
  611. }
  612. // for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  613. // {
  614. // p_resBBC_EP[iHarm] = (TProfile*) fiRes->Get(Form("p_resBBC_EP%i", iHarm));
  615. // }
  616. //Read resolution fit
  617. TFile *fiResFit = new TFile(resFitFile, "read");
  618. TH1D *hResBBCFULL[fNharmonics + 1];
  619. TH1D *hResBBCHalf[fNharmonics + 1];
  620. TH1D *hResZDCFULL[fNharmonics + 1];
  621. TH1D *hResZDCHalf[fNharmonics + 1];
  622. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  623. {
  624. hResBBCFULL[iHarm] = (TH1D *)fiResFit->Get(Form("hResBBCFULL%i", iHarm));
  625. hResBBCHalf[iHarm] = (TH1D *)fiResFit->Get(Form("hResBBCHalf%i", iHarm));
  626. }
  627. for (int iHarm = 0; iHarm < fNharmonics; iHarm++)
  628. {
  629. hResZDCFULL[iHarm] = (TH1D *)fiResFit->Get(Form("hResZDCFULL%i", iHarm));
  630. hResZDCHalf[iHarm] = (TH1D *)fiResFit->Get(Form("hResZDCHalf%i", iHarm));
  631. }
  632. //Manage gain correction
  633. TProfile2D *BBCgain_East[fArraySize];
  634. TProfile2D *BBCgain_West[fArraySize];
  635. TFile *fiGain = new TFile(gainBBC, "read");
  636. fiGain->cd();
  637. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  638. {
  639. BBCgain_East[iVtx] = (TProfile2D *)fiGain->Get(Form("p_gainBBC_East_Vtx%i", iVtx));
  640. BBCgain_West[iVtx] = (TProfile2D *)fiGain->Get(Form("p_gainBBC_West_Vtx%i", iVtx));
  641. }
  642. //Manage recentering BBC
  643. std::map<Double_t, Double_t> p_BBC_Qx_Full_EP[fNharmonics][fArraySize][fNCent];
  644. std::map<Double_t, Double_t> p_BBC_Qy_Full_EP[fNharmonics][fArraySize][fNCent];
  645. std::map<Double_t, Double_t> p_BBC_Qx_East_EP[fNharmonics][fArraySize][fNCent];
  646. std::map<Double_t, Double_t> p_BBC_Qy_East_EP[fNharmonics][fArraySize][fNCent];
  647. std::map<Double_t, Double_t> p_BBC_Qx_West_EP[fNharmonics][fArraySize][fNCent];
  648. std::map<Double_t, Double_t> p_BBC_Qy_West_EP[fNharmonics][fArraySize][fNCent];
  649. TFile *fiReCentBBC = new TFile(reCentFileBBC, "read");
  650. std::cout << "Reading file for BBC recentering..." << std::endl;
  651. for (int iHarm = 0; iHarm < fNharmonics; iHarm++)
  652. {
  653. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  654. {
  655. std::cout << "iHarm: " << iHarm << " iVtx: " << iVtx << std::endl;
  656. prof = (TProfile2D *)fiReCentBBC->Get(Form("p_BBC_Qx_Full_EP%i_vtx%i", iHarm, iVtx));
  657. for (int i = 0; i < fNBins; i++)
  658. {
  659. for (int iCent = 0; iCent < fNCent; iCent++)
  660. {
  661. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  662. if (binCont == 0.)
  663. continue;
  664. p_BBC_Qx_Full_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  665. }
  666. }
  667. delete prof;
  668. prof = (TProfile2D *)fiReCentBBC->Get(Form("p_BBC_Qy_Full_EP%i_vtx%i", iHarm, iVtx));
  669. for (int i = 0; i < fNBins; i++)
  670. {
  671. for (int iCent = 0; iCent < fNCent; iCent++)
  672. {
  673. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  674. if (binCont == 0.)
  675. continue;
  676. p_BBC_Qy_Full_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  677. }
  678. }
  679. delete prof;
  680. prof = (TProfile2D *)fiReCentBBC->Get(Form("p_BBC_Qx_East_EP%i_vtx%i", iHarm, iVtx));
  681. for (int i = 0; i < fNBins; i++)
  682. {
  683. for (int iCent = 0; iCent < fNCent; iCent++)
  684. {
  685. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  686. if (binCont == 0.)
  687. continue;
  688. p_BBC_Qx_East_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  689. }
  690. }
  691. delete prof;
  692. prof = (TProfile2D *)fiReCentBBC->Get(Form("p_BBC_Qy_East_EP%i_vtx%i", iHarm, iVtx));
  693. for (int i = 0; i < fNBins; i++)
  694. {
  695. for (int iCent = 0; iCent < fNCent; iCent++)
  696. {
  697. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  698. if (binCont == 0.)
  699. continue;
  700. p_BBC_Qy_East_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  701. }
  702. }
  703. delete prof;
  704. prof = (TProfile2D *)fiReCentBBC->Get(Form("p_BBC_Qx_West_EP%i_vtx%i", iHarm, iVtx));
  705. for (int i = 0; i < fNBins; i++)
  706. {
  707. for (int iCent = 0; iCent < fNCent; iCent++)
  708. {
  709. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  710. if (binCont == 0.)
  711. continue;
  712. p_BBC_Qx_West_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  713. }
  714. }
  715. delete prof;
  716. prof = (TProfile2D *)fiReCentBBC->Get(Form("p_BBC_Qy_West_EP%i_vtx%i", iHarm, iVtx));
  717. for (int i = 0; i < fNBins; i++)
  718. {
  719. for (int iCent = 0; iCent < fNCent; iCent++)
  720. {
  721. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  722. if (binCont == 0.)
  723. continue;
  724. p_BBC_Qy_West_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  725. }
  726. }
  727. delete prof;
  728. }
  729. }
  730. //Manage ShiftCorr BBC
  731. std::map<Double_t, Double_t> p_BBC_Cos_Full_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  732. std::map<Double_t, Double_t> p_BBC_Sin_Full_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  733. std::map<Double_t, Double_t> p_BBC_Cos_East_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  734. std::map<Double_t, Double_t> p_BBC_Sin_East_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  735. std::map<Double_t, Double_t> p_BBC_Cos_West_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  736. std::map<Double_t, Double_t> p_BBC_Sin_West_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  737. TFile *fiShiftBBC = new TFile(shiftFileBBC, "read");
  738. fiShiftBBC->cd();
  739. std::cout << "Reading file for BBC shift corrections..." << std::endl;
  740. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  741. {
  742. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  743. {
  744. for (int iShift = 0; iShift < NShiftOrderMax * 3; iShift++)
  745. {
  746. std::cout << "iHarm: " << iHarm << " iVtx: " << iVtx << " iShiftOrder: " << iShift << std::endl;
  747. prof = (TProfile2D *)fiShiftBBC->Get(Form("p_BBC_Cos%i_Full_EP%i_vtx%i", iShift, iHarm, iVtx));
  748. for (int i = 0; i < fNBins; i++)
  749. {
  750. for (int iCent = 0; iCent < fNCent; iCent++)
  751. {
  752. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  753. if (binCont == 0.)
  754. continue;
  755. p_BBC_Cos_Full_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  756. }
  757. }
  758. delete prof;
  759. prof = (TProfile2D *)fiShiftBBC->Get(Form("p_BBC_Sin%i_Full_EP%i_vtx%i", iShift, iHarm, iVtx));
  760. for (int i = 0; i < fNBins; i++)
  761. {
  762. for (int iCent = 0; iCent < fNCent; iCent++)
  763. {
  764. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  765. if (binCont == 0.)
  766. continue;
  767. p_BBC_Sin_Full_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  768. }
  769. }
  770. delete prof;
  771. prof = (TProfile2D *)fiShiftBBC->Get(Form("p_BBC_Cos%i_East_EP%i_vtx%i", iShift, iHarm, iVtx));
  772. for (int i = 0; i < fNBins; i++)
  773. {
  774. for (int iCent = 0; iCent < fNCent; iCent++)
  775. {
  776. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  777. if (binCont == 0.)
  778. continue;
  779. p_BBC_Cos_East_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  780. }
  781. }
  782. delete prof;
  783. prof = (TProfile2D *)fiShiftBBC->Get(Form("p_BBC_Sin%i_East_EP%i_vtx%i", iShift, iHarm, iVtx));
  784. for (int i = 0; i < fNBins; i++)
  785. {
  786. for (int iCent = 0; iCent < fNCent; iCent++)
  787. {
  788. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  789. if (binCont == 0.)
  790. continue;
  791. p_BBC_Sin_East_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  792. }
  793. }
  794. delete prof;
  795. prof = (TProfile2D *)fiShiftBBC->Get(Form("p_BBC_Cos%i_West_EP%i_vtx%i", iShift, iHarm, iVtx));
  796. for (int i = 0; i < fNBins; i++)
  797. {
  798. for (int iCent = 0; iCent < fNCent; iCent++)
  799. {
  800. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  801. if (binCont == 0.)
  802. continue;
  803. p_BBC_Cos_West_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  804. }
  805. }
  806. delete prof;
  807. prof = (TProfile2D *)fiShiftBBC->Get(Form("p_BBC_Sin%i_West_EP%i_vtx%i", iShift, iHarm, iVtx));
  808. for (int i = 0; i < fNBins; i++)
  809. {
  810. for (int iCent = 0; iCent < fNCent; iCent++)
  811. {
  812. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  813. if (binCont == 0.)
  814. continue;
  815. p_BBC_Sin_West_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  816. }
  817. }
  818. delete prof;
  819. }
  820. }
  821. }
  822. //Manage recentering ZDC
  823. std::map<Double_t, Double_t> p_ZDC_Qx_Full_EP[fNharmonics][fArraySize][fNCent];
  824. std::map<Double_t, Double_t> p_ZDC_Qy_Full_EP[fNharmonics][fArraySize][fNCent];
  825. std::map<Double_t, Double_t> p_ZDC_Qx_East_EP[fNharmonics][fArraySize][fNCent];
  826. std::map<Double_t, Double_t> p_ZDC_Qy_East_EP[fNharmonics][fArraySize][fNCent];
  827. std::map<Double_t, Double_t> p_ZDC_Qx_West_EP[fNharmonics][fArraySize][fNCent];
  828. std::map<Double_t, Double_t> p_ZDC_Qy_West_EP[fNharmonics][fArraySize][fNCent];
  829. TFile *fiReCentZDC = new TFile(reCentFileZDC, "read");
  830. std::cout << "Reading file for ZDC recentering..." << std::endl;
  831. for (int iHarm = 0; iHarm < fNharmonics; iHarm++)
  832. {
  833. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  834. {
  835. std::cout << "iHarm: " << iHarm << " iVtx: " << iVtx << std::endl;
  836. prof = (TProfile2D *)fiReCentZDC->Get(Form("p_ZDC_Qx_Full_EP%i_vtx%i", iHarm, iVtx));
  837. for (int i = 0; i < fNBins; i++)
  838. {
  839. for (int iCent = 0; iCent < fNCent; iCent++)
  840. {
  841. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  842. if (binCont == 0.)
  843. continue;
  844. p_ZDC_Qx_Full_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  845. }
  846. }
  847. delete prof;
  848. prof = (TProfile2D *)fiReCentZDC->Get(Form("p_ZDC_Qy_Full_EP%i_vtx%i", iHarm, iVtx));
  849. for (int i = 0; i < fNBins; i++)
  850. {
  851. for (int iCent = 0; iCent < fNCent; iCent++)
  852. {
  853. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  854. if (binCont == 0.)
  855. continue;
  856. p_ZDC_Qy_Full_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  857. }
  858. }
  859. delete prof;
  860. prof = (TProfile2D *)fiReCentZDC->Get(Form("p_ZDC_Qx_East_EP%i_vtx%i", iHarm, iVtx));
  861. for (int i = 0; i < fNBins; i++)
  862. {
  863. for (int iCent = 0; iCent < fNCent; iCent++)
  864. {
  865. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  866. if (binCont == 0.)
  867. continue;
  868. p_ZDC_Qx_East_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  869. }
  870. }
  871. delete prof;
  872. prof = (TProfile2D *)fiReCentZDC->Get(Form("p_ZDC_Qy_East_EP%i_vtx%i", iHarm, iVtx));
  873. for (int i = 0; i < fNBins; i++)
  874. {
  875. for (int iCent = 0; iCent < fNCent; iCent++)
  876. {
  877. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  878. if (binCont == 0.)
  879. continue;
  880. p_ZDC_Qy_East_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  881. }
  882. }
  883. delete prof;
  884. prof = (TProfile2D *)fiReCentZDC->Get(Form("p_ZDC_Qx_West_EP%i_vtx%i", iHarm, iVtx));
  885. for (int i = 0; i < fNBins; i++)
  886. {
  887. for (int iCent = 0; iCent < fNCent; iCent++)
  888. {
  889. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  890. if (binCont == 0.)
  891. continue;
  892. p_ZDC_Qx_West_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  893. }
  894. }
  895. delete prof;
  896. prof = (TProfile2D *)fiReCentZDC->Get(Form("p_ZDC_Qy_West_EP%i_vtx%i", iHarm, iVtx));
  897. for (int i = 0; i < fNBins; i++)
  898. {
  899. for (int iCent = 0; iCent < fNCent; iCent++)
  900. {
  901. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  902. if (binCont == 0.)
  903. continue;
  904. p_ZDC_Qy_West_EP[iHarm][iVtx][iCent][(Double_t)(runId_min + i)] = binCont;
  905. }
  906. }
  907. delete prof;
  908. }
  909. }
  910. //Manage ShiftCorr ZDC
  911. std::map<Double_t, Double_t> p_ZDC_Cos_Full_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  912. std::map<Double_t, Double_t> p_ZDC_Sin_Full_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  913. std::map<Double_t, Double_t> p_ZDC_Cos_East_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  914. std::map<Double_t, Double_t> p_ZDC_Sin_East_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  915. std::map<Double_t, Double_t> p_ZDC_Cos_West_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  916. std::map<Double_t, Double_t> p_ZDC_Sin_West_EP[fNharmonics + 1][fArraySize][NShiftOrderMax * 3][fNCent];
  917. TFile *fiShiftZDC = new TFile(shiftFileZDC, "read");
  918. fiShiftZDC->cd();
  919. std::cout << "Reading file for ZDC shift corrections..." << std::endl;
  920. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  921. {
  922. for (int iVtx = 0; iVtx < fArraySize; iVtx++)
  923. {
  924. for (int iShift = 0; iShift < NShiftOrderMax * 3; iShift++)
  925. {
  926. std::cout << "iHarm: " << iHarm << " iVtx: " << iVtx << " iShiftOrder: " << iShift << std::endl;
  927. prof = (TProfile2D *)fiShiftZDC->Get(Form("p_ZDC_Cos%i_Full_EP%i_vtx%i", iShift, iHarm, iVtx));
  928. for (int i = 0; i < fNBins; i++)
  929. {
  930. for (int iCent = 0; iCent < fNCent; iCent++)
  931. {
  932. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  933. if (binCont == 0.)
  934. continue;
  935. p_ZDC_Cos_Full_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  936. }
  937. }
  938. delete prof;
  939. prof = (TProfile2D *)fiShiftZDC->Get(Form("p_ZDC_Sin%i_Full_EP%i_vtx%i", iShift, iHarm, iVtx));
  940. for (int i = 0; i < fNBins; i++)
  941. {
  942. for (int iCent = 0; iCent < fNCent; iCent++)
  943. {
  944. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  945. if (binCont == 0.)
  946. continue;
  947. p_ZDC_Sin_Full_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  948. }
  949. }
  950. delete prof;
  951. prof = (TProfile2D *)fiShiftZDC->Get(Form("p_ZDC_Cos%i_East_EP%i_vtx%i", iShift, iHarm, iVtx));
  952. for (int i = 0; i < fNBins; i++)
  953. {
  954. for (int iCent = 0; iCent < fNCent; iCent++)
  955. {
  956. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  957. if (binCont == 0.)
  958. continue;
  959. p_ZDC_Cos_East_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  960. }
  961. }
  962. delete prof;
  963. prof = (TProfile2D *)fiShiftZDC->Get(Form("p_ZDC_Sin%i_East_EP%i_vtx%i", iShift, iHarm, iVtx));
  964. for (int i = 0; i < fNBins; i++)
  965. {
  966. for (int iCent = 0; iCent < fNCent; iCent++)
  967. {
  968. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  969. if (binCont == 0.)
  970. continue;
  971. p_ZDC_Sin_East_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  972. }
  973. }
  974. delete prof;
  975. prof = (TProfile2D *)fiShiftZDC->Get(Form("p_ZDC_Cos%i_West_EP%i_vtx%i", iShift, iHarm, iVtx));
  976. for (int i = 0; i < fNBins; i++)
  977. {
  978. for (int iCent = 0; iCent < fNCent; iCent++)
  979. {
  980. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  981. if (binCont == 0.)
  982. continue;
  983. p_ZDC_Cos_West_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  984. }
  985. }
  986. delete prof;
  987. prof = (TProfile2D *)fiShiftZDC->Get(Form("p_ZDC_Sin%i_West_EP%i_vtx%i", iShift, iHarm, iVtx));
  988. for (int i = 0; i < fNBins; i++)
  989. {
  990. for (int iCent = 0; iCent < fNCent; iCent++)
  991. {
  992. binCont = prof->GetBinContent(prof->FindBin((Double_t)(runId_min + i), (Double_t)iCent));
  993. if (binCont == 0.)
  994. continue;
  995. p_ZDC_Sin_West_EP[iHarm][iVtx][iShift][iCent][(Double_t)(runId_min + i)] = binCont;
  996. }
  997. }
  998. delete prof;
  999. }
  1000. }
  1001. }
  1002. //Manage output TProfiles
  1003. //TProfile *p_v2_EP[9][NEtaGaps];
  1004. //TProfile *p_v3_EP[9][NEtaGaps];
  1005. //TProfile *p_v2cent_EP[NEtaGaps];
  1006. //TProfile *p_v3cent_EP[NEtaGaps];
  1007. TProfile2D *p_v2cent_EP_ptgaps[NEtaGaps];
  1008. TProfile2D *p_v3cent_EP_ptgaps[NEtaGaps];
  1009. TProfile2D *p_v2cent_SP_ptgaps[NEtaGaps];
  1010. TProfile2D *p_v3cent_SP_ptgaps[NEtaGaps];
  1011. TProfile2D *p_v2WEST_EP_ptgaps[NEtaGaps];
  1012. TProfile2D *p_v3WEST_EP_ptgaps[NEtaGaps];
  1013. TProfile2D *p_v2EAST_EP_ptgaps[NEtaGaps];
  1014. TProfile2D *p_v3EAST_EP_ptgaps[NEtaGaps];
  1015. TProfile2D *p_vnBBC[fNharmonics + 1];
  1016. // TProfile2D *p_vnZDC[fNharmonics+1];
  1017. // TProfile2D *p_vnBBCEast[fNharmonics+1];
  1018. // TProfile2D *p_vnBBCWest[fNharmonics+1];
  1019. TProfile2D *p_v2run_EP[NEtaGaps][16]; // runId vs pt
  1020. TProfile2D *p_v3run_EP[NEtaGaps][16]; // runId vs pt
  1021. TProfile2D *p_v2run_SP[NEtaGaps][16]; // runId vs pt
  1022. TProfile2D *p_v3run_SP[NEtaGaps][16]; // runId vs pt
  1023. TProfile2D *p_v2run_BBC[16]; // runId vs pt
  1024. TProfile2D *p_v2run_ZDC[16]; // runId vs pt
  1025. TProfile2D *p_v2run_ZDC_East[16]; // runId vs pt
  1026. TProfile2D *p_v2run_ZDC_West[16]; // runId vs pt
  1027. //TH2D *p_ptrun[16]; // to calculate <pT> for each pT bin
  1028. //TH2D *p1_ptrun[16]; // to calculate <pT> for each pT bin
  1029. /*TProfile2D *p_v2cent_EP_3subTPC;
  1030. TProfile2D *p_v2cent_EP_3subBBCEast;
  1031. TProfile2D *p_v2cent_EP_3subBBCWest;
  1032. TProfile2D *p_v2_VtxZsys[NEtaGaps];
  1033. TProfile2D *p_v2_DCAsys[NEtaGaps];
  1034. TProfile2D *p_v2_Nhitsys[NEtaGaps];
  1035. TProfile2D *p_v3_VtxZsys[NEtaGaps];
  1036. TProfile2D *p_v3_DCAsys[NEtaGaps];
  1037. TProfile2D *p_v3_Nhitsys[NEtaGaps];*/
  1038. // <vn> vs RunId & centrality - for RunQA
  1039. // In this case, standard EP from 2-sub(TPC) method is used
  1040. // TProfile2D *p_v2_vs_run;
  1041. // TProfile2D *p_v3_vs_run;
  1042. // p_v2cent_EP_3subTPC = new TProfile2D(Form("p_v2cent_EP_3subTPC"),Form("p_v2cent_EP_3subTPC"),16,-0.5,15.5,50,0.15,5.15);
  1043. // p_v2cent_EP_3subBBCEast = new TProfile2D(Form("p_v2cent_EP_3subBBCEast"),Form("p_v2cent_EP_3subBBCEast"),16,-0.5,15.5,50,0.15,5.15);
  1044. // p_v2cent_EP_3subBBCWest = new TProfile2D(Form("p_v2cent_EP_3subBBCWest"),Form("p_v2cent_EP_3subBBCWest"),16,-0.5,15.5,50,0.15,5.15);
  1045. // p_v2_vs_run = new TProfile2D(Form("p_v2_vs_run"),Form("p_v2_vs_run"),fNBins, runId_min - 0.5, runId_max + 0.5, 16, -0.5, 15.5);
  1046. // p_v3_vs_run = new TProfile2D(Form("p_v3_vs_run"),Form("p_v3_vs_run"),fNBins, runId_min - 0.5, runId_max + 0.5, 16, -0.5, 15.5);
  1047. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  1048. {
  1049. for (int iCent = 0; iCent < 16; iCent++)
  1050. {
  1051. p_v2run_EP[iGap][iCent] = new TProfile2D(Form("p_v2_run_EP_gap%i_cent%i", iGap, iCent), Form("p_v2_run_EP_gap%i_cent%i", iGap, iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1052. p_v3run_EP[iGap][iCent] = new TProfile2D(Form("p_v3_run_EP_gap%i_cent%i", iGap, iCent), Form("p_v3_run_EP_gap%i_cent%i", iGap, iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1053. p_v2run_SP[iGap][iCent] = new TProfile2D(Form("p_v2_run_SP_gap%i_cent%i", iGap, iCent), Form("p_v2_run_SP_gap%i_cent%i", iGap, iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1054. p_v3run_SP[iGap][iCent] = new TProfile2D(Form("p_v3_run_SP_gap%i_cent%i", iGap, iCent), Form("p_v3_run_SP_gap%i_cent%i", iGap, iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1055. if (iGap == 0)
  1056. {
  1057. p_v2run_BBC[iCent] = new TProfile2D(Form("p_v2_run_BBC_cent%i", iCent), Form("p_v2_run_BBC_cent%i", iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1058. p_v2run_ZDC[iCent] = new TProfile2D(Form("p_v2_run_ZDC_cent%i", iCent), Form("p_v2_run_ZDC_cent%i", iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1059. p_v2run_ZDC_East[iCent] = new TProfile2D(Form("p_v2_run_ZDC_East_cent%i", iCent), Form("p_v2_run_ZDC_East_cent%i", iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1060. p_v2run_ZDC_West[iCent] = new TProfile2D(Form("p_v2_run_ZDC_West_cent%i", iCent), Form("p_v2_run_ZDC_West_cent%i", iCent), fNBins, runId_min - 0.5, runId_max + 0.5, 50, 0.15, 5.15);
  1061. }
  1062. }
  1063. }
  1064. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  1065. {
  1066. p_v2cent_EP_ptgaps[iGap] = new TProfile2D(Form("p_v2cent_EP_gap%i_ptgaps", iGap), Form("p_v2cent_EP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1067. p_v3cent_EP_ptgaps[iGap] = new TProfile2D(Form("p_v3cent_EP_gap%i_ptgaps", iGap), Form("p_v3cent_EP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1068. p_v2cent_SP_ptgaps[iGap] = new TProfile2D(Form("p_v2cent_SP_gap%i_ptgaps", iGap), Form("p_v2cent_SP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1069. p_v3cent_SP_ptgaps[iGap] = new TProfile2D(Form("p_v3cent_SP_gap%i_ptgaps", iGap), Form("p_v3cent_SP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1070. p_v2WEST_EP_ptgaps[iGap] = new TProfile2D(Form("p_v2WEST_EP_gap%i_ptgaps", iGap), Form("p_v2WEST_EP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1071. p_v2EAST_EP_ptgaps[iGap] = new TProfile2D(Form("p_v2EAST_EP_gap%i_ptgaps", iGap), Form("p_v2EAST_EP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1072. p_v3WEST_EP_ptgaps[iGap] = new TProfile2D(Form("p_v3WEST_EP_gap%i_ptgaps", iGap), Form("p_v3WEST_EP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1073. p_v3EAST_EP_ptgaps[iGap] = new TProfile2D(Form("p_v3EAST_EP_gap%i_ptgaps", iGap), Form("p_v3EAST_EP_gap%i_ptgaps", iGap), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1074. /*p_v2_VtxZsys[iGap] = new TProfile2D(Form("p_v2_VtxZsys%i",iGap),Form("p_v2_VtxZsys%i",iGap),16,-0.5,15.5,50,0.15,5.15);
  1075. p_v2_DCAsys[iGap] = new TProfile2D(Form("p_v2_DCAsys%i",iGap),Form("p_v2_DCAsys%i",iGap),16,-0.5,15.5,50,0.15,5.15);
  1076. p_v2_Nhitsys[iGap] = new TProfile2D(Form("p_v2_Nhitsys%i",iGap),Form("p_v2_Nhitsys%i",iGap),16,-0.5,15.5,50,0.15,5.15);
  1077. p_v3_VtxZsys[iGap] = new TProfile2D(Form("p_v3_VtxZsys%i",iGap),Form("p_v3_VtxZsys%i",iGap),16,-0.5,15.5,50,0.15,5.15);
  1078. p_v3_DCAsys[iGap] = new TProfile2D(Form( "p_v3_DCAsys%i",iGap),Form( "p_v3_DCAsys%i",iGap),16,-0.5,15.5,50,0.15,5.15);
  1079. p_v3_Nhitsys[iGap] = new TProfile2D(Form("p_v3_Nhitsys%i",iGap),Form("p_v3_Nhitsys%i",iGap),16,-0.5,15.5,50,0.15,5.15);*/
  1080. }
  1081. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  1082. {
  1083. p_vnBBC[iHarm] = new TProfile2D(Form("p_vnBBC%i", iHarm), Form("p_vnBBC%i", iHarm), 16, -0.5, 15.5, 50, 0.15, 5.15);
  1084. // p_vnBBCEast[iHarm] = new TProfile2D(Form("p_vnBBCEast%i",iHarm),Form("p_vnBBCEast%i",iHarm),16,-0.5,15.5,50,0.15,5.15);
  1085. // p_vnBBCWest[iHarm] = new TProfile2D(Form("p_vnBBCWest%i",iHarm),Form("p_vnBBCWest%i",iHarm),16,-0.5,15.5,50,0.15,5.15);
  1086. }
  1087. //Counters
  1088. Int_t fUsedTracks = 0;
  1089. Int_t fQcountFull = 0;
  1090. Int_t fQcountFullEast = 0;
  1091. Int_t fQcountFullWest = 0;
  1092. Int_t fQcountWest[NEtaGaps];
  1093. Int_t fQcountEast[NEtaGaps];
  1094. //Q-vectors
  1095. TVector2 fQv2FullEP;
  1096. TVector2 fQv2FullEPCorr;
  1097. TVector2 fQv2FullSP;
  1098. TVector2 fQv3FullEP;
  1099. TVector2 fQv3FullSP;
  1100. TVector2 fQv2WestEP[NEtaGaps];
  1101. TVector2 fQv2EastEP[NEtaGaps];
  1102. TVector2 fQv2WestSP[NEtaGaps];
  1103. TVector2 fQv2EastSP[NEtaGaps];
  1104. TVector2 fQv3WestEP[NEtaGaps];
  1105. TVector2 fQv3EastEP[NEtaGaps];
  1106. TVector2 fQv3WestSP[NEtaGaps];
  1107. TVector2 fQv3EastSP[NEtaGaps];
  1108. TVector2 QvTMP;
  1109. TVector2 fQv2WestSP_Shift[NEtaGaps];
  1110. TVector2 fQv2EastSP_Shift[NEtaGaps];
  1111. TVector2 fQv3WestSP_Shift[NEtaGaps];
  1112. TVector2 fQv3EastSP_Shift[NEtaGaps];
  1113. TVector2 fUvSP;
  1114. Double_t weight;
  1115. Int_t VtxSign;
  1116. Double_t psiShiftedTMP;
  1117. Double_t PsiSin;
  1118. Double_t PsiCos;
  1119. Long64_t goodEventCounter = 0;
  1120. Double_t Psi2FullEP, Psi3FullEP;
  1121. Double_t Psi2EastEP[NEtaGaps], Psi3EastEP[NEtaGaps];
  1122. Double_t Psi2WestEP[NEtaGaps], Psi3WestEP[NEtaGaps];
  1123. Double_t Psi2EastSP[NEtaGaps], Psi3EastSP[NEtaGaps];
  1124. Double_t Psi2WestSP[NEtaGaps], Psi3WestSP[NEtaGaps];
  1125. Double_t Psi_ReCenter, dPsi;
  1126. Int_t bin;
  1127. Double_t res2EP, res3EP, res2EPsqr, res3EPsqr;
  1128. Double_t flow2EP;
  1129. Double_t flow3EP;
  1130. Double_t res2SP, res3SP, res2SPsqr, res3SPsqr;
  1131. Double_t flow2SP;
  1132. Double_t flow3SP;
  1133. Int_t shiftBin;
  1134. Double_t psiSP_rec;
  1135. Double_t psiEP_rec, psiEP_BBC_Full[fNharmonics + 1], shiftCos, shiftSin;
  1136. Double_t psiEP_BBC_East[fNharmonics + 1], psiEP_BBC_West[fNharmonics + 1];
  1137. // ZDC related EP determination
  1138. Double_t psiEP_ZDC_Full[fNharmonics + 1], psiEP_ZDC_East[fNharmonics + 1], psiEP_ZDC_West[fNharmonics + 1];
  1139. TVector2 qRecEastZDC[fNharmonics + 1], qRecWestZDC[fNharmonics + 1], qRecFullZDC[fNharmonics + 1];
  1140. Double_t qxEast, qyEast, adcxEast, adcyEast;
  1141. Double_t qxWest, qyWest, adcxWest, adcyWest;
  1142. Double_t qxFull, qyFull, adcxFull, adcyFull;
  1143. Double_t qxRecEast, qyRecEast;
  1144. Double_t qxRecWest, qyRecWest;
  1145. Double_t qxRecFull, qyRecFull;
  1146. Double_t resEastWestZDC[fNharmonics + 1];
  1147. // Loop over events
  1148. for (Long64_t iEvent = 0; iEvent < events2read; iEvent++)
  1149. {
  1150. if ((iEvent + 1) % 1000 == 0)
  1151. {
  1152. std::cout << "Working on event #[" << (iEvent + 1)
  1153. << "/" << events2read << "]" << std::endl;
  1154. }
  1155. Bool_t readEvent = femtoReader->readFemtoEvent(iEvent);
  1156. if (!readEvent)
  1157. {
  1158. std::cout << "Something went wrong, Master! Nothing to analyze..." << std::endl;
  1159. break;
  1160. }
  1161. // Retrieve femtoDst
  1162. StFemtoDst *dst = femtoReader->femtoDst();
  1163. // Retrieve event information
  1164. StFemtoEvent *event = dst->event();
  1165. if (!event)
  1166. {
  1167. std::cout << "Something went wrong, Master! Event is hiding from me..." << std::endl;
  1168. break;
  1169. }
  1170. // Event selection
  1171. if (!isGoodEvent(event))
  1172. continue;
  1173. goodEventCounter++;
  1174. TVector3 pVtx = event->primaryVertex();
  1175. // Track analysis
  1176. Int_t nTracks = dst->numberOfTracks();
  1177. //Counters
  1178. fUsedTracks = 0;
  1179. fQcountFull = 0;
  1180. fQcountFullEast = 0;
  1181. fQcountFullWest = 0;
  1182. psiShiftedTMP = 0.;
  1183. PsiSin = 0.;
  1184. PsiCos = 0.;
  1185. fQv2FullEP.Set(0., 0.);
  1186. fQv2FullSP.Set(0., 0.);
  1187. fQv3FullEP.Set(0., 0.);
  1188. fQv3FullSP.Set(0., 0.);
  1189. QvTMP.Set(0., 0.);
  1190. for (int i = 0; i < NEtaGaps; i++)
  1191. {
  1192. fQcountWest[i] = 0;
  1193. fQcountEast[i] = 0;
  1194. fQv2WestEP[i].Set(0., 0.);
  1195. fQv2EastEP[i].Set(0., 0.);
  1196. fQv2WestSP[i].Set(0., 0.);
  1197. fQv2EastSP[i].Set(0., 0.);
  1198. fQv3WestEP[i].Set(0., 0.);
  1199. fQv3EastEP[i].Set(0., 0.);
  1200. fQv3WestSP[i].Set(0., 0.);
  1201. fQv3EastSP[i].Set(0., 0.);
  1202. }
  1203. // Vertex sign
  1204. VtxSign = GetVzBin(pVtx.Z());
  1205. if (VtxSign == -1)
  1206. continue;
  1207. //BBC EP
  1208. Double_t adcNormEastInner = BBCgain_East[VtxSign]->Integral(BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), 1, 6) / 6.;
  1209. Double_t adcNormEastOuter = BBCgain_East[VtxSign]->Integral(BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), 7, 16) / 10.;
  1210. Double_t adcNormWestInner = BBCgain_West[VtxSign]->Integral(BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), 1, 6) / 6.;
  1211. Double_t adcNormWestOuter = BBCgain_West[VtxSign]->Integral(BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), BBCgain_East[VtxSign]->GetXaxis()->FindBin(event->runId()), 7, 16) / 10.;
  1212. float egain[16] = {
  1213. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 1)) / adcNormEastInner),
  1214. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 2)) / adcNormEastInner),
  1215. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 3)) / adcNormEastInner),
  1216. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 4)) / adcNormEastInner),
  1217. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 5)) / adcNormEastInner),
  1218. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 6)) / adcNormEastInner),
  1219. (float)((0.5) * BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 7)) / adcNormEastOuter),
  1220. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 8)) / adcNormEastOuter),
  1221. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 9)) / adcNormEastOuter),
  1222. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 10)) / adcNormEastOuter),
  1223. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 11)) / adcNormEastOuter),
  1224. (float)((0.5) * BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 12)) / adcNormEastOuter),
  1225. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 13)) / adcNormEastOuter),
  1226. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 14)) / adcNormEastOuter),
  1227. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 15)) / adcNormEastOuter),
  1228. (float)(BBCgain_East[VtxSign]->GetBinContent(BBCgain_East[VtxSign]->FindBin(event->runId(), 16)) / adcNormEastOuter)};
  1229. float wgain[16] = {
  1230. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 1)) / adcNormWestInner),
  1231. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 2)) / adcNormWestInner),
  1232. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 3)) / adcNormWestInner),
  1233. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 4)) / adcNormWestInner),
  1234. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 5)) / adcNormWestInner),
  1235. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 6)) / adcNormWestInner),
  1236. (float)((0.5) * BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 7)) / adcNormWestOuter),
  1237. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 8)) / adcNormWestOuter),
  1238. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 9)) / adcNormWestOuter),
  1239. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 10)) / adcNormWestOuter),
  1240. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 11)) / adcNormWestOuter),
  1241. (float)((0.5) * BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 12)) / adcNormWestOuter),
  1242. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 13)) / adcNormWestOuter),
  1243. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 14)) / adcNormWestOuter),
  1244. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 15)) / adcNormWestOuter),
  1245. (float)(BBCgain_West[VtxSign]->GetBinContent(BBCgain_West[VtxSign]->FindBin(event->runId(), 16)) / adcNormWestOuter)};
  1246. float nHitE_Gain[16], nHitW_Gain[16];
  1247. for (int i = 0; i < 16; i++)
  1248. {
  1249. nHitE_Gain[i] = event->bbcAdcEast(i) / egain[i];
  1250. nHitW_Gain[i] = event->bbcAdcWest(i) / wgain[i];
  1251. }
  1252. Double_t psiFull[fNharmonics + 1];
  1253. TVector2 qGainFull[fNharmonics + 1];
  1254. TVector2 qRecFull[fNharmonics + 1];
  1255. Double_t psiEast[fNharmonics + 1];
  1256. TVector2 qGainEast[fNharmonics + 1];
  1257. TVector2 qRecEast[fNharmonics + 1];
  1258. Double_t psiWest[fNharmonics + 1];
  1259. TVector2 qGainWest[fNharmonics + 1];
  1260. TVector2 qRecWest[fNharmonics + 1];
  1261. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  1262. {
  1263. //BBC Full
  1264. //v1*y > 0 by conventions most reasonable to the STAR event plane
  1265. //therefore the west event plane has the right sign for the event plane
  1266. //more simply (Psi_w = 0 => QWest . x_STAR > 0) and (Psi_e = 0 => QEast . x_STAR < 0)
  1267. //The east event plane points opposite that of the west and the west finds the "correct" EP for the STAR coordinates, use West-East
  1268. Double_t QVector_GainX = 0., QVector_GainY = 0.;
  1269. Double_t EventPlaneGainFull = 0.;
  1270. Float_t eXFsum_Gain = 0., wXFsum_Gain = 0., eYFsum_Gain = 0., wYFsum_Gain = 0., eWFgt_Gain = 0., wWFgt_Gain = 0.;
  1271. TVector2 QFullGain;
  1272. for (int iTile = 0; iTile < 16; iTile++)
  1273. {
  1274. eXFsum_Gain += cos((iHarm + 1.) * BBC_GetPhi(0, iTile)) * nHitE_Gain[iTile];
  1275. wXFsum_Gain += cos((iHarm + 1.) * BBC_GetPhi(1, iTile)) * nHitW_Gain[iTile];
  1276. eYFsum_Gain += sin((iHarm + 1.) * BBC_GetPhi(0, iTile)) * nHitE_Gain[iTile];
  1277. wYFsum_Gain += sin((iHarm + 1.) * BBC_GetPhi(1, iTile)) * nHitW_Gain[iTile];
  1278. eWFgt_Gain += nHitE_Gain[iTile];
  1279. wWFgt_Gain += nHitW_Gain[iTile];
  1280. }
  1281. QVector_GainX = (eWFgt_Gain > 0. && wWFgt_Gain > 0.) ? wXFsum_Gain / wWFgt_Gain + eXFsum_Gain / eWFgt_Gain : 0.;
  1282. QVector_GainY = (eWFgt_Gain > 0. && wWFgt_Gain > 0.) ? wYFsum_Gain / wWFgt_Gain + eYFsum_Gain / eWFgt_Gain : 0.;
  1283. QFullGain.Set(QVector_GainX, QVector_GainY);
  1284. if (QFullGain.Mod())
  1285. {
  1286. EventPlaneGainFull = QFullGain.Phi();
  1287. if (EventPlaneGainFull < 0.0)
  1288. {
  1289. EventPlaneGainFull += 2. * TMath::Pi() / (iHarm + 1.);
  1290. }
  1291. }
  1292. psiFull[iHarm] = EventPlaneGainFull;
  1293. qGainFull[iHarm] = QFullGain;
  1294. //BBC West
  1295. //v1*y > 0 by conventions most reasonable to the STAR event plane
  1296. //therefore the west event plane has the right sign for the event plane
  1297. //more simply (Psi_w = 0 => QWest . x_STAR > 0) and (Psi_e = 0 => QEast . x_STAR < 0)
  1298. Double_t QVectorW_GainX = 0., QVectorW_GainY = 0.;
  1299. Double_t EventPlaneGainWest = 0.;
  1300. Float_t wXsum_Gain = 0., wYsum_Gain = 0., wWgt_Gain = 0.;
  1301. TVector2 QWestGain;
  1302. for (int iTile = 0; iTile < 16; iTile++)
  1303. {
  1304. wXsum_Gain += cos((iHarm + 1.) * BBC_GetPhi(1, iTile)) * nHitW_Gain[iTile];
  1305. wYsum_Gain += sin((iHarm + 1.) * BBC_GetPhi(1, iTile)) * nHitW_Gain[iTile];
  1306. wWgt_Gain += nHitW_Gain[iTile];
  1307. }
  1308. QVectorW_GainX = (wWgt_Gain > 0.0) ? wXsum_Gain / wWgt_Gain : 0.0;
  1309. QVectorW_GainY = (wWgt_Gain > 0.0) ? wYsum_Gain / wWgt_Gain : 0.0;
  1310. QWestGain.Set(QVectorW_GainX, QVectorW_GainY);
  1311. if (QWestGain.Mod())
  1312. {
  1313. EventPlaneGainWest = QWestGain.Phi();
  1314. if (EventPlaneGainWest < 0.0)
  1315. {
  1316. EventPlaneGainWest += 2. * TMath::Pi() / (iHarm + 1.);
  1317. }
  1318. }
  1319. psiWest[iHarm] = EventPlaneGainWest;
  1320. qGainWest[iHarm] = QWestGain;
  1321. //BBC East
  1322. //in BBC_GetPhi the fact that the tile numbering scheme is reversed about the y axis for the east BBC is accounted for
  1323. //The east event plane points opposite that of the west since the spectators are on different sides -- see west comments
  1324. Double_t QVectorE_GainX = 0., QVectorE_GainY = 0.;
  1325. Double_t EventPlaneGainEast = 0.;
  1326. Float_t eXsum_Gain = 0., eYsum_Gain = 0., eWgt_Gain = 0.;
  1327. TVector2 QEastGain;
  1328. for (int iTile = 0; iTile < 16; iTile++)
  1329. {
  1330. eXsum_Gain += cos((iHarm + 1.) * BBC_GetPhi(0, iTile)) * nHitE_Gain[iTile];
  1331. eYsum_Gain += sin((iHarm + 1.) * BBC_GetPhi(0, iTile)) * nHitE_Gain[iTile];
  1332. eWgt_Gain += nHitE_Gain[iTile];
  1333. }
  1334. QVectorE_GainX = (eWgt_Gain > 0.0) ? eXsum_Gain / eWgt_Gain : 0.0;
  1335. QVectorE_GainY = (eWgt_Gain > 0.0) ? eYsum_Gain / eWgt_Gain : 0.0;
  1336. QEastGain.Set(QVectorE_GainX, QVectorE_GainY);
  1337. if (QEastGain.Mod())
  1338. {
  1339. EventPlaneGainEast = QEastGain.Phi();
  1340. if (EventPlaneGainEast < 0.0)
  1341. {
  1342. EventPlaneGainEast += 2. * TMath::Pi() / (iHarm + 1.);
  1343. }
  1344. }
  1345. psiEast[iHarm] = EventPlaneGainEast;
  1346. qGainEast[iHarm] = QEastGain;
  1347. }
  1348. // Apply recentering
  1349. for (int iHarm = 0; iHarm < fNharmonics; iHarm++)
  1350. {
  1351. TVector2 recFullTMP((Double_t)p_BBC_Qx_Full_EP[iHarm][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()],
  1352. (Double_t)p_BBC_Qy_Full_EP[iHarm][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1353. TVector2 recEastTMP((Double_t)p_BBC_Qx_East_EP[iHarm][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()],
  1354. (Double_t)p_BBC_Qy_East_EP[iHarm][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1355. TVector2 recWestTMP((Double_t)p_BBC_Qx_West_EP[iHarm][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()],
  1356. (Double_t)p_BBC_Qy_West_EP[iHarm][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1357. qRecEast[iHarm] = qGainEast[iHarm] - recEastTMP;
  1358. qRecWest[iHarm] = qGainWest[iHarm] - recWestTMP;
  1359. qRecFull[iHarm] = qGainFull[iHarm] - recFullTMP;
  1360. }
  1361. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  1362. {
  1363. // Full BBC
  1364. if (qRecFull[iHarm].Mod())
  1365. {
  1366. psiEP_rec = qRecFull[iHarm].Phi() / (iHarm + 1.);
  1367. if (psiEP_rec < 0.)
  1368. {
  1369. psiEP_rec += 2 * TMath::Pi() / (iHarm + 1.);
  1370. }
  1371. }
  1372. dPsi = 0.;
  1373. for (int iK = 0; iK < NShiftOrderMax * 3; iK++)
  1374. {
  1375. shiftCos = p_BBC_Cos_Full_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1376. shiftSin = p_BBC_Sin_Full_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1377. dPsi += (1. / (iHarm + 1.)) * (2. / (iK + 1.)) *
  1378. (-1. * shiftSin * cos((iHarm + 1.) * (iK + 1.) * psiEP_rec) +
  1379. 1. * shiftCos * sin((iHarm + 1.) * (iK + 1.) * psiEP_rec));
  1380. }
  1381. psiEP_BBC_Full[iHarm] = psiEP_rec + dPsi;
  1382. if (psiEP_BBC_Full[iHarm] < 0.0)
  1383. psiEP_BBC_Full[iHarm] += 2. * TMath::Pi() / (iHarm + 1.);
  1384. if (psiEP_BBC_Full[iHarm] > 2. * TMath::Pi() / (iHarm + 1.))
  1385. psiEP_BBC_Full[iHarm] -= 2. * TMath::Pi() / (iHarm + 1.);
  1386. // East BBC
  1387. if (qRecEast[iHarm].Mod())
  1388. {
  1389. psiEP_rec = qRecEast[iHarm].Phi() / (iHarm + 1.);
  1390. if (psiEP_rec < 0.)
  1391. {
  1392. psiEP_rec += 2 * TMath::Pi() / (iHarm + 1.);
  1393. }
  1394. }
  1395. dPsi = 0.;
  1396. for (int iK = 0; iK < NShiftOrderMax * 3; iK++)
  1397. {
  1398. shiftCos = p_BBC_Cos_East_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1399. shiftSin = p_BBC_Sin_East_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1400. dPsi += (1. / (iHarm + 1.)) * (2. / (iK + 1.)) *
  1401. (-1. * shiftSin * cos((iHarm + 1.) * (iK + 1.) * psiEP_rec) +
  1402. 1. * shiftCos * sin((iHarm + 1.) * (iK + 1.) * psiEP_rec));
  1403. }
  1404. psiEP_BBC_East[iHarm] = psiEP_rec + dPsi;
  1405. if (psiEP_BBC_East[iHarm] < 0.0)
  1406. psiEP_BBC_East[iHarm] += 2. * TMath::Pi() / (iHarm + 1.);
  1407. if (psiEP_BBC_East[iHarm] > 2. * TMath::Pi() / (iHarm + 1.))
  1408. psiEP_BBC_East[iHarm] -= 2. * TMath::Pi() / (iHarm + 1.);
  1409. // West BBC
  1410. if (qRecWest[iHarm].Mod())
  1411. {
  1412. psiEP_rec = qRecWest[iHarm].Phi() / (iHarm + 1.);
  1413. if (psiEP_rec < 0.)
  1414. {
  1415. psiEP_rec += 2 * TMath::Pi() / (iHarm + 1.);
  1416. }
  1417. }
  1418. dPsi = 0.;
  1419. for (int iK = 0; iK < NShiftOrderMax * 3; iK++)
  1420. {
  1421. shiftCos = p_BBC_Cos_West_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1422. shiftSin = p_BBC_Sin_West_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1423. dPsi += (1. / (iHarm + 1.)) * (2. / (iK + 1.)) *
  1424. (-1. * shiftSin * cos((iHarm + 1.) * (iK + 1.) * psiEP_rec) +
  1425. 1. * shiftCos * sin((iHarm + 1.) * (iK + 1.) * psiEP_rec));
  1426. }
  1427. psiEP_BBC_West[iHarm] = psiEP_rec + dPsi;
  1428. if (psiEP_BBC_West[iHarm] < 0.0)
  1429. psiEP_BBC_West[iHarm] += 2. * TMath::Pi() / (iHarm + 1.);
  1430. if (psiEP_BBC_West[iHarm] > 2. * TMath::Pi() / (iHarm + 1.))
  1431. psiEP_BBC_West[iHarm] -= 2. * TMath::Pi() / (iHarm + 1.);
  1432. }
  1433. //EP from BBC is ready: psiEP_BBC_Full[iHarm], where iHarm = 0 for 1st harmonics, 1 for 2nd & 2 for 3rd.
  1434. // ZDC EP
  1435. if (event->zdcSumAdcEast() < 1.)
  1436. continue;
  1437. if (event->zdcSumAdcWest() < 1.)
  1438. continue;
  1439. qxEast = 0.;
  1440. qyEast = 0.;
  1441. adcxEast = 0.;
  1442. adcyEast = 0.;
  1443. qxWest = 0.;
  1444. qyWest = 0.;
  1445. adcxWest = 0.;
  1446. adcyWest = 0.;
  1447. qxFull = 0.;
  1448. qyFull = 0.;
  1449. adcxFull = 0.;
  1450. adcyFull = 0.;
  1451. // Vertical ZDC-SMD
  1452. for (int iStrip = 0; iStrip < fNZdcSmdStripsVertical; iStrip++)
  1453. {
  1454. qxEast += event->zdcSmdEastVertical(iStrip) * GetZDCPosition(0, 0, iStrip);
  1455. adcxEast += event->zdcSmdEastVertical(iStrip);
  1456. qxWest += event->zdcSmdWestVertical(iStrip) * GetZDCPosition(1, 0, iStrip);
  1457. adcxWest += event->zdcSmdWestVertical(iStrip);
  1458. }
  1459. // Horizontal ZDC-SMD
  1460. for (int iStrip = 0; iStrip < fNZdcSmdStripsHorizontal; iStrip++)
  1461. {
  1462. qyEast += event->zdcSmdEastHorizontal(iStrip) * GetZDCPosition(0, 1, iStrip);
  1463. adcyEast += event->zdcSmdEastHorizontal(iStrip);
  1464. qyWest += event->zdcSmdWestHorizontal(iStrip) * GetZDCPosition(1, 1, iStrip);
  1465. adcyWest += event->zdcSmdWestHorizontal(iStrip);
  1466. }
  1467. if (adcxEast > 0)
  1468. qxEast /= adcxEast;
  1469. else
  1470. qxEast = -999.;
  1471. if (adcyEast > 0)
  1472. qyEast /= adcyEast;
  1473. else
  1474. qyEast = -999.;
  1475. if (adcxWest > 0)
  1476. qxWest /= adcxWest;
  1477. else
  1478. qxWest = -999.;
  1479. if (adcyWest > 0)
  1480. qyWest /= adcyWest;
  1481. else
  1482. qyWest = -999.;
  1483. // Full ZDC-SMD Q-vector
  1484. if (qxEast == -999. || qxWest == -999.)
  1485. qxFull = -999.;
  1486. else
  1487. qxFull = qxEast - qxWest;
  1488. if (qyEast == -999. || qyWest == -999.)
  1489. qyFull = -999.;
  1490. else
  1491. qyFull = qyEast - qyWest;
  1492. if (qxEast != -999.)
  1493. qxRecEast = qxEast - (Double_t)p_ZDC_Qx_East_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()];
  1494. if (qyEast != -999.)
  1495. qyRecEast = qyEast - (Double_t)p_ZDC_Qy_East_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()];
  1496. if (qxWest != -999.)
  1497. qxRecWest = qxWest - (Double_t)p_ZDC_Qx_West_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()];
  1498. if (qyWest != -999.)
  1499. qyRecWest = qyWest - (Double_t)p_ZDC_Qy_West_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()];
  1500. if (qxFull != -999.)
  1501. qxRecFull = qxFull - (Double_t)p_ZDC_Qx_Full_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()];
  1502. if (qyFull != -999.)
  1503. qyRecFull = qyFull - (Double_t)p_ZDC_Qy_Full_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()];
  1504. if (qxEast == -999.)
  1505. qxRecEast = qxEast;
  1506. if (qyEast == -999.)
  1507. qyRecEast = qyEast;
  1508. if (qxWest == -999.)
  1509. qxRecWest = qxWest;
  1510. if (qyWest == -999.)
  1511. qyRecWest = qyWest;
  1512. if (qxFull == -999.)
  1513. qxRecFull = qxFull;
  1514. if (qyFull == -999.)
  1515. qyRecFull = qyFull;
  1516. PsiSin = 0.;
  1517. PsiCos = 0.;
  1518. psiShiftedTMP = 0.;
  1519. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  1520. {
  1521. qRecEastZDC[iHarm].Set(qxRecEast, qyRecEast);
  1522. qRecWestZDC[iHarm].Set(qxRecWest, qyRecWest);
  1523. qRecFullZDC[iHarm].Set(qxRecFull, qyRecFull);
  1524. // Full ZDC
  1525. if (qRecFullZDC[iHarm].Mod())
  1526. {
  1527. psiEP_rec = qRecFullZDC[iHarm].Phi() / (iHarm + 1.);
  1528. if (psiEP_rec < 0.)
  1529. {
  1530. psiEP_rec += 2 * TMath::Pi() / (iHarm + 1.);
  1531. }
  1532. }
  1533. dPsi = 0.;
  1534. for (int iK = 0; iK < NShiftOrderMax * 3; iK++)
  1535. {
  1536. shiftCos = p_ZDC_Cos_Full_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1537. shiftSin = p_ZDC_Sin_Full_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1538. dPsi += (1. / (iHarm + 1.)) * (2. / (iK + 1.)) *
  1539. (-1. * shiftSin * cos((iHarm + 1.) * (iK + 1.) * psiEP_rec) +
  1540. 1. * shiftCos * sin((iHarm + 1.) * (iK + 1.) * psiEP_rec));
  1541. }
  1542. psiEP_ZDC_Full[iHarm] = psiEP_rec + dPsi;
  1543. if (psiEP_ZDC_Full[iHarm] < 0.0)
  1544. psiEP_ZDC_Full[iHarm] += 2. * TMath::Pi() / (iHarm + 1.);
  1545. if (psiEP_ZDC_Full[iHarm] > 2. * TMath::Pi() / (iHarm + 1.))
  1546. psiEP_ZDC_Full[iHarm] -= 2. * TMath::Pi() / (iHarm + 1.);
  1547. // East ZDC
  1548. if (qRecEastZDC[iHarm].Mod())
  1549. {
  1550. psiEP_rec = qRecEastZDC[iHarm].Phi() / (iHarm + 1.);
  1551. if (psiEP_rec < 0.)
  1552. {
  1553. psiEP_rec += 2 * TMath::Pi() / (iHarm + 1.);
  1554. }
  1555. }
  1556. dPsi = 0.;
  1557. for (int iK = 0; iK < NShiftOrderMax * 3; iK++)
  1558. {
  1559. shiftCos = p_ZDC_Cos_East_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1560. shiftSin = p_ZDC_Sin_East_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1561. dPsi += (1. / (iHarm + 1.)) * (2. / (iK + 1.)) *
  1562. (-1. * shiftSin * cos((iHarm + 1.) * (iK + 1.) * psiEP_rec) +
  1563. 1. * shiftCos * sin((iHarm + 1.) * (iK + 1.) * psiEP_rec));
  1564. }
  1565. psiEP_ZDC_East[iHarm] = psiEP_rec + dPsi;
  1566. if (psiEP_ZDC_East[iHarm] < 0.0)
  1567. psiEP_ZDC_East[iHarm] += 2. * TMath::Pi() / (iHarm + 1.);
  1568. if (psiEP_ZDC_East[iHarm] > 2. * TMath::Pi() / (iHarm + 1.))
  1569. psiEP_ZDC_East[iHarm] -= 2. * TMath::Pi() / (iHarm + 1.);
  1570. // West ZDC
  1571. if (qRecWestZDC[iHarm].Mod())
  1572. {
  1573. psiEP_rec = qRecWestZDC[iHarm].Phi() / (iHarm + 1.);
  1574. if (psiEP_rec < 0.)
  1575. {
  1576. psiEP_rec += 2 * TMath::Pi() / (iHarm + 1.);
  1577. }
  1578. }
  1579. dPsi = 0.;
  1580. for (int iK = 0; iK < NShiftOrderMax * 3; iK++)
  1581. {
  1582. shiftCos = p_ZDC_Cos_West_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1583. shiftSin = p_ZDC_Sin_West_EP[iHarm][VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1584. dPsi += (1. / (iHarm + 1.)) * (2. / (iK + 1.)) *
  1585. (-1. * shiftSin * cos((iHarm + 1.) * (iK + 1.) * psiEP_rec) +
  1586. 1. * shiftCos * sin((iHarm + 1.) * (iK + 1.) * psiEP_rec));
  1587. }
  1588. psiEP_ZDC_West[iHarm] = psiEP_rec + dPsi;
  1589. if (psiEP_ZDC_West[iHarm] < 0.0)
  1590. psiEP_ZDC_West[iHarm] += 2. * TMath::Pi() / (iHarm + 1.);
  1591. if (psiEP_ZDC_West[iHarm] > 2. * TMath::Pi() / (iHarm + 1.))
  1592. psiEP_ZDC_West[iHarm] -= 2. * TMath::Pi() / (iHarm + 1.);
  1593. }
  1594. // Track loop
  1595. for (Int_t iTrk = 0; iTrk < nTracks; iTrk++)
  1596. {
  1597. // Retrieve i-th femto track
  1598. StFemtoTrack *femtoTrack = dst->track(iTrk);
  1599. if (!femtoTrack)
  1600. continue;
  1601. // Must be a primary track
  1602. if (!femtoTrack->isPrimary())
  1603. continue;
  1604. //Track selection
  1605. if (!isGoodTrack(femtoTrack, energy, pVtx))
  1606. continue;
  1607. fUsedTracks++;
  1608. //Fill recentered Q-vectors for all TPC (FULL)
  1609. weight = GetWeight(femtoTrack);
  1610. QvTMP.SetX(p_Qx_FULL_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1611. QvTMP.SetY(p_Qx_FULL_EP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1612. fQv2FullEP += weight * (CalcQvector(femtoTrack, 2) - QvTMP);
  1613. QvTMP.Set(0., 0.);
  1614. QvTMP.SetX(p_Qx_FULL_EP[1][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1615. QvTMP.SetY(p_Qy_FULL_EP[1][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1616. fQv3FullEP += weight * (CalcQvector(femtoTrack, 3) - QvTMP);
  1617. QvTMP.Set(0., 0.);
  1618. QvTMP.SetX(p_Qx_FULL_SP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1619. QvTMP.SetY(p_Qy_FULL_SP[0][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1620. fQv2FullSP += 1. * (CalcQvector(femtoTrack, 2) - QvTMP);
  1621. QvTMP.Set(0., 0.);
  1622. QvTMP.SetX(p_Qx_FULL_SP[1][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1623. QvTMP.SetY(p_Qy_FULL_SP[1][VtxSign][(Int_t)event->cent16()][(Double_t)event->runId()]);
  1624. fQv3FullSP += 1. * (CalcQvector(femtoTrack, 3) - QvTMP);
  1625. QvTMP.Set(0., 0.);
  1626. fQcountFull++;
  1627. if (femtoTrack->eta() >= 0.)
  1628. {
  1629. fQcountFullWest++;
  1630. }
  1631. else
  1632. {
  1633. fQcountFullEast++;
  1634. }
  1635. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  1636. {
  1637. //fill Qvectors from EAST arm
  1638. if (femtoTrack->eta() > -1. * cutEta && femtoTrack->eta() < 0.) //cutEtaGap[iGap])
  1639. {
  1640. QvTMP.SetX(p_Qx_EAST_EP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1641. QvTMP.SetY(p_Qy_EAST_EP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1642. fQv2EastEP[iGap] += weight * (CalcQvector(femtoTrack, 2) - QvTMP);
  1643. QvTMP.Set(0., 0.);
  1644. QvTMP.SetX(p_Qx_EAST_EP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1645. QvTMP.SetY(p_Qy_EAST_EP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1646. fQv3EastEP[iGap] += weight * (CalcQvector(femtoTrack, 3) - QvTMP);
  1647. QvTMP.Set(0., 0.);
  1648. QvTMP.SetX(p_Qx_EAST_SP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1649. QvTMP.SetY(p_Qy_EAST_SP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1650. fQv2EastSP[iGap] += 1. * (CalcQvector(femtoTrack, 2) - QvTMP);
  1651. QvTMP.Set(0., 0.);
  1652. QvTMP.SetX(p_Qx_EAST_SP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1653. QvTMP.SetY(p_Qy_EAST_SP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1654. fQv3EastSP[iGap] += 1. * (CalcQvector(femtoTrack, 3) - QvTMP);
  1655. QvTMP.Set(0., 0.);
  1656. fQcountEast[iGap]++;
  1657. }
  1658. //fill Qvectors from WEST arm
  1659. if (femtoTrack->eta() < 1. * cutEta && femtoTrack->eta() > 0.) //cutEtaGap[iGap])
  1660. {
  1661. QvTMP.SetX(p_Qx_WEST_EP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1662. QvTMP.SetY(p_Qy_WEST_EP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1663. fQv2WestEP[iGap] += weight * (CalcQvector(femtoTrack, 2) - QvTMP);
  1664. QvTMP.Set(0., 0.);
  1665. QvTMP.SetX(p_Qx_WEST_EP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1666. QvTMP.SetY(p_Qy_WEST_EP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1667. fQv3WestEP[iGap] += weight * (CalcQvector(femtoTrack, 3) - QvTMP);
  1668. QvTMP.Set(0., 0.);
  1669. QvTMP.SetX(p_Qx_WEST_SP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1670. QvTMP.SetY(p_Qy_WEST_SP[0][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1671. fQv2WestSP[iGap] += 1. * (CalcQvector(femtoTrack, 2) - QvTMP);
  1672. QvTMP.Set(0., 0.);
  1673. QvTMP.SetX(p_Qx_WEST_SP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1674. QvTMP.SetY(p_Qy_WEST_SP[1][VtxSign][(Int_t)event->cent16()][iGap][(Double_t)event->runId()]);
  1675. fQv3WestSP[iGap] += 1. * (CalcQvector(femtoTrack, 3) - QvTMP);
  1676. QvTMP.Set(0., 0.);
  1677. fQcountWest[iGap]++;
  1678. }
  1679. }
  1680. // Check if track has TOF signal
  1681. if (femtoTrack->isTofTrack())
  1682. {
  1683. } //if( isTofTrack() )
  1684. } //for(Int_t iTrk=0; iTrk<nTracks; iTrk++)
  1685. //Getting PsiEP with recentering + shift correction
  1686. Psi_ReCenter = 0.;
  1687. Double_t mCos, mSin;
  1688. if (fQcountFullWest + fQcountFullEast > cutNcountQvFull)
  1689. {
  1690. Psi2FullEP = 0.;
  1691. Psi3FullEP = 0.;
  1692. //FULL 2-nd order
  1693. Psi_ReCenter = TMath::ATan2(fQv2FullEP.Y(), fQv2FullEP.X()) / 2.;
  1694. dPsi = 0.;
  1695. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1696. {
  1697. mCos = p_Cos2_FULL_EP[VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1698. mSin = p_Cos2_FULL_EP[VtxSign][iK][(Int_t)event->cent16()][(Double_t)event->runId()];
  1699. dPsi += (1. / 2.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff2.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff2.at(iK) * Psi_ReCenter));
  1700. }
  1701. Psi2FullEP = AngleShift(Psi_ReCenter + dPsi, 2.);
  1702. }
  1703. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  1704. {
  1705. if (fQcountEast[iGap] > cutNcountQvGap &&
  1706. fQcountWest[iGap] > cutNcountQvGap)
  1707. {
  1708. Psi2EastEP[iGap] = 0.;
  1709. Psi3EastEP[iGap] = 0.;
  1710. Psi2WestEP[iGap] = 0.;
  1711. Psi3WestEP[iGap] = 0.;
  1712. Psi2EastSP[iGap] = 0.;
  1713. Psi3EastSP[iGap] = 0.;
  1714. Psi2WestSP[iGap] = 0.;
  1715. Psi3WestSP[iGap] = 0.;
  1716. //EAST 2-nd order
  1717. Psi_ReCenter = TMath::ATan2(fQv2EastEP[iGap].Y(), fQv2EastEP[iGap].X()) / 2.;
  1718. dPsi = 0.;
  1719. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1720. {
  1721. mCos = p_Cos2_EAST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1722. mSin = p_Cos2_EAST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1723. dPsi += (1. / 2.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff2.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff2.at(iK) * Psi_ReCenter));
  1724. }
  1725. Psi2EastEP[iGap] = AngleShift(Psi_ReCenter + dPsi, 2.);
  1726. Psi_ReCenter = TMath::ATan2(fQv2EastSP[iGap].Y(), fQv2EastSP[iGap].X()) / 2.;
  1727. dPsi = 0.;
  1728. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1729. {
  1730. mCos = p_Cos2_EAST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1731. mSin = p_Cos2_EAST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1732. dPsi += (1. / 2.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff2.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff2.at(iK) * Psi_ReCenter));
  1733. }
  1734. Psi2EastSP[iGap] = AngleShift(Psi_ReCenter + dPsi, 2.);
  1735. fQv2EastSP_Shift[iGap].Set(fQv2EastSP[iGap].Mod() * TMath::Cos(2. * Psi2EastSP[iGap]), fQv2EastSP[iGap].Mod() * TMath::Sin(2. * Psi2EastSP[iGap]));
  1736. //WEST 2-nd order
  1737. Psi_ReCenter = TMath::ATan2(fQv2WestEP[iGap].Y(), fQv2WestEP[iGap].X()) / 2.;
  1738. dPsi = 0.;
  1739. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1740. {
  1741. mCos = p_Cos2_WEST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1742. mSin = p_Cos2_WEST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1743. dPsi += (1. / 2.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff2.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff2.at(iK) * Psi_ReCenter));
  1744. }
  1745. Psi2WestEP[iGap] = AngleShift(Psi_ReCenter + dPsi, 2.);
  1746. Psi_ReCenter = TMath::ATan2(fQv2WestSP[iGap].Y(), fQv2WestSP[iGap].X()) / 2.;
  1747. dPsi = 0.;
  1748. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1749. {
  1750. mCos = p_Cos2_WEST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1751. mSin = p_Cos2_WEST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1752. dPsi += (1. / 2.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff2.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff2.at(iK) * Psi_ReCenter));
  1753. }
  1754. Psi2WestSP[iGap] = AngleShift(Psi_ReCenter + dPsi, 2.);
  1755. fQv2WestSP_Shift[iGap].Set(fQv2WestSP[iGap].Mod() * TMath::Cos(2. * Psi2WestSP[iGap]), fQv2WestSP[iGap].Mod() * TMath::Sin(2. * Psi2WestSP[iGap]));
  1756. //EAST 3-nd order
  1757. Psi_ReCenter = TMath::ATan2(fQv3EastEP[iGap].Y(), fQv3EastEP[iGap].X()) / 3.;
  1758. dPsi = 0.;
  1759. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1760. {
  1761. mCos = p_Cos3_EAST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1762. mSin = p_Cos3_EAST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1763. dPsi += (1. / 3.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff3.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff3.at(iK) * Psi_ReCenter));
  1764. }
  1765. Psi3EastEP[iGap] = AngleShift(Psi_ReCenter + dPsi, 3.);
  1766. Psi_ReCenter = TMath::ATan2(fQv3EastSP[iGap].Y(), fQv3EastSP[iGap].X()) / 3.;
  1767. dPsi = 0.;
  1768. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1769. {
  1770. mCos = p_Cos3_EAST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1771. mSin = p_Cos3_EAST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1772. dPsi += (1. / 3.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff3.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff3.at(iK) * Psi_ReCenter));
  1773. }
  1774. Psi3EastSP[iGap] = AngleShift(Psi_ReCenter + dPsi, 3.);
  1775. fQv3EastSP_Shift[iGap].Set(fQv3EastSP[iGap].Mod() * TMath::Cos(3. * Psi3EastSP[iGap]), fQv3EastSP[iGap].Mod() * TMath::Sin(3. * Psi3EastSP[iGap]));
  1776. //WEST 3-nd order
  1777. Psi_ReCenter = TMath::ATan2(fQv3WestEP[iGap].Y(), fQv3WestEP[iGap].X()) / 3.;
  1778. dPsi = 0.;
  1779. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1780. {
  1781. mCos = p_Cos3_WEST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1782. mSin = p_Cos3_WEST_EP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1783. dPsi += (1. / 3.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff3.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff3.at(iK) * Psi_ReCenter));
  1784. }
  1785. Psi3WestEP[iGap] = AngleShift(Psi_ReCenter + dPsi, 3.);
  1786. Psi_ReCenter = TMath::ATan2(fQv3WestSP[iGap].Y(), fQv3WestSP[iGap].X()) / 3.;
  1787. dPsi = 0.;
  1788. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1789. {
  1790. mCos = p_Cos3_WEST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1791. mSin = p_Cos3_WEST_SP[VtxSign][iK][(Int_t)event->cent16()][iGap][(Double_t)event->runId()];
  1792. dPsi += (1. / 3.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff3.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff3.at(iK) * Psi_ReCenter));
  1793. }
  1794. Psi3WestSP[iGap] = AngleShift(Psi_ReCenter + dPsi, 3.);
  1795. fQv3WestSP_Shift[iGap].Set(fQv3WestSP[iGap].Mod() * TMath::Cos(3. * Psi3WestSP[iGap]), fQv3WestSP[iGap].Mod() * TMath::Sin(3. * Psi3WestSP[iGap]));
  1796. }
  1797. }
  1798. //FLOW CALCULATIONS
  1799. // Second Track loop
  1800. for (Int_t iTrk = 0; iTrk < nTracks; iTrk++)
  1801. {
  1802. // Retrieve i-th femto track
  1803. StFemtoTrack *femtoTrack = dst->track(iTrk);
  1804. if (!femtoTrack)
  1805. continue;
  1806. // Must be a primary track
  1807. if (!femtoTrack->isPrimary())
  1808. continue;
  1809. //Track selection
  1810. if (isGoodTrackFlow(femtoTrack, energy, pVtx))
  1811. {
  1812. weight = GetWeight(femtoTrack);
  1813. // Flow with BBC EP
  1814. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  1815. {
  1816. res2EP = hResBBCFULL[iHarm]->GetBinContent(hResBBCFULL[iHarm]->FindBin(event->cent16()));
  1817. flow2EP = TMath::Cos((iHarm + 1.) * (femtoTrack->phi() - psiEP_BBC_Full[iHarm])) / res2EP;
  1818. p_vnBBC[iHarm]->Fill(event->cent16(), femtoTrack->pt(), flow2EP, weight);
  1819. if (iHarm == 1)
  1820. {
  1821. p_v2run_BBC[(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2EP, weight);
  1822. }
  1823. /*res2EP = hResBBCHalf[iHarm]->GetBinContent(hResBBCHalf[iHarm]->FindBin(event->cent16()));
  1824. flow2EP = TMath::Cos((iHarm+1.)*(femtoTrack->phi()-psiEP_BBC_East[iHarm])) / res2EP;
  1825. p_vnBBCEast[iHarm]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1826. res2EP = hResBBCHalf[iHarm]->GetBinContent(hResBBCHalf[iHarm]->FindBin(event->cent16()));
  1827. flow2EP = TMath::Cos((iHarm+1.)*(femtoTrack->phi()-psiEP_BBC_West[iHarm])) / res2EP;
  1828. p_vnBBCWest[iHarm]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);*/
  1829. }
  1830. // Flow with ZDC EP
  1831. // Full
  1832. res2EP = hResZDCFULL[1]->GetBinContent(hResZDCFULL[1]->FindBin(event->cent16()));
  1833. flow2EP = TMath::Cos(2. * (femtoTrack->phi() - psiEP_ZDC_Full[0])) / res2EP;
  1834. p_v2run_ZDC[(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2EP, weight);
  1835. // East
  1836. res2EP = hResZDCHalf[1]->GetBinContent(hResZDCHalf[1]->FindBin(event->cent16()));
  1837. flow2EP = TMath::Cos(2. * (femtoTrack->phi() - psiEP_ZDC_East[0])) / res2EP;
  1838. p_v2run_ZDC_East[(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2EP, weight);
  1839. // West
  1840. res2EP = hResZDCHalf[1]->GetBinContent(hResZDCHalf[1]->FindBin(event->cent16()));
  1841. flow2EP = TMath::Cos(2. * (femtoTrack->phi() - psiEP_ZDC_West[0])) / res2EP;
  1842. p_v2run_ZDC_West[(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2EP, weight);
  1843. ///////////////////////////////////////////////////////////////////////////////////////////
  1844. //p_ptrun[(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), weight);
  1845. //p1_ptrun[(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), 1.);
  1846. /*
  1847. // 3-sub method
  1848. //Get rid of autocorrelations
  1849. //Since pt<2 GeV/c cut was used in EP determination, only tracks within this range should be corrected
  1850. if (isGoodTrack(femtoTrack, energy, pVtx))
  1851. {
  1852. QvTMP.SetX(p_Qx_FULL_EP[0][VtxSign]->GetBinContent(p_Qx_FULL_EP[0][VtxSign]->FindBin((Double_t)event->runId(),(Double_t)event->cent16())));
  1853. QvTMP.SetY(p_Qy_FULL_EP[0][VtxSign]->GetBinContent(p_Qy_FULL_EP[0][VtxSign]->FindBin((Double_t)event->runId(),(Double_t)event->cent16())));
  1854. fQv2FullEPCorr = fQv2FullEP - weight*(CalcQvector(femtoTrack,2) - QvTMP);
  1855. QvTMP.Set(0.,0.);
  1856. Psi_ReCenter = TMath::ATan2(fQv2FullEPCorr.Y(), fQv2FullEPCorr.X()) / 2.;
  1857. dPsi = 0.;
  1858. for (int iK = 0; iK < NShiftOrderMax; iK++)
  1859. {
  1860. bin = p_Cos2_FULL_EP[VtxSign][iK]->FindBin((Double_t)event->runId(), (Double_t)event->cent16());
  1861. mCos = p_Cos2_FULL_EP[VtxSign][iK]->GetBinContent(bin);
  1862. bin = p_Cos2_FULL_EP[VtxSign][iK]->FindBin((Double_t)event->runId(), (Double_t)event->cent16());
  1863. mSin = p_Cos2_FULL_EP[VtxSign][iK]->GetBinContent(bin);
  1864. dPsi += (1. / 2.) * (2. / (iK + 1)) * (-1. * mSin * TMath::Cos(shiftOrderCoeff2.at(iK) * Psi_ReCenter) + mCos * TMath::Sin(shiftOrderCoeff2.at(iK) * Psi_ReCenter));
  1865. }
  1866. Psi2FullEP = AngleShift(Psi_ReCenter + dPsi, 2.);
  1867. }
  1868. res2EPsqr = p_res2_EP_3sub_AB->GetBinContent(p_res2_EP_3sub_AB->FindBin(event->cent16())) *
  1869. p_res2_EP_3sub_AC->GetBinContent(p_res2_EP_3sub_AC->FindBin(event->cent16())) /
  1870. p_res2_EP_3sub_BC->GetBinContent(p_res2_EP_3sub_BC->FindBin(event->cent16()));
  1871. res2EP = TMath::Sqrt(res2EPsqr);
  1872. flow2EP = TMath::Cos(2.*(femtoTrack->phi()-Psi2FullEP)) / res2EP;
  1873. p_v2cent_EP_3subTPC->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1874. // Calculate flow
  1875. res2EPsqr = p_res2_EP_3sub_AB->GetBinContent(p_res2_EP_3sub_AB->FindBin(event->cent16())) *
  1876. p_res2_EP_3sub_BC->GetBinContent(p_res2_EP_3sub_BC->FindBin(event->cent16())) /
  1877. p_res2_EP_3sub_AC->GetBinContent(p_res2_EP_3sub_AC->FindBin(event->cent16()));
  1878. res2EP = TMath::Sqrt(res2EPsqr);
  1879. flow2EP = TMath::Cos(2.*(femtoTrack->phi()-psiEP_BBC_East[1])) / res2EP;
  1880. p_v2cent_EP_3subBBCEast->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1881. res2EPsqr = p_res2_EP_3sub_AC->GetBinContent(p_res2_EP_3sub_AC->FindBin(event->cent16())) *
  1882. p_res2_EP_3sub_BC->GetBinContent(p_res2_EP_3sub_BC->FindBin(event->cent16())) /
  1883. p_res2_EP_3sub_AB->GetBinContent(p_res2_EP_3sub_AB->FindBin(event->cent16()));
  1884. res2EP = TMath::Sqrt(res2EPsqr);
  1885. flow2EP = TMath::Cos(2.*(femtoTrack->phi()-psiEP_BBC_West[1])) / res2EP;
  1886. p_v2cent_EP_3subBBCWest->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1887. ///////////////////////////////////////////////////////////////////////////////////////////
  1888. */
  1889. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  1890. {
  1891. res2EPsqr = p_res2_EP[iGap]->GetBinContent(p_res2_EP[iGap]->FindBin(event->cent16()));
  1892. res2EP = TMath::Sqrt(res2EPsqr);
  1893. res3EPsqr = p_res3_EP[iGap]->GetBinContent(p_res3_EP[iGap]->FindBin(event->cent16()));
  1894. res3EP = TMath::Sqrt(res3EPsqr);
  1895. res2SPsqr = p_res2_SP[iGap]->GetBinContent(p_res2_SP[iGap]->FindBin(event->cent16()));
  1896. if (res2SPsqr < 0)
  1897. std::cout << "Event " << iEvent << " | Res2SP NEGATIVEE: " << res2SPsqr << std::endl;
  1898. if (res2SPsqr == 0)
  1899. std::cout << "Res2SP ZEROOOOO" << std::endl;
  1900. res2SP = TMath::Sqrt(res2SPsqr);
  1901. res3SPsqr = p_res3_SP[iGap]->GetBinContent(p_res3_SP[iGap]->FindBin(event->cent16()));
  1902. res3SP = TMath::Sqrt(res3SPsqr);
  1903. //EAST
  1904. //if (track->eta() > -1.*cutEta && track->eta() < 0.)
  1905. if (femtoTrack->eta() > -1. * cutEta && femtoTrack->eta() < -1. * cutEtaGap.at(iGap))
  1906. {
  1907. flow2EP = TMath::Cos(2. * (femtoTrack->phi() - Psi2WestEP[iGap])) / res2EP;
  1908. flow3EP = TMath::Cos(3. * (femtoTrack->phi() - Psi3WestEP[iGap])) / res3EP;
  1909. p_v2cent_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow2EP, weight);
  1910. p_v3cent_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow3EP, weight);
  1911. p_v2EAST_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow2EP, weight);
  1912. p_v3EAST_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow3EP, weight);
  1913. p_v2run_EP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2EP, weight);
  1914. p_v3run_EP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow3EP, weight);
  1915. /*if (pVtx.Z() < 20.)
  1916. {
  1917. p_v2_VtxZsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1918. p_v3_VtxZsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow3EP,weight);
  1919. }
  1920. if (femtoTrack->gDCA(pVtx).Mag() < 2.)
  1921. {
  1922. p_v2_DCAsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1923. p_v3_DCAsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow3EP,weight);
  1924. }
  1925. if (femtoTrack->nHitsFit() > 10.)
  1926. {
  1927. p_v2_Nhitsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1928. p_v3_Nhitsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow3EP,weight);
  1929. }
  1930. if (iGap == 0)
  1931. {
  1932. p_v2_vs_run->Fill(event->runId(),event->cent16(),flow2EP);
  1933. p_v3_vs_run->Fill(event->runId(),event->cent16(),flow3EP);
  1934. }*/
  1935. fUvSP.Set(1. * TMath::Cos(2. * femtoTrack->phi()), 1. * TMath::Sin(2. * femtoTrack->phi()));
  1936. flow2SP = fUvSP * fQv2WestSP_Shift[iGap] / res2SP;
  1937. fUvSP.Set(1. * TMath::Cos(3. * femtoTrack->phi()), 1. * TMath::Sin(3. * femtoTrack->phi()));
  1938. flow3SP = fUvSP * fQv3WestSP_Shift[iGap] / res3SP;
  1939. p_v2cent_SP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow2SP, weight);
  1940. p_v3cent_SP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow3SP, weight);
  1941. p_v2run_SP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2SP, weight);
  1942. p_v3run_SP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow3SP, weight);
  1943. }
  1944. //WEST
  1945. //if (femtoTrack->eta() < 1.*cutEta && femtoTrack->eta() > 0.)
  1946. if (femtoTrack->eta() < 1. * cutEta && femtoTrack->eta() > 1. * cutEtaGap.at(iGap))
  1947. {
  1948. flow2EP = TMath::Cos(2. * (femtoTrack->phi() - Psi2EastEP[iGap])) / res2EP;
  1949. flow3EP = TMath::Cos(3. * (femtoTrack->phi() - Psi3EastEP[iGap])) / res3EP;
  1950. p_v2cent_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow2EP, weight);
  1951. p_v3cent_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow3EP, weight);
  1952. p_v2WEST_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow2EP, weight);
  1953. p_v3WEST_EP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow3EP, weight);
  1954. p_v2run_EP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2EP, weight);
  1955. p_v3run_EP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow3EP, weight);
  1956. /*if (pVtx.Z() < 20.)
  1957. {
  1958. p_v2_VtxZsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1959. p_v3_VtxZsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow3EP,weight);
  1960. }
  1961. if (femtoTrack->gDCA(pVtx).Mag() < 2.)
  1962. {
  1963. p_v2_DCAsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1964. p_v3_DCAsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow3EP,weight);
  1965. }
  1966. if (femtoTrack->nHitsFit() > 10.)
  1967. {
  1968. p_v2_Nhitsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow2EP,weight);
  1969. p_v3_Nhitsys[iGap]->Fill(event->cent16(),femtoTrack->pt(),flow3EP,weight);
  1970. }
  1971. if (iGap == 0)
  1972. {
  1973. p_v2_vs_run->Fill(event->runId(),event->cent16(),flow2EP);
  1974. p_v3_vs_run->Fill(event->runId(),event->cent16(),flow3EP);
  1975. }*/
  1976. fUvSP.Set(1. * TMath::Cos(2. * femtoTrack->phi()), 1. * TMath::Sin(2. * femtoTrack->phi()));
  1977. flow2SP = fUvSP * fQv2EastSP_Shift[iGap] / res2SP;
  1978. fUvSP.Set(1. * TMath::Cos(3. * femtoTrack->phi()), 1. * TMath::Sin(3. * femtoTrack->phi()));
  1979. flow3SP = fUvSP * fQv3EastSP_Shift[iGap] / res3SP;
  1980. p_v2cent_SP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow2SP, weight);
  1981. p_v3cent_SP_ptgaps[iGap]->Fill(event->cent16(), femtoTrack->pt(), flow3SP, weight);
  1982. p_v2run_SP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow2SP, weight);
  1983. p_v3run_SP[iGap][(Int_t)event->cent16()]->Fill(event->runId(), femtoTrack->pt(), flow3SP, weight);
  1984. }
  1985. }
  1986. }
  1987. }
  1988. } //for(Long64_t iEvent=0; iEvent<events2read; iEvent++)
  1989. femtoReader->Finish();
  1990. TFile *output = new TFile(outFile, "recreate");
  1991. for (int iGap = 0; iGap < NEtaGaps; iGap++)
  1992. {
  1993. // p_v2cent_EP_ptgaps[iGap]->Write();
  1994. // p_v3cent_EP_ptgaps[iGap]->Write();
  1995. // p_v2cent_SP_ptgaps[iGap]->Write();
  1996. // p_v3cent_SP_ptgaps[iGap]->Write();
  1997. p_v2EAST_EP_ptgaps[iGap]->Write();
  1998. p_v3EAST_EP_ptgaps[iGap]->Write();
  1999. p_v2WEST_EP_ptgaps[iGap]->Write();
  2000. p_v3WEST_EP_ptgaps[iGap]->Write();
  2001. for (int iCent = 0; iCent < 16; iCent++)
  2002. {
  2003. p_v2run_EP[iGap][iCent]->Write();
  2004. p_v3run_EP[iGap][iCent]->Write();
  2005. p_v2run_SP[iGap][iCent]->Write();
  2006. p_v3run_SP[iGap][iCent]->Write();
  2007. if (iGap == 0)
  2008. {
  2009. p_v2run_BBC[iCent]->Write();
  2010. }
  2011. }
  2012. for (int iCent = 0; iCent < 16; iCent++)
  2013. {
  2014. if (iGap == 0)
  2015. {
  2016. p_v2run_ZDC[iCent]->Write();
  2017. p_v2run_ZDC_East[iCent]->Write();
  2018. p_v2run_ZDC_West[iCent]->Write();
  2019. }
  2020. }
  2021. for (int iCent = 0; iCent < 16; iCent++)
  2022. {
  2023. if (iGap == 0)
  2024. {
  2025. //p_ptrun[iCent]->Write();
  2026. //p1_ptrun[iCent]->Write();
  2027. }
  2028. }
  2029. /*p_v2_VtxZsys[iGap]->Write();
  2030. p_v2_DCAsys[iGap]->Write();
  2031. p_v2_Nhitsys[iGap]->Write();
  2032. p_v3_VtxZsys[iGap]->Write();
  2033. p_v3_DCAsys[iGap]->Write();
  2034. p_v3_Nhitsys[iGap]->Write();*/
  2035. }
  2036. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  2037. {
  2038. p_vnBBC[iHarm]->Write();
  2039. //p_vnBBCEast[iHarm]->Write();
  2040. //p_vnBBCWest[iHarm]->Write();
  2041. }
  2042. /*p_v2cent_EP_3subTPC->Write();
  2043. p_v2cent_EP_3subBBCEast->Write();
  2044. p_v2cent_EP_3subBBCWest->Write();
  2045. p_v2_vs_run->Write();
  2046. p_v3_vs_run->Write();*/
  2047. output->Close();
  2048. std::cout << "I'm done with analysis. We'll have a Nobel Prize, Master!"
  2049. << std::endl;
  2050. std::cout << "Good events: " << goodEventCounter << std::endl;
  2051. timer.Stop();
  2052. timer.Print();
  2053. }
  2054. Bool_t isGoodEvent(StFemtoEvent *const &event)
  2055. {
  2056. if (!event)
  2057. return false;
  2058. if (event == nullptr)
  2059. return false;
  2060. if (event->primaryVertex().Perp() > cutVtxR)
  2061. return false;
  2062. if (TMath::Abs(event->primaryVertex().Z()) > cutVtxZEnergy.at(energy))
  2063. return false;
  2064. if ((energy == 200.) && TMath::Abs(event->primaryVertex().Z() - event->vpdVz()) > cutVpdVz)
  2065. return false;
  2066. return true;
  2067. }
  2068. Bool_t isGoodTrack(StFemtoTrack *const &track, Float_t _energy, TVector3 pVtx)
  2069. {
  2070. if (!track)
  2071. return false;
  2072. // if (!track->isPrimary()) return false;
  2073. if (track->nHitsFit() < cutNhits)
  2074. return false;
  2075. if (track->nHitsPoss() <= cutNhitsPoss)
  2076. return false;
  2077. if ((Double_t)track->nHitsFit() / track->nHitsPoss() < cutNhitsRatio)
  2078. return false;
  2079. if (TMath::Abs(track->eta()) >= cutEta)
  2080. return false;
  2081. if (track->pt() <= cutPtMin.at(_energy))
  2082. return false;
  2083. if (track->pt() > cutPtMax)
  2084. return false;
  2085. if (track->ptot() > cutPMax)
  2086. return false;
  2087. if (track->gDCA(pVtx).Mag() >= cutDCA.at(_energy))
  2088. return false;
  2089. return true;
  2090. }
  2091. Bool_t isGoodTrackFlow(StFemtoTrack *const &track, Float_t _energy, TVector3 pVtx)
  2092. {
  2093. if (!track)
  2094. return false;
  2095. // if (!track->isPrimary()) return false;
  2096. if (track->nHitsFit() < cutNhits)
  2097. return false;
  2098. if (track->nHitsPoss() <= cutNhitsPoss)
  2099. return false;
  2100. if ((Double_t)track->nHitsFit() / track->nHitsPoss() < cutNhitsRatio)
  2101. return false;
  2102. if (TMath::Abs(track->eta()) >= cutEta)
  2103. return false;
  2104. if (track->pt() <= cutPtMin.at(_energy))
  2105. return false;
  2106. //if (track->pt() > cutPtMax) return false;
  2107. if (track->ptot() > cutPMax)
  2108. return false;
  2109. if (track->gDCA(pVtx).Mag() >= cutDCA.at(_energy))
  2110. return false;
  2111. return true;
  2112. }
  2113. Double_t GetWeight(StFemtoTrack *const &track)
  2114. {
  2115. Double_t weight;
  2116. if (track->pt() <= cutPtWeightEP)
  2117. {
  2118. weight = track->pt();
  2119. }
  2120. else
  2121. {
  2122. weight = cutPtWeightEP;
  2123. }
  2124. return weight;
  2125. }
  2126. TVector2 CalcQvector(StFemtoTrack *const &track, Int_t _harm)
  2127. {
  2128. TVector2 qv(0., 0.);
  2129. qv.Set(TMath::Cos(_harm * track->phi()), TMath::Sin(_harm * track->phi()));
  2130. return qv;
  2131. }
  2132. Double_t AngleShift(Double_t Psi, Double_t order)
  2133. {
  2134. Double_t PsiCorr = Psi;
  2135. if (PsiCorr > TMath::Pi() / order)
  2136. {
  2137. PsiCorr = Psi - 2. * TMath::Pi() / order;
  2138. }
  2139. if (PsiCorr < -1. * TMath::Pi() / order)
  2140. {
  2141. PsiCorr = Psi + 2. * TMath::Pi() / order;
  2142. }
  2143. return PsiCorr;
  2144. }
  2145. Int_t GetVzBin(Double_t vtxZ)
  2146. {
  2147. for (Int_t i = 0; i < fArraySize; i++)
  2148. {
  2149. if (vtxZ >= VtxBins[i] && vtxZ < VtxBins[i + 1])
  2150. return i;
  2151. }
  2152. return -1;
  2153. }
  2154. //--------------------------------------------------------------------------------------------------------------------------//
  2155. //this function simply connects the gain values read in to the BBC azimuthal distribution
  2156. //since tiles 7 and 9 (+ 13 and 15) share a gain value it is ambiguous how to assign the geometry here
  2157. //I prefer assigning the angle between the tiles thus "greying out" the adcs.
  2158. //Others have assigned all of the adc to one (exclusive) or the the other.
  2159. Float_t BBC_GetPhi(const Int_t eastWest, const Int_t tileId)
  2160. {
  2161. //float GetPhiInBBC(int eastWest, int bbcN) { //tileId=0 to 23
  2162. const float Pi = TMath::Pi();
  2163. const float Phi_div = Pi / 6;
  2164. float bbc_phi = Phi_div;
  2165. switch (tileId)
  2166. {
  2167. case 0:
  2168. bbc_phi = 3. * Phi_div;
  2169. break;
  2170. case 1:
  2171. bbc_phi = Phi_div;
  2172. break;
  2173. case 2:
  2174. bbc_phi = -1. * Phi_div;
  2175. break;
  2176. case 3:
  2177. bbc_phi = -3. * Phi_div;
  2178. break;
  2179. case 4:
  2180. bbc_phi = -5. * Phi_div;
  2181. break;
  2182. case 5:
  2183. bbc_phi = 5. * Phi_div;
  2184. break;
  2185. //case 6: bbc_phi= (mRndm.Rndm() > 0.5) ? 2.*Phi_div:4.*Phi_div; //tiles 7 and 9 are gained together we randomly assign the gain to one XOR the other
  2186. case 6:
  2187. bbc_phi = 3. * Phi_div;
  2188. break;
  2189. case 7:
  2190. bbc_phi = 3. * Phi_div;
  2191. break;
  2192. case 8:
  2193. bbc_phi = Phi_div;
  2194. break;
  2195. case 9:
  2196. bbc_phi = 0.;
  2197. break;
  2198. case 10:
  2199. bbc_phi = -1. * Phi_div;
  2200. break;
  2201. //case 11: bbc_phi = (mRndm.Rndm() > 0.5) ? -2.*Phi_div:-4.*Phi_div; //tiles 13 and 15 are gained together
  2202. case 11:
  2203. bbc_phi = -3. * Phi_div;
  2204. break;
  2205. case 12:
  2206. bbc_phi = -3. * Phi_div;
  2207. break;
  2208. case 13:
  2209. bbc_phi = -5. * Phi_div;
  2210. break;
  2211. case 14:
  2212. bbc_phi = Pi;
  2213. break;
  2214. case 15:
  2215. bbc_phi = 5. * Phi_div;
  2216. break;
  2217. }
  2218. //if we're looking at the east BBC we need to flip around x in the STAR coordinates,
  2219. //a line parallel to the beam would go through tile 1 on the W BBC and tile 3 on the
  2220. if (0 == eastWest)
  2221. {
  2222. if (bbc_phi > -0.001)
  2223. { //this is not a >= since we are talking about finite adcs -- not to important
  2224. bbc_phi = Pi - bbc_phi;
  2225. }
  2226. else
  2227. {
  2228. bbc_phi = -Pi - bbc_phi;
  2229. }
  2230. }
  2231. if (bbc_phi < 0.0)
  2232. bbc_phi += 2. * Pi;
  2233. if (bbc_phi > 2. * Pi)
  2234. bbc_phi -= 2. * Pi;
  2235. return bbc_phi;
  2236. }
  2237. Bool_t isBadRun(StFemtoEvent *const &event)
  2238. {
  2239. Int_t run = (Int_t)event->runId();
  2240. if (run == 12132026 ||
  2241. run == 12134014 ||
  2242. run == 12134051 ||
  2243. run == 12135008 ||
  2244. run == 12136006 ||
  2245. run == 12136025 ||
  2246. run == 12136047 ||
  2247. run == 12136064)
  2248. return true;
  2249. else
  2250. return false;
  2251. }
  2252. Double_t GetZDCPosition(Int_t eastwest, Int_t verthori, Int_t strip)
  2253. // Get position of each slat;strip starts from 0
  2254. {
  2255. Double_t zdcsmd_x[7] = {0.5, 2, 3.5, 5, 6.5, 8, 9.5};
  2256. Double_t zdcsmd_y[8] = {1.25, 3.25, 5.25, 7.25, 9.25, 11.25, 13.25, 15.25};
  2257. Double_t mZDCSMDCenterex = 4.72466;
  2258. Double_t mZDCSMDCenterey = 5.53629;
  2259. Double_t mZDCSMDCenterwx = 4.39604;
  2260. Double_t mZDCSMDCenterwy = 5.19968;
  2261. if (eastwest == 0 && verthori == 0)
  2262. return zdcsmd_x[strip] - mZDCSMDCenterex;
  2263. if (eastwest == 1 && verthori == 0)
  2264. return mZDCSMDCenterwx - zdcsmd_x[strip];
  2265. if (eastwest == 0 && verthori == 1)
  2266. return zdcsmd_y[strip] / sqrt(2.) - mZDCSMDCenterey;
  2267. if (eastwest == 1 && verthori == 1)
  2268. return zdcsmd_y[strip] / sqrt(2.) - mZDCSMDCenterwy;
  2269. return -999.;
  2270. }