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",
233 if (relatVectorShaperToReco.
size() > 0)
246 if (relatVectorRecoToTH.
size() > 0)
271 for (
int j = 0; j < (int) relatVectorTHToClus.
size(); j ++) {
273 relatVectorTHToClus[j]->getSensorID().getSensorNumber(), relatVectorTHToClus[j]->isUCluster());
275 if (relatVectorTHToClus[j]->isUCluster() && ! hasU) {
278 }
else if (!relatVectorTHToClus[j]->isUCluster() && ! hasV) {
296 if (relatVectorClusToTH.
size() > 0)
303 for (
int q = 0; q < (int)relatVectorClusToTH.
size(); q ++) {
313 else if (triggerBin == 1)
315 else if (triggerBin == 2)
317 else if (triggerBin == 3)
321 (clus.getClsTimeSigma()));
324 if (clus.isUCluster()) {
326 (relatVectorClusToTH[q])->getU());
328 (relatVectorClusToTH[q])->getU()) / (clus.getPositionSigma()));
330 (relatVectorClusToTH[q])->getU()), (clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()));
334 (clus.getPositionSigma()));
336 (clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()));
342 if (relatVectorClusToTH.
size() > 0) {
346 int numberOfGoodTHInACluster = 0;
347 int numberOfGoodTHInAClusterGood = 0;
348 for (
int k = 0; k < (int)(relatVectorClusToTH.
size()); k ++) {
350 numberOfGoodTHInACluster ++;
351 numberOfGoodTHInAClusterGood ++;
355 if (numberOfGoodTHInAClusterGood > 0)
360 for (
int k = 0; k < (int)relatVectorClusToReco.
size(); k++) {
361 RelationVector<SVDTrueHit> relatVectorRecoFromClusToTH = DataStore::getRelationsWithObj<SVDTrueHit>(relatVectorClusToReco[k]);
363 if (relatVectorRecoFromClusToTH.
size() > 0)
375 for (
int k = 0; k < (int)relatVectorClusToReco.
size(); k++) {
376 RelationVector<SVDTrueHit> relatVectorRecoFromClusToTH = DataStore::getRelationsWithObj<SVDTrueHit>(relatVectorClusToReco[k]);
378 if (relatVectorRecoFromClusToTH.
size() > 0)
394 for (
int k = 0; k <
m_Nsets; k ++) {
473 TDirectory* oldDir = gDirectory;
476 TDirectory* dir_strtime = oldDir->mkdir(
"strip_time");
479 while ((obj = nextH_strtime()))
482 TDirectory* dir_cltime = oldDir->mkdir(
"cluster_time");
485 while ((obj = nextH_cltime()))
488 TDirectory* dir_cltimepull = oldDir->mkdir(
"cluster_time_pull");
489 dir_cltimepull->cd();
491 while ((obj = nextH_cltimepull()))
494 TDirectory* dir_clpos = oldDir->mkdir(
"cluster_position");
497 while ((obj = nextH_clpos()))
500 TDirectory* dir_clpospull = oldDir->mkdir(
"cluster_position_pull");
503 while ((obj = nextH_clpospull()))
506 TDirectory* dir_clpostime = oldDir->mkdir(
"cluster_timeVSposition");
509 while ((obj = nextH_clpostime()))
512 TDirectory* dir_clinpurTM = oldDir->mkdir(
"intra_cluster_purity_TM");
515 while ((obj = nextH_clinpurTM()))
518 TDirectory* dir_clinpurTM2D = oldDir->mkdir(
"intra_cluster_purity_TM2D");
519 dir_clinpurTM2D->cd();
521 while ((obj = nextH_clinpurTM2D()))
524 TDirectory* dir_clinpurNOTM = oldDir->mkdir(
"intra_cluster_purity_NOTM");
525 dir_clinpurNOTM->cd();
527 while ((obj = nextH_clinpurNOTM()))
530 TDirectory* dir_puddle = oldDir->mkdir(
"trueHits_in_cluster");
533 while ((obj = nextH_puddle()))
536 TDirectory* dir_puddleTM = oldDir->mkdir(
"trueHits_in_TMcluster");
539 while ((obj = nextH_puddleTM()))
542 TDirectory* dir_goodPuddleTM = oldDir->mkdir(
"goodTrueHits_in_TMcluster");
543 dir_goodPuddleTM->cd();
545 while ((obj = nextH_GoodPuddleTM()))
548 TDirectory* dir_goodPuddleTMGood = oldDir->mkdir(
"goodTrueHits_in_GoodTMcluster");
549 dir_goodPuddleTMGood->cd();
551 while ((obj = nextH_GoodPuddleTMGood()))
554 TDirectory* dir_graph = oldDir->mkdir(
"graphs");
557 while ((obj = nextH_graph()))
560 TDirectory* dir_controlsMC = oldDir->mkdir(
"controlMC");
561 dir_controlsMC->cd();
563 while ((obj = nextH_controlsMC()))
581 Int_t nbins, Double_t min, Double_t max,
582 const char* xtitle, TList* histoList)
584 TH1F* h =
new TH1F(name, title, nbins, min, max);
586 h->GetXaxis()->SetTitle(xtitle);
595 Int_t nbinsX, Double_t minX, Double_t maxX,
597 Int_t nbinsY, Double_t minY, Double_t maxY,
598 const char* titleY, TList* histoList)
601 TH2F* h =
new TH2F(name, title, nbinsX, minX, maxX, nbinsY, minY, maxY);
603 h->GetXaxis()->SetTitle(titleX);
604 h->GetYaxis()->SetTitle(titleY);
616 if (LayerNumber == 3) {
622 if (SensorNumber == 1) {
654 if (idx == 2 || idx == 3)
676 TString xTitle, TString yTitle, TList* list)
684 for (
int set = 0; set <
m_Nsets; set++) {
690 ratio[set] = (float)vNum[set] / (
float)vDen[set];
691 ratioErr[set] =
sqrt(ratio[set] * (1 - ratio[set]) / (
float)vDen[set]);
696 TCanvas* c =
new TCanvas(name, title);
697 TGraphErrors* g =
new TGraphErrors(
m_Nsets, x, ratio, xErr, ratioErr);
700 g->GetXaxis()->SetTitle(xTitle.Data());
701 g->GetYaxis()->SetTitle(yTitle.Data());
702 g->GetYaxis()->SetRangeUser(0.00001, 1.10);
704 g->SetMarkerStyle(20);
705 g->SetMarkerSize(0.8);
706 TAxis* xAxis = g->GetXaxis();
708 TText* t =
new TText();
710 t->SetTextSize(0.035);
712 TString labels[
m_Nsets] = {
"3U",
"3V",
"456FU",
"456FV",
"456BU",
"456BV"};
713 for (Int_t i = 0; i <
m_Nsets; i++) {
714 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
723 float xErr[m_Nsets],
float y[m_Nsets],
float yErr[m_Nsets], TString xTitle, TString yTitle, TList* list,
int len)
730 B2INFO(
"ERROR, WRONG LENGTH FOR MEANS TGRAPH CREATION!!!");
734 float xErr[m_Nsets],
float y[m_Nsets],
float yErr[m_Nsets], TString xTitle, TString yTitle, TList* list)
737 TCanvas* c =
new TCanvas(name, title);
738 TGraphErrors* g =
new TGraphErrors(
m_Nsets, x, y, xErr, yErr);
741 g->GetXaxis()->SetTitle(xTitle.Data());
742 g->GetYaxis()->SetTitle(yTitle.Data());
744 g->SetMarkerStyle(20);
745 g->SetMarkerSize(0.8);
746 TAxis* xAxis = g->GetXaxis();
748 TText* t =
new TText();
750 t->SetTextSize(0.035);
752 TString labels[
m_Nsets] = {
"3U",
"3V",
"456FU",
"456FV",
"456BU",
"456BV"};
753 for (Int_t i = 0; i <
m_Nsets; i++) {
754 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
763 float xErr[m_NsetsRed],
float y[m_NsetsRed],
float yErr[m_NsetsRed], TString xTitle, TString yTitle, TList* list)
766 TCanvas* c =
new TCanvas(name, title);
767 TGraphErrors* g =
new TGraphErrors(
m_NsetsRed, x, y, xErr, yErr);
770 g->GetXaxis()->SetTitle(xTitle.Data());
771 g->GetYaxis()->SetTitle(yTitle.Data());
773 g->SetMarkerStyle(20);
774 g->SetMarkerSize(0.8);
775 TAxis* xAxis = g->GetXaxis();
777 TText* t =
new TText();
779 t->SetTextSize(0.035);
781 TString labels[
m_NsetsRed] = {
"3",
"456F",
"456B"};
783 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
799 if (relatVectorTHToMC.
size() > 0) {
803 float charge = relatVectorTHToMC[0]->getCharge();
804 bool primary = relatVectorTHToMC[0]->isPrimaryParticle();
809 if (charge != 0 && primary)
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
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.
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!)
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 arbitrarly 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.
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.
virtual void terminate() override
This method is called at the end of the event processing.
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]
numner 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)
TString FWFromIndex(int idx)
Function returning "Forward" or "Backword" depending on the index.
virtual void beginRun() override
Called when entering a new run.
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.
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
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.
void createEfficiencyGraph(const char *name, const char *title, int vNum[m_Nsets], 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...
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
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 arbitrarly 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
numnber 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.