Angular analysis of B+->K*+(K+pi0)mumu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

518 lines
14 KiB

  1. //Classes and function used in MCtruthmatching.cpp to truthmatch the samples
  2. //Renata Kopečná
  3. #include "GlobalFunctions.hh"
  4. class counters{
  5. public:
  6. int B_plus_VETO;
  7. int K_star_plus_VETO;
  8. int mu_VETO;
  9. int J_psi_VETO;
  10. int K_plus_VETO;
  11. int pi_zero_VETO;
  12. int gammas_VETO;
  13. int MOTHER_ID_VETO;
  14. int GD_MOTHER_ID_VETO;
  15. int GD_GD_MOTHER_ID_VETO;
  16. int K_short_VETO;
  17. int Ks_pi_VETO;
  18. int pi_plus_VETO;
  19. int Kshort_pi_zero_daughters;
  20. int ReconstructedPionsWhichAreMuons;
  21. counters(){ //default constructor
  22. B_plus_VETO = 0;
  23. K_star_plus_VETO = 0;
  24. mu_VETO = 0;
  25. J_psi_VETO = 0;
  26. K_plus_VETO = 0;
  27. pi_zero_VETO = 0;
  28. gammas_VETO = 0;
  29. MOTHER_ID_VETO = 0;
  30. GD_MOTHER_ID_VETO = 0;
  31. GD_GD_MOTHER_ID_VETO = 0;
  32. K_short_VETO = 0;
  33. Ks_pi_VETO = 0;
  34. pi_plus_VETO = 0;
  35. Kshort_pi_zero_daughters = 0;
  36. ReconstructedPionsWhichAreMuons = 0;
  37. }
  38. void printCounters(bool B0, bool K1);
  39. ~counters(); //destuctor
  40. };
  41. void counters::printCounters(bool B0, bool K1){
  42. coutInfo("The incorrect reconstructed particles are the following:");
  43. coutInfo("(only the first found-incorrect particle is counted)");
  44. coutInfo("");
  45. coutInfo((B0 ? "B_zero:\t\t" : "B_plus:\t\t")+to_string(B_plus_VETO));
  46. coutInfo((B0 ? "K_star_zero:\t" : ( K1 ? "K_one_plus:\t" : "K_star_plus:\t"))+to_string(K_star_plus_VETO));
  47. coutInfo("mu:\t\t"+to_string(mu_VETO));
  48. if(Kst2Kpluspi0Resolved){
  49. coutInfo("K_plus:\t\t"+to_string(K_plus_VETO));
  50. coutInfo("pi_zero TM:\t"+to_string(pi_zero_VETO));
  51. coutInfo("gamma:\t\t"+to_string(gammas_VETO));
  52. }
  53. if(Kst2Kspiplus){
  54. coutInfo("K_short:\t"+to_string(K_short_VETO));
  55. coutInfo("Ks_pi_minus:\t"+to_string(Ks_pi_VETO));
  56. coutInfo("pi_plus:\t"+to_string(pi_plus_VETO));
  57. }
  58. coutInfo("J_psi:\t\t"+to_string(J_psi_VETO));
  59. if(Kst2Kspiplus){
  60. coutInfo("Pi0 daughers of the Kshort:\t"+to_string(Kshort_pi_zero_daughters));
  61. coutInfo("Muons mis-IDed as pions:\t"+to_string(ReconstructedPionsWhichAreMuons)+"/"+to_string(Ks_pi_VETO + pi_plus_VETO));
  62. }
  63. coutInfo("Total incorrect family members of all particles: "+to_string(MOTHER_ID_VETO + GD_MOTHER_ID_VETO + GD_GD_MOTHER_ID_VETO));
  64. coutInfo("MotherID:\t"+to_string(MOTHER_ID_VETO));
  65. coutInfo("GDmotherID:\t"+to_string(GD_MOTHER_ID_VETO));
  66. coutInfo("GDGDmotherID:\t"+to_string(GD_GD_MOTHER_ID_VETO));
  67. return;
  68. }
  69. counters::~counters(){ //destuctor
  70. B_plus_VETO = 0;
  71. K_star_plus_VETO = 0;
  72. mu_VETO = 0;
  73. J_psi_VETO = 0;
  74. K_plus_VETO = 0;
  75. pi_zero_VETO = 0;
  76. gammas_VETO = 0;
  77. MOTHER_ID_VETO = 0;
  78. GD_MOTHER_ID_VETO = 0;
  79. K_short_VETO = 0;
  80. Ks_pi_VETO = 0;
  81. pi_plus_VETO = 0;
  82. Kshort_pi_zero_daughters = 0;
  83. ReconstructedPionsWhichAreMuons = 0;
  84. }
  85. bool isBKGCAT(int BKGCAT, bool ReferenceChannel){
  86. if (Kst2Kspiplus){
  87. if(ReferenceChannel){
  88. if(BKGCAT == 0 || BKGCAT == 50) return true;
  89. else return false;
  90. }
  91. else{
  92. if(BKGCAT == 10 || BKGCAT == 50) return true;
  93. else return false;
  94. }
  95. }
  96. else{
  97. if(ReferenceChannel){
  98. if(BKGCAT == 0 || BKGCAT == 40 || BKGCAT == 50) return true;
  99. else return false;
  100. }
  101. else{
  102. if(BKGCAT == 10 || BKGCAT == 40 || BKGCAT == 50) return true;
  103. else return false;
  104. }
  105. }
  106. }
  107. //TRUED B+
  108. class B_plus_IDs{
  109. public:
  110. int B_plus_TRUEID;
  111. B_plus_IDs(){
  112. B_plus_TRUEID = 0;
  113. }
  114. ~B_plus_IDs(){
  115. B_plus_TRUEID = 0;
  116. }
  117. bool isBplus(counters *counter, bool B_plus_TM){
  118. if (!B_plus_TM) return true;
  119. if(TMath::Abs(B_plus_TRUEID) != TRUEID.B_PLUS){
  120. counter->B_plus_VETO++;
  121. return false;
  122. }
  123. else return true;
  124. }
  125. };
  126. //TRUEID K*+
  127. class K_star_IDs{
  128. public:
  129. int K_star_plus_TRUEID;
  130. int K_star_plus_MOTHER_ID;
  131. K_star_IDs(){
  132. K_star_plus_TRUEID = 0;
  133. K_star_plus_MOTHER_ID = 0;
  134. }
  135. ~K_star_IDs(){
  136. K_star_plus_TRUEID = 0;
  137. K_star_plus_MOTHER_ID = 0;
  138. }
  139. bool isKstar(counters *counter, bool K_star_plus_TM, bool B_plus_TM){
  140. if (K_star_plus_TM && TMath::Abs(K_star_plus_TRUEID) != TRUEID.K_STAR_PLUS){
  141. counter->K_star_plus_VETO++;
  142. return false;
  143. }
  144. if (B_plus_TM && TMath::Abs(K_star_plus_MOTHER_ID) != TRUEID.B_PLUS){
  145. counter->MOTHER_ID_VETO++;
  146. return false;
  147. }
  148. return true;
  149. }
  150. };
  151. //TRUEID K+
  152. class K_plus_IDs{
  153. public:
  154. int K_plus_TRUEID;
  155. int K_plus_MOTHER_ID;
  156. int K_plus_GD_MOTHER_ID;
  157. K_plus_IDs(){
  158. K_plus_TRUEID = 0;
  159. K_plus_MOTHER_ID = 0;
  160. K_plus_GD_MOTHER_ID = 0;
  161. }
  162. ~K_plus_IDs(){
  163. K_plus_TRUEID = 0;
  164. K_plus_MOTHER_ID = 0;
  165. K_plus_GD_MOTHER_ID = 0;
  166. }
  167. bool isKplus(counters *counter, bool K_plus_TM, bool K_star_plus_TM, bool B_plus_TM){// flags *allFlags){
  168. if (K_plus_TM && TMath::Abs(K_plus_TRUEID) != TRUEID.K_PLUS){
  169. counter->K_plus_VETO++;
  170. return false;
  171. }
  172. if (K_star_plus_TM && TMath::Abs(K_plus_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  173. counter->MOTHER_ID_VETO++;
  174. return false;
  175. }
  176. if (B_plus_TM && TMath::Abs(K_plus_GD_MOTHER_ID) != TRUEID.B_PLUS){
  177. counter->GD_MOTHER_ID_VETO++;
  178. return false;
  179. }
  180. return true;
  181. }
  182. };
  183. //TRUEID pi0
  184. class pi_zero_IDs{
  185. public:
  186. int pi_zero_TRUEID;
  187. int pi_zero_MOTHER_ID;
  188. int pi_zero_GD_MOTHER_ID;
  189. pi_zero_IDs(){
  190. pi_zero_TRUEID = 0;
  191. pi_zero_MOTHER_ID = 0;
  192. pi_zero_GD_MOTHER_ID = 0;
  193. }
  194. ~pi_zero_IDs(){
  195. pi_zero_TRUEID = 0;
  196. pi_zero_MOTHER_ID = 0;
  197. pi_zero_GD_MOTHER_ID = 0;
  198. }
  199. bool isPi0(counters *counter, bool pi_zero_TM, bool K_star_plus_TM, bool B_plus_TM, double pi_zero_resolved_M, double B_plus_M, TH1D *h_pi0_mismatched_mass, TH1D *h_Bplus_mass_pi0mismatched, TH1D *h_pi0_resolved_mass){
  200. if (pi_zero_TM){
  201. if(TMath::Abs(pi_zero_TRUEID) == TRUEID.PI_ZERO){
  202. h_pi0_resolved_mass->Fill(pi_zero_resolved_M);
  203. }
  204. else{
  205. counter->pi_zero_VETO++;
  206. h_pi0_mismatched_mass->Fill(pi_zero_resolved_M);
  207. h_Bplus_mass_pi0mismatched->Fill(B_plus_M);
  208. return false;
  209. }
  210. }
  211. if (K_star_plus_TM && TMath::Abs(pi_zero_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  212. counter->MOTHER_ID_VETO++;
  213. return false;
  214. }
  215. if (B_plus_TM && TMath::Abs(pi_zero_GD_MOTHER_ID) != TRUEID.B_PLUS){
  216. counter->GD_MOTHER_ID_VETO++;
  217. return false;
  218. }
  219. return true;
  220. }
  221. };
  222. //TRUEID gamma
  223. class gamma_IDs{
  224. public:
  225. int gamma_TRUEID;
  226. int gamma_MOTHER_ID;
  227. int gamma_GD_MOTHER_ID;
  228. int gamma_GD_GD_MOTHER_ID;
  229. gamma_IDs(){
  230. gamma_TRUEID = 0;
  231. gamma_MOTHER_ID = 0;
  232. gamma_GD_MOTHER_ID = 0;
  233. gamma_GD_GD_MOTHER_ID = 0;
  234. }
  235. ~gamma_IDs(){
  236. gamma_TRUEID = 0;
  237. gamma_MOTHER_ID = 0;
  238. gamma_GD_MOTHER_ID = 0;
  239. gamma_GD_GD_MOTHER_ID = 0;
  240. }
  241. //Check if gamma was converted
  242. bool isGammaConversion(counters *counter, bool gamma_TM, bool pi_zero_TM, bool K_star_plus_TM){
  243. if(gamma_TM && TMath::Abs(gamma_TRUEID) != TRUEID.ELECTRON){
  244. ++counter->gammas_VETO;
  245. return false;
  246. }
  247. if(gamma_TM && TMath::Abs(gamma_MOTHER_ID) != TRUEID.GAMMA){
  248. ++counter->gammas_VETO;
  249. return false;
  250. }
  251. if(pi_zero_TM && TMath::Abs(gamma_GD_MOTHER_ID) != TRUEID.PI_ZERO){
  252. ++counter->MOTHER_ID_VETO;
  253. return false;
  254. }
  255. if(K_star_plus_TM && TMath::Abs(gamma_GD_GD_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  256. ++counter->GD_MOTHER_ID_VETO;
  257. return false;
  258. }
  259. return true;
  260. }
  261. //TRUEID gamma
  262. bool isGammaTrue(counters *counter, bool gamma_TM,bool gamma_TM_full, bool pi_zero_TM, bool K_star_plus_TM, bool B_plus_TM){
  263. if (!gamma_TM_full) return true;
  264. if(gamma_TM && TMath::Abs(gamma_TRUEID) != TRUEID.GAMMA){
  265. ++counter->gammas_VETO;
  266. return false;
  267. }
  268. if (pi_zero_TM && TMath::Abs(gamma_MOTHER_ID) != TRUEID.PI_ZERO){
  269. ++counter->MOTHER_ID_VETO;
  270. return false;
  271. }
  272. if (K_star_plus_TM && TMath::Abs(gamma_GD_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  273. ++counter->GD_MOTHER_ID_VETO;
  274. return false;
  275. }
  276. if (B_plus_TM && TMath::Abs(gamma_GD_GD_MOTHER_ID) != TRUEID.B_PLUS){
  277. ++counter->GD_GD_MOTHER_ID_VETO;
  278. return false;
  279. }
  280. return true;
  281. }
  282. };
  283. //TRUEID Ks
  284. class K_short_IDs{
  285. public:
  286. int K_short_TRUEID;
  287. int K_short_MOTHER_ID;
  288. int K_short_GD_MOTHER_ID;
  289. K_short_IDs(){
  290. K_short_TRUEID = 0;
  291. K_short_MOTHER_ID = 0;
  292. K_short_GD_MOTHER_ID = 0;
  293. }
  294. ~K_short_IDs(){
  295. K_short_TRUEID = 0;
  296. K_short_MOTHER_ID = 0;
  297. K_short_GD_MOTHER_ID = 0;
  298. }
  299. bool isKshort(counters *counter){
  300. if(TMath::Abs(K_short_TRUEID) != TRUEID.K_SHORT){
  301. counter->K_short_VETO++;
  302. return false;
  303. }
  304. if(TMath::Abs(K_short_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  305. counter->MOTHER_ID_VETO++;
  306. return false;
  307. }
  308. if(TMath::Abs(K_short_GD_MOTHER_ID) != TRUEID.B_PLUS){
  309. counter->GD_MOTHER_ID_VETO++;
  310. return false;
  311. }
  312. return true;
  313. }
  314. };
  315. //TRUEID pi+
  316. class pi_plus_IDs{
  317. public:
  318. int pi_plus_TRUEID;
  319. int pi_plus_MOTHER_ID;
  320. int pi_plus_GD_MOTHER_ID;
  321. pi_plus_IDs(){
  322. pi_plus_TRUEID = 0;
  323. pi_plus_MOTHER_ID = 0;
  324. pi_plus_GD_MOTHER_ID = 0;
  325. }
  326. ~pi_plus_IDs(){
  327. pi_plus_TRUEID = 0;
  328. pi_plus_MOTHER_ID = 0;
  329. pi_plus_GD_MOTHER_ID = 0;
  330. }
  331. bool isPiPlus(counters *counter){
  332. if(TMath::Abs(pi_plus_TRUEID) != TRUEID.PI_PLUS){
  333. if(TMath::Abs(pi_plus_TRUEID) == TRUEID.MU_MINUS) counter->ReconstructedPionsWhichAreMuons++;
  334. counter->pi_plus_VETO++;
  335. return false;
  336. }
  337. if(TMath::Abs(pi_plus_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  338. counter->MOTHER_ID_VETO++;
  339. return false;
  340. }
  341. if(TMath::Abs(pi_plus_GD_MOTHER_ID) != TRUEID.B_PLUS){
  342. counter->GD_MOTHER_ID_VETO++;
  343. return false;
  344. }
  345. return true;
  346. }
  347. };
  348. //TRUEID pions coming from Ks
  349. class Ks_pi_IDs{
  350. public:
  351. int Ks_pi_TRUEID;
  352. int Ks_pi_MOTHER_ID;
  353. int Ks_pi_GD_MOTHER_ID;
  354. int Ks_pi_GD_GD_MOTHER_ID;
  355. Ks_pi_IDs(){
  356. Ks_pi_TRUEID = 0;
  357. Ks_pi_MOTHER_ID = 0;
  358. Ks_pi_GD_MOTHER_ID = 0;
  359. Ks_pi_GD_GD_MOTHER_ID = 0;
  360. }
  361. ~Ks_pi_IDs(){
  362. Ks_pi_TRUEID = 0;
  363. Ks_pi_MOTHER_ID = 0;
  364. Ks_pi_GD_MOTHER_ID = 0;
  365. Ks_pi_GD_GD_MOTHER_ID = 0;
  366. }
  367. bool isKsPi(counters *counter){
  368. if(TMath::Abs(Ks_pi_TRUEID) != TRUEID.PI_PLUS){
  369. if(TMath::Abs(Ks_pi_TRUEID) == TRUEID.PI_ZERO)counter->Kshort_pi_zero_daughters++;
  370. if(TMath::Abs(Ks_pi_TRUEID) == TRUEID.MU_MINUS)counter->ReconstructedPionsWhichAreMuons++;
  371. counter->Ks_pi_VETO++;
  372. return false;
  373. }
  374. if(TMath::Abs(Ks_pi_MOTHER_ID) != TRUEID.K_SHORT){
  375. counter->MOTHER_ID_VETO++;
  376. return false;
  377. }
  378. if(TMath::Abs(Ks_pi_GD_MOTHER_ID) != TRUEID.K_STAR_PLUS){
  379. counter->GD_MOTHER_ID_VETO++;
  380. return false;
  381. }
  382. if(TMath::Abs(Ks_pi_GD_GD_MOTHER_ID) != TRUEID.B_PLUS){
  383. counter->GD_GD_MOTHER_ID_VETO++;
  384. return false;
  385. }
  386. return true;
  387. }
  388. };
  389. //TRUEID muon
  390. class mu_IDs{
  391. public:
  392. int mu_TRUEID;
  393. int mu_MOTHER_ID;
  394. int mu_GD_MOTHER_ID;
  395. bool ReferenceChannel = false;
  396. mu_IDs(bool isRefChan){
  397. mu_TRUEID = 0;
  398. mu_MOTHER_ID = 0;
  399. mu_GD_MOTHER_ID = 0;
  400. ReferenceChannel = isRefChan;
  401. }
  402. ~mu_IDs(){
  403. mu_TRUEID = 0;
  404. mu_MOTHER_ID = 0;
  405. mu_GD_MOTHER_ID = 0;
  406. ReferenceChannel = 0;
  407. }
  408. bool isMu(counters *counter, bool mu_TM, bool J_psi_TM, bool B_plus_TM){//flags *allFlags){
  409. if (mu_TM && TMath::Abs(mu_TRUEID) != TRUEID.MU_MINUS){
  410. counter->mu_VETO++;
  411. return false;
  412. }
  413. if(ReferenceChannel){
  414. if (J_psi_TM && TMath::Abs(mu_MOTHER_ID) != TRUEID.J_PSI){
  415. counter->MOTHER_ID_VETO++;
  416. return false;
  417. }
  418. if(B_plus_TM && TMath::Abs(mu_GD_MOTHER_ID) != TRUEID.B_PLUS){
  419. counter->GD_MOTHER_ID_VETO++;
  420. return false;
  421. }
  422. }
  423. else{
  424. if(B_plus_TM && TMath::Abs(mu_MOTHER_ID) != TRUEID.B_PLUS){
  425. counter->MOTHER_ID_VETO++;
  426. return false;
  427. }
  428. }
  429. return true;
  430. }
  431. };
  432. //TRUEID J/psi
  433. class J_psi_IDs{
  434. public:
  435. int J_psi_TRUEID;
  436. int J_psi_MOTHER_ID;
  437. int J_psi_GD_MOTHER_ID;
  438. bool ReferenceChannel = false;
  439. J_psi_IDs(bool isRefChan){
  440. J_psi_TRUEID = 0;
  441. J_psi_MOTHER_ID = 0;
  442. J_psi_GD_MOTHER_ID = 0;
  443. ReferenceChannel = isRefChan;
  444. }
  445. ~J_psi_IDs(){
  446. J_psi_TRUEID = 0;
  447. J_psi_MOTHER_ID = 0;
  448. J_psi_GD_MOTHER_ID = 0;
  449. ReferenceChannel = 0;
  450. }
  451. bool isJpsi(counters *counter, bool J_psi_TM, bool B_plus_TM){
  452. if(ReferenceChannel){
  453. if(J_psi_TM && TMath::Abs(J_psi_TRUEID) != TRUEID.J_PSI){
  454. counter->J_psi_VETO++;
  455. return false;
  456. }
  457. if(B_plus_TM && TMath::Abs(J_psi_MOTHER_ID) != TRUEID.B_PLUS){
  458. counter->MOTHER_ID_VETO++;
  459. return false;
  460. }
  461. }
  462. else{
  463. if(J_psi_TM && TMath::Abs(J_psi_TRUEID) == TRUEID.J_PSI){
  464. counter->J_psi_VETO++;
  465. return false;
  466. }
  467. }
  468. return true;
  469. }
  470. };