Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-08 08:36:28

0001 // A C++ script to read data from a CSV file and plot multiple files on the same graph
0002 // using the ROOT framework.
0003 
0004 #include <iostream>
0005 #include <fstream>
0006 #include <string>
0007 #include <vector>
0008 
0009 // Include necessary ROOT headers
0010 #include "TGraph.h"
0011 #include "TMultiGraph.h"
0012 #include "TCanvas.h"
0013 #include "TFile.h"
0014 #include "TAxis.h"
0015 #include "TLegend.h"
0016 #include "TLatex.h"
0017 
0018 //================================================================================
0019 // Function to read data from a single CSV file and create a TGraph object.
0020 //================================================================================
0021 TGraph* createGraphFromFile(TString filename, const char* title, Bool_t logY = kFALSE, Double_t shiftX = 0.) {
0022   // Open the CSV file.
0023   std::ifstream inputFile(filename.Data());
0024 
0025   // Check if the file was successfully opened.
0026   if (!inputFile.is_open()) {
0027     std::cerr << "Error: Could not open file " << filename.Data() << std::endl;
0028     return nullptr;
0029   }
0030 
0031   // Vectors to store the current and voltage data.
0032   std::vector<double> voltage;
0033   std::vector<double> current;
0034 
0035   // Skip the header line.
0036   std::string headerLine;
0037   std::getline(inputFile, headerLine);
0038 
0039   // Read data line by line from the CSV.
0040   std::string line;
0041   while (std::getline(inputFile, line)) {
0042     // Find the comma separator.
0043     size_t commaPos = line.find(',');
0044     if (commaPos != std::string::npos) {
0045       // Extract voltage and current strings.
0046       std::string voltageStr = line.substr(0, commaPos);
0047       std::string currentStr = line.substr(commaPos + 1);
0048 
0049       // Convert string data to double and store in vectors.
0050       try {
0051         voltage.push_back(std::stod(voltageStr)-shiftX);
0052         if (logY){
0053           current.push_back(TMath::Log(std::stod(currentStr)));
0054         } else {
0055           current.push_back(std::stod(currentStr));
0056         }
0057       } catch (const std::exception& e) {
0058         std::cerr << "Error converting data: " << e.what() << std::endl;
0059         continue;
0060       }
0061     }
0062   }
0063   inputFile.close();
0064 
0065   // Check if any valid data was read.
0066   if (voltage.empty() || current.empty() || voltage.size() != current.size()) {
0067     std::cerr << "Error: No valid data found or mismatch in data size for file " << filename.Data() << std::endl;
0068     return nullptr;
0069   }
0070 
0071   // Create a TGraph object and return it.
0072   TGraph* graph = new TGraph(voltage.size(), voltage.data(), current.data());
0073   graph->SetTitle(title);
0074   return graph;
0075 }
0076 
0077 //================================================================================
0078 // The main function to convert the files to root graphs
0079 //================================================================================
0080 void ConvertSiPMIrradData() {
0081 
0082     // Define an array of colors and markers to use for the plots.
0083     int colors[] = {kRed+1, kBlue+1, kGreen + 2, kCyan+1}; //, kOrange, kMagenta
0084     int markers[] = {kFullCircle, kFullSquare, 33, 28, 34, 24, 25, 27, 42, 46, 43, 47, 29, 30};
0085     
0086     Int_t l[4] = {-1, -1, -1, -1};
0087     TString labelsNP[7] =  {"10^{0}", "10^{8}", "10^{9}", "10^{10}", "10^{11}", "10^{12}", "10^{13}"}; 
0088     TString outNP[7] =  {"10_0", "10_8", "10_9", "10_10", "10_11", "10_12", "10_13"}; 
0089     Double_t NP[7] =  {1e0, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13}; 
0090     
0091     TString labelsSiPM[4] =  {"A", "B", "C", "D"}; 
0092 
0093     //*****************************************************************************
0094     // Original data from: 
0095     // https://arxiv.org/pdf/2503.14622
0096     // https://zenodo.org/records/14520936
0097     //*****************************************************************************
0098     // Define a list of file names you want to plot.
0099     std::vector<std::string> filenamesS14_1315 = {
0100         "Data/S14_1315/New_Irradiated/1315A00_UTC_20240815__21_40_converted.csv",
0101         "Data/S14_1315/New_Irradiated/1315A08_UTC_20240815__22_43_converted.csv",
0102         "Data/S14_1315/New_Irradiated/1315A09_UTC_20240815__22_59_converted.csv",
0103         "Data/S14_1315/New_Irradiated/1315B9_UTC_20240816__18_13_converted.csv",
0104         "Data/S14_1315/New_Irradiated/1315C9_UTC_20240816__19_33_converted.csv",
0105         "Data/S14_1315/New_Irradiated/1315A10_UTC_20240815__23_14_converted.csv",
0106         "Data/S14_1315/New_Irradiated/1315B10_UTC_20240816__18_26_converted.csv",  
0107         "Data/S14_1315/New_Irradiated/1315C10_UTC_20240816__19_45_converted.csv",
0108         "Data/S14_1315/New_Irradiated/1315A11_UTC_20240815__23_25_converted.csv",
0109         "Data/S14_1315/New_Irradiated/1315B11_UTC_20240816__18_48_converted.csv",
0110         "Data/S14_1315/New_Irradiated/1315C11_UTC_20240816__19_56_converted.csv",
0111         "Data/S14_1315/New_Irradiated/1315A12_UTC_20240815__23_50_converted.csv", 
0112         "Data/S14_1315/New_Irradiated/1315B12_UTC_20240816__19_00_converted.csv",
0113         "Data/S14_1315/New_Irradiated/1315C12_UTC_20240816__20_06_converted.csv",
0114         "Data/S14_1315/New_Irradiated/1315A13_UTC_20240816__00_10_converted.csv",
0115         "Data/S14_1315/New_Irradiated/1315B13_UTC_20240816__19_15_converted.csv",
0116         // Add more file names here as needed.
0117     };
0118 
0119     std::vector<TString> labelsS14_1315 = {
0120         "A 10^{0} N_{p^{+}}",
0121         "A 10^{8} N_{p^{+}}",
0122         "A 10^{9} N_{p^{+}}",
0123         "B 10^{9} N_{p^{+}}",
0124         "C 10^{9} N_{p^{+}}",
0125         "A 10^{10} N_{p^{+}}",
0126         "B 10^{10} N_{p^{+}}",
0127         "C 10^{10} N_{p^{+}}",
0128         "A 10^{11} N_{p^{+}}",
0129         "B 10^{11} N_{p^{+}}",
0130         "C 10^{11} N_{p^{+}}",
0131         "A 10^{12} N_{p^{+}}",
0132         "B 10^{12} N_{p^{+}}",
0133         "C 10^{12} N_{p^{+}}",
0134         "A 10^{13} N_{p^{+}}",
0135         "B 10^{13} N_{p^{+}}",
0136         // Add more file names here as needed.
0137     };
0138 
0139     std::vector<std::string> filenamesS14_3015 = {
0140       "Data/S14_3015/New_Nonirradiated/Hex_Nonirradiated_Retest_SiPM_A_UTC_20240726__16_57_converted.txt",
0141       "Data/S14_3015/New_Nonirradiated/Hex_Nonirradiated_Retest_SiPM_B_UTC_20240726__17_16_converted.txt",
0142       "Data/S14_3015/New_Nonirradiated/Hex_Nonirradiated_Retest_SiPM_C_UTC_20240726__17_28_converted.txt",
0143       "Data/S14_3015/New_Nonirradiated/Hex_Nonirradiated_UTC_20240724__00_19_converted.txt",
0144       "Data/S14_3015/New_Irradiated/Hex_3015A08_UTC_20240724__23_44_coverted.csv",
0145       // "Data/S14_3015/New_Irradiated/Hex_3015A09_UTC_20240725__00_04_converted.csv",
0146       "Data/S14_3015/New_Irradiated/Hex_3015A9_Retest_UTC_20240726__17_59_converted.csv",
0147       // "Data/S14_3015/New_Irradiated/Hex_3015B9_UTC_20240725__00_15_converted.csv",
0148       "Data/S14_3015/New_Irradiated/Hex_3015B9_Retest_UTC_20240726__18_19_converted.csv",
0149       "Data/S14_3015/New_Irradiated/Hex_3015A10_UTC_20240725__16_55_converted.csv",
0150       "Data/S14_3015/New_Irradiated/Hex_3015B10_UTC_20240725__17_13_converted.csv",
0151       "Data/S14_3015/New_Irradiated/Hex_3015A11_UTC_20240725__17_35_converted.csv",
0152       "Data/S14_3015/New_Irradiated/Hex_3015B11_UTC_20240725__17_47_converted.csv",
0153       "Data/S14_3015/New_Irradiated/Hex_3015C11_UTC_20240725__18_11_converted.csv",
0154       // "Data/S14_3015/New_Irradiated/Hex_3015A12_UTC_20240724__18_12_converted.csv",
0155       "Data/S14_3015/New_Irradiated/Hex_3015A12_Retest_UTC_20240726__19_00_converted.csv",
0156       // "Data/S14_3015/New_Irradiated/Hex_3015B12_UTC_20240724__22_20_converted.csv",
0157       "Data/S14_3015/New_Irradiated/Hex_3015B12_Retest_UTC_20240726__19_31_converted.csv",
0158       // "Data/S14_3015/New_Irradiated/Hex_3015C12_UTC_20240724__22_33_converted.csv",
0159       "Data/S14_3015/New_Irradiated/Hex_3015C12_Retest_UTC_20240726__21_26_converted.csv",
0160       "Data/S14_3015/New_Irradiated/Hex_3015A13_UTC_20240725__20_03_converted.csv",
0161     };
0162 
0163     std::vector<TString> labelsS14_3015 = {
0164         "A 10^{0} N_{p^{+}}",
0165         "B 10^{0} N_{p^{+}}",
0166         "C 10^{0} N_{p^{+}}",
0167         "D 10^{0} N_{p^{+}}",
0168         "A 10^{8} N_{p^{+}}",
0169         "A 10^{9} N_{p^{+}}",
0170         // "A 10^{9} N_{p^{+}}",
0171         "B 10^{9} N_{p^{+}}",
0172         // "B 10^{9} N_{p^{+}}",
0173         "A 10^{10} N_{p^{+}}",
0174         "B 10^{10} N_{p^{+}}",
0175         "A 10^{11} N_{p^{+}}",
0176         "B 10^{11} N_{p^{+}}",
0177         "C 10^{11} N_{p^{+}}",
0178         "A 10^{12} N_{p^{+}}",
0179         // "A 10^{12} N_{p^{+}}",
0180         "B 10^{12} N_{p^{+}}",
0181         // "B 10^{12} N_{p^{+}}",
0182         "C 10^{12} N_{p^{+}}",
0183         // "C 10^{12} N_{p^{+}}",
0184         "A 10^{13} N_{p^{+}}",
0185         // Add more file names here as needed.
0186     };
0187     
0188     TFile* outputRoot = new TFile("Data/IrradiationStudies.root","UPDATE");
0189     outputRoot->mkdir("S14160-1315");
0190     outputRoot->cd("S14160-1315");
0191     
0192     TGraph* graphSignalS14_1315 = createGraphFromFile("Data/S14_1315/TimeVsAmplitude.csv", "SignalShape-13mm");
0193     graphSignalS14_1315->SetLineColor(kBlue+2);
0194     graphSignalS14_1315->SetMarkerColor(kBlue+2);
0195     graphSignalS14_1315->SetMarkerStyle(20);
0196     graphSignalS14_1315->GetXaxis()->SetTitle("#it{t} (ns)");
0197     graphSignalS14_1315->GetYaxis()->SetTitle("#it{A} (a.U.)");
0198     graphSignalS14_1315->Print();
0199 
0200     TGraph* graphPhotonEffi = createGraphFromFile("Data/S14_1315/WaveLengthvsPhotonEffi.csv", "PhotonEfficiencyVsWavelength");
0201     graphPhotonEffi->SetLineColor(kBlue+2);
0202     graphPhotonEffi->SetMarkerColor(kBlue+2);
0203     graphPhotonEffi->SetMarkerStyle(20);
0204     graphPhotonEffi->GetXaxis()->SetTitle("#lambda (nm)");
0205     graphPhotonEffi->GetYaxis()->SetTitle("#PDE (%)");
0206     // graphPhotonEffi->Print();
0207 
0208     TGraph* graphGain = createGraphFromFile("Data/S14_1315/OverVoltageVsGain.csv", "Gain");
0209     graphGain->SetLineColor(kBlue+2);
0210     graphGain->SetMarkerColor(kBlue+2);
0211     graphGain->SetMarkerStyle(20);
0212     graphGain->GetXaxis()->SetTitle("#it{V_{ov}} (V)");
0213     graphGain->GetYaxis()->SetTitle("#it{G} (a.U.)");
0214     graphGain->Print();
0215     
0216     TGraph* graphSignalS14_3015 = createGraphFromFile("Data/S14_3015/TimeVsAmplitude.csv", "SignalShape-30mm");
0217     graphSignalS14_3015->SetLineColor(kBlue+2);
0218     graphSignalS14_3015->SetMarkerColor(kBlue+2);
0219     graphSignalS14_3015->SetMarkerStyle(20);
0220     graphSignalS14_3015->GetXaxis()->SetTitle("#it{t} (ns)");
0221     graphSignalS14_3015->GetYaxis()->SetTitle("#it{A} (a.U.)");
0222     
0223     TGraph* DCRvsRad1mm[8];
0224     TGraph* DCRvsRad3mm[8];
0225     for (Int_t v= 0; v< 8; v++){
0226         DCRvsRad1mm[v] = new TGraph(100);
0227         DCRvsRad3mm[v] = new TGraph(100);
0228     }
0229     Int_t nPoints1mm = 0;
0230     Int_t nPoints3mm = 0;
0231     // Loop through the list of filenames, create a graph for each, and add it to the TMultiGraph.
0232     for (size_t i = 0; i < filenamesS14_1315.size(); ++i) {
0233       std::string title = "File " + std::to_string(i + 1);
0234       TGraph* graph = createGraphFromFile(Form("%s",filenamesS14_1315[i].c_str()), title.c_str());
0235       std::cout << filenamesS14_1315[i].c_str() << std::endl;
0236       Int_t j = -1;
0237       if (graph) {
0238           // Set properties for the graph.
0239           if (labelsS14_1315[i].BeginsWith("A")) j = 0; 
0240           if (labelsS14_1315[i].BeginsWith("B")) j = 1; 
0241           if (labelsS14_1315[i].BeginsWith("C")) j = 2; 
0242 
0243           if (labelsS14_1315[i].Contains("10^{0}")) l[j] = 0; 
0244           if (labelsS14_1315[i].Contains("10^{8}")) l[j] = 1; 
0245           if (labelsS14_1315[i].Contains("10^{9}")) l[j] = 2; 
0246           if (labelsS14_1315[i].Contains("10^{10}")) l[j] = 3; 
0247           if (labelsS14_1315[i].Contains("10^{11}")) l[j] = 4; 
0248           if (labelsS14_1315[i].Contains("10^{12}")) l[j] = 5; 
0249           if (labelsS14_1315[i].Contains("10^{13}")) l[j] = 6; 
0250           SetMarkerDefaultsTGraph(graph, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0251           
0252           // Add the graph to the multigraph and the legend.
0253           graph->Write(Form("%s_%s",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);
0254      
0255           std::string title2 = "File " + std::to_string(i + 1)+"log";
0256           TGraph* graphLogI = createGraphFromFile(Form("%s",filenamesS14_1315[i].c_str()), title2.c_str(),kTRUE);
0257           SetMarkerDefaultsTGraph(graphLogI, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0258           graphLogI->Write(Form("%s_%s_Log",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);   
0259           
0260           TGraph* graphDer = new TGraph(graphLogI->GetN()-2);
0261           TF1* fitLocal = new TF1("lin","[0]+[1]*x");
0262           for (Int_t p = 1; p < graphLogI->GetN()-1; p++){
0263             graphLogI->Fit(fitLocal,"C0NQ", "", graphLogI->GetX()[p-1], graphLogI->GetX()[p+1]);
0264             graphDer->SetPoint(p-1, graphLogI->GetX()[p-1], fitLocal->GetParameter(1));  
0265           }
0266           SetMarkerDefaultsTGraph(graphDer, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0267           while(graphDer->GetX()[graphDer->GetN()-1] > 42) graphDer->RemovePoint(graphDer->GetN()-1);
0268           graphDer->Write(Form("%s_%s_Log_Derivative",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);
0269 
0270           // Find maximum of Derivative curve to determine approximate break down voltage
0271           Double_t maxY = TMath::MaxElement(graphDer->GetN(),graphDer->GetY());
0272           Int_t pMax    = 0;
0273           while (maxY != graphDer->GetY()[pMax] && pMax < graphDer->GetN()) pMax++;
0274           Double_t maxX = graphDer->GetX()[pMax];
0275           std::cout << maxX << "\t"<< maxY<< std::endl;              
0276           // Fixing Vbr for non irradiated SiPMs
0277           if (j == 0 && l[j] == 0) maxX = 39.35;
0278           if (j == 0 && l[j] == 1) maxX = 38.54;
0279           if (j == 0 && l[j] == 2) maxX = 38.54;
0280           if (j == 1 && l[j] == 2) maxX = 38.54;
0281           if (j == 2 && l[j] == 2) maxX = 38.54;
0282           std::string title3 = "File " + std::to_string(i + 1)+"_3";
0283           TGraph* graphvsVoV = createGraphFromFile(Form("%s",filenamesS14_1315[i].c_str()), title3.c_str(),kFALSE, maxX);
0284           SetMarkerDefaultsTGraph(graphvsVoV, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0285           graphvsVoV->Write(Form("%s_%s_VoV",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);   
0286           
0287           for (Int_t v = 0; v < 8; v++){
0288               Double_t vov  = (Double_t)v*0.5+2;
0289               Double_t iD   = graphvsVoV->Eval(vov);
0290               Double_t gain = graphGain->Eval(vov);
0291               Double_t qe   = 1.602e-19;
0292               Double_t drc  = iD/(gain*qe);
0293               std::cout <<"Vov: " << vov << "\t I_D: "<< iD<< "\t gain: "<< gain<< "\t DCR: "<< drc<< std::endl;
0294               DCRvsRad1mm[v]->SetPoint(nPoints1mm, log10(NP[l[j]]), drc);
0295           }
0296           nPoints1mm++;
0297       }
0298     }
0299     graphSignalS14_1315->Write("SignalShape",TObject::kOverwrite);
0300     graphPhotonEffi->Write("PhotonEfficiencyVsWavelength",TObject::kOverwrite);
0301     graphGain->Write("GainVsOvervoltage",TObject::kOverwrite);    
0302     for (Int_t v= 0; v< 8; v++){
0303       Double_t vov  = (Double_t)v*0.5+2;
0304       while (DCRvsRad1mm[v]->GetN()> nPoints1mm  ) DCRvsRad1mm[v]->RemovePoint(DCRvsRad1mm[v]->GetN()-1);
0305       DCRvsRad1mm[v]->Write(Form("DCR_%1.1fV",vov),TObject::kOverwrite);    
0306       DCRvsRad1mm[v]->Print();
0307     }
0308     
0309     outputRoot->cd();
0310     outputRoot->mkdir("S14160-3015");
0311     outputRoot->cd("S14160-3015");
0312     // Loop through the list of filenames, create a graph for each, and add it to the TMultiGraph.
0313     for (size_t i = 0; i < filenamesS14_3015.size(); ++i) {
0314       std::string title = "File " + std::to_string(i + 1);
0315       TGraph* graph = createGraphFromFile(Form("%s",filenamesS14_3015[i].c_str()), title.c_str());
0316       std::cout << filenamesS14_3015[i].c_str() << std::endl;
0317       Int_t j = -1;
0318       if (graph) {
0319           // Set properties for the graph.
0320           if (labelsS14_3015[i].BeginsWith("A")) j = 0; 
0321           if (labelsS14_3015[i].BeginsWith("B")) j = 1; 
0322           if (labelsS14_3015[i].BeginsWith("C")) j = 2; 
0323           if (labelsS14_3015[i].BeginsWith("D")) j = 3; 
0324           
0325           if (labelsS14_3015[i].Contains("10^{0}")) l[j] = 0; 
0326           if (labelsS14_3015[i].Contains("10^{8}")) l[j] = 1; 
0327           if (labelsS14_3015[i].Contains("10^{9}")) l[j] = 2; 
0328           if (labelsS14_3015[i].Contains("10^{10}")) l[j] = 3; 
0329           if (labelsS14_3015[i].Contains("10^{11}")) l[j] = 4; 
0330           if (labelsS14_3015[i].Contains("10^{12}")) l[j] = 5; 
0331           if (labelsS14_3015[i].Contains("10^{13}")) l[j] = 6; 
0332           SetMarkerDefaultsTGraph(graph, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0333           
0334           // Add the graph to the multigraph and the legend.
0335           graph->Write(Form("%s_%s",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);
0336 
0337           std::string title2 = "File " + std::to_string(i + 1)+"log";
0338           TGraph* graphLogI = createGraphFromFile(Form("%s",filenamesS14_3015[i].c_str()), title2.c_str(),kTRUE);
0339           SetMarkerDefaultsTGraph(graphLogI, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0340           graphLogI->Write(Form("%s_%s_Log",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);   
0341           
0342           TGraph* graphDer = new TGraph(graphLogI->GetN()-2);
0343           TF1* fitLocal = new TF1("lin","[0]+[1]*x");
0344           for (Int_t p = 1; p < graphLogI->GetN()-1; p++){
0345             graphLogI->Fit(fitLocal,"C0NQ", "", graphLogI->GetX()[p-1], graphLogI->GetX()[p+1]);
0346             graphDer->SetPoint(p-1, graphLogI->GetX()[p-1], fitLocal->GetParameter(1));  
0347           }
0348           SetMarkerDefaultsTGraph(graphDer, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0349           while(graphDer->GetX()[graphDer->GetN()-1] > 42) graphDer->RemovePoint(graphDer->GetN()-1);
0350           graphDer->Write(Form("%s_%s_Log_Derivative",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);
0351         
0352           // Find maximum of Derivative curve to determine approximate break down voltage
0353           Double_t maxY = TMath::MaxElement(graphDer->GetN(),graphDer->GetY());
0354           Int_t pMax    = 0;
0355           while (maxY != graphDer->GetY()[pMax] && pMax < graphDer->GetN()) pMax++;
0356           Double_t maxX = graphDer->GetX()[pMax];
0357           std::cout << maxX << "\t"<< maxY<< std::endl;              
0358           // Fixing Vbr for non irradiated SiPMs
0359           if (j == 0 && l[j] == 0) maxX = 38.96;
0360           if (j == 1 && l[j] == 0) maxX = 38.96;
0361           if (j == 2 && l[j] == 0) maxX = 38.85;
0362           if (j == 3 && l[j] == 0) maxX = 38.71;
0363           std::string title3 = "File " + std::to_string(i + 1)+"_3";
0364           TGraph* graphvsVoV = createGraphFromFile(Form("%s",filenamesS14_3015[i].c_str()), title3.c_str(),kFALSE, maxX);
0365           SetMarkerDefaultsTGraph(graphvsVoV, markers[l[j]], 1, colors[j], colors[j], 1, 1, kFALSE, 0, kFALSE);
0366           graphvsVoV->Write(Form("%s_%s_VoV",labelsSiPM[j].Data(),outNP[l[j]].Data() ),TObject::kOverwrite);   
0367           
0368            for (Int_t v = 0; v < 8; v++){
0369               Double_t vov  = (Double_t)v*0.5+2;
0370               Double_t iD   = graphvsVoV->Eval(vov);
0371               Double_t gain = graphGain->Eval(vov);
0372               Double_t qe   = 1.602e-19;
0373               Double_t drc  = iD/(gain*qe);
0374               std::cout <<"Vov: " << vov << "\t I_D: "<< iD<< "\t gain: "<< gain<< "\t DCR: "<< drc<< std::endl;
0375               DCRvsRad3mm[v]->SetPoint(nPoints3mm, log10(NP[l[j]]), drc);
0376           }
0377           nPoints3mm++;
0378       }
0379     }
0380         
0381     graphSignalS14_3015->Write("SignalShape",TObject::kOverwrite);
0382     graphPhotonEffi->Write("PhotonEfficiencyVsWavelength",TObject::kOverwrite);
0383     graphGain->Write("GainVsOvervoltage",TObject::kOverwrite);
0384     for (Int_t v= 0; v< 8; v++){
0385       Double_t vov  = (Double_t)v*0.5+2;
0386       while (DCRvsRad3mm[v]->GetN()> nPoints3mm  ) DCRvsRad3mm[v]->RemovePoint(DCRvsRad3mm[v]->GetN()-1);
0387       DCRvsRad3mm[v]->Write(Form("DCR_%1.1fV",vov),TObject::kOverwrite);    
0388       DCRvsRad3mm[v]->Print();
0389     }
0390 
0391     
0392     outputRoot->Write();
0393     outputRoot->Close();
0394 }