PandaRoot
FWHM.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /*
14  * FWHM.h
15  *
16  * Created on: 22.11.2023
17  * Author: tstockmanns
18  */
19 
20 #ifndef TOOLS_FWHM_H_
21 #define TOOLS_FWHM_H_
22 
23 #include <TH1.h>
24 
25 static double FWHM(TH1* h1){
26  int bin1 = h1->FindFirstBinAbove(h1->GetMaximum()/2);
27  int bin2 = h1->FindLastBinAbove(h1->GetMaximum()/2);
28  double fwhm = h1->GetBinCenter(bin2) - h1->GetBinCenter(bin1);
29 
30 // std::cout << h1->GetName() << std::endl;
31 // std::cout << "FWHM: max: " << h1->GetMaximum() << " halfMax " << h1->GetMaximum()/2 << " bin1 - bin2 " << bin1 << " - " << bin2 << " fwhm " << fwhm << std::endl;
32  return fwhm;
33 }
34 
35 #endif /* TOOLS_FWHM_H_ */
static double FWHM(TH1 *h1)
Definition: FWHM.h:25