Commit 42dce392 authored by Luca Mastrolorenzo's avatar Luca Mastrolorenzo
Browse files

addition of the classes allowing the calibration procedure be performed all at...

addition of the classes allowing the calibration procedure be performed all at once + trgCalib.cpp main dedicated only to run these classes + addition of analysis histos in CoefficientDetClu3D.hh
parent 64510062
#ifndef CalibResults_HH
#define CalibResults_HH
#include <iostream>
#include <cassert>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include "TH1F.h"
#include "TH2F.h"
#include "TProfile.h"
#include "Random.hh"
#include "TE1F.hh"
#include "TE2F.hh"
#include "AnalysisBase.hh"
#include "Event.hh"
#include "TMath.h"
class CalibResults : public AnalysisBase {
public:
enum {
kCutBins=50
};
CalibResults(const std::string &sRoot="", const std::string &sOut="")
: AnalysisBase("CalibResults",sRoot,sOut) {
//AnalysisBase(sName), fTwoPi(2.0*acos(-1.0)) {
h_events = new TH1F("h_events", "h_events",2,0,2);
h_Matrix_T = new TH2F("h_Matrix_T","d_e_i * d_e_j", 53, 0, 53, 53, 0, 53);
h_N2 = new TH2F("h_N2","N2", 53, 0, 53, 53, 0, 53);
h_Vector_T = new TH1F("h_Vector_T","vector_T", 53, 0, 53);
h_N = new TH1F("h_N","N", 53, 0, 53);
h_C3dPtResponse = new TH1F("h_C3dPtResponse","h_C3dPtResponse",100,0,2);
h_C3dPtResponse2D = new TH2F("h_C3dPtResponse2D","h_C3dPtResponse2D",600,0,300,600,0,300);
double deltaEta(double eta1, double eta2);
double deltaPhi(double phi1, double phi2);
double dist2D(double x1, double y1, double x2, double y2);
for(unsigned e(0); e<Geometry::kNumberOfEndcaps; e++)
for(unsigned l(0); l<52; l++)
for(unsigned w(0); w<700; w++)
MatrixEvent[e][l][w] = -1;
calibFile.open((sOut+"/calibrationCoefficient.txt"));
}
virtual ~CalibResults() {
}
virtual bool event(Event &event) {
double Eta_min = 1.7;
double Eta_max = 2.7;
unsigned minC2dInC3d = 3;
TString ParticleType = "photon";
bool debug_ = false;
if(fEventNumber <= 1){
for(int i=0; i<40; i++){
if(debug_) std::cout<< "layer weight = " << Calibration::layerWeight(i) << std::endl;
}
}
if(true) std::cout << fName << " Event " << fEventNumber << std::endl;
h_events->Fill(1);
for(unsigned e(0);e<Geometry::kNumberOfEndcaps;e++) {
double t_deposits_T[Geometry::kNumberOfLayers + Geometry::kNumberOfBHLayers + 1];
double t_weightDep_T[Geometry::kNumberOfLayers + Geometry::kNumberOfBHLayers + 1];
for(int i(0); i< Geometry::kNumberOfLayers + Geometry::kNumberOfBHLayers + 1; i++){
t_deposits_T[i]=0.;
t_weightDep_T[i]=0.;
}
std::vector<Particle> vSig;
//(event.photons(e));
if(ParticleType=="pion"){
std::cout << "Using Pions! \n";
vSig=event.pions(e);
}else if(ParticleType=="photon"){
std::cout << "Using Photons! \n";
vSig=event.photons(e);
}else if(ParticleType=="electron"){
std::cout << "Using Electrons! \n";
vSig=event.electrons(e);
}
//select event with signal particle in the geometrical and kinematical acceptance
int goodLayer = 0;
for(unsigned l(0); l<Geometry::kNumberOfLayers; l++) {
std::vector<Particle> vSigProjTest;
for(unsigned i(0);i<vSig.size();i++){
vSigProjTest.push_back(vSig[i].project(Geometry::layerZ(e,l)));
}
for(unsigned i(0);i<vSigProjTest.size();i++){
if( fabs( vSigProjTest[i].position().eta() ) > Eta_min && fabs( vSigProjTest[i].position().eta() ) < Eta_max ) goodLayer = goodLayer + 1 ;
}
}
//consider only the true particles that are goemetrically allowed to deposits in at least 40 layer (EE+FH?)
if(goodLayer<40) continue;
/** LOOP 3d clusters **/
std::vector<TrgC3d> vTrgC3d( event.trgC3ds(e) );
std::sort( vTrgC3d.begin(), vTrgC3d.end(), eneTranOrderC3d );
if(vTrgC3d.size()<=0) continue;
//select the best 3D-cluster per given endcap and assign the correspondent vector of 2D-cluster
std::vector<TrgC2d*> &vTrgC2d_fromMaxC3d( vTrgC3d[0].trgC2ds() );
//select only those maximum clusters that have more then 3 C2d inside
if(vTrgC2d_fromMaxC3d.size()<=minC2dInC3d) continue;
//loop over the C2d clusters collection of the max-C3d
for( unsigned iC2d = 0; iC2d < vTrgC2d_fromMaxC3d.size(); iC2d++ ) {
if(vTrgC2d_fromMaxC3d[iC2d]->transverseMips()>0 ){
t_deposits_T[vTrgC2d_fromMaxC3d[iC2d]->layer()] = vTrgC2d_fromMaxC3d[iC2d]->transverseMips();
t_weightDep_T[vTrgC2d_fromMaxC3d[iC2d]->layer()] = vTrgC2d_fromMaxC3d[iC2d]->transverseMips() * vSig[0].FourP().Et();
if(debug_) std::cout<< "--------->>>>>>>>>> " << t_deposits_T[vTrgC2d_fromMaxC3d[iC2d]->layer()] << std::endl;
}else{
t_deposits_T[vTrgC2d_fromMaxC3d[iC2d]->layer()] = 0;
t_weightDep_T[vTrgC2d_fromMaxC3d[iC2d]->layer()] = 0;
}
//assign 0 to proper layers without energy deposits
for(int ll=0; ll<52; ll++){
if( t_deposits_T[ll]<0.0001 || !(t_deposits_T[ll]==0 || t_deposits_T[ll]!=0)){
t_deposits_T[ll] = 0.;
t_weightDep_T[ll] = 0.;
if( isnan( t_weightDep_T[ll] )) if(debug_) std::cout<< "IS NAN " << std::endl;
}
}
}// end loop over C2d from MaxC3d
t_deposits_T[52] = 1.;
t_weightDep_T[52] = 1. * vSig[0].FourP().Et();
for(int hh=0; hh<52; hh++){
if( isnan( t_deposits_T[hh] )){
t_deposits_T[hh] = 0.;
if(debug_) std::cout<< "IS NAN " << std::endl;
}
if(debug_) std::cout<< "cross check deposit vec = "<< hh << ", " << t_deposits_T[hh] << std::endl;
}
double E_CluCalibMIPt_26trgLayers = 0.;
std::string content;
int i=0;
while(calibFile >> content) {
cout << "READING CALIB FILE : " << content << std::endl;
E_CluCalibMIPt_26trgLayers += t_deposits_T[i] * atof(content.c_str());
i++;
}
std::cout << "CALIBRATED ENERGY = "<< E_CluCalibMIPt_26trgLayers << " GeV" << std::endl;
if(vTrgC3d.size()>0){
//if(debug_) std::cout<< "energy particle mc << " << vSig[0].FourP().Et() << " energy after " << E_CluCalibMIPt_26trgLayers<< std::endl;
h_C3dPtResponse->Fill(E_CluCalibMIPt_26trgLayers/vSig[0].FourP().Et());
h_C3dPtResponse2D->Fill(vSig[0].FourP().Et(), E_CluCalibMIPt_26trgLayers);
}
for(int i=0; i<Geometry::kNumberOfLayers + Geometry::kNumberOfBHLayers + 1; i++){
h_N->Fill(i,1);
if( t_weightDep_T[i]>0 ){
if(debug_) std::cout<< " =============== fill transverse vector = " << i << " , " << t_weightDep_T[i] << std::endl;
h_Vector_T->Fill(i,t_weightDep_T[i]);
}
for(int j=0; j<Geometry::kNumberOfLayers + Geometry::kNumberOfBHLayers + 1; j++){
h_N2->Fill(i, j, 1);
if(t_deposits_T[i]>0 && t_deposits_T[j]>0){
h_Matrix_T->Fill( i, j, t_deposits_T[i] * t_deposits_T[j] );
}
}
}
}//end loop ever endcap
return true;
}
private:
// const double fTwoPi;
TH1F *h_events;
TH2F *h_Matrix_T;
TH1F *h_Vector_T;
TH2F *h_N2;
TH1F *h_N;
TH1F *h_C3dPtResponse;
TH2F *h_C3dPtResponse2D;
int MatrixEvent[2][52][700];
double deltaPhi( double phi1, double phi2) {
double dPhi(phi1-phi2);
double pi(acos(-1.0));
if (dPhi<=-pi) dPhi+=2.0*pi;
else if(dPhi> pi) dPhi-=2.0*pi;
return dPhi;
}
double deltaEta(double eta1, double eta2){
double dEta = (eta1-eta2);
return dEta;
}
double deltaR(double eta1, double eta2, double phi1, double phi2) {
double dEta = deltaEta(eta1, eta2);
double dPhi = deltaPhi(phi1, phi2);
return sqrt(dEta*dEta+dPhi*dPhi);
}
double dist2D(double x1, double y1, double x2, double y2){
double dx = ( x1 - x2 );
double dy = ( y1 - y2 );
return sqrt( dx*dx + dy*dy );
}
ifstream calibFile;
};
#endif
......@@ -25,7 +25,7 @@
double Eta_min = 1.7;
double Eta_max = 2.7;
unsigned minC2dInC3d = 3;
TString ParticleType = "photon";
TString ParticleType = "pion";
bool debug_ = false;
class CoefficientDetClu3D : public AnalysisBase {
......@@ -56,6 +56,9 @@ public:
h_N = new TH1F("h_N","N", 53, 0, 53);
h_C3dPtResponse = new TH1F("h_C3dPtResponse","h_C3dPtResponse",100,0,2);
h_C3dPtResponse2D = new TH2F("h_C3dPtResponse2D","h_C3dPtResponse2D",600,0,300,600,0,300);
h_C3dPtResponseGammaPi2D = new TH2F("h_C3dPtResponseGammaPi2D","h_C3dPtResponseGammaPi2D",600,0,300,600,0,300);
h_C3dPtDensityGammaPi2D = new TH2F("h_C3dPtDensityGammaPi2D","h_C3dPtDensityGammaPi2D",100,0,5,100,0,5);
h_CluEtaResponseVsEtaC2d = new TH2F("h_CluEtaResponseVsEtaC2d","h_CluEtaResponseVsEtaC2d",200,1.4,3.2, 200, -0.5, 0.5);
h_CluPhiResponseVsPhiC2d = new TH2F("h_CluPhiResponseVsPhiC2d","h_CluPhiResponseVsPhiC2d",200,-3.5,3.5, 200, -0.5, 0.5);
h_CluEtaResponseVsEtTrue = new TH2F("h_CluEtaResponseVsEtTrue","h_CluEtaResponseVsEtTrue",150,0,150, 200, -0.5, 0.5);
......@@ -97,6 +100,7 @@ public:
h_C2dSigMipTvsTotSimHitsMipT = new TH2F("h_C2dSigMipTvsTotSimHitsMipT", "h_C2dSigMipTvsTotSimHitsMipT", 400, 0, 16000, 100, 0, 400);
h_C2dMipTvsC2dLayer = new TH2F("h_C2dMipTvsC2dLayer", "h_C2dMipTvsC2dLayer", 52, 0, 52, 250, 0, 1000);
h_C2dSigMipTvsC2dLayer = new TH2F("h_C2dSigMipTvsC2dLayer", "h_C2dSigMipTvsC2dLayer", 52, 0, 52, 250, 0, 1000);
h_C2dMaxVsAllRatio = new TH1F("h_C2dMaxVsAllRatio","h_C2dMaxVsAllRatio",110,0,1.1);
h_NC3d = new TH1F("h_NC3d","h_NC3d",1200,0,1200);
h_NC3d_vs_C3dMipT = new TH2F("h_NC3d_vs_C3dMipT","h_NC3d_vs_C3dMipT", 400,0,16000,1200,0,1200);
h_NC3d_vs_C3dTrueSigMipT = new TH2F( "h_NC3d_vs_C3dTrueSigMipT", "h_NC3d_vs_C3dTrueSigMipT", 400, 0, 16000, 1200, 0, 1200 );
......@@ -108,6 +112,7 @@ public:
h_MaxC3dTrueSimMipT_spectrum = new TH1F( "h_MaxC3dTrueSimMipT_spectrum", "h_MaxC3dTrueSimMipT_spectrum", 400, 0, 16000 );
h_MaxC3dNoiseAndPU_spectrum = new TH1F( "h_MaxC3dNoiseAndPU_spectrum", "h_MAxC3dNoiseAndPU_spectrum", 800, -8000, 8000 );
h_NTrgHitPerC2d = new TH1F("h_NTrgHitPerC2d", "h_NTrgHitPerC2d", 50, 0, 50);
h_NTrgHitPerC3d = new TH1F("h_NTrgHitPerC3d", "h_NTrgHitPerC3d", 250, 0, 250);
h_NTrgHitPerLayer = new TH1F("h_NTrgHitPerLayer", "h_NTrgHitPerLayer", 75, 0, 75);
h_NC2dPerLayer = new TH1F("h_NC2dPerLayer", "h_NC2dPerLayer", 52, 0, 52);
h_NC2dInC3d_vs_C3dSigToTotMipT = new TH2F("h_NC2dInC3d_vs_C3dSigToTotMipT", "h_NC2dInC3d_vs_C3dSigToTotMipT", 200, 0, 2, 100,0,100);
......@@ -139,6 +144,28 @@ public:
h_SumAllC2dSigMipToSimHitsMipT_vs_SimHitsMipT = new TH2F("h_SumAllC2dSigMipToSimHitsMipT_vs_SimHitsMipT","h_SumAllC2dSigMipToSimHitsMipT_vs_SimHitsMipT", 400, 0, 16000, 200, 0, 2);
h_MaxC3dSimMipT_vs_SimHitsMipT = new TH1F("h_MaxC3dSimMipT_vs_SimHitsMipT", "h_MaxC3dSimMipT_vs_SimHitsMipT", 200, 0, 2);
h_MaxC3dSimMipToSimHitsMipT_vs_SimHitsMipT = new TH2F("h_MaxC3dSimMipToSimHitsMipT_vs_SimHitsMipT", "h_MaxC3dSimMipToSimHitsMipT_vs_SimHitsMipT", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_05 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_05", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_05", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_05 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_05", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_05", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_10 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_10", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_10", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_10 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_10", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_10", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_15 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_15", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_15", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_15 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_15", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_15", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_20 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_20", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_20", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_20 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_20", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_20", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_25 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_25", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_25", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_25 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_25", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_25", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_30 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_30", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_30", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_30 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_30", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_30", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_35 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_35", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_35", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_35 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_35", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_35", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_40 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_40", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_40", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_40 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_40", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_40", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_45 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_45", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_45", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_45 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_45", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_45", 400, 0, 16000,200, 0, 2);
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_50 = new TH1F("h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_50", "h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_50", 200, 0, 2);
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_50 = new TH2F("h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_50", "h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_50", 400, 0, 16000,200, 0, 2);
h_NC3dWithSigMipT = new TH1F("h_NC3dWithSigMipT","h_NC3dWithSigMipT", 100,0,100);
h_NC3dWithSigMipT_vs_TOTsimMipT = new TH2F("h_NC3dWithSigMipT_vs_TOTsimMipT","h_NC3dWithSigMipT_vs_TOTsimMipT",400, 0, 16000, 100,0,100);
h_C3dNumber_vs_SigMipTfrac = new TH2F("h_C3dNumber_vs_SigMipTfrac","h_C3dNumber_vs_SigMipTfrac", 30,0,30,140,0,1.4);
......@@ -151,8 +178,11 @@ public:
h_EventWithAtLeastAC3d = new TH1F("h_EventWithAtLeastAC3d", "h_EventWithAtLeastAC3d", 2,0,2);
h_EvtWithSharedC3d = new TH1F("h_EvtWithSharedC3d","h_EvtWithSharedC3d",2,0,2);
h_SharedC2dLayerVsSharedFrac = new TH2F("h_SharedC2dLayerVsSharedFrac","h_SharedC2dLayerVsSharedFrac",52,0,52,200,0,1.2);
h_NotSharedC2dLayerVsSharedFrac = new TH2F("h_NotSharedC2dLayerVsSharedFrac","h_NotSharedC2dLayerVsSharedFrac",52,0,52,200,0,1.2);
h_layerGap_vs_C3dSigMipT = new TH2F("h_layerGap_vs_C3dSigMipT","h_layerGap_vs_C3dSigMipT",52,0,52, 400, 0, 16000 );
h_TrgHitSigMipTFrac_vs_Threshold = new TH2F("h_TrgHitSigMipTFrac_vs_Threshold","h_TrgHitSigMipTFrac_vs_Threshold",20,0,10,200,0,1.2);
h_TrgHitSigMipFrac_vs_Threshold = new TH2F("h_TrgHitSigMipFrac_vs_Threshold","h_TrgHitSigMipFrac_vs_Threshold",11,0,22,200,0,1.2);
double deltaEta(double eta1, double eta2);
double deltaPhi(double phi1, double phi2);
double dist2D(double x1, double y1, double x2, double y2);
......@@ -242,6 +272,18 @@ public:
double TrgHitSigMipT_tot_40 = 0.;
double TrgHitSigMipT_tot_45 = 0.;
double TrgHitSigMipT_tot_50 = 0.;
double mip_TOT_endcap = 0.;
double TrgHitSigMip_tot_20 = 0.;
double TrgHitSigMip_tot_40 = 0.;
double TrgHitSigMip_tot_60 = 0.;
double TrgHitSigMip_tot_80 = 0.;
double TrgHitSigMip_tot_100 = 0.;
double TrgHitSigMip_tot_120 = 0.;
double TrgHitSigMip_tot_140 = 0.;
double TrgHitSigMip_tot_160 = 0.;
double TrgHitSigMip_tot_180 = 0.;
double TrgHitSigMip_tot_200 = 0.;
double AllC2dSigMipT=0.;
for(unsigned l(0);l<Geometry::kNumberOfLayers;l++) {
for(unsigned w(0);w<Geometry::numberOfWafers(l);w++) {
......@@ -249,18 +291,34 @@ public:
//over TrgHits
TrgHit *vTH(event.trgHits(e,l,w));
for(unsigned c(0);c<Geometry::numberOfTriggerCells(l,w);c++){
if(vTH[c].simTransverseMips(true)<=0) continue;
mipT_TOT_endcap+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>0.5) TrgHitSigMipT_tot_05+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>1.0) TrgHitSigMipT_tot_10+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>1.5) TrgHitSigMipT_tot_15+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>2.0) TrgHitSigMipT_tot_20+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>2.5) TrgHitSigMipT_tot_25+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>3.0) TrgHitSigMipT_tot_30+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>3.5) TrgHitSigMipT_tot_35+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>4.0) TrgHitSigMipT_tot_40+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>4.5) TrgHitSigMipT_tot_45+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>5.0) TrgHitSigMipT_tot_50+=vTH[c].simTransverseMips(true);
//if(vTH[c].simTransverseMips(true)<=0) continue;
if(vTH[c].simTransverseMips(true)>0){
mipT_TOT_endcap+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>0.5) TrgHitSigMipT_tot_05+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>1.0) TrgHitSigMipT_tot_10+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>1.5) TrgHitSigMipT_tot_15+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>2.0) TrgHitSigMipT_tot_20+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>2.5) TrgHitSigMipT_tot_25+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>3.0) TrgHitSigMipT_tot_30+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>3.5) TrgHitSigMipT_tot_35+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>4.0) TrgHitSigMipT_tot_40+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>4.5) TrgHitSigMipT_tot_45+=vTH[c].simTransverseMips(true);
if(vTH[c].simTransverseMips(true)>5.0) TrgHitSigMipT_tot_50+=vTH[c].simTransverseMips(true);
}
if(vTH[c].simMips(true)>0){
mip_TOT_endcap+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>2.0) TrgHitSigMip_tot_20+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>4.0) TrgHitSigMip_tot_40+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>6.0) TrgHitSigMip_tot_60+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>8.0) TrgHitSigMip_tot_80+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>10.0) TrgHitSigMip_tot_100+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>12.0) TrgHitSigMip_tot_120+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>14.0) TrgHitSigMip_tot_140+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>16.0) TrgHitSigMip_tot_160+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>18.0) TrgHitSigMip_tot_180+=vTH[c].simMips(true);
if(vTH[c].simMips(true)>20.0) TrgHitSigMip_tot_200+=vTH[c].simMips(true);
}
}//end loop over the trigger cells
}
}//end loop over wafers
......@@ -284,6 +342,39 @@ public:
h_TrgHitSigMipTFrac_vs_Threshold->Fill(4.5,TrgHitSigMipT_tot_45/mipT_TOT_endcap );
h_TrgHitSigMipTFrac_vs_Threshold->Fill(5.0,TrgHitSigMipT_tot_50/mipT_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(2.0,TrgHitSigMip_tot_20/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(4.0,TrgHitSigMip_tot_40/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(6.0,TrgHitSigMip_tot_60/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(8.0,TrgHitSigMip_tot_80/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(10.0,TrgHitSigMip_tot_100/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(12.0,TrgHitSigMip_tot_120/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(14.0,TrgHitSigMip_tot_140/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(16.0,TrgHitSigMip_tot_160/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(18.0,TrgHitSigMip_tot_180/mip_TOT_endcap );
h_TrgHitSigMipFrac_vs_Threshold->Fill(20.0,TrgHitSigMip_tot_200/mip_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_05->Fill( TrgHitSigMipT_tot_05/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_10->Fill( TrgHitSigMipT_tot_10/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_15->Fill( TrgHitSigMipT_tot_15/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_20->Fill( TrgHitSigMipT_tot_20/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_25->Fill( TrgHitSigMipT_tot_25/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_30->Fill( TrgHitSigMipT_tot_30/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_35->Fill( TrgHitSigMipT_tot_35/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_40->Fill( TrgHitSigMipT_tot_40/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_45->Fill( TrgHitSigMipT_tot_45/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_50->Fill( TrgHitSigMipT_tot_50/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_05->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_05/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_10->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_10/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_15->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_15/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_20->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_20/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_25->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_25/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_30->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_30/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_35->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_35/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_40->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_40/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_45->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_45/mipT_TOT_endcap );
h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_50->Fill( mipT_TOT_endcap, TrgHitSigMipT_tot_50/mipT_TOT_endcap );
if(debug_) std::cout << " the total TRUE energy in the endcap " << e << " is = " << mipT_TOT_endcap << std::endl;
......@@ -443,6 +534,7 @@ public:
h_CluEtaC3dVsEtaTrue->Fill( vSig[0].project(Geometry::layerZ(e,0)).FourP().Eta(), vTrgC3d[0].centerEtaPhi().first );
h_CluPhiC3dVsPhiTrue->Fill( vSig[0].project(Geometry::layerZ(e,0)).FourP().Phi(), vTrgC3d[0].centerEtaPhi().second );
// h_layerGap_vs_C3dSigMipT->Fill(vTrgC3d[0].simTransverseMips(true),vTrgC3d[0].LayerGapInC3d() );
bool IsShared=false;
//internal loop over all the C3d in order to evaluate the mutual distance
for(std::vector<TrgC3d>::iterator clu3d_tmp = vTrgC3d.begin(); clu3d_tmp != vTrgC3d.end(); clu3d_tmp++ ){
......@@ -452,13 +544,21 @@ public:
h_MaxC3dSharedMipWithAll->Fill( vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp)) );
std::cout << " IC3D = "<< clu3d_tmp - vTrgC3d.begin() << " frac shared = " << vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp))/vTrgC3d[0].transverseMips() <<std::endl;
std::vector<double> vSharedC2dLayer = vTrgC3d[0].C3dSharedC2dLayer( &(*clu3d_tmp));
std::vector<double> vNotSharedC2dLayer = vTrgC3d[0].C3dNotSharedC2dLayer( &(*clu3d_tmp));
std::cout << "shared layer "<<std::endl;
for(unsigned sl = 0; sl < vSharedC2dLayer.size(); sl++){
if(vSharedC2dLayer.size()>0){
std::cout << " " << vSharedC2dLayer[sl] << std::endl;
std::cout << " shared layer: " << vSharedC2dLayer[sl] << std::endl;
h_SharedC2dLayerVsSharedFrac->Fill(vSharedC2dLayer[sl], vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp))/vTrgC3d[0].transverseMips());
}
}
std::cout << "non-shared layer "<<std::endl;
for(unsigned nsl = 0; nsl < vNotSharedC2dLayer.size(); nsl++){
if(vNotSharedC2dLayer.size()>0){
std::cout << " non shared layer: " << vNotSharedC2dLayer[nsl] <<std::endl;
h_NotSharedC2dLayerVsSharedFrac->Fill(vNotSharedC2dLayer[nsl], vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp))/vTrgC3d[0].transverseMips());
}
}
h_FracSharedEnergy_vs_CardPosC3d->Fill( clu3d_tmp - vTrgC3d.begin(), vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp))/vTrgC3d[0].transverseMips());
h_FracSharedEnergy_vs_DistFromMaxC3d->Fill( vTrgC3d[0].C3dDistanceNorm( &(*clu3d_tmp) ), vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp))/vTrgC3d[0].transverseMips());
if(vTrgC3d[0].C3dSharedTransverseMips( &(*clu3d_tmp))/vTrgC3d[0].transverseMips() > 0.8) IsShared=true;
......@@ -493,7 +593,7 @@ public:
h_EneDensity_vs_C2dLayer->Fill( vTrgC2d_fromMaxC3d[iC2d]->layer(), C2d_SigEneDensity );
h_SigEneDensity_vs_C2dSigMipT->Fill( vTrgC2d_fromMaxC3d[iC2d]->transverseMips(), C2d_EneDensity );
h_EneDensity_vs_C2dMipt->Fill( vTrgC2d_fromMaxC3d[iC2d]->simTransverseMips(true), C2d_SigEneDensity );
h_C2dMaxVsAllRatio->Fill(vTrgC2d_fromMaxC3d[iC2d]->trgC2dMaxVsAllHitRatio());
double eta_sig = vSig[0].project(Geometry::layerZ(e,0)).FourP().Eta();
double phi_sig = vSig[0].project(Geometry::layerZ(e,0)).FourP().Phi();
......@@ -568,6 +668,9 @@ public:
}
double E_CluCalibMIPt_26trgLayers = calibCluster(t_deposits_T);
double E_CluCalibMIPt_GammaCoeff = calibClusterGamma(t_deposits_T);
double E_CluCalibMIPt_PiCoeff = calibClusterPion(t_deposits_T);
if(vTrgC3d.size()>0){
double fracMaxC3d = vTrgC3d[0].transverseMips() / totC3dMipT;
h_totC3dMipT_vs_Sig->Fill(totC3dMipT);
......@@ -576,7 +679,9 @@ public:
if(debug_) std::cout<< "energy particle mc << " << vSig[0].FourP().Et() << " energy after " << E_CluCalibMIPt_26trgLayers<< std::endl;
h_C3dPtResponse->Fill(E_CluCalibMIPt_26trgLayers/vSig[0].FourP().Et());
h_C3dPtResponse2D->Fill(vSig[0].FourP().Et(), E_CluCalibMIPt_26trgLayers);
h_C3dPtResponseGammaPi2D->Fill(E_CluCalibMIPt_GammaCoeff, E_CluCalibMIPt_PiCoeff);
h_C3dPtDensityGammaPi2D->Fill(E_CluCalibMIPt_GammaCoeff/vTrgC3d[0].numberOfTrgHits(), E_CluCalibMIPt_PiCoeff/ vTrgC3d[0].numberOfTrgHits());
h_NTrgHitPerC3d->Fill(vTrgC3d[0].numberOfTrgHits());
}else{
if(debug_) std::cout << "fraction of the energy in the main cluster: " << 0. << std::endl;
h_FracMipTMaxC3d->Fill(0.);
......@@ -616,6 +721,8 @@ private:
TH1F *h_SigPhi;
TH1F *h_C3dPtResponse;
TH2F *h_C3dPtResponse2D;
TH2F *h_C3dPtResponseGammaPi2D;
TH2F *h_C3dPtDensityGammaPi2D;
TH1F *h_C3dEtaResponse;
TH1F *h_C3dPhiResponse;
......@@ -658,6 +765,7 @@ private:
TH1F *h_MaxC3dTrueSimMipT_spectrum;
TH1F *h_MaxC3dNoiseAndPU_spectrum;
TH1F *h_NTrgHitPerC2d;
TH1F *h_NTrgHitPerC3d;
TH1F *h_NTrgHitPerLayer;
TH2F *h_NC2dInC3d_vs_C3dSigToTotMipT;
TH1F *h_NC2dPerLayer;
......@@ -673,6 +781,7 @@ private:
TH2F *h_C2dSigMipTvsTotSimHitsMipT;
TH2F *h_C2dMipTvsC2dLayer;
TH2F *h_C2dSigMipTvsC2dLayer;
TH1F *h_C2dMaxVsAllRatio;
TH2F *h_SigEneDensity_vs_C2dLayer;
TH2F *h_EneDensity_vs_C2dLayer;
TH2F *h_SigEneDensity_vs_C2dSigMipT;
......@@ -689,6 +798,28 @@ private:
TH1F *h_mipTsimVsC3d_RatioMaxC3d;
TH2F *h_mipTsimVsC3d_RatioMaxC3d_vs_C3dMipT;
TH2F *h_mipTsimVsC3d_RatioMaxC3d_vs_C3dTrueSigMipT;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_05;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_10;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_15;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_20;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_25;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_30;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_35;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_40;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_45;
TH1F *h_SumAllTrgHitsSigMipT_vs_SimHItsMipT_50;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_05;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_10;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_15;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_20;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_25;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_30;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_35;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_40;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_45;
TH2F *h_SumAllTrgHitsSigMipToSimHitsMipT_vs_SimHitsMipT_50;
TH1F *h_SumAllC3dSimMipT_vs_SimHitsMipT;
TH2F *h_SumAllC3dSimMipToSimHitsMipT_vs_SimHitsMipT;
......@@ -708,6 +839,9 @@ private:
TH1F *h_EvtWithSharedC3d;
TH2F *h_SharedC2dLayerVsSharedFrac;
TH2F *h_TrgHitSigMipTFrac_vs_Threshold;
TH2F *h_TrgHitSigMipFrac_vs_Threshold;
TH2F *h_layerGap_vs_C3dSigMipT;
TH2F *h_NotSharedC2dLayerVsSharedFrac;
int MatrixEvent[2][52][700];
......
#ifndef FillMatrixForCalib_HH
#define FillMatrixForCalib_HH
#include <iostream>
#include <cassert>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include "TH1F.h"
#include "TH2F.h"
#include "TProfile.h"
#include "Random.hh"
#include "TE1F.hh"
#include "TE2F.hh"
#include "AnalysisBase.hh"
#include "Event.hh"
#include "TMath.h"
class FillMatrixForCalib : public AnalysisBase {
public:
enum {
kCutBins=50
};
FillMatrixForCalib(const std::string &sRoot="", const std::string &sOut="")
: AnalysisBase("FillMatrixForCalib",sRoot,sOut) {
//AnalysisBase(sName), fTwoPi(2.0*acos(-1.0)) {
h_events = new TH1F("h_events", "h_events",2,0,2);
h_Matrix_T = new TH2F("h_Matrix_T","d_e_i * d_e_j", 53, 0, 53, 53, 0, 53);
h_N2 = new TH2F("h_N2","N2", 53, 0, 53, 53, 0, 53);
h_Vector_T = new TH1F("h_Vector_T","vector_T", 53, 0, 53);
h_N = new TH1F("h_N","N", 53, 0, 53);
double deltaEta(double eta1, double eta2);
double deltaPhi(double phi1, double phi2);
double dist2D(double x1, double y1, double x2, double y2);