obj_types.cpp 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. #include "filval/filval.hpp"
  2. #include "filval/root/filval.hpp"
  3. #include<cmath>
  4. #include "TrackingNtuple.h"
  5. using namespace std;
  6. using namespace fv;
  7. using namespace fv::root;
  8. typedef TreeDataSet<TrackingNtuple> TrackingDataSet;
  9. //#^#=========================================================================
  10. //==============PIXEL REC HIT=================================================
  11. //============================================================================
  12. struct PixRecHit {
  13. unsigned int idx;
  14. unsigned short det;
  15. unsigned short lay;
  16. unsigned short ladder_blade;
  17. unsigned int detId;
  18. unsigned short simType;
  19. float x;
  20. float y;
  21. float z;
  22. float xx;
  23. float xy;
  24. float yy;
  25. float yz;
  26. float zz;
  27. float zx;
  28. float radL;
  29. float bbxi;
  30. vector<int> trkIdx;
  31. vector<int> seeIdx;
  32. vector<int> simHitIdx;
  33. vector<float> chargeFraction;
  34. float phi() const {
  35. return atan2(x, y);
  36. }
  37. };
  38. Value<vector<PixRecHit>>*
  39. register_pixrec_hits(TrackingDataSet &tds){
  40. auto builder = func<std::vector<PixRecHit>(vector<unsigned short>,
  41. vector<unsigned short>,
  42. vector<unsigned short>,
  43. vector<unsigned int>,
  44. vector<unsigned short>,
  45. vector<float>,
  46. vector<float>,
  47. vector<float>,
  48. vector<float>,
  49. vector<float>,
  50. vector<float>,
  51. vector<float>,
  52. vector<float>,
  53. vector<float>,
  54. vector<float>,
  55. vector<float>,
  56. vector<vector<int>>,
  57. vector<vector<int>>,
  58. vector<vector<int>>,
  59. vector<vector<float>>)>("build_pixrec_hits",
  60. FUNC(([](const vector<unsigned short>& det,
  61. const vector<unsigned short>& lay,
  62. const vector<unsigned short>& ladder_blade,
  63. const vector<unsigned int>& detId,
  64. const vector<unsigned short>& simType,
  65. const vector<float>& x,
  66. const vector<float>& y,
  67. const vector<float>& z,
  68. const vector<float>& xx,
  69. const vector<float>& xy,
  70. const vector<float>& yy,
  71. const vector<float>& yz,
  72. const vector<float>& zz,
  73. const vector<float>& zx,
  74. const vector<float>& radL,
  75. const vector<float>& bbxi,
  76. const vector<vector<int>>& trkIdx,
  77. const vector<vector<int>>& seeIdx,
  78. const vector<vector<int>>& simHitIdx,
  79. const vector<vector<float>>& chargeFraction){
  80. std::vector<PixRecHit> pixrec_hits;
  81. for(unsigned int i=0; i<det.size(); i++)
  82. pixrec_hits.push_back({i,
  83. det[i],
  84. lay[i],
  85. ladder_blade[i],
  86. detId[i],
  87. simType[i],
  88. x[i],
  89. y[i],
  90. z[i],
  91. xx[i],
  92. xy[i],
  93. yy[i],
  94. yz[i],
  95. zz[i],
  96. zx[i],
  97. radL[i],
  98. bbxi[i],
  99. trkIdx[i],
  100. seeIdx[i],
  101. simHitIdx[i],
  102. chargeFraction[i]
  103. });
  104. return pixrec_hits;
  105. })));
  106. return tup_apply(builder,
  107. fv::tuple(tds.track_branch_obj<vector<unsigned short>>("pix_det"),
  108. tds.track_branch_obj<vector<unsigned short>>("pix_lay"),
  109. tds.track_branch_obj<vector<unsigned short>>("pix_ladder_blade"),
  110. tds.track_branch_obj<vector<unsigned int>>("pix_detId"),
  111. tds.track_branch_obj<vector<unsigned short>>("pix_simType"),
  112. tds.track_branch_obj<vector<float>>("pix_x"),
  113. tds.track_branch_obj<vector<float>>("pix_y"),
  114. tds.track_branch_obj<vector<float>>("pix_z"),
  115. tds.track_branch_obj<vector<float>>("pix_xx"),
  116. tds.track_branch_obj<vector<float>>("pix_xy"),
  117. tds.track_branch_obj<vector<float>>("pix_yy"),
  118. tds.track_branch_obj<vector<float>>("pix_yz"),
  119. tds.track_branch_obj<vector<float>>("pix_zz"),
  120. tds.track_branch_obj<vector<float>>("pix_zx"),
  121. tds.track_branch_obj<vector<float>>("pix_radL"),
  122. tds.track_branch_obj<vector<float>>("pix_bbxi"),
  123. tds.track_branch_obj<vector<vector<int>>>("pix_trkIdx"),
  124. tds.track_branch_obj<vector<vector<int>>>("pix_seeIdx"),
  125. tds.track_branch_obj<vector<vector<int>>>("pix_simHitIdx"),
  126. tds.track_branch_obj<vector<vector<float>>>("pix_chargeFraction")),
  127. "pixrec_hits");
  128. }
  129. //#^#=========================================================================
  130. //===================SIM HIT==================================================
  131. //============================================================================
  132. struct SimHit {
  133. unsigned int idx;
  134. unsigned short det;
  135. unsigned short lay;
  136. unsigned int detId;
  137. float x;
  138. float y;
  139. float z;
  140. int particle;
  141. short process;
  142. float eloss;
  143. float tof;
  144. int simTrkIdx;
  145. vector<int> hitIdx;
  146. vector<int> hitType;
  147. };
  148. Value<vector<SimHit>>*
  149. register_sim_hits(TrackingDataSet &tds){
  150. auto builder =
  151. func<std::vector<SimHit>(vector<unsigned short>, // det;
  152. vector<unsigned short>, // lay;
  153. vector<unsigned int>, // detId;
  154. vector<float>, // x;
  155. vector<float>, // y;
  156. vector<float>, // z;
  157. vector<int> , // particle;
  158. vector<short>, // process;
  159. vector<float>, // eloss;
  160. vector<float>, // tof;
  161. vector<int> , // simTrkIdx;
  162. vector<vector<int>>, // hitIdx;
  163. vector<vector<int>> // hitType;
  164. )>("build_sim_hits", FUNC(([](
  165. const vector<unsigned short>& det,
  166. const vector<unsigned short>& lay,
  167. const vector<unsigned int>& detId,
  168. const vector<float>& x,
  169. const vector<float>& y,
  170. const vector<float>& z,
  171. const vector<int>& particle,
  172. const vector<short>& process,
  173. const vector<float>& eloss,
  174. const vector<float>& tof,
  175. const vector<int>& simTrkIdx,
  176. const vector<vector<int>>& hitIdx,
  177. const vector<vector<int>>& hitType
  178. ){
  179. std::vector<SimHit> sim_hits;
  180. for(unsigned int i=0; i<det.size(); i++)
  181. sim_hits.push_back({i,
  182. det[i],
  183. lay[i],
  184. detId[i],
  185. x[i],
  186. y[i],
  187. z[i],
  188. particle[i],
  189. process[i],
  190. eloss[i],
  191. tof[i],
  192. simTrkIdx[i],
  193. hitIdx[i],
  194. hitType[i]});
  195. return sim_hits;
  196. })));
  197. return tup_apply(builder,
  198. fv::tuple(tds.track_branch_obj<vector<unsigned short>>("simhit_det"),
  199. tds.track_branch_obj<vector<unsigned short>>("simhit_lay"),
  200. tds.track_branch_obj<vector<unsigned int>>("simhit_detId"),
  201. tds.track_branch_obj<vector<float>>("simhit_x"),
  202. tds.track_branch_obj<vector<float>>("simhit_y"),
  203. tds.track_branch_obj<vector<float>>("simhit_z"),
  204. tds.track_branch_obj<vector<int>>("simhit_particle"),
  205. tds.track_branch_obj<vector<short>>("simhit_process"),
  206. tds.track_branch_obj<vector<float>>("simhit_eloss"),
  207. tds.track_branch_obj<vector<float>>("simhit_tof"),
  208. tds.track_branch_obj<vector<int>>("simhit_simTrkIdx"),
  209. tds.track_branch_obj<vector<vector<int>>>("simhit_hitIdx"),
  210. tds.track_branch_obj<vector<vector<int>>>("simhit_hitType")),
  211. "sim_hits");
  212. }
  213. //#^#=========================================================================
  214. //=======================SEED=================================================
  215. //============================================================================
  216. struct Seed {
  217. unsigned int idx;
  218. short fitok;
  219. float px;
  220. float py;
  221. float pz;
  222. float pt;
  223. float eta;
  224. float phi;
  225. float dxy;
  226. float dz;
  227. float ptErr;
  228. float etaErr;
  229. float phiErr;
  230. float dxyErr;
  231. float dzErr;
  232. float chi2;
  233. int q;
  234. unsigned int nValid;
  235. unsigned int nPixel;
  236. unsigned int nGlued;
  237. unsigned int nStrip;
  238. unsigned int algo;
  239. unsigned int algoOriginal;
  240. int trkIdx;
  241. vector<float> shareFrac;
  242. vector<int> simTrkIdx;
  243. vector<int> hitIdx;
  244. vector<int> hitType;
  245. unsigned int offset;
  246. unsigned char hitsMask;
  247. int subDet2;
  248. float dRz2;
  249. float dPhi2;
  250. float dRz2Pos;
  251. float dPhi2Pos;
  252. int subDet1;
  253. float dRz1;
  254. float dPhi1;
  255. float dRz1Pos;
  256. float dPhi1Pos;
  257. float hoe1;
  258. float hoe2;
  259. float superClusterEnergy;
  260. float superClusterEta;
  261. float superClusterPhi;
  262. float superClusterEt;
  263. int superClusterIdx;
  264. unsigned int ecalDriven;
  265. unsigned int trkDriven;
  266. };
  267. Value<vector<Seed>>*
  268. register_seeds(TrackingDataSet &tds){
  269. auto builder = func<std::vector<Seed>(vector<short>, // fitok;
  270. vector<float>, // px;
  271. vector<float>, // py;
  272. vector<float>, // pz;
  273. vector<float>, // pt;
  274. vector<float>, // eta;
  275. vector<float>, // phi;
  276. vector<float>, // dxy;
  277. vector<float>, // dz;
  278. vector<float>, // ptErr;
  279. vector<float>, // etaErr;
  280. vector<float>, // phiErr;
  281. vector<float>, // dxyErr;
  282. vector<float>, // dzErr;
  283. vector<float>, // chi2;
  284. vector<int>, // q;
  285. vector<unsigned int>, // nValid;
  286. vector<unsigned int>, // nPixel;
  287. vector<unsigned int>, // nGlued;
  288. vector<unsigned int>, // nStrip;
  289. vector<unsigned int>, // algo;
  290. vector<unsigned int>, // algoOriginal;
  291. vector<int>, // trkIdx;
  292. vector<vector<float> >, // shareFrac;
  293. vector<vector<int> >, // simTrkIdx;
  294. vector<vector<int> >, // hitIdx;
  295. vector<vector<int> >, // hitType;
  296. vector<unsigned int>, // offset;
  297. vector<unsigned char>, // hitsMask;
  298. vector<int>, // subDet2;
  299. vector<float>, // dRz2;
  300. vector<float>, // dPhi2;
  301. vector<float>, // dRz2Pos;
  302. vector<float>, // dPhi2Pos;
  303. vector<int>, // subDet1;
  304. vector<float>, // dRz1;
  305. vector<float>, // dPhi1;
  306. vector<float>, // dRz1Pos;
  307. vector<float>, // dPhi1Pos;
  308. vector<float>, // hoe1;
  309. vector<float>, // hoe2;
  310. vector<float>, // superClusterEnergy;
  311. vector<float>, // superClusterEta;
  312. vector<float>, // superClusterPhi;
  313. vector<float>, // superClusterEt;
  314. vector<int>, // superClusterIdx;
  315. vector<unsigned int>, // ecalDriven;
  316. vector<unsigned int> // trkDriven;
  317. )>("build_seeds", FUNC(([](
  318. const vector<short>& fitok,
  319. const vector<float>& px,
  320. const vector<float>& py,
  321. const vector<float>& pz,
  322. const vector<float>& pt,
  323. const vector<float>& eta,
  324. const vector<float>& phi,
  325. const vector<float>& dxy,
  326. const vector<float>& dz,
  327. const vector<float>& ptErr,
  328. const vector<float>& etaErr,
  329. const vector<float>& phiErr,
  330. const vector<float>& dxyErr,
  331. const vector<float>& dzErr,
  332. const vector<float>& chi2,
  333. const vector<int>& q,
  334. const vector<unsigned int>& nValid,
  335. const vector<unsigned int>& nPixel,
  336. const vector<unsigned int>& nGlued,
  337. const vector<unsigned int>& nStrip,
  338. const vector<unsigned int>& algo,
  339. const vector<unsigned int>& algoOriginal,
  340. const vector<int>& trkIdx,
  341. const vector<vector<float> >& shareFrac,
  342. const vector<vector<int> >& simTrkIdx,
  343. const vector<vector<int> >& hitIdx,
  344. const vector<vector<int> >& hitType,
  345. const vector<unsigned int>& offset,
  346. const vector<unsigned char>& hitsMask,
  347. const vector<int>& subDet2,
  348. const vector<float>& dRz2,
  349. const vector<float>& dPhi2,
  350. const vector<float>& dRz2Pos,
  351. const vector<float>& dPhi2Pos,
  352. const vector<int>& subDet1,
  353. const vector<float>& dRz1,
  354. const vector<float>& dPhi1,
  355. const vector<float>& dRz1Pos,
  356. const vector<float>& dPhi1Pos,
  357. const vector<float>& hoe1,
  358. const vector<float>& hoe2,
  359. const vector<float>& superClusterEnergy,
  360. const vector<float>& superClusterEta,
  361. const vector<float>& superClusterPhi,
  362. const vector<float>& superClusterEt,
  363. const vector<int>& superClusterIdx,
  364. const vector<unsigned int>& ecalDriven,
  365. const vector<unsigned int>& trkDriven){
  366. std::vector<Seed> seeds;
  367. for(unsigned int i=0; i<fitok.size(); i++)
  368. seeds.push_back({i,
  369. fitok[i],
  370. px[i],
  371. py[i],
  372. pz[i],
  373. pt[i],
  374. eta[i],
  375. phi[i],
  376. dxy[i],
  377. dz[i],
  378. ptErr[i],
  379. etaErr[i],
  380. phiErr[i],
  381. dxyErr[i],
  382. dzErr[i],
  383. chi2[i],
  384. q[i],
  385. nValid[i],
  386. nPixel[i],
  387. nGlued[i],
  388. nStrip[i],
  389. algo[i],
  390. algoOriginal[i],
  391. trkIdx[i],
  392. shareFrac[i],
  393. simTrkIdx[i],
  394. hitIdx[i],
  395. hitType[i],
  396. offset[i],
  397. hitsMask[i],
  398. subDet2[i],
  399. dRz2[i],
  400. dPhi2[i],
  401. dRz2Pos[i],
  402. dPhi2Pos[i],
  403. subDet1[i],
  404. dRz1[i],
  405. dPhi1[i],
  406. dRz1Pos[i],
  407. dPhi1Pos[i],
  408. hoe1[i],
  409. hoe2[i],
  410. superClusterEnergy[i],
  411. superClusterEta[i],
  412. superClusterPhi[i],
  413. superClusterEt[i],
  414. superClusterIdx[i],
  415. ecalDriven[i],
  416. trkDriven[i]});
  417. return seeds;
  418. })));
  419. return tup_apply(builder,
  420. fv::tuple(tds.track_branch_obj<vector<short>>("see_fitok"),
  421. tds.track_branch_obj<vector<float>>("see_px"),
  422. tds.track_branch_obj<vector<float>>("see_py"),
  423. tds.track_branch_obj<vector<float>>("see_pz"),
  424. tds.track_branch_obj<vector<float>>("see_pt"),
  425. tds.track_branch_obj<vector<float>>("see_eta"),
  426. tds.track_branch_obj<vector<float>>("see_phi"),
  427. tds.track_branch_obj<vector<float>>("see_dxy"),
  428. tds.track_branch_obj<vector<float>>("see_dz"),
  429. tds.track_branch_obj<vector<float>>("see_ptErr"),
  430. tds.track_branch_obj<vector<float>>("see_etaErr"),
  431. tds.track_branch_obj<vector<float>>("see_phiErr"),
  432. tds.track_branch_obj<vector<float>>("see_dxyErr"),
  433. tds.track_branch_obj<vector<float>>("see_dzErr"),
  434. tds.track_branch_obj<vector<float>>("see_chi2"),
  435. tds.track_branch_obj<vector<int>>("see_q"),
  436. tds.track_branch_obj<vector<unsigned int>>("see_nValid"),
  437. tds.track_branch_obj<vector<unsigned int>>("see_nPixel"),
  438. tds.track_branch_obj<vector<unsigned int>>("see_nGlued"),
  439. tds.track_branch_obj<vector<unsigned int>>("see_nStrip"),
  440. tds.track_branch_obj<vector<unsigned int>>("see_algo"),
  441. tds.track_branch_obj<vector<unsigned int>>("see_algoOriginal"),
  442. tds.track_branch_obj<vector<int>>("see_trkIdx"),
  443. tds.track_branch_obj<vector<vector<float> >> ("see_shareFrac"),
  444. tds.track_branch_obj<vector<vector<int> >>("see_simTrkIdx"),
  445. tds.track_branch_obj<vector<vector<int> >>("see_hitIdx"),
  446. tds.track_branch_obj<vector<vector<int> >>("see_hitType"),
  447. tds.track_branch_obj<vector<unsigned int>>("see_offset"),
  448. tds.track_branch_obj<vector<unsigned char>>("see_hitsMask"),
  449. tds.track_branch_obj<vector<int>>("see_subDet2"),
  450. tds.track_branch_obj<vector<float>>("see_dRz2"),
  451. tds.track_branch_obj<vector<float>>("see_dPhi2"),
  452. tds.track_branch_obj<vector<float>>("see_dRz2Pos"),
  453. tds.track_branch_obj<vector<float>>("see_dPhi2Pos"),
  454. tds.track_branch_obj<vector<int>>("see_subDet1"),
  455. tds.track_branch_obj<vector<float>>("see_dRz1"),
  456. tds.track_branch_obj<vector<float>>("see_dPhi1"),
  457. tds.track_branch_obj<vector<float>>("see_dRz1Pos"),
  458. tds.track_branch_obj<vector<float>>("see_dPhi1Pos"),
  459. tds.track_branch_obj<vector<float>>("see_hoe1"),
  460. tds.track_branch_obj<vector<float>>("see_hoe2"),
  461. tds.track_branch_obj<vector<float>>("see_superClusterEnergy"),
  462. tds.track_branch_obj<vector<float>>("see_superClusterEta"),
  463. tds.track_branch_obj<vector<float>>("see_superClusterPhi"),
  464. tds.track_branch_obj<vector<float>>("see_superClusterEt"),
  465. tds.track_branch_obj<vector<int>>("see_superClusterIdx"),
  466. tds.track_branch_obj<vector<unsigned int>>("see_ecalDriven"),
  467. tds.track_branch_obj<vector<unsigned int>>("see_trkDriven")),
  468. "seeds");
  469. }
  470. //#^#=========================================================================
  471. //=======================TRACK================================================
  472. //============================================================================
  473. struct Track{
  474. unsigned int idx;
  475. float px;
  476. float py;
  477. float pz;
  478. float pt;
  479. float inner_px;
  480. float inner_py;
  481. float inner_pz;
  482. float inner_pt;
  483. float outer_px;
  484. float outer_py;
  485. float outer_pz;
  486. float outer_pt;
  487. float eta;
  488. float lambda;
  489. float cotTheta;
  490. float phi;
  491. float dxy;
  492. float dz;
  493. float ptErr;
  494. float etaErr;
  495. float lambdaErr;
  496. float phiErr;
  497. float dxyErr;
  498. float dzErr;
  499. float refpoint_x;
  500. float refpoint_y;
  501. float refpoint_z;
  502. float nChi2;
  503. int q;
  504. unsigned int nValid;
  505. unsigned int nInvalid;
  506. unsigned int nPixel;
  507. unsigned int nStrip;
  508. unsigned int nPixelLay;
  509. unsigned int nStripLay;
  510. unsigned int n3DLay;
  511. unsigned int nOuterLost;
  512. unsigned int nInnerLost;
  513. unsigned int algo;
  514. unsigned int originalAlgo;
  515. ULong64_t algoMask;
  516. unsigned int stopReason;
  517. short isHP;
  518. int seedIdx;
  519. float vtxx;
  520. float vtxy;
  521. float vtxz;
  522. vector<float> shareFrac;
  523. vector<int> simTrkIdx;
  524. vector<int> hitIdx;
  525. vector<int> hitType;
  526. int genIdx;
  527. float genDR;
  528. };
  529. Value<vector<Track>>*
  530. register_tracks(TrackingDataSet &tds){
  531. auto builder =
  532. func<std::vector<Track>(vector<float>, // px;
  533. vector<float>, // py;
  534. vector<float>, // pz;
  535. vector<float>, // pt;
  536. vector<float>, // inner_px;
  537. vector<float>, // inner_py;
  538. vector<float>, // inner_pz;
  539. vector<float>, // inner_pt;
  540. vector<float>, // outer_px;
  541. vector<float>, // outer_py;
  542. vector<float>, // outer_pz;
  543. vector<float>, // outer_pt;
  544. vector<float>, // eta;
  545. vector<float>, // lambda;
  546. vector<float>, // cotTheta;
  547. vector<float>, // phi;
  548. vector<float>, // dxy;
  549. vector<float>, // dz;
  550. vector<float>, // ptErr;
  551. vector<float>, // etaErr;
  552. vector<float>, // lambdaErr;
  553. vector<float>, // phiErr;
  554. vector<float>, // dxyErr;
  555. vector<float>, // dzErr;
  556. vector<float>, // refpoint_x;
  557. vector<float>, // refpoint_y;
  558. vector<float>, // refpoint_z;
  559. vector<float>, // nChi2;
  560. vector<int>, // q;
  561. vector<unsigned int>, // nValid;
  562. vector<unsigned int>, // nInvalid;
  563. vector<unsigned int>, // nPixel;
  564. vector<unsigned int>, // nStrip;
  565. vector<unsigned int>, // nPixelLay;
  566. vector<unsigned int>, // nStripLay;
  567. vector<unsigned int>, // n3DLay;
  568. vector<unsigned int>, // nOuterLost;
  569. vector<unsigned int>, // nInnerLost;
  570. vector<unsigned int>, // algo;
  571. vector<unsigned int>, // originalAlgo;
  572. vector<ULong64_t>, // algoMask;
  573. vector<unsigned int>, // stopReason;
  574. vector<short>, // isHP;
  575. vector<int>, // seedIdx;
  576. vector<float>, // vtxx;
  577. vector<float>, // vtxy;
  578. vector<float>, // vtxz;
  579. vector<vector<float>>, // shareFrac;
  580. vector<vector<int>>, // simTrkIdx;
  581. vector<vector<int>>, // hitIdx;
  582. vector<vector<int>>, // hitType;
  583. vector<int>, // genIdx;
  584. vector<float> // genDR;
  585. )>("build_tracks", FUNC(([](const vector<float>& px,
  586. const vector<float>& py,
  587. const vector<float>& pz,
  588. const vector<float>& pt,
  589. const vector<float>& inner_px,
  590. const vector<float>& inner_py,
  591. const vector<float>& inner_pz,
  592. const vector<float>& inner_pt,
  593. const vector<float>& outer_px,
  594. const vector<float>& outer_py,
  595. const vector<float>& outer_pz,
  596. const vector<float>& outer_pt,
  597. const vector<float>& eta,
  598. const vector<float>& lambda,
  599. const vector<float>& cotTheta,
  600. const vector<float>& phi,
  601. const vector<float>& dxy,
  602. const vector<float>& dz,
  603. const vector<float>& ptErr,
  604. const vector<float>& etaErr,
  605. const vector<float>& lambdaErr,
  606. const vector<float>& phiErr,
  607. const vector<float>& dxyErr,
  608. const vector<float>& dzErr,
  609. const vector<float>& refpoint_x,
  610. const vector<float>& refpoint_y,
  611. const vector<float>& refpoint_z,
  612. const vector<float>& nChi2,
  613. const vector<int>& q,
  614. const vector<unsigned int>& nValid,
  615. const vector<unsigned int>& nInvalid,
  616. const vector<unsigned int>& nPixel,
  617. const vector<unsigned int>& nStrip,
  618. const vector<unsigned int>& nPixelLay,
  619. const vector<unsigned int>& nStripLay,
  620. const vector<unsigned int>& n3DLay,
  621. const vector<unsigned int>& nOuterLost,
  622. const vector<unsigned int>& nInnerLost,
  623. const vector<unsigned int>& algo,
  624. const vector<unsigned int>& originalAlgo,
  625. const vector<ULong64_t>& algoMask,
  626. const vector<unsigned int>& stopReason,
  627. const vector<short>& isHP,
  628. const vector<int>& seedIdx,
  629. const vector<float>& vtxx,
  630. const vector<float>& vtxy,
  631. const vector<float>& vtxz,
  632. const vector<vector<float>>& shareFrac,
  633. const vector<vector<int>>& simTrkIdx,
  634. const vector<vector<int>>& hitIdx,
  635. const vector<vector<int>>& hitType,
  636. const vector<int>& genIdx,
  637. const vector<float>& genDR){
  638. std::vector<Track> tracks;
  639. for(unsigned int i=0; i<px.size(); i++)
  640. tracks.push_back({i,
  641. px[i],
  642. py[i],
  643. pz[i],
  644. pt[i],
  645. inner_px[i],
  646. inner_py[i],
  647. inner_pz[i],
  648. inner_pt[i],
  649. outer_px[i],
  650. outer_py[i],
  651. outer_pz[i],
  652. outer_pt[i],
  653. eta[i],
  654. lambda[i],
  655. cotTheta[i],
  656. phi[i],
  657. dxy[i],
  658. dz[i],
  659. ptErr[i],
  660. etaErr[i],
  661. lambdaErr[i],
  662. phiErr[i],
  663. dxyErr[i],
  664. dzErr[i],
  665. refpoint_x[i],
  666. refpoint_y[i],
  667. refpoint_z[i],
  668. nChi2[i],
  669. q[i],
  670. nValid[i],
  671. nInvalid[i],
  672. nPixel[i],
  673. nStrip[i],
  674. nPixelLay[i],
  675. nStripLay[i],
  676. n3DLay[i],
  677. nOuterLost[i],
  678. nInnerLost[i],
  679. algo[i],
  680. originalAlgo[i],
  681. algoMask[i],
  682. stopReason[i],
  683. isHP[i],
  684. seedIdx[i],
  685. vtxx[i],
  686. vtxy[i],
  687. vtxz[i],
  688. shareFrac[i],
  689. simTrkIdx[i],
  690. hitIdx[i],
  691. hitType[i],
  692. genIdx[i],
  693. genDR[i]});
  694. return tracks;
  695. })));
  696. return tup_apply(builder,
  697. fv::tuple(tds.track_branch_obj<vector<float>>("trk_px"),
  698. tds.track_branch_obj<vector<float>>("trk_py"),
  699. tds.track_branch_obj<vector<float>>("trk_pz"),
  700. tds.track_branch_obj<vector<float>>("trk_pt"),
  701. tds.track_branch_obj<vector<float>>("trk_inner_px"),
  702. tds.track_branch_obj<vector<float>>("trk_inner_py"),
  703. tds.track_branch_obj<vector<float>>("trk_inner_pz"),
  704. tds.track_branch_obj<vector<float>>("trk_inner_pt"),
  705. tds.track_branch_obj<vector<float>>("trk_outer_px"),
  706. tds.track_branch_obj<vector<float>>("trk_outer_py"),
  707. tds.track_branch_obj<vector<float>>("trk_outer_pz"),
  708. tds.track_branch_obj<vector<float>>("trk_outer_pt"),
  709. tds.track_branch_obj<vector<float>>("trk_eta"),
  710. tds.track_branch_obj<vector<float>>("trk_lambda"),
  711. tds.track_branch_obj<vector<float>>("trk_cotTheta"),
  712. tds.track_branch_obj<vector<float>>("trk_phi"),
  713. tds.track_branch_obj<vector<float>>("trk_dxy"),
  714. tds.track_branch_obj<vector<float>>("trk_dz"),
  715. tds.track_branch_obj<vector<float>>("trk_ptErr"),
  716. tds.track_branch_obj<vector<float>>("trk_etaErr"),
  717. tds.track_branch_obj<vector<float>>("trk_lambdaErr"),
  718. tds.track_branch_obj<vector<float>>("trk_phiErr"),
  719. tds.track_branch_obj<vector<float>>("trk_dxyErr"),
  720. tds.track_branch_obj<vector<float>>("trk_dzErr"),
  721. tds.track_branch_obj<vector<float>>("trk_refpoint_x"),
  722. tds.track_branch_obj<vector<float>>("trk_refpoint_y"),
  723. tds.track_branch_obj<vector<float>>("trk_refpoint_z"),
  724. tds.track_branch_obj<vector<float>>("trk_nChi2"),
  725. tds.track_branch_obj<vector<int>>("trk_q"),
  726. tds.track_branch_obj<vector<unsigned int>>("trk_nValid"),
  727. tds.track_branch_obj<vector<unsigned int>>("trk_nInvalid"),
  728. tds.track_branch_obj<vector<unsigned int>>("trk_nPixel"),
  729. tds.track_branch_obj<vector<unsigned int>>("trk_nStrip"),
  730. tds.track_branch_obj<vector<unsigned int>>("trk_nPixelLay"),
  731. tds.track_branch_obj<vector<unsigned int>>("trk_nStripLay"),
  732. tds.track_branch_obj<vector<unsigned int>>("trk_n3DLay"),
  733. tds.track_branch_obj<vector<unsigned int>>("trk_nOuterLost"),
  734. tds.track_branch_obj<vector<unsigned int>>("trk_nInnerLost"),
  735. tds.track_branch_obj<vector<unsigned int>>("trk_algo"),
  736. tds.track_branch_obj<vector<unsigned int>>("trk_originalAlgo"),
  737. tds.track_branch_obj<vector<ULong64_t>>("trk_algoMask"),
  738. tds.track_branch_obj<vector<unsigned int>>("trk_stopReason"),
  739. tds.track_branch_obj<vector<short>>("trk_isHP"),
  740. tds.track_branch_obj<vector<int>>("trk_seedIdx"),
  741. tds.track_branch_obj<vector<float>>("trk_vtxx"),
  742. tds.track_branch_obj<vector<float>>("trk_vtxy"),
  743. tds.track_branch_obj<vector<float>>("trk_vtxz"),
  744. tds.track_branch_obj<vector<vector<float>>>("trk_shareFrac"),
  745. tds.track_branch_obj<vector<vector<int>>>("trk_simTrkIdx"),
  746. tds.track_branch_obj<vector<vector<int>>>("trk_hitIdx"),
  747. tds.track_branch_obj<vector<vector<int>>>("trk_hitType"),
  748. tds.track_branch_obj<vector<int>>("trk_genIdx"),
  749. tds.track_branch_obj<vector<float>>("trk_genDR")),
  750. "tracks");
  751. }
  752. //#^#=========================================================================
  753. //===================SIM TRACK================================================
  754. //============================================================================
  755. struct SimTrack{
  756. unsigned int idx;
  757. int event;
  758. int bunchCrossing;
  759. int pdgId;
  760. float px;
  761. float py;
  762. float pz;
  763. float pt;
  764. float eta;
  765. float phi;
  766. float pca_pt;
  767. float pca_eta;
  768. float pca_lambda;
  769. float pca_cotTheta;
  770. float pca_phi;
  771. float pca_dxy;
  772. float pca_dz;
  773. int q;
  774. unsigned int nValid;
  775. unsigned int nPixel;
  776. unsigned int nStrip;
  777. unsigned int nLay;
  778. unsigned int nPixelLay;
  779. unsigned int n3DLay;
  780. vector<int> trkIdx;
  781. vector<float> shareFrac;
  782. int parentVtxIdx;
  783. vector<int> decayVtxIdx;
  784. vector<int> simHitIdx;
  785. };
  786. Value<vector<SimTrack>>*
  787. register_sim_tracks(TrackingDataSet &tds){
  788. auto builder =
  789. func<std::vector<SimTrack>(vector<int>, // event;
  790. vector<int>, // bunchCrossing;
  791. vector<int>, // pdgId;
  792. vector<float>, // px;
  793. vector<float>, // py;
  794. vector<float>, // pz;
  795. vector<float>, // pt;
  796. vector<float>, // eta;
  797. vector<float>, // phi;
  798. vector<float>, // pca_pt;
  799. vector<float>, // pca_eta;
  800. vector<float>, // pca_lambda;
  801. vector<float>, // pca_cotTheta;
  802. vector<float>, // pca_phi;
  803. vector<float>, // pca_dxy;
  804. vector<float>, // pca_dz;
  805. vector<int>, // q;
  806. vector<unsigned int>, // nValid;
  807. vector<unsigned int>, // nPixel;
  808. vector<unsigned int>, // nStrip;
  809. vector<unsigned int>, // nLay;
  810. vector<unsigned int>, // nPixelLay;
  811. vector<unsigned int>, // n3DLay;
  812. vector<vector<int>>, // trkIdx;
  813. vector<vector<float>>, // shareFrac;
  814. vector<int>, // parentVtxIdx;
  815. vector<vector<int>>, // decayVtxIdx;
  816. vector<vector<int>> // simHitIdx;
  817. )>("build_sim_tracks", FUNC(([](
  818. const vector<int>& event,
  819. const vector<int>& bunchCrossing,
  820. const vector<int>& pdgId,
  821. const vector<float>& px,
  822. const vector<float>& py,
  823. const vector<float>& pz,
  824. const vector<float>& pt,
  825. const vector<float>& eta,
  826. const vector<float>& phi,
  827. const vector<float>& pca_pt,
  828. const vector<float>& pca_eta,
  829. const vector<float>& pca_lambda,
  830. const vector<float>& pca_cotTheta,
  831. const vector<float>& pca_phi,
  832. const vector<float>& pca_dxy,
  833. const vector<float>& pca_dz,
  834. const vector<int>& q,
  835. const vector<unsigned int>& nValid,
  836. const vector<unsigned int>& nPixel,
  837. const vector<unsigned int>& nStrip,
  838. const vector<unsigned int>& nLay,
  839. const vector<unsigned int>& nPixelLay,
  840. const vector<unsigned int>& n3DLay,
  841. const vector<vector<int>>& trkIdx,
  842. const vector<vector<float>>& shareFrac,
  843. const vector<int>& parentVtxIdx,
  844. const vector<vector<int>>& decayVtxIdx,
  845. const vector<vector<int>>& simHitIdx){
  846. std::vector<SimTrack> sim_tracks;
  847. for(unsigned int i=0; i<event.size(); i++)
  848. sim_tracks.push_back({i,
  849. event[i],
  850. bunchCrossing[i],
  851. pdgId[i],
  852. px[i],
  853. py[i],
  854. pz[i],
  855. pt[i],
  856. eta[i],
  857. phi[i],
  858. pca_pt[i],
  859. pca_eta[i],
  860. pca_lambda[i],
  861. pca_cotTheta[i],
  862. pca_phi[i],
  863. pca_dxy[i],
  864. pca_dz[i],
  865. q[i],
  866. nValid[i],
  867. nPixel[i],
  868. nStrip[i],
  869. nLay[i],
  870. nPixelLay[i],
  871. n3DLay[i],
  872. trkIdx[i],
  873. shareFrac[i],
  874. parentVtxIdx[i],
  875. decayVtxIdx[i],
  876. simHitIdx[i]});
  877. return sim_tracks;
  878. })));
  879. return tup_apply(builder,
  880. fv::tuple(tds.track_branch_obj<vector<int>>("sim_event"),
  881. tds.track_branch_obj<vector<int>>("sim_bunchCrossing"),
  882. tds.track_branch_obj<vector<int>>("sim_pdgId"),
  883. tds.track_branch_obj<vector<float>>("sim_px"),
  884. tds.track_branch_obj<vector<float>>("sim_py"),
  885. tds.track_branch_obj<vector<float>>("sim_pz"),
  886. tds.track_branch_obj<vector<float>>("sim_pt"),
  887. tds.track_branch_obj<vector<float>>("sim_eta"),
  888. tds.track_branch_obj<vector<float>>("sim_phi"),
  889. tds.track_branch_obj<vector<float>>("sim_pca_pt"),
  890. tds.track_branch_obj<vector<float>>("sim_pca_eta"),
  891. tds.track_branch_obj<vector<float>>("sim_pca_lambda"),
  892. tds.track_branch_obj<vector<float>>("sim_pca_cotTheta"),
  893. tds.track_branch_obj<vector<float>>("sim_pca_phi"),
  894. tds.track_branch_obj<vector<float>>("sim_pca_dxy"),
  895. tds.track_branch_obj<vector<float>>("sim_pca_dz"),
  896. tds.track_branch_obj<vector<int>>("sim_q"),
  897. tds.track_branch_obj<vector<unsigned int>>("sim_nValid"),
  898. tds.track_branch_obj<vector<unsigned int>>("sim_nPixel"),
  899. tds.track_branch_obj<vector<unsigned int>>("sim_nStrip"),
  900. tds.track_branch_obj<vector<unsigned int>>("sim_nLay"),
  901. tds.track_branch_obj<vector<unsigned int>>("sim_nPixelLay"),
  902. tds.track_branch_obj<vector<unsigned int>>("sim_n3DLay"),
  903. tds.track_branch_obj<vector<vector<int>>>("sim_trkIdx"),
  904. tds.track_branch_obj<vector<vector<float>>>("sim_shareFrac"),
  905. tds.track_branch_obj<vector<int>>("sim_parentVtxIdx"),
  906. tds.track_branch_obj<vector<vector<int>>>("sim_decayVtxIdx"),
  907. tds.track_branch_obj<vector<vector<int>>>("sim_simHitIdx")),
  908. "sim_tracks");
  909. }
  910. //#^#=========================================================================
  911. //==============SUPER CLUSTERS================================================
  912. //============================================================================
  913. struct SuperCluster {
  914. unsigned int idx;
  915. float e;
  916. float px;
  917. float py;
  918. float pz;
  919. float x;
  920. float y;
  921. float z;
  922. vector<int> charge;
  923. vector<int> lay1;
  924. vector<int> lay2;
  925. vector<int> ladder_blade1;
  926. vector<int> ladder_blade2;
  927. vector<int> subDet1;
  928. vector<int> subDet2;
  929. vector<float> dRz1;
  930. vector<float> dPhi1;
  931. vector<float> dRz2;
  932. vector<float> dPhi2;
  933. vector<int> seedType;
  934. vector<int> seedHitIdx1;
  935. vector<int> seedHitIdx2;
  936. };
  937. Value<vector<SuperCluster>>*
  938. register_super_clusters(TrackingDataSet &tds){
  939. auto builder =
  940. func<std::vector<SuperCluster>(vector<float>, // e,
  941. vector<float>, // px,
  942. vector<float>, // py,
  943. vector<float>, // pz,
  944. vector<float>, // x,
  945. vector<float>, // y,
  946. vector<float>, // z,
  947. vector<vector<int>>, // charge;
  948. vector<vector<int>>, // lay1;
  949. vector<vector<int>>, // lay2;
  950. vector<vector<int>>, // ladder_blade1;
  951. vector<vector<int>>, // ladder_blade2;
  952. vector<vector<int>>, // subDet1;
  953. vector<vector<int>>, // subDet2;
  954. vector<vector<float>>, // dRz1;
  955. vector<vector<float>>, // dPhi1;
  956. vector<vector<float>>, // dRz2;
  957. vector<vector<float>>, // dPhi2;
  958. vector<vector<int>>, // seedType;
  959. vector<vector<int>>, // seedHitIdx1;
  960. vector<vector<int>> // seedHitIdx1;
  961. )>("build_super_clusters",
  962. FUNC(([](const vector<float>& e,
  963. const vector<float>& px,
  964. const vector<float>& py,
  965. const vector<float>& pz,
  966. const vector<float>& x,
  967. const vector<float>& y,
  968. const vector<float>& z,
  969. const vector<vector<int>>& charge,
  970. const vector<vector<int>>& lay1,
  971. const vector<vector<int>>& lay2,
  972. const vector<vector<int>>& ladder_blade1,
  973. const vector<vector<int>>& ladder_blade2,
  974. const vector<vector<int>>& subDet1,
  975. const vector<vector<int>>& subDet2,
  976. const vector<vector<float>>& dRz1,
  977. const vector<vector<float>>& dPhi1,
  978. const vector<vector<float>>& dRz2,
  979. const vector<vector<float>>& dPhi2,
  980. const vector<vector<int>>& seedType,
  981. const vector<vector<int>>& seedHitIdx1,
  982. const vector<vector<int>>& seedHitIdx2){
  983. std::vector<SuperCluster> super_clusters;
  984. for(unsigned int i=0; i<e.size(); i++)
  985. super_clusters.push_back({i,
  986. e[i],
  987. px[i],
  988. py[i],
  989. pz[i],
  990. x[i],
  991. y[i],
  992. z[i],
  993. charge[i],
  994. lay1[i],
  995. lay2[i],
  996. ladder_blade1[i],
  997. ladder_blade2[i],
  998. subDet1[i],
  999. subDet2[i],
  1000. dRz1[i],
  1001. dPhi1[i],
  1002. dRz2[i],
  1003. dPhi2[i],
  1004. seedType[i],
  1005. seedHitIdx1[i],
  1006. seedHitIdx2[i]});
  1007. return super_clusters;
  1008. })));
  1009. return tup_apply(builder,
  1010. fv::tuple(tds.track_branch_obj<vector<float>>("scl_e"),
  1011. tds.track_branch_obj<vector<float>>("scl_px"),
  1012. tds.track_branch_obj<vector<float>>("scl_py"),
  1013. tds.track_branch_obj<vector<float>>("scl_pz"),
  1014. tds.track_branch_obj<vector<float>>("scl_x"),
  1015. tds.track_branch_obj<vector<float>>("scl_y"),
  1016. tds.track_branch_obj<vector<float>>("scl_z"),
  1017. tds.track_branch_obj<vector<vector<int>>>("scl_charge"),
  1018. tds.track_branch_obj<vector<vector<int>>>("scl_lay1"),
  1019. tds.track_branch_obj<vector<vector<int>>>("scl_lay2"),
  1020. tds.track_branch_obj<vector<vector<int>>>("scl_ladder_blade1"),
  1021. tds.track_branch_obj<vector<vector<int>>>("scl_ladder_blade2"),
  1022. tds.track_branch_obj<vector<vector<int>>>("scl_subDet1"),
  1023. tds.track_branch_obj<vector<vector<int>>>("scl_subDet2"),
  1024. tds.track_branch_obj<vector<vector<float>>>("scl_dRz1"),
  1025. tds.track_branch_obj<vector<vector<float>>>("scl_dPhi1"),
  1026. tds.track_branch_obj<vector<vector<float>>>("scl_dRz2"),
  1027. tds.track_branch_obj<vector<vector<float>>>("scl_dPhi2"),
  1028. tds.track_branch_obj<vector<vector<int>>>("scl_seedType"),
  1029. tds.track_branch_obj<vector<vector<int>>>("scl_seedHitIdx1"),
  1030. tds.track_branch_obj<vector<vector<int>>>("scl_seedHitIdx2")
  1031. ), "super_clusters");
  1032. }