StAtConverter.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. // C++ headers
  2. #include <iostream>
  3. #include <string>
  4. #include <utility>
  5. #include <set>
  6. #include <map>
  7. #include <functional>
  8. // ROOT headers
  9. #include <TROOT.h>
  10. #include <TFile.h>
  11. #include <TChain.h>
  12. #include <TTree.h>
  13. #include <TSystem.h>
  14. #include <TH1.h>
  15. #include <TH2.h>
  16. #include <TMath.h>
  17. #include <TString.h>
  18. #include <TStopwatch.h>
  19. // FemtoDst headers
  20. #include "StFemtoDstReader.h"
  21. #include "StFemtoDst.h"
  22. #include "StFemtoEvent.h"
  23. #include "StFemtoTrack.h"
  24. // AnalysisTree headers
  25. #include "AnalysisTree/Configuration.hpp"
  26. #include "AnalysisTree/DataHeader.hpp"
  27. #include "AnalysisTree/EventHeader.hpp"
  28. #include "AnalysisTree/Detector.hpp"
  29. #include "AnalysisTree/Matching.hpp"
  30. float get_beamP(float sqrtSnn, float m_target = 0.938, float m_beam = 0.938);
  31. float GetCentFromCent9(int cent9);
  32. float GetCentFromCent16(int cent16);
  33. TVector3 GetBbcPositionEast(int imod);
  34. TVector3 GetBbcPositionWest(int imod);
  35. TVector3 GetZdcPositionXEast(int strip);
  36. TVector3 GetZdcPositionYEast(int strip);
  37. TVector3 GetZdcPositionXWest(int strip);
  38. TVector3 GetZdcPositionYWest(int strip);
  39. int main(int argc, char **argv)
  40. {
  41. TString iFileName, oFileName;
  42. std::string system="";
  43. float sqrtSnn = -1.;
  44. bool isDataHeaderDefined = false;
  45. if (argc < 5)
  46. {
  47. std::cerr << "./MpdDst2AnalysisTree -i inputfile/inputlist -o outputfile [OPTIONAL: --sqrtSnn sqrtSnn --system colliding_system_name]" << std::endl;
  48. return 1;
  49. }
  50. for (int i = 1; i < argc; i++)
  51. {
  52. if (std::string(argv[i]) != "-i" &&
  53. std::string(argv[i]) != "-o" &&
  54. std::string(argv[i]) != "--sqrtSnn" &&
  55. std::string(argv[i]) != "--system")
  56. {
  57. std::cerr << "\n[ERROR]: Unknown parameter " << i << ": " << argv[i] << std::endl;
  58. return 1;
  59. }
  60. else
  61. {
  62. if (std::string(argv[i]) == "-i" && i != argc - 1)
  63. {
  64. iFileName = argv[++i];
  65. continue;
  66. }
  67. if (std::string(argv[i]) == "-i" && i == argc - 1)
  68. {
  69. std::cerr << "\n[ERROR]: Input file name was not specified " << std::endl;
  70. return 1;
  71. }
  72. if (std::string(argv[i]) == "-o" && i != argc - 1)
  73. {
  74. oFileName = argv[++i];
  75. continue;
  76. }
  77. if (std::string(argv[i]) == "-o" && i == argc - 1)
  78. {
  79. std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl;
  80. return 1;
  81. }
  82. if (std::string(argv[i]) == "--system" && i != argc - 1)
  83. {
  84. system = std::string(argv[++i]);
  85. isDataHeaderDefined = true;
  86. continue;
  87. }
  88. if (std::string(argv[i]) == "--system" && i == argc - 1)
  89. {
  90. std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl;
  91. return 1;
  92. }
  93. if (std::string(argv[i]) == "--sqrtSnn" && i != argc - 1)
  94. {
  95. sqrtSnn = std::stof(std::string(argv[++i]));
  96. isDataHeaderDefined = true;
  97. continue;
  98. }
  99. if (std::string(argv[i]) == "--sqrtSnn" && i == argc - 1)
  100. {
  101. std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl;
  102. return 1;
  103. }
  104. }
  105. }
  106. const int NbbcModules = 32; // 0-15 - east, 16-31 - west
  107. const int NbbcModulesHalf = 16;
  108. const int NzdcStipsX = 7;
  109. const int NzdcStipsY = 8;
  110. TStopwatch timer;
  111. timer.Start();
  112. StFemtoDstReader* femtoReader = new StFemtoDstReader(iFileName.Data());
  113. femtoReader->Init();
  114. // This is a way if you want to spead up IO
  115. std::cout << "Explicit read status for some branches" << std::endl;
  116. femtoReader->SetStatus("*",0);
  117. femtoReader->SetStatus("Event",1);
  118. femtoReader->SetStatus("Track",1);
  119. std::cout << "Status has been set" << std::endl;
  120. if( !femtoReader->chain() ) {
  121. std::cout << "No chain has been found." << std::endl;
  122. }
  123. Long64_t eventsInTree = femtoReader->tree()->GetEntries();
  124. std::cout << "eventsInTree: " << eventsInTree << std::endl;
  125. Long64_t events2read = femtoReader->chain()->GetEntries();
  126. std::cout << "Number of events to read: " << events2read << std::endl;
  127. // Set up output dst
  128. TFile *outFile = new TFile(oFileName.Data(), "RECREATE");
  129. TTree *outTree = new TTree("aTree","AnalysisTree Dst at STAR");
  130. // Set up AnalysisTree data header
  131. AnalysisTree::DataHeader *dataHeader = new AnalysisTree::DataHeader;
  132. if (system != "") dataHeader->SetSystem(system);
  133. if (sqrtSnn > 0) dataHeader->SetBeamMomentum(get_beamP(sqrtSnn));
  134. auto &bbc_mod_pos = dataHeader->AddDetector();
  135. TVector3 modulePos;
  136. for (int imodule=0; imodule<NbbcModules; imodule++)
  137. {
  138. auto *module = bbc_mod_pos.AddChannel();
  139. if (imodule < NbbcModulesHalf) modulePos = GetBbcPositionEast(imodule);
  140. if (imodule >= NbbcModulesHalf) modulePos = GetBbcPositionWest(imodule-NbbcModulesHalf);
  141. module->SetPosition(modulePos);
  142. }
  143. // Set up AnalysisTree configureation
  144. AnalysisTree::Configuration *out_config = new AnalysisTree::Configuration;
  145. // Set up AnalysisTree configuration
  146. std::string str_reco_event_branch = "RecoEvent";
  147. std::string str_tpc_tracks_branch = "TpcTracks";
  148. std::string str_bbc_branch = "BbcModules";
  149. std::string str_zdc_horizontal_branch = "ZdcHitsHorizontal";
  150. std::string str_zdc_vertical_branch = "ZdcHitsVertical";
  151. AnalysisTree::BranchConfig reco_event_branch(str_reco_event_branch.c_str(), AnalysisTree::DetType::kEventHeader);
  152. AnalysisTree::BranchConfig tpc_tracks_branch(str_tpc_tracks_branch.c_str(), AnalysisTree::DetType::kTrack);
  153. AnalysisTree::BranchConfig bbc_branch(str_bbc_branch.c_str(), AnalysisTree::DetType::kModule);
  154. AnalysisTree::BranchConfig zdc_horizontal_branch(str_zdc_horizontal_branch.c_str(), AnalysisTree::DetType::kHit);
  155. AnalysisTree::BranchConfig zdc_vertical_branch(str_zdc_vertical_branch.c_str(), AnalysisTree::DetType::kHit);
  156. reco_event_branch.AddField<int>("runId");
  157. reco_event_branch.AddField<int>("refMult");
  158. reco_event_branch.AddField<int>("refMult2");
  159. reco_event_branch.AddField<float>("cent9");
  160. reco_event_branch.AddField<float>("cent16");
  161. reco_event_branch.AddField<int>("numberOfBTofHit");
  162. reco_event_branch.AddField<int>("numberOfTofMatched");
  163. reco_event_branch.AddField<float>("vpdVz");
  164. tpc_tracks_branch.AddField<int>("nHits");
  165. tpc_tracks_branch.AddField<int>("nHitsFit");
  166. tpc_tracks_branch.AddField<int>("nHitsPoss");
  167. tpc_tracks_branch.AddField<float>("nHits_Fit2Poss");
  168. tpc_tracks_branch.AddField<float>("nSigmaPion");
  169. tpc_tracks_branch.AddField<float>("nSigmaKaon");
  170. tpc_tracks_branch.AddField<float>("nSigmaProton");
  171. tpc_tracks_branch.AddField<float>("dEdx");
  172. tpc_tracks_branch.AddField<float>("tofMass2");
  173. tpc_tracks_branch.AddFields<float>({"dca_x","dca_y","dca_z"});
  174. tpc_tracks_branch.AddField<float>("dca");
  175. tpc_tracks_branch.AddField<bool>("isPrimary");
  176. tpc_tracks_branch.AddField<bool>("isTofTrack");
  177. auto hasher = std::hash<std::string>();
  178. // Initialize AnalysisTree Dst components
  179. out_config->AddBranchConfig(reco_event_branch);
  180. AnalysisTree::EventHeader *reco_event = new AnalysisTree::EventHeader( Short_t(hasher(reco_event_branch.GetName())) );
  181. out_config->AddBranchConfig(tpc_tracks_branch);
  182. AnalysisTree::TrackDetector *tpc_tracks = new AnalysisTree::TrackDetector( Short_t(hasher(tpc_tracks_branch.GetName())) );
  183. out_config->AddBranchConfig(bbc_branch);
  184. AnalysisTree::ModuleDetector *bbc_modules = new AnalysisTree::ModuleDetector( Short_t(hasher(bbc_branch.GetName())) );
  185. out_config->AddBranchConfig(zdc_horizontal_branch);
  186. AnalysisTree::HitDetector *zdc_horizontal_hits = new AnalysisTree::HitDetector( Short_t(hasher(zdc_horizontal_branch.GetName())) );
  187. out_config->AddBranchConfig(zdc_vertical_branch);
  188. AnalysisTree::HitDetector *zdc_vertical_hits = new AnalysisTree::HitDetector( Short_t(hasher(zdc_vertical_branch.GetName())) );
  189. reco_event->Init(reco_event_branch);
  190. // reco_event's additional field ids
  191. const int irunId = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("runId");
  192. const int irefMult = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("refMult");
  193. const int irefMult2 = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("refMult2");
  194. const int icent9 = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("cent9");
  195. const int icent16 = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("cent16");
  196. const int inumberOfBTofHit = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("numberOfBTofHit");
  197. const int inumberOfTofMatched = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("numberOfTofMatched");
  198. const int ivpdVz = out_config->GetBranchConfig(str_reco_event_branch).GetFieldId("vpdVz");
  199. // tpc_tracks' additional field ids
  200. const int inHits = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nHits");
  201. const int inHitsFit = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nHitsFit");
  202. const int inHitsPoss = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nHitsPoss");
  203. const int inHits_Fit2Poss = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nHits_Fit2Poss");
  204. const int inSigmaPion = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nSigmaPion");
  205. const int inSigmaKaon = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nSigmaKaon");
  206. const int inSigmaProton = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("nSigmaProton");
  207. const int idEdx = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("dEdx");
  208. const int itofMass2 = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("tofMass2");
  209. const int idca_x = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("dca_x");
  210. const int idca_y = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("dca_y");
  211. const int idca_z = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("dca_z");
  212. const int idca = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("dca");
  213. const int iisPrimary = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("isPrimary");
  214. const int iisTofTrack = out_config->GetBranchConfig(str_tpc_tracks_branch).GetFieldId("isTofTrack");
  215. // Create branches in the output tree
  216. outTree->Branch(str_reco_event_branch.c_str(), "AnalysisTree::EventHeader", &reco_event, 32000, 99);
  217. outTree->Branch(str_tpc_tracks_branch.c_str(), "AnalysisTree::TrackDetector", &tpc_tracks, 256000, 99);
  218. outTree->Branch(str_bbc_branch.c_str(), "AnalysisTree::ModuleDetector", &bbc_modules, 128000, 99);
  219. outTree->Branch(str_zdc_horizontal_branch.c_str(), "AnalysisTree::HitDetector", &zdc_horizontal_hits, 128000, 99);
  220. outTree->Branch(str_zdc_vertical_branch.c_str(), "AnalysisTree::HitDetector", &zdc_vertical_hits, 128000, 99);
  221. // Printout basic configuration info
  222. out_config->Print();
  223. // Starting event loop
  224. TVector3 pVtx;
  225. // Loop over events
  226. for(Long64_t iEvent=0; iEvent<events2read; iEvent++)
  227. {
  228. if (iEvent % 1000 == 0)
  229. {
  230. std::cout << "Working on event #[" << (iEvent+1)
  231. << "/" << events2read << "]" << std::endl;
  232. }
  233. Bool_t readEvent = femtoReader->readFemtoEvent(iEvent);
  234. if( !readEvent ) {
  235. std::cout << "Something went wrong! Nothing to analyze..." << std::endl;
  236. break;
  237. }
  238. // Retrieve femtoDst
  239. StFemtoDst *dst = femtoReader->femtoDst();
  240. // Retrieve event information
  241. StFemtoEvent *event = dst->event();
  242. if( !event ) {
  243. std::cout << "Something went wrong! Event is hiding from me..." << std::endl;
  244. break;
  245. }
  246. // Return primary vertex position
  247. pVtx = event->primaryVertex();
  248. // Reject vertices that are far from the central membrane along the beam
  249. if( TMath::Abs( pVtx.Z() ) > 200. ) continue;
  250. tpc_tracks->ClearChannels();
  251. bbc_modules->ClearChannels();
  252. zdc_horizontal_hits->ClearChannels();
  253. zdc_vertical_hits->ClearChannels();
  254. // Reading Reco Event
  255. reco_event->SetVertexPosition3(pVtx);
  256. reco_event->SetField(int(event->runId()), irunId);
  257. reco_event->SetField(int(event->refMult()), irefMult);
  258. reco_event->SetField(int(event->refMult2()), irefMult2);
  259. reco_event->SetField(float(GetCentFromCent9(event->cent9())), icent9);
  260. reco_event->SetField(float(GetCentFromCent16(event->cent16())), icent16);
  261. reco_event->SetField(int(event->numberOfBTofHit()), inumberOfBTofHit);
  262. reco_event->SetField(int(event->numberOfTofMatched()), inumberOfTofMatched);
  263. reco_event->SetField(float(event->vpdVz()), ivpdVz);
  264. // Track analysis
  265. Int_t nTracks = dst->numberOfTracks();
  266. tpc_tracks->Reserve(nTracks);
  267. // Track loop
  268. for(Int_t iTrk=0; iTrk<nTracks; iTrk++)
  269. {
  270. // Retrieve i-th femto track
  271. StFemtoTrack *femtoTrack = dst->track(iTrk);
  272. if (!femtoTrack) continue;
  273. auto *track = tpc_tracks->AddChannel();
  274. track->Init(out_config->GetBranchConfig(str_tpc_tracks_branch));
  275. // Reading Reco Track
  276. track->SetMomentum(femtoTrack->pMom().X(),femtoTrack->pMom().Y(),femtoTrack->pMom().Z());
  277. track->SetField(int(femtoTrack->nHits()), inHits);
  278. track->SetField(int(femtoTrack->nHitsFit()), inHitsFit);
  279. track->SetField(int(femtoTrack->nHitsPoss()), inHitsPoss);
  280. track->SetField(float(femtoTrack->nHitsFit()/femtoTrack->nHitsPoss()), inHits_Fit2Poss);
  281. track->SetField(float(femtoTrack->nSigmaPion()), inSigmaPion);
  282. track->SetField(float(femtoTrack->nSigmaKaon()), inSigmaKaon);
  283. track->SetField(float(femtoTrack->nSigmaProton()), inSigmaProton);
  284. track->SetField(float(femtoTrack->dEdx()), idEdx);
  285. track->SetField(float(femtoTrack->massSqr()), itofMass2);
  286. track->SetField(float(femtoTrack->gDCA(pVtx).Mag()), idca);
  287. track->SetField(float(femtoTrack->gDCA(pVtx).X()), idca_x);
  288. track->SetField(float(femtoTrack->gDCA(pVtx).Y()), idca_y);
  289. track->SetField(float(femtoTrack->gDCA(pVtx).Z()), idca_z);
  290. track->SetField(bool(femtoTrack->isPrimary()), iisPrimary);
  291. track->SetField(bool(femtoTrack->isTofTrack()), iisTofTrack);
  292. } //for(Int_t iTrk=0; iTrk<nTracks; iTrk++)
  293. // Fill BBC information
  294. bbc_modules->Reserve(NbbcModules);
  295. for (int imodule = 0; imodule<NbbcModules; imodule++)
  296. {
  297. auto *module = bbc_modules->AddChannel();
  298. module->Init(out_config->GetBranchConfig(str_bbc_branch));
  299. module->SetNumber(imodule);
  300. if (imodule < NbbcModulesHalf) module->SetSignal(event->bbcAdcEast(imodule));
  301. if (imodule >= NbbcModulesHalf) module->SetSignal(event->bbcAdcWest(imodule-NbbcModulesHalf));
  302. }
  303. // Fill ZDC-SMD information
  304. // There are 7 vertical and 8 horizontal strips of ZDC-SMD. To calculate Q-vectors from ZDC
  305. // one has to sum up signal from those strips separately:
  306. // Qx = sum zdcSmdVertical * position_of_the_vertical_strip, (sum over 7 strips)
  307. // Qy = sum zdcSmdHorizontal * position_of_the_Horizontal_strip, (sum over 8 strips)
  308. // To translate this information into AnalysisTree, HitDetector was chosen for horizontal
  309. // and vertical strips separately.
  310. zdc_horizontal_hits->Reserve(2*NzdcStipsY);
  311. zdc_vertical_hits->Reserve(2*NzdcStipsX);
  312. TVector3 geomZdcPos;
  313. // Fill ZDC-SMD East - horizontal
  314. for (int ihity=0; ihity<NzdcStipsY; ihity++)
  315. {
  316. auto *hit = zdc_horizontal_hits->AddChannel();
  317. hit->Init(out_config->GetBranchConfig(str_zdc_horizontal_branch));
  318. geomZdcPos = GetZdcPositionYEast(ihity);
  319. hit->SetPosition(geomZdcPos);
  320. hit->SetSignal(event->zdcSmdEastHorizontal(ihity));
  321. }
  322. // Fill ZDC-SMD East - vertical
  323. for (int ihitx=0; ihitx<NzdcStipsX; ihitx++)
  324. {
  325. auto *hit = zdc_vertical_hits->AddChannel();
  326. hit->Init(out_config->GetBranchConfig(str_zdc_vertical_branch));
  327. geomZdcPos = GetZdcPositionXEast(ihitx);
  328. hit->SetPosition(geomZdcPos);
  329. hit->SetSignal(event->zdcSmdEastVertical(ihitx));
  330. }
  331. // Fill ZDC-SMD West - horizontal
  332. for (int ihity=0; ihity<NzdcStipsY; ihity++)
  333. {
  334. auto *hit = zdc_horizontal_hits->AddChannel();
  335. hit->Init(out_config->GetBranchConfig(str_zdc_horizontal_branch));
  336. geomZdcPos = GetZdcPositionYWest(ihity);
  337. hit->SetPosition(geomZdcPos);
  338. hit->SetSignal(event->zdcSmdWestHorizontal(ihity));
  339. }
  340. // Fill ZDC-SMD West - vertical
  341. for (int ihitx=0; ihitx<NzdcStipsX; ihitx++)
  342. {
  343. auto *hit = zdc_vertical_hits->AddChannel();
  344. hit->Init(out_config->GetBranchConfig(str_zdc_vertical_branch));
  345. geomZdcPos = GetZdcPositionXWest(ihitx);
  346. hit->SetPosition(geomZdcPos);
  347. hit->SetSignal(event->zdcSmdWestVertical(ihitx));
  348. }
  349. outTree->Fill();
  350. } //for(Long64_t iEvent=0; iEvent<events2read; iEvent++)
  351. outFile->cd();
  352. outTree->Print();
  353. outTree->Write();
  354. if (isDataHeaderDefined) dataHeader->Write("DataHeader");
  355. out_config->Write("Configuration");
  356. outFile->Close();
  357. femtoReader->Finish();
  358. timer.Stop();
  359. timer.Print();
  360. return 0;
  361. }
  362. float get_beamP(float sqrtSnn, float m_target, float m_beam)
  363. {
  364. return sqrt( pow((pow(sqrtSnn,2) - pow(m_target,2) - pow(m_beam,2))/(2*m_target), 2) - pow(m_beam,2) );
  365. }
  366. float GetCentFromCent9(int cent9)
  367. {
  368. if (cent9 == 0) return 75.;
  369. if (cent9 == 1) return 65.;
  370. if (cent9 == 2) return 55.;
  371. if (cent9 == 3) return 45.;
  372. if (cent9 == 4) return 35.;
  373. if (cent9 == 5) return 25.;
  374. if (cent9 == 6) return 15.;
  375. if (cent9 == 7) return 7.5;
  376. if (cent9 == 8) return 2.5;
  377. return -1.;
  378. }
  379. float GetCentFromCent16(int cent16)
  380. {
  381. if (cent16 == 0) return 77.5;
  382. if (cent16 == 1) return 72.5;
  383. if (cent16 == 2) return 67.5;
  384. if (cent16 == 3) return 62.5;
  385. if (cent16 == 4) return 57.5;
  386. if (cent16 == 5) return 52.5;
  387. if (cent16 == 6) return 47.5;
  388. if (cent16 == 7) return 42.5;
  389. if (cent16 == 8) return 37.5;
  390. if (cent16 == 9) return 32.5;
  391. if (cent16 == 10) return 27.5;
  392. if (cent16 == 11) return 22.5;
  393. if (cent16 == 12) return 17.5;
  394. if (cent16 == 13) return 12.5;
  395. if (cent16 == 14) return 7.5;
  396. if (cent16 == 15) return 2.5;
  397. return -1.;
  398. }
  399. //--------------------------------------------------------------------------------------------------------------------------//
  400. //this function simply connects the gain values read in to the BBC azimuthal distribution
  401. //since tiles 7 and 9 (+ 13 and 15) share a gain value it is ambiguous how to assign the geometry here
  402. //It is preferred sometimes assigning the angle between the tiles thus "greying out" the adcs.
  403. //Others have assigned all of the adc to one (exclusive) or the the other.
  404. TVector3 GetBbcPositionEast(int imod)
  405. {
  406. double z_pos = -375.; // in cm
  407. double radius=0.;;
  408. // Radius here is an artificial value just to distinguish between different rings of BBC modules.
  409. // It does not represent the true geometrical positions of the modules themself.
  410. if (imod >=0 && imod < 6) radius = 1.;
  411. if (imod >=6 && imod < 16) radius = 2.;
  412. //float GetPhiInBBC(int eastWest, int bbcN) { //imod=0 to 23
  413. const float Pi = TMath::Pi();
  414. const float Phi_div = Pi / 6;
  415. float bbc_phi = Phi_div;
  416. switch(imod) {
  417. case 0: bbc_phi = 3.*Phi_div;
  418. break;
  419. case 1: bbc_phi = Phi_div;
  420. break;
  421. case 2: bbc_phi = -1.*Phi_div;
  422. break;
  423. case 3: bbc_phi = -3.*Phi_div;
  424. break;
  425. case 4: bbc_phi = -5.*Phi_div;
  426. break;
  427. case 5: bbc_phi = 5.*Phi_div;
  428. break;
  429. //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
  430. case 6: bbc_phi = 3.*Phi_div;
  431. break;
  432. case 7: bbc_phi = 3.*Phi_div;
  433. break;
  434. case 8: bbc_phi = Phi_div;
  435. break;
  436. case 9: bbc_phi = 0.;
  437. break;
  438. case 10: bbc_phi = -1.*Phi_div;
  439. break;
  440. //case 11: bbc_phi = (mRndm.Rndm() > 0.5) ? -2.*Phi_div:-4.*Phi_div; //tiles 13 and 15 are gained together
  441. case 11: bbc_phi = -3.*Phi_div;
  442. break;
  443. case 12: bbc_phi = -3.*Phi_div;
  444. break;
  445. case 13: bbc_phi = -5.*Phi_div;
  446. break;
  447. case 14: bbc_phi = Pi;
  448. break;
  449. case 15: bbc_phi = 5.*Phi_div;
  450. break;
  451. }
  452. //if we're looking at the east BBC we need to flip around x in the STAR coordinates,
  453. //a line parallel to the beam would go through tile 1 on the W BBC and tile 3 on the
  454. // E BBC
  455. if (bbc_phi > -0.001){ //this is not a >= since we are talking about finite adcs -- not to important
  456. bbc_phi = Pi - bbc_phi;
  457. }
  458. else {
  459. bbc_phi= -Pi - bbc_phi;
  460. }
  461. if(bbc_phi < 0.0) bbc_phi += 2.*Pi;
  462. if(bbc_phi > 2.*Pi) bbc_phi -= 2.*Pi;
  463. TVector3 vresult;
  464. vresult.SetXYZ(radius*TMath::Cos(bbc_phi), radius*TMath::Sin(bbc_phi), z_pos);
  465. return vresult;
  466. }
  467. TVector3 GetBbcPositionWest(int imod)
  468. {
  469. double z_pos = 375.; // in cm
  470. double radius=0.;;
  471. // Radius here is an artificial value just to distinguish between different rings of BBC modules.
  472. // It does not represent the true geometrical positions of the modules themself.
  473. if (imod >=0 && imod < 6) radius = 1.;
  474. if (imod >=6 && imod < 16) radius = 2.;
  475. //float GetPhiInBBC(int eastWest, int bbcN) { //imod=0 to 23
  476. const float Pi = TMath::Pi();
  477. const float Phi_div = Pi / 6;
  478. float bbc_phi = Phi_div;
  479. switch(imod) {
  480. case 0: bbc_phi = 3.*Phi_div;
  481. break;
  482. case 1: bbc_phi = Phi_div;
  483. break;
  484. case 2: bbc_phi = -1.*Phi_div;
  485. break;
  486. case 3: bbc_phi = -3.*Phi_div;
  487. break;
  488. case 4: bbc_phi = -5.*Phi_div;
  489. break;
  490. case 5: bbc_phi = 5.*Phi_div;
  491. break;
  492. //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
  493. case 6: bbc_phi = 3.*Phi_div;
  494. break;
  495. case 7: bbc_phi = 3.*Phi_div;
  496. break;
  497. case 8: bbc_phi = Phi_div;
  498. break;
  499. case 9: bbc_phi = 0.;
  500. break;
  501. case 10: bbc_phi = -1.*Phi_div;
  502. break;
  503. //case 11: bbc_phi = (mRndm.Rndm() > 0.5) ? -2.*Phi_div:-4.*Phi_div; //tiles 13 and 15 are gained together
  504. case 11: bbc_phi = -3.*Phi_div;
  505. break;
  506. case 12: bbc_phi = -3.*Phi_div;
  507. break;
  508. case 13: bbc_phi = -5.*Phi_div;
  509. break;
  510. case 14: bbc_phi = Pi;
  511. break;
  512. case 15: bbc_phi = 5.*Phi_div;
  513. break;
  514. }
  515. if(bbc_phi < 0.0) bbc_phi += 2.*Pi;
  516. if(bbc_phi > 2.*Pi) bbc_phi -= 2.*Pi;
  517. TVector3 vresult;
  518. vresult.SetXYZ(radius*TMath::Cos(bbc_phi), radius*TMath::Sin(bbc_phi), z_pos);
  519. return vresult;
  520. }
  521. // Get position of each slat;strip starts from 0
  522. TVector3 GetZdcPositionXEast(int strip)
  523. {
  524. TVector3 vresult;
  525. double x_pos, y_pos;
  526. double z_pos = -1800.; // in cm
  527. Double_t zdcsmd_x[7] = {0.5,2,3.5,5,6.5,8,9.5};
  528. Double_t mZDCSMDCenterex = 4.72466;
  529. Double_t mZDCSMDCenterey = 5.53629;
  530. y_pos = mZDCSMDCenterey;
  531. if (strip>=0 && strip<7)
  532. {
  533. x_pos = zdcsmd_x[strip]-mZDCSMDCenterex;
  534. }
  535. else
  536. {
  537. x_pos = 0.;
  538. }
  539. vresult.SetXYZ(x_pos, y_pos, z_pos);
  540. return vresult;
  541. }
  542. TVector3 GetZdcPositionYEast(int strip)
  543. {
  544. TVector3 vresult;
  545. double x_pos, y_pos;
  546. double z_pos = -1800.; // in cm
  547. Double_t zdcsmd_y[8] = {1.25,3.25,5.25,7.25,9.25,11.25,13.25,15.25};
  548. Double_t mZDCSMDCenterex = 4.72466;
  549. Double_t mZDCSMDCenterey = 5.53629;
  550. x_pos = mZDCSMDCenterex;
  551. if (strip>=0 && strip<8)
  552. {
  553. y_pos = zdcsmd_y[strip]/TMath::Sqrt(2.)-mZDCSMDCenterey;
  554. }
  555. else
  556. {
  557. x_pos = 0.;
  558. }
  559. vresult.SetXYZ(x_pos, y_pos, z_pos);
  560. return vresult;
  561. }
  562. // Get position of each slat;strip starts from 0
  563. TVector3 GetZdcPositionXWest(int strip)
  564. {
  565. TVector3 vresult;
  566. double x_pos, y_pos;
  567. double z_pos = 1800.; // in cm
  568. Double_t zdcsmd_x[7] = {0.5,2,3.5,5,6.5,8,9.5};
  569. Double_t mZDCSMDCenterwx = 4.39604;
  570. Double_t mZDCSMDCenterwy = 5.19968;
  571. y_pos = mZDCSMDCenterwy;
  572. if (strip>=0 && strip<7)
  573. {
  574. x_pos = mZDCSMDCenterwx-zdcsmd_x[strip];
  575. }
  576. else
  577. {
  578. x_pos = 0.;
  579. }
  580. vresult.SetXYZ(x_pos, y_pos, z_pos);
  581. return vresult;
  582. }
  583. // Get position of each slat;strip starts from 0
  584. TVector3 GetZdcPositionYWest(int strip)
  585. {
  586. TVector3 vresult;
  587. double x_pos, y_pos;
  588. double z_pos = 1800.; // in cm
  589. Double_t zdcsmd_y[8] = {1.25,3.25,5.25,7.25,9.25,11.25,13.25,15.25};
  590. Double_t mZDCSMDCenterwx = 4.39604;
  591. Double_t mZDCSMDCenterwy = 5.19968;
  592. x_pos = mZDCSMDCenterwx;
  593. if (strip>=0 && strip<8)
  594. {
  595. y_pos = zdcsmd_y[strip]/sqrt(2.)-mZDCSMDCenterwy;
  596. }
  597. else
  598. {
  599. y_pos = 0.;
  600. }
  601. vresult.SetXYZ(x_pos, y_pos, z_pos);
  602. return vresult;
  603. }