Skip to content

Commit

Permalink
debug cout deleted, include header not necessary deleted, function du…
Browse files Browse the repository at this point in the history
…plication solved
  • Loading branch information
denisecasazza committed Oct 1, 2024
1 parent 2834108 commit 5946f61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 82 deletions.
15 changes: 0 additions & 15 deletions include/SANDClustering.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#ifndef SANDCLUSTERING_H
#define SANDCLUSTERING_H

#include <complex> // check if needed
#include <fstream>
#include <iostream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include "TFile.h"
#include "TLeaf.h"
#include "TTree.h"
#include "TSystem.h"

//#include "SANDClusteringLinkDef.h"
#include "struct.h"
//#include "utils.h"

std::tuple<double, double, double, double> fit_ls(int, double[], double[],
double[]);
Expand All @@ -40,17 +32,10 @@ cluster Create_cluster(std::vector<dg_cell>);
bool RepetitionCheck(std::vector<int>, int);
bool isNeighbour(int, int);

//
/// Maybe duplication of identical functions
//
double TfromTDC(double t1, double t2, double L);
double AttenuationFactor(double d, int planeID);
double EfromADC(double adc1, double adc2, double d1, double d2, int planeID);
double EfromADCsingle(double adc, double f);
double DfromTDC(double, double);

bool endsWith(const std::string& fullString, const std::string& ending);

// void Clust_info(cluster);

#endif
64 changes: 7 additions & 57 deletions src/SANDClustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ std::vector<cluster> Clusterize(std::vector<dg_cell>* vec_cellraw)

std::vector<int> checked_array;
std::vector<int> vec_cell;

std::vector<int> chck;

for (int i = 0; i < multicomplete_cells.size(); i++) {
Expand Down Expand Up @@ -77,12 +76,12 @@ std::vector<cluster> Clusterize(std::vector<dg_cell>* vec_cellraw)
void Clust_info(cluster clus)
{
std::cout << "Cluster Energy " << clus.e << " MeV" << std::endl;
std::cout << "Coordinate centroide: " << clus.x << " [X] " << clus.y
<< " [Y] " << clus.z << " [z] e tempo di arrivo medio " << clus.t
<< " ns" << std::endl;
std::cout << "Varianza: " << clus.varx << " [X] " << clus.vary << " [Y] "
std::cout << "Centroid coordinates: " << clus.x << " [X] " << clus.y
<< " [Y] " << clus.z << " [z] , and mean arrival time: " << clus.t
<< " ns." << std::endl;
std::cout << "Variance: " << clus.varx << " [X] " << clus.vary << " [Y] "
<< clus.varz << " [z]" << std::endl;
std::cout << "Composto dalle seguenti celle: ";
std::cout << "Composed by the following cells: ";
for (int i = 0; i < clus.reco_cells.size(); i++) {
std::cout << "Cell: " << clus.reco_cells.at(i).id
<< " X: " << clus.reco_cells.at(i).x
Expand Down Expand Up @@ -1073,56 +1072,7 @@ std::pair<std::vector<dg_cell>, std::vector<int>> GetNeighbours(
return std::make_pair(neigh_chain, checked);
}

double AttenuationFactor(double d, int planeID)
{
/*
dE/dx attenuation - Ea=p1*exp(-d/atl1)+(1.-p1)*exp(-d/atl2)
d distance from photocatode - 2 cells/cell; d1 and d2
atl1 50. cm
atl2 430 cm planes 1-2 innermost plane is 1
380 cm plane 3
330 cm planes 4-5
p1 0.35
*/
double atl2 = 0.0;

switch (planeID) {
case 0:
atl2 = sand_reco::ecal::attenuation::atl2_01;
break;
case 1:
atl2 = sand_reco::ecal::attenuation::atl2_01;
break;

case 2:
atl2 = sand_reco::ecal::attenuation::atl2_2;
break;

case 3:
atl2 = sand_reco::ecal::attenuation::atl2_34;
break;

case 4:
atl2 = sand_reco::ecal::attenuation::atl2_34;
break;

default:

atl2 = -999.0;
break;
}

return sand_reco::ecal::attenuation::p1 *
TMath::Exp(-d / sand_reco::ecal::attenuation::atl1) +
(1. - sand_reco::ecal::attenuation::p1) * TMath::Exp(-d / atl2);
}

double TfromTDC(double t1, double t2, double L)
{
return 0.5 * (t1 + t2 -
sand_reco::ecal::scintillation::vlfb * L /
sand_reco::conversion::m_to_mm);
}

double EfromADCsingle(double adc, double f)
{
Expand All @@ -1133,8 +1083,8 @@ double EfromADCsingle(double adc, double f)

double DfromTDC(double ta, double tb)
{
return 0.5 * (ta - tb) / sand_reco::ecal::scintillation::vlfb *
sand_reco::conversion::m_to_mm;
return 0.5 * (ta - tb) / sand_reco::ecal::scintillation::vlfb *
sand_reco::conversion::m_to_mm;
}

bool endsWith(const std::string& fullString, const std::string& ending)
Expand Down
21 changes: 11 additions & 10 deletions src/SANDECALClustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ int clustering(std::string const& input)
const char* finname = input.c_str();
TFile f(finname, "READ");
TTree* t = (TTree*)f.Get("tDigit");

if (f.IsZombie()){
std::cout << "Error in opening file\n";
exit(1);
}

if (t == nullptr ){
std::cout << "Error in retrieving objects from root file: tDigit" << std::endl;
exit(-1);
}

int nEvents = t->GetEntries();
std::vector<dg_cell>* cell = new std::vector<dg_cell>;
std::vector<cluster> f_clust, og_clust;
Expand All @@ -17,19 +28,9 @@ int clustering(std::string const& input)
t->SetBranchAddress("dg_cell", &cell);

for (int i = 0; i < nEvents; i++) {
//std::cout <<"EVENT: " << i <<std::endl;
t->GetEntry(i);
std::vector<cluster> clust = Clusterize(std::move(cell));

double CluEn = 0;
int n_clu = 0;
std::cout << "ENTRY: "<< i << ", FINAL CONFIGURATION: " << std::endl;
for (auto const& clu_info : clust) {
std::cout << "Cluster number: " << n_clu << std::endl;
Clust_info(clu_info);
std::cout << std::endl;
n_clu++;
}
f_clust = clust;
tout.Fill();
clust.clear();
Expand Down

0 comments on commit 5946f61

Please sign in to comment.