Newer
Older
/*****************************************************************************
* Copyright (C) 2009-2016 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Sandra GIRON contact address: giron@ipno.in2p3.fr *
* Benjamin LE CROM lecrom@ipno.in2p3.fr *
* Creation Date : march 2014 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold exogam treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
*****************************************************************************/
#include "TExogamPhysics.h"
using namespace EXOGAM_LOCAL;

GIRARD ALCINDOR Valérian
committed
// STL
#include <cmath>

GIRARD ALCINDOR Valérian
committed
#include <iostream>
#include <sstream>
#include <stdlib.h>
Hugo Jacob
committed
#include <functional>
// NPL
#include "NPOptionManager.h"

GIRARD ALCINDOR Valérian
committed
#include "NPVDetector.h"
#include "RootInput.h"
#include "RootOutput.h"
// ROOT
#include "TChain.h"
///////////////////////////////////////////////////////////////////////////
ClassImp(TExogamPhysics)

GIRARD ALCINDOR Valérian
committed
///////////////////////////////////////////////////////////////////////////
TExogamPhysics::TExogamPhysics() {
EventMultiplicity = 0;
ECC_Multiplicity = 0;
GOCCE_Multiplicity = 0;
NumberOfHitClover = 0;
NumberOfHitCristal = 0;
m_Spectra = NULL;
NumberOfClover = 0;
Hugo Jacob
committed
m_EXO_E_RAW_Threshold = 0;
m_EXO_E_Threshold = 0;
m_EXO_EHG_RAW_Threshold = 0;
m_EXO_TDC_RAW_Threshold = 0;
m_EXO_TDC_RAW_Threshold = 0;

GIRARD ALCINDOR Valérian
committed
m_PreTreatedData = new TExogamData;
m_EventData = new TExogamData;
m_EventPhysics = this;

GIRARD ALCINDOR Valérian
committed
NumberOfClover = 0;
CloverMult = 0;

GIRARD ALCINDOR Valérian
committed
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::BuildSimplePhysicalEvent() { BuildPhysicalEvent(); }
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::PreTreat() {
Hugo Jacob
committed
// Clearing PreTreat TExogamData
ClearPreTreatedData();
// Clearing local variables for pretreat
ResetPreTreatVariable();

GIRARD ALCINDOR Valérian
committed
//E
Hugo Jacob
committed
m_EXO_Mult = m_EventData->GetExoMult();
for (unsigned int i = 0; i < m_EXO_Mult; ++i) {
if (m_EventData->GetExoE(i) > m_EXO_E_RAW_Threshold)
EXO_E = fEXO_E(m_EventData, i);
if (m_EventData->GetExoEHG(i) > m_EXO_EHG_RAW_Threshold)
EXO_EHG = fEXO_EHG(m_EventData, i);
if (m_EventData->GetExoTDC(i) > m_EXO_TDC_RAW_Threshold)
EXO_TDC = fEXO_T(m_EventData, i);
EXO_Outer1 = fEXO_Outer(m_EventData, i, 1);
EXO_Outer2 = fEXO_Outer(m_EventData, i, 2);
EXO_Outer3 = fEXO_Outer(m_EventData, i, 3);
EXO_Outer4 = fEXO_Outer(m_EventData, i, 4);
if(EXO_E > m_EXO_E_Threshold){
m_PreTreatedData->SetExo(m_EventData->GetExoCrystal(i), EXO_E,
EXO_EHG, m_EventData->GetExoTS(i), EXO_TDC,
m_EventData->GetExoBGO(i), m_EventData->GetExoCsI(i), EXO_Outer1,
EXO_Outer2, EXO_Outer3, EXO_Outer4);
}

GIRARD ALCINDOR Valérian
committed
}
}
///////////////////////////////////////////////////////////////////////////
Hugo Jacob
committed
void TExogamPhysics::ResetPreTreatVariable(){
EXO_E = -1000;
EXO_EHG = -1000;
EXO_TDC = -1000;
EXO_Outer1 = -1000;
EXO_Outer2 = -1000;
EXO_Outer3 = -1000;
EXO_Outer4 = -1000;
}

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::BuildPhysicalEvent() {
if (NPOptionManager::getInstance()->IsReader() == true) {
m_EventData = &(**r_ReaderEventData);
}
Hugo Jacob
committed
//PreTreat();
//for(unsigned int i = 0; i < m_PreTreatedData->GetExoMult(); i++){
// mean_free_path = ComputeMeanFreePath(m_PreTreatedData->GetExoE(i));
//}
std::cout << ComputeMeanFreePath(7000) << std::endl;
/*

GIRARD ALCINDOR Valérian
committed
if(PreTreatedData -> GetECCEMult() != PreTreatedData -> GetECCTMult()) cout << PreTreatedData -> GetECCEMult() << " "
<< PreTreatedData -> GetECCTMult() << endl;
for(unsigned int i = 0 ; i < PreTreatedData -> GetECCEMult(); i++) {

GIRARD ALCINDOR Valérian
committed
// cout << i << " " << cristal_E << endl;

GIRARD ALCINDOR Valérian
committed
// if(PreTreatedData->GetECCTTime(i) > 0)
{
ECC_E.push_back(PreTreatedData->GetECCEEnergy(i));
ECC_T.push_back(PreTreatedData->GetECCTTime(i));
ECC_CloverNumber.push_back(PreTreatedData->GetECCEClover(i));
ECC_CristalNumber.push_back(PreTreatedData->GetECCECristal(i));

GIRARD ALCINDOR Valérian
committed
// cout << "BuildPhys " << PreTreatedData->GetECCEClover(i) << " " << PreTreatedData->GetECCECristal(i)<< " " <<
PreTreatedData->GetECCTTime(i) << " " << endl;
}
}

GIRARD ALCINDOR Valérian
committed
for(unsigned int j = 0 ; j < PreTreatedData -> GetGOCCEEMult(); j++) {
GOCCE_E.push_back(PreTreatedData->GetGOCCEEEnergy(j));
GOCCE_CloverNumber.push_back(PreTreatedData->GetGOCCEEClover(j));
GOCCE_CristalNumber.push_back(PreTreatedData->GetGOCCEECristal(j));
GOCCE_SegmentNumber.push_back(PreTreatedData->GetGOCCEESegment(j));
}

GIRARD ALCINDOR Valérian
committed
//int NumberOfHitClover = 0;

GIRARD ALCINDOR Valérian
committed
int DetectorID = -1;

GIRARD ALCINDOR Valérian
committed
for( unsigned short i = 0 ; i < PreTreatedData->GetECCEMult() ; i++ )

GIRARD ALCINDOR Valérian
committed
{
// cout << PreTreatedData->GetECCEClover(i) << endl;
if( PreTreatedData->GetECCEClover(i) != DetectorID)

GIRARD ALCINDOR Valérian
committed
{
if(i==0)
{
NumberOfHitClover++;
}
else if(PreTreatedData->GetECCEClover(i)!= PreTreatedData->GetECCEClover(i-1) )
{
NumberOfHitClover++;
}
}
if(NumberOfHitClover == 4) break;
//clover_mult -> Fill(NumberOfHitClover);

GIRARD ALCINDOR Valérian
committed

GIRARD ALCINDOR Valérian
committed
//cout << "NumberOfHitClover " << NumberOfHitClover << endl;

GIRARD ALCINDOR Valérian
committed
map<int, vector<int> > MapCristal;

GIRARD ALCINDOR Valérian
committed
map<int, vector<int> > MapSegment;
map<int, vector<int> > :: iterator it; // iterator used with MapCristal
map<int, vector<int> > :: iterator at; // iterator used with MapSegment
vector<int> PositionOfCristal_Buffer_ECC;
vector<int> PositionOfSegment_Buffer_GOCCE;

GIRARD ALCINDOR Valérian
committed
//Fill map Cristal
for(int clo = 0; clo < NumberOfClover; clo++)
{
for(unsigned int k = 0; k < ECC_CloverNumber.size(); k++)

GIRARD ALCINDOR Valérian
committed
{
if(ECC_CloverNumber.at(k) == clo) // && ECC_CristalNumber.at(k)== cri )
PositionOfCristal_Buffer_ECC.push_back(k);
}
if(PositionOfCristal_Buffer_ECC.size() != 0) MapCristal[clo] = PositionOfCristal_Buffer_ECC;

GIRARD ALCINDOR Valérian
committed
PositionOfCristal_Buffer_ECC.clear();

GIRARD ALCINDOR Valérian
committed

GIRARD ALCINDOR Valérian
committed
//Fill map Segment
for(int clo = 0; clo < NumberOfClover; clo++)
{
for(int cri = 0; cri < 4 ; cri++)

GIRARD ALCINDOR Valérian
committed
{
// for(int seg = 0; seg < 4 ; seg++)
{
for(unsigned int m = 0; m < GOCCE_CloverNumber.size(); m++)
{
if(GOCCE_CloverNumber.at(m) == clo && GOCCE_CristalNumber.at(m) == cri)// && GOCCE_SegmentNumber.at(m) == seg)
{
// PositionOfSegment_Buffer_GOCCE.push_back(4*clo+cri);
PositionOfSegment_Buffer_GOCCE.push_back(m);
}

GIRARD ALCINDOR Valérian
committed
}
if(PositionOfSegment_Buffer_GOCCE.size() != 0) MapSegment[4*clo+cri] = PositionOfSegment_Buffer_GOCCE;

GIRARD ALCINDOR Valérian
committed
PositionOfSegment_Buffer_GOCCE.clear();
}
}
// Treatment
for(int clo = 0; clo < NumberOfClover ; clo++)
{
double E = 0; double T = 0;
int mult_cristal = 0;
int cristal = -1 , segment;
int cristal_Emax = 0; int cristal_Emin = 0;
int Emax = 0, Emin = 1000000;
int Tmin = 0, Tmax = 0;

GIRARD ALCINDOR Valérian
committed
//ADD-BACK
it = MapCristal.find(clo);
int cristal_cond = 0;

GIRARD ALCINDOR Valérian
committed
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
if(it != MapCristal.end())
{
vector<int> PositionOfCristal = it -> second;
mult_cristal = PositionOfCristal.size();
//if(mult_cristal!=0) cristal_mult -> Fill(mult_cristal);
// ADD-BACK
//cout << "boucle" << endl;
for(unsigned int k = 0; k < PositionOfCristal.size(); k++)
{
int indice = PositionOfCristal.at(k);
cristal_cond += ECC_CristalNumber.at(indice);
// cout << ECC_CristalNumber.at(k) << " " ECC_E.at(k) << endl;
if(mult_cristal < 3)
{
E+= ECC_E.at(indice);
if(ECC_E.at(indice) < Emin) {
cristal_Emin = ECC_CristalNumber.at(indice);
Emin = ECC_E.at(indice);
Tmin = ECC_T.at(indice);
}
if(ECC_E.at(indice) > Emax) {
cristal_Emax = ECC_CristalNumber.at(indice);
Emax = ECC_E.at(indice);
Tmax = ECC_T.at(indice);
}
}
else // case of multiplicity = 3 or 4
{
E = -1; cristal_Emax = -1; cristal_Emin = -1; Tmax = -1; Tmin = -1;
}
// cout << ECC_E.at(indice) << " " << Emax << " " << cristal_Emax << " " << Emin << " " << cristal_Emin << endl;
}
if( (mult_cristal==1) || (mult_cristal ==2 && cristal_cond %2 == 1) )
{
// cout << cristal_cond << endl;
//cristal = cristal_Emax; T = Tmax;
//cout << Emax << " " << cristal_Emax << " " << Emin << " " << cristal_Emin << endl;
if(E > 500) { cristal = cristal_Emax; T = Tmax; }
else { cristal = cristal_Emin; T = Tmin; }
// DOPPLER CORRECTION
at = MapSegment.find(4*clo+cristal);
segment = -1;
if(at != MapSegment.end())
{
vector<int> PositionOfSegment = at -> second; // position of segment k in the vector
int segment_max = -1, E_temp = -1;
for(unsigned int m = 0; m < PositionOfSegment.size(); m++) // loop on hit segments of cristal cri of
clover clo
{
int indice = PositionOfSegment.at(m);
if(GOCCE_E.at(indice) > 0 && GOCCE_CristalNumber.at(indice) == cristal)
{
if( GOCCE_E.at(indice) > E_temp )
{
segment_max = GOCCE_SegmentNumber.at(indice) ;
E_temp = GOCCE_E.at(indice);
}
}
}
segment = segment_max;
}
}
if(E > 0 && cristal != -1 && segment != -1)
{
TotalEnergy_lab.push_back(E);
Time.push_back(T);
CloverNumber.push_back(clo);
CristalNumber.push_back(cristal);
SegmentNumber.push_back(segment);
double theta = GetSegmentAngleTheta(clo, cristal, segment);
Theta.push_back(theta);
double doppler_E = DopplerCorrection(E, theta);
DopplerCorrectedEnergy.push_back(doppler_E);
// cout << E << " " << clo << " " << cristal << " " << segment << " " << theta << " " << doppler_E << endl;
}
} // end of condition over CristalMap
} // loop over NumberOfClover
CloverMult = GetClover_Mult();

GIRARD ALCINDOR Valérian
committed
//cout << "Exogam fine" << endl;
Hugo Jacob
committed
*/

GIRARD ALCINDOR Valérian
committed
}
Hugo Jacob
committed
double TExogamPhysics::ComputeMeanFreePath(double Energy){
auto b = Map_PhotonCS.lower_bound(Energy);
auto a = prev(b);
if(b == Map_PhotonCS.begin()){
a = b;
b++;
}
else if(b == Map_PhotonCS.end()){
b--;
a = prev(b);
}
std::cout << a->first << " " << b->first << " " << a->second << " " << b->second << std::endl;
double coeff = (Energy - a->first)/(b->first - a->first);
double PhotonCrossSection = a->second + coeff*(b->second - a->second); // mm2/g
return 1./(GeDensity*PhotonCrossSection);
}

GIRARD ALCINDOR Valérian
committed
double TExogamPhysics::DopplerCorrection(double E, double Theta) {
double Pi = 3.141592654;
TString filename = "configs/beta.txt";
ifstream file;

GIRARD ALCINDOR Valérian
committed
// cout << filename << endl;
file.open(filename);

GIRARD ALCINDOR Valérian
committed
if (!file)
cout << filename << " was not opened" << endl;
double E_corr = 0;

GIRARD ALCINDOR Valérian
committed
double beta = 0.;
file >> beta;
double gamma = 1. / sqrt(1 - beta * beta);

GIRARD ALCINDOR Valérian
committed
E_corr = gamma * E * (1. - beta * cos(Theta * Pi / 180.));

GIRARD ALCINDOR Valérian
committed
return (E_corr);
}
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::Clear() {
EventMultiplicity = 0;
ECC_Multiplicity = 0;
GOCCE_Multiplicity = 0;

GIRARD ALCINDOR Valérian
committed
NumberOfHitClover = 0;
NumberOfHitCristal = 0;

GIRARD ALCINDOR Valérian
committed
ECC_CloverNumber.clear();
ECC_CristalNumber.clear();
GOCCE_CloverNumber.clear();
GOCCE_CristalNumber.clear();
GOCCE_SegmentNumber.clear();
// ECC

GIRARD ALCINDOR Valérian
committed
ECC_E.clear();
ECC_T.clear();
// GOCCE

GIRARD ALCINDOR Valérian
committed
GOCCE_E.clear();

GIRARD ALCINDOR Valérian
committed
CristalNumber.clear();
SegmentNumber.clear();
CloverNumber.clear();

GIRARD ALCINDOR Valérian
committed
TotalEnergy_lab.clear();
Time.clear();
DopplerCorrectedEnergy.clear();
Position.clear();
Theta.clear();
}
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
//// Innherited from VDetector Class ////
// Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::ReadConfiguration(NPL::InputParser parser) {
vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("EXOGAM");

GIRARD ALCINDOR Valérian
committed
if (NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " EXOGAM clover found " << endl;
// FIXME ANGLE FILE??? NOT SURE I GET IT...
// For Doppler I guess... Something like that should be added later
// But maybe the more stand R,THETA,PHI or X,Y,Z
// vector<string> token = {"ANGLE_FILE"};
vector<string> token = {"Board, Flange, Channel0, Channel1"};
// FIXME To be implemented in the future
// vector<string> token = {"Board, Flange, Channel0, Channel1, R, THETA, PHI"};

GIRARD ALCINDOR Valérian
committed
for (unsigned int i = 0; i < blocks.size(); i++) {
if (blocks[i]->HasTokenList(token)) {
int Board, Flange, Channel0, Channel1; // FIXME!!!! Should come from Data...
AddClover(Board, Flange, Channel0, Channel1);

GIRARD ALCINDOR Valérian
committed
else {
cout << "ERROR: check your input file formatting " << endl;
exit(1);
}
}
Hugo Jacob
committed
ReadAnalysisConfig();
Hugo Jacob
committed
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
void TExogamPhysics::ReadAnalysisConfig() {
bool ReadingStatus = false;
// path to photon cross section
string CSFilename = "../../Inputs/PhotonCrossSection/CoherentGe.xcom";
string LineBuffer;
ifstream CSFile;
CSFile.open(CSFilename.c_str());
if (!CSFile.is_open()) {
cout << " No CS file found "
<< CSFilename << endl;
return;
}
while(CSFile.good()){
double gammaE, CrossSection;
getline(CSFile, LineBuffer);
istringstream ss(LineBuffer);
ss >> gammaE >> CrossSection; // E in MeV, converted to keV, CrossSection in cm2/g
gammaE *= 1000.; // Convertion to keV
CrossSection *= 100.;
Map_PhotonCS[gammaE] = CrossSection;
}
// path to file
string FileName = "./configs/ConfigExogam.dat";
// open analysis config file
ifstream AnalysisConfigFile;
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigExogam.dat found: Default parameters loaded for "
"Analysis "
<< FileName << endl;
return;
}
string DataBuffer, whatToDo;
while (!AnalysisConfigFile.eof()) {
// Pick-up next line
getline(AnalysisConfigFile, LineBuffer);
// search for "header"
if (LineBuffer.compare(0, 11, "ConfigExogam") == 0)
ReadingStatus = true;
// loop on tokens and data
while (ReadingStatus) {
whatToDo = "";
AnalysisConfigFile >> whatToDo;
// Search for comment symbol (%)
if (whatToDo.compare(0, 1, "%") == 0) {
AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n');
}
else if (whatToDo == "EXO_Threshold") {
//AnalysisConfigFile >> DataBuffer;
//m_MaximumStripMultiplicityAllowed = atoi(DataBuffer.c_str());
//cout << "MAXIMUN STRIP MULTIPLICITY " << m_MaximumStripMultiplicityAllowed << endl;
}
}
}
}
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::InitSpectra() { m_Spectra = new TExogamSpectra(NumberOfClover); }
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::FillSpectra() {
m_Spectra->FillRawSpectra(m_EventData);
m_Spectra->FillPreTreatedSpectra(m_PreTreatedData);
m_Spectra->FillPhysicsSpectra(m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::CheckSpectra() { m_Spectra->CheckSpectra(); }
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::ClearSpectra() {
// To be done
}
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
map<string, TH1*> TExogamPhysics::GetSpectra() {
if (m_Spectra)
return m_Spectra->GetMapHisto();

GIRARD ALCINDOR Valérian
committed
else {
map<string, TH1*> empty;
return empty;
}

GIRARD ALCINDOR Valérian
committed
}
//////////////////////////////////////////////////////////////////////////
void TExogamPhysics::AddClover(int Board, int Flange, int Channel0, int Channel1) {

GIRARD ALCINDOR Valérian
committed
}

GIRARD ALCINDOR Valérian
committed
// FIXME Legacy thing... Might delete later
//////////////////////////////////////////////////////////////////////////
// void TExogamPhysics::AddClover(string AngleFile) {
// ifstream file;
// // TString filename = Form("posBaptiste/angles_exogam_clover%d.txt",NumberOfClover);
// // TString filename = Form("posz42_simu50mm/angles_exogam_clover%d.txt",NumberOfClover);
// // TString filename = Form("posz42_exp_stat_demiring/angles_exogam_clover%d.txt",NumberOfClover);

GIRARD ALCINDOR Valérian
committed
// string path = "configs/";
// TString filename = path + AngleFile;
// cout << filename << endl;
// file.open(filename);
// if (!file)
// cout << filename << " was not opened" << endl;
// vector<double> Angles;
// vector<vector<double>> Segment_angles;
// vector<vector<vector<double>>> Cristal_angles;
// Cristal_angles.clear();

GIRARD ALCINDOR Valérian
committed
// double angle;
// string buffer;

GIRARD ALCINDOR Valérian
committed
// for (int i = 0; i < 4; i++) {
// Segment_angles.clear();

GIRARD ALCINDOR Valérian
committed
// for (int j = 0; j < 4; j++) {
// Angles.clear();

GIRARD ALCINDOR Valérian
committed
// for (int k = 0; k < 2; k++) {
// file >> buffer >> angle;

GIRARD ALCINDOR Valérian
committed
// Angles.push_back(angle); // Theta (k = 0) Phi (k = 1)
// // cout << angle << endl;
// if (Angles.size() == 2)
// cout << "Clover " << NumberOfClover << ": Theta=" << Angles[0] << " Phi=" << Angles[1] << endl;
// }

GIRARD ALCINDOR Valérian
committed
// Segment_angles.push_back(Angles);
// }
// Cristal_angles.push_back(Segment_angles);
// }
// Clover_Angles_Theta_Phi.push_back(Cristal_angles);
// file.close();
// NumberOfClover++;
// }
// Add Parameter to the CalibrationManger

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::AddParameterToCalibrationManager() {
CalibrationManager* Cal = CalibrationManager::getInstance();

GIRARD ALCINDOR Valérian
committed
for (int i = 0; i < NumberOfClover; i++) {
for (int j = 0; j < 4; j++) {
Cal->AddParameter("EXOGAM", "Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_Elow",
"EXOGAM_Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_Elow");
Cal->AddParameter("EXOGAM", "Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_Ehigh",
"EXOGAM_Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_Ehigh");
Cal->AddParameter("EXOGAM", "Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_T",
"EXOGAM_Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_T");
for (int k = 0; k < 4; k++) {
Cal->AddParameter("EXOGAM", "Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_Seg" + NPL::itoa(k) + "_E",
"EXOGAM_Cl" + NPL::itoa(i) + "_Cr" + NPL::itoa(j) + "_Seg" + NPL::itoa(k) + "_E");
}

GIRARD ALCINDOR Valérian
committed
}
}
// Activated associated Branches and link it to the private member DetectorData address
// In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::InitializeRootInputRaw() {
Hugo Jacob
committed
TChain* inputChain = RootInput::getInstance()->GetChain();
// Option to use the nptreereader anaysis
if (NPOptionManager::getInstance()->IsReader() == true) {
TTreeReader* inputTreeReader = RootInput::getInstance()->GetTreeReader();
inputTreeReader->SetTree(inputChain);
}
// Option to use the standard npanalysis
else{

GIRARD ALCINDOR Valérian
committed
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchStatus("EXOGAM", true);
inputChain->SetBranchStatus("fEXO_*", true);
inputChain->SetBranchAddress("EXOGAM", &m_EventData);
/*
TList* outputList = RootOutput::getInstance()->GetList();
clover_mult = new TH1F("clover_mult","clover_mult",20,0,20);
outputList->Add(clover_mult);
cristal_mult = new TH1F("cristal_mult","cristal_mult",20,0,20);
outputList->Add(cristal_mult);
*/
Hugo Jacob
committed
}
/////////////////////////////////////////////////////////////////////
// Activated associated Branches and link it to the private member DetectorPhysics address
// In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated
void TExogamPhysics::InitializeRootInputPhysics() {
Hugo Jacob
committed
TChain* inputChain = RootInput::getInstance()->GetChain();
// Option to use the nptreereader anaysis
if (NPOptionManager::getInstance()->IsReader() == true) {
TTreeReader* inputTreeReader = RootInput::getInstance()->GetTreeReader();
inputTreeReader->SetTree(inputChain);
}
// Option to use the standard npanalysis
else{
TChain* inputChain = RootInput::getInstance()->GetChain();

GIRARD ALCINDOR Valérian
committed
inputChain->SetBranchStatus("EventMultiplicty", true);
inputChain->SetBranchStatus("ECC_Multiplicity", true);
inputChain->SetBranchStatus("GOCCE_Multiplicity", true);
inputChain->SetBranchStatus("ECC_CloverNumber", true);
inputChain->SetBranchStatus("ECC_CristalNumber", true);
inputChain->SetBranchStatus("GOCCE_CloverNumber", true);
inputChain->SetBranchStatus("GOCCE_CristalNumber", true);
inputChain->SetBranchStatus("GOCCE_SegmentNumber", true);
inputChain->SetBranchStatus("ECC_E", true);
inputChain->SetBranchStatus("ECC_T", true);
inputChain->SetBranchStatus("GOCCE_E", true);
inputChain->SetBranchStatus("CristalNumber", true);
inputChain->SetBranchStatus("SegmentNumber", true);
inputChain->SetBranchStatus("CloverNumber", true);
inputChain->SetBranchStatus("CloverMult", true);
inputChain->SetBranchStatus("TotalEnergy_lab", true);
inputChain->SetBranchStatus("Time", true);
inputChain->SetBranchStatus("DopplerCorrectedEnergy", true);
inputChain->SetBranchStatus("Position", true);
inputChain->SetBranchStatus("Theta", true);
inputChain->SetBranchAddress("EXOGAM", &m_EventPhysics);
Hugo Jacob
committed
}
/////////////////////////////////////////////////////////////////////
// Create associated branches and associated private member DetectorPhysics address

GIRARD ALCINDOR Valérian
committed
void TExogamPhysics::InitializeRootOutput() {
TTree* outputTree = RootOutput::getInstance()->GetTree();
outputTree->Branch("EXOGAM", "TExogamPhysics", &m_EventPhysics);
// control histograms if needed

GIRARD ALCINDOR Valérian
committed
/*
TList* outputList = RootOutput::getInstance()->GetList();
controle = new TH1F("controle","histo de controle",20,0,20);
outputList->Add(controle);
*/
}
Hugo Jacob
committed
void TExogamPhysics::SetTreeReader(TTreeReader* TreeReader) {
TExogamPhysicsReader::r_SetTreeReader(TreeReader);
}
///////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
namespace EXOGAM_LOCAL {
// tranform an integer to a string
Hugo Jacob
committed
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
double fEXO_E(const TExogamData* m_EventData, const unsigned int& i) {
static string name;
name = "EXOGAM/Cr_";
name += NPL::itoa(m_EventData->GetExoE(i));
name += "_E";
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoE(i));
}
double fEXO_EHG(const TExogamData* m_EventData, const unsigned int& i) {
static string name;
name = "EXOGAM/Cr_";
name += NPL::itoa(m_EventData->GetExoEHG(i));
name += "_EHG";
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoEHG(i));
}
double fEXO_T(const TExogamData* m_EventData, const unsigned int& i) {
static string name;
name = "EXOGAM/Cr_";
name += NPL::itoa(m_EventData->GetExoTDC(i));
name += "_TDC";
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoTDC(i));
}
double fEXO_Outer(const TExogamData* m_EventData, const unsigned int& i, const unsigned int OuterNumber) {
static string name;
name = "EXOGAM/Cr_";
name += NPL::itoa(m_EventData->GetExoE(i));
name += "_Outer";
name += NPL::itoa(OuterNumber);
name += "_E";
if(OuterNumber == 1)
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoOuter1(i));
else if(OuterNumber == 2)
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoOuter2(i));
else if(OuterNumber == 3)
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoOuter3(i));
else if(OuterNumber == 4)
return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetExoOuter4(i));
else{
std::cout << "WARNING: Outer number != 1-4, something is wrong\n";
return 0;
};
}

GIRARD ALCINDOR Valérian
committed
string itoa(int value) {
std::ostringstream o;

GIRARD ALCINDOR Valérian
committed
if (!(o << value))

GIRARD ALCINDOR Valérian
committed
return "";
return o.str();
}

GIRARD ALCINDOR Valérian
committed
} // namespace EXOGAM_LOCAL
/////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
NPL::VDetector* TExogamPhysics::Construct() { return (NPL::VDetector*)new TExogamPhysics(); }
Hugo Jacob
committed
NPL::VTreeReader* TExogamPhysics::ConstructReader() { return (NPL::VTreeReader*)new TExogamPhysicsReader(); }
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////

GIRARD ALCINDOR Valérian
committed
extern "C" {
class proxy_exogam {
public:
proxy_exogam() {
NPL::DetectorFactory::getInstance()->AddToken("Exogam", "Exogam");
NPL::DetectorFactory::getInstance()->AddDetector("Exogam", TExogamPhysics::Construct);
Hugo Jacob
committed
NPL::DetectorFactory::getInstance()->AddDetectorReader("Exogam", TExogamPhysics::ConstructReader);

GIRARD ALCINDOR Valérian
committed
}