FemtoDstAnalyzer_FlowPIDsys1.C 107 KB

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