9#include <svd/modules/svdPerformance/SVDClusterEvaluationTrueInfoModule.h>
10#include <framework/datastore/StoreArray.h>
11#include <mdst/dataobjects/MCParticle.h>
12#include <svd/dataobjects/SVDShaperDigit.h>
13#include <svd/dataobjects/SVDRecoDigit.h>
14#include <svd/dataobjects/SVDCluster.h>
15#include <svd/dataobjects/SVDTrueHit.h>
19#include <TGraphErrors.h>
33 setDescription(
"This modules generates performance plots on SVD clustering.");
35 addParam(
"outputFileName",
m_outputFileName,
"output rootfile name", std::string(
"SVDClusterEvaluationTrueInfo.root"));
40SVDClusterEvaluationTrueInfoModule::~SVDClusterEvaluationTrueInfoModule()
54 SVDShaperDigits.isRequired();
56 SVDClusters.isRequired();
81 for (
int i = 0; i <
m_Nsets; i ++) {
87 "U_reco - U_true (cm)",
93 "(U_reco - U_true)/U_sigma",
153 "number of TM recoDigits / cluster size",
167 "number of TM recoDigits / cluster size",
229 if (relatVectorShaperToReco.
size() > 0)
242 if (relatVectorRecoToTH.
size() > 0)
267 for (
int j = 0; j < (int) relatVectorTHToClus.
size(); j ++) {
269 relatVectorTHToClus[j]->getSensorID().getSensorNumber(), relatVectorTHToClus[j]->isUCluster());
271 if (relatVectorTHToClus[j]->isUCluster() && ! hasU) {
274 }
else if (!relatVectorTHToClus[j]->isUCluster() && ! hasV) {
292 if (relatVectorClusToTH.
size() > 0)
299 for (
int q = 0; q < (int)relatVectorClusToTH.
size(); q ++) {
309 else if (triggerBin == 1)
311 else if (triggerBin == 2)
313 else if (triggerBin == 3)
317 (clus.getClsTimeSigma()));
320 if (clus.isUCluster()) {
322 (relatVectorClusToTH[q])->getU());
324 (relatVectorClusToTH[q])->getU()) / (clus.getPositionSigma()));
326 (relatVectorClusToTH[q])->getU()), (clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()));
330 (clus.getPositionSigma()));
332 (clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()));
338 if (relatVectorClusToTH.
size() > 0) {
342 int numberOfGoodTHInACluster = 0;
343 int numberOfGoodTHInAClusterGood = 0;
344 for (
int k = 0; k < (int)(relatVectorClusToTH.
size()); k ++) {
346 numberOfGoodTHInACluster ++;
347 numberOfGoodTHInAClusterGood ++;
351 if (numberOfGoodTHInAClusterGood > 0)
356 for (
int k = 0; k < (int)relatVectorClusToReco.
size(); k++) {
359 if (relatVectorRecoFromClusToTH.
size() > 0)
371 for (
int k = 0; k < (int)relatVectorClusToReco.
size(); k++) {
374 if (relatVectorRecoFromClusToTH.
size() > 0)
390 for (
int k = 0; k <
m_Nsets; k ++) {
469 TDirectory* oldDir = gDirectory;
472 TDirectory* dir_strtime = oldDir->mkdir(
"strip_time");
475 while ((obj = nextH_strtime()))
478 TDirectory* dir_cltime = oldDir->mkdir(
"cluster_time");
481 while ((obj = nextH_cltime()))
484 TDirectory* dir_cltimepull = oldDir->mkdir(
"cluster_time_pull");
485 dir_cltimepull->cd();
487 while ((obj = nextH_cltimepull()))
490 TDirectory* dir_clpos = oldDir->mkdir(
"cluster_position");
493 while ((obj = nextH_clpos()))
496 TDirectory* dir_clpospull = oldDir->mkdir(
"cluster_position_pull");
499 while ((obj = nextH_clpospull()))
502 TDirectory* dir_clpostime = oldDir->mkdir(
"cluster_timeVSposition");
505 while ((obj = nextH_clpostime()))
508 TDirectory* dir_clinpurTM = oldDir->mkdir(
"intra_cluster_purity_TM");
511 while ((obj = nextH_clinpurTM()))
514 TDirectory* dir_clinpurTM2D = oldDir->mkdir(
"intra_cluster_purity_TM2D");
515 dir_clinpurTM2D->cd();
517 while ((obj = nextH_clinpurTM2D()))
520 TDirectory* dir_clinpurNOTM = oldDir->mkdir(
"intra_cluster_purity_NOTM");
521 dir_clinpurNOTM->cd();
523 while ((obj = nextH_clinpurNOTM()))
526 TDirectory* dir_puddle = oldDir->mkdir(
"trueHits_in_cluster");
529 while ((obj = nextH_puddle()))
532 TDirectory* dir_puddleTM = oldDir->mkdir(
"trueHits_in_TMcluster");
535 while ((obj = nextH_puddleTM()))
538 TDirectory* dir_goodPuddleTM = oldDir->mkdir(
"goodTrueHits_in_TMcluster");
539 dir_goodPuddleTM->cd();
541 while ((obj = nextH_GoodPuddleTM()))
544 TDirectory* dir_goodPuddleTMGood = oldDir->mkdir(
"goodTrueHits_in_GoodTMcluster");
545 dir_goodPuddleTMGood->cd();
547 while ((obj = nextH_GoodPuddleTMGood()))
550 TDirectory* dir_graph = oldDir->mkdir(
"graphs");
553 while ((obj = nextH_graph()))
556 TDirectory* dir_controlsMC = oldDir->mkdir(
"controlMC");
557 dir_controlsMC->cd();
559 while ((obj = nextH_controlsMC()))
573 Int_t nbins, Double_t min, Double_t max,
574 const char* xtitle, TList* histoList)
576 TH1F* h =
new TH1F(name, title, nbins, min, max);
578 h->GetXaxis()->SetTitle(xtitle);
587 Int_t nbinsX, Double_t minX, Double_t maxX,
589 Int_t nbinsY, Double_t minY, Double_t maxY,
590 const char* titleY, TList* histoList)
593 TH2F* h =
new TH2F(name, title, nbinsX, minX, maxX, nbinsY, minY, maxY);
595 h->GetXaxis()->SetTitle(titleX);
596 h->GetYaxis()->SetTitle(titleY);
608 if (LayerNumber == 3) {
614 if (SensorNumber == 1) {
646 if (idx == 2 || idx == 3)
668 TString xTitle, TString yTitle, TList* list)
676 for (
int set = 0; set <
m_Nsets; set++) {
682 ratio[set] = (float)vNum[set] / (
float)vDen[set];
683 ratioErr[set] =
sqrt(ratio[set] * (1 - ratio[set]) / (
float)vDen[set]);
688 TCanvas* c =
new TCanvas(name, title);
689 TGraphErrors* g =
new TGraphErrors(
m_Nsets, x, ratio, xErr, ratioErr);
692 g->GetXaxis()->SetTitle(xTitle.Data());
693 g->GetYaxis()->SetTitle(yTitle.Data());
694 g->GetYaxis()->SetRangeUser(0.00001, 1.10);
696 g->SetMarkerStyle(20);
697 g->SetMarkerSize(0.8);
698 TAxis* xAxis = g->GetXaxis();
700 TText* t =
new TText();
702 t->SetTextSize(0.035);
704 TString labels[
m_Nsets] = {
"3U",
"3V",
"456FU",
"456FV",
"456BU",
"456BV"};
705 for (Int_t i = 0; i <
m_Nsets; i++) {
706 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
715 float xErr[
m_Nsets],
float y[
m_Nsets],
float yErr[
m_Nsets], TString xTitle, TString yTitle, TList* list,
int len)
722 B2INFO(
"ERROR, WRONG LENGTH FOR MEANS TGRAPH CREATION!!!");
726 float xErr[
m_Nsets],
float y[
m_Nsets],
float yErr[
m_Nsets], TString xTitle, TString yTitle, TList* list)
729 TCanvas* c =
new TCanvas(name, title);
730 TGraphErrors* g =
new TGraphErrors(
m_Nsets, x, y, xErr, yErr);
733 g->GetXaxis()->SetTitle(xTitle.Data());
734 g->GetYaxis()->SetTitle(yTitle.Data());
736 g->SetMarkerStyle(20);
737 g->SetMarkerSize(0.8);
738 TAxis* xAxis = g->GetXaxis();
740 TText* t =
new TText();
742 t->SetTextSize(0.035);
744 TString labels[
m_Nsets] = {
"3U",
"3V",
"456FU",
"456FV",
"456BU",
"456BV"};
745 for (Int_t i = 0; i <
m_Nsets; i++) {
746 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
758 TCanvas* c =
new TCanvas(name, title);
759 TGraphErrors* g =
new TGraphErrors(
m_NsetsRed, x, y, xErr, yErr);
762 g->GetXaxis()->SetTitle(xTitle.Data());
763 g->GetYaxis()->SetTitle(yTitle.Data());
765 g->SetMarkerStyle(20);
766 g->SetMarkerSize(0.8);
767 TAxis* xAxis = g->GetXaxis();
769 TText* t =
new TText();
771 t->SetTextSize(0.035);
773 TString labels[
m_NsetsRed] = {
"3",
"456F",
"456B"};
775 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
791 if (relatVectorTHToMC.
size() > 0) {
795 float charge = relatVectorTHToMC[0]->getCharge();
796 bool primary = relatVectorTHToMC[0]->isPrimaryParticle();
801 if (charge != 0 && primary)
static RelationVector< T > getRelationsWithObj(const TObject *object, const std::string &name="", const std::string &namedRelation="")
Get the relations between an object and other objects in a store array.
A Class to store the Monte Carlo particle information.
void setDescription(const std::string &description)
Sets the description of the module.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
TH1F * m_histo_StripTimeResolution[m_Nsets]
Vector of histograms depicting Strip Time Residuals.
TList * m_histoList_StripTimeResolution
Lists used to easily Draw the corresponding histos; last one is used to draw the TGraphs.
float m_RMS_GoodTHinClusterTM[m_Nsets]
good true hits in cluster truth matched rms
float m_mean_ClusterTimeResolution[m_Nsets]
average cl time resid
TString NameOfHisto
Strings to pass names of the histos in the vectors of hitos.
TFile * m_outputFile
output file
static TString UVFromIndex(int idx)
Function returning "U" or "V" depending on the index.
int m_NumberOfClustersRelatedToTH[m_Nsets]
number of clusters related to true hits
TString TitleOfHisto
Strings to pass titles of the histos in the vectors of hitos.
TList * m_graphList
histo list, TGraphs
TH1F * m_histoControl_MCcharge
Control Histos and List to check if the function used to define a TH as "good" is working fine.
static void createArbitraryGraphErrorChooser(const char *name, const char *title, float x[m_Nsets], float xErr[m_Nsets], float y[m_Nsets], float yErr[m_Nsets], TString xTitle, TString yTitle, TList *list, int len)
Function choosing between the two following functions depending on the length of the provided arrays.
TList * m_histoList_PurityInsideTMCluster
histo list truth matched cluster purity (2D)
float m_RMS_ClusterTimeResolution[m_Nsets]
rms cluster time resid
TH1F * m_histo_ClusterUPositionPull[m_NsetsRed]
Vector of histograms depicting Cluster U Position Pull (Reduced length!)
static void createArbitraryGraphError_Red(const char *name, const char *title, float x[m_NsetsRed], float xErr[m_NsetsRed], float y[m_NsetsRed], float yErr[m_NsetsRed], TString xTitle, TString yTitle, TList *list)
Function returning an arbitrarily defined TGraph with arrays length equal to m_NsetsRed.
TH1F * m_histo_ClusterUPositionResolution[m_NsetsRed]
Vector of histograms depicting Cluster U Position Residual (Reduced length!)
TList * m_histoList_ClusterTimeResolution
histo list cluster time resolution
int m_NumberOfShaperDigit[m_Nsets]
Vectors used to compute the quantities depicted in Histos and Graphs.
static void createEfficiencyGraph(const char *name, const char *title, const int vNum[m_Nsets], const int vDen[m_Nsets], TString xTitle, TString yTitle, TList *list)
Function returning a TGraph with Y axis limited to 1 given numerator and denumerator vectors and plot...
float m_RMS_THinClusterTM[m_Nsets]
true hits in truth matched cluster rms
int m_NumberOfRecoDigit[m_Nsets]
number of reco digits
float m_RMS_THinCluster[m_Nsets]
true hits in cluster rms
virtual void initialize() override
Initialize the SVDClusterEvaluationTrueInfo.
TList * m_histo2DList_TresVsPosres
histo list ime tresol VS position resol
int m_NumberOfTMRecoInNOTMCluster
number of truth matched reco digits in not truth matched clusters
int indexForHistosAndGraphs
Index used for the lists and for the vectors of histograms: it indicates the set of sensors we are lo...
TH1F * m_histo_ClusterVPositionPull[m_NsetsRed]
Vector of histograms depicting Cluster U Position Pull (Reduced length!)
virtual void event() override
This method is the core of the SVDClusterEvaluationTrueInfo.
float m_mean_GoodTHinClusterTM[m_Nsets]
good true hits in cluster truth matched average
int m_NumberOfTMClusters[m_Nsets]
number of truth matched clusters
float m_mean_ClusterVPositionResolution[m_Nsets]
average cl V position reosl
TH2F * createHistogram2D(const char *name, const char *title, Int_t nbinsX, Double_t minX, Double_t maxX, const char *titleX, Int_t nbinsY, Double_t minY, Double_t maxY, const char *titleY, TList *histoList)
Function returning TH2F.
TH1F * m_histo_ClusterTimeResolution_bin1[m_Nsets]
Vector of histograms depicting Cluster Time Residuals, divided by TriggerBin.
TH1F * m_histo_THinCluster[m_Nsets]
Vector of histograms depicting Number of TH inside a Cluster.
virtual void endRun() override
This method is called if the current run ends.
TH1F * m_histoControl_MCisPrimary
control histo: MC is primary
float m_mean_ClusterUPositionResolution[m_Nsets]
average cl U position resol
TH2F * m_histo2D_TresVsPosres[m_Nsets]
Vector of 2D histograms depicting Time Residuals Vs Position (U/V) Residuals for Histos.
TH1F * m_histo_GoodTHinClusterTM[m_Nsets]
Vector of histograms depicting Number of Good TH inside a TM Cluster.
TList * m_histoList_ClusterTimePull
histo list cluster time pull
TList * m_histoList_GoodTHinClusterTMGood
histo list goo true hits in cluster truth match good
float m_RMS_StripTimeResolution[m_Nsets]
rms of strip time residual
float m_mean_THinClusterTM[m_Nsets]
true hits in truth matched cluster average
float m_RMS_ClusterVPositionResolution[m_Nsets]
rms cl V position resol
int m_NumberOfTH[m_Nsets]
number of true hits
float m_RMS_PurityInsideTMCluster[m_Nsets]
cluster purity rms
float m_OrderingVec[m_Nsets]
Vectors used to Draw the TGraphs (defined in the cc) depicting the averages and the means of the hist...
TList * m_histoList_ClusterPositionPull
histo list cluster position pull
TList * m_histo2DList_PurityInsideTMCluster
histo list truth matched cluster purity (2D)
TList * m_histoList_PurityInsideNOTMCluster
histo list not truth matched cluster purity
TH1F * m_histo_PurityInsideTMCluster[m_Nsets]
Vector of histograms depicting Cluster Internal Purity (TM Recos over Reco inside a Cluster)
static TString FWFromIndex(int idx)
Function returning "Forward" or "Backward" depending on the index.
TH1F * m_histo_ClusterTimeResolution[m_Nsets]
Vector of histograms depicting Cluster Time Residuals.
TH1F * m_histo_ClusterTimePull[m_Nsets]
Vector of histograms depicting Cluster Time Pull.
static int indexFromLayerSensorSide(int LayerNumber, int SensorNumber, int UVNumber)
Function returning the index used for Histos.
static const int m_NsetsRed
numbner of reduced sets
TList * m_histoList_GoodTHinClusterTM
histo list good true hits in cluster truth matched
float m_mean_PurityInsideTMCluster[m_Nsets]
cluster purity average
bool goodTrueHit(const SVDTrueHit *thino)
Function defining if a TH is good (based on charge and primaryness)
float m_RMS_ClusterUPositionResolution[m_Nsets]
rms cl U position resol
static TString IntExtFromIndex(int idx)
Function returning "Internal" or "External" depending on the index.
float m_RMS_GoodTHinClusterTMGood[m_Nsets]
good true hits in cluster truth match good rms
std::string m_svdEventInfoName
Name of the SVDEventInfo object.
TH1F * m_histo_GoodTHinClusterTMGood[m_Nsets]
Vector of histograms depicting Number of Good TH inside a Good TM Cluster.
TH1F * createHistogram1D(const char *name, const char *title, Int_t nbins, Double_t min, Double_t max, const char *xtitle, TList *histoList)
Function returning a TH1F.
TH1F * m_histo_ClusterTimeResolution_bin3[m_Nsets]
TB3.
SVDClusterEvaluationTrueInfoModule()
constructor
TH1F * m_histoControl_THToMCsize
control histo: true hit to mc size
TH1F * m_histo_ClusterVPositionResolution[m_NsetsRed]
Vector of histograms depicting Cluster V Position Residual (Reduced length!)
TList * m_histoList_THinCluster
histo list true hits in cluster
float m_NullVec[m_Nsets]
null vector
TH2F * m_histo2D_PurityInsideTMCluster[m_Nsets]
Vector of 2D histograms depicting TM Reco Vs Total Reco inside a TM Cluster.
float m_mean_GoodTHinClusterTMGood[m_Nsets]
good true hits in cluster truth match good average
TList * m_histoList_Control
control histo
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo
Storage for SVDEventInfo object.
TH1F * m_histo_ClusterTimeResolution_bin4[m_Nsets]
TB4.
TList * m_histoList_ClusterPositionResolution
histo list cluster position resolution
static void createArbitraryGraphError_Std(const char *name, const char *title, float x[m_Nsets], float xErr[m_Nsets], float y[m_Nsets], float yErr[m_Nsets], TString xTitle, TString yTitle, TList *list)
Function returning an arbitrarily defined TGraph with arrays length equal to m_Nsets.
TH1F * m_histo_PurityInsideNOTMCluster[m_Nsets]
Vector of histograms depicting TM Cluster Internal Purity (TM Recos over Reco inside a Cluster)
int m_NumberOfClusters[m_Nsets]
number of clusters
static const int m_Nsets
number of sets: L3-barrel-U, L3-barrel-V, L456-barrel-U, L456-barrel-V, L456-slanted-U,...
int m_NumberOfTMRecoInTMCluster
number of true match reco digit in truth match cluster
float m_mean_StripTimeResolution[m_Nsets]
Vectors of floats containing the mean and the RMS from the corresponding histo.
TH1F * m_histo_ClusterTimeResolution_bin2[m_Nsets]
TB2.
TH1F * m_histo_THinClusterTM[m_Nsets]
Vector of histograms depicting Number of TH inside a TM Cluster.
std::string m_outputFileName
output file name
TList * m_histoList_THinClusterTM
histo list true hits in clsuter truth match
float m_mean_THinCluster[m_Nsets]
true hits in cluster average
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Class to store SVD mode information.
baseType getTriggerBin() const
Get the triggerBin id.
The SVD ShaperDigit class.
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.