Fork me on GitHub

source: svn/trunk/Delphes.cpp@ 555

Last change on this file since 555 was 555, checked in by severine ovyn, 15 years ago

/*

/----------------------------------------------\
| Delphes, a framework for the fast simulation |
| of a generic collider experiment |
\------------- arXiv:0903.2225v1 ------------/


This package uses:
------------------
ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86
FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]
Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]
FROG: [hep-ex/0901.2718v1]
HepMC: Comput. Phys. Commun.134 (2001) 41

------------------------------------------------------------------

Main authors:
-------------

Severine Ovyn Xavier Rouby
severine.ovyn@… xavier.rouby@cern

Center for Particle Physics and Phenomenology (CP3)
Universite catholique de Louvain (UCL)
Louvain-la-Neuve, Belgium

Copyright (C) 2008-2009,
All rights reserved.

*/

/ \file SmearUtil.cc
/ \brief RESOLution class, and some generic definitions

#include "SmearUtil.h"
#include "TStopwatch.h"

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib> for exit()
using namespace std;

------------------------------------------------------------------------------

RESOLution::RESOLution() {

Detector characteristics
CEN_max_tracker = 2.5;
Maximum tracker coverage
CEN_max_calo_cen = 1.7; central calorimeter coverage
CEN_max_calo_ec = 3.0;
calorimeter endcap coverage
CEN_max_calo_fwd = 5.0; forward calorimeter pseudorapidity coverage
CEN_max_mu = 2.4;
muon chambers pseudorapidity coverage


Energy resolution for electron/photon
\sigma/E = C + N/E + S/\sqrt{E}
ELG_Scen = 0.05; S term for central ECAL
ELG_Ncen = 0.25;
N term
ELG_Ccen = 0.005; C term
ELG_Sec = 0.05;
S term for central ECAL endcap
ELG_Nec = 0.25; S term
ELG_Cec = 0.005;
S term
ELG_Sfwd = 2.084; S term for FCAL
ELG_Nfwd = 0.0;
N term
ELG_Cfwd = 0.107; C term
ELG_Szdc = 0.70;
S term for ZDC
ELG_Nzdc = 0.0; N term
ELG_Czdc = 0.08;
C term

Energy resolution for hadrons in ecal/hcal/fwd
\sigma/E = C + N/E + S/\sqrt{E}
HAD_Scen = 1.5; S term for central HCAL
HAD_Ncen = 0.;
N term
HAD_Ccen = 0.05; C term
HAD_Sec = 1.5;
S term for HCAL endcap
HAD_Nec = 0.; N term
HAD_Cec = 0.05;
C term
HAD_Sfwd = 2.7; S term for FCAL
HAD_Nfwd = 0.;
N term
HAD_Cfwd = 0.13; C term
HAD_Szdc = 1.38;
S term for ZDC
HAD_Nzdc = 0.; N term
HAD_Czdc = 0.13;
C term

Muon smearing
MU_SmearPt = 0.01;

time resolution
ZDC_T_resolution = 0;
resolution for time measurement [s]
RP220_T_resolution = 0;
RP420_T_resolution = 0;

Tracking efficiencies
TRACK_ptmin = 0.9;
minimal pt needed to reach the calorimeter in GeV
TRACK_eff = 100; efficiency associated to the tracking

Calorimetric towers
TOWER_number = 40;
const float tower_eta_edges[41] = {

0., 0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609, 0.696, 0.783, 0.870, 0.957, 1.044, 1.131, 1.218, 1.305, 1.392, 1.479, 1.566,
1.653, 1.740, 1.830, 1.930, 2.043, 2.172, 2.322, 2.500, 2.650, 2.868, 2.950, 3.125, 3.300, 3.475, 3.650, 3.825, 4.000, 4.175,
4.350, 4.525, 4.700, 5.000}; temporary object

TOWER_eta_edges = new float[TOWER_number+1];
for(unsigned int i=0; i<TOWER_number +1; i++) TOWER_eta_edges[i] = tower_eta_edges[i];


const float tower_dphi[40] = {

5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10,
10,10,10,10,10, 10,10,10,10,10, 10,10,10,10,10, 10,10,10,20, 20 }; temporary object

TOWER_dphi = new float[TOWER_number];
for(unsigned int i=0; i<TOWER_number; i++) TOWER_dphi[i] = tower_dphi[i];

Thresholds for reconstructed objetcs (GeV)
PTCUT_elec = 10.0;
PTCUT_muon = 10.0;
PTCUT_jet = 20.0;
PTCUT_gamma = 10.0;
PTCUT_taujet = 10.0;

ZDC_gamma_E = 20; GeV
ZDC_n_E = 50;
GeV

Isolation
ISOL_PT = 2.0;
minimal pt of tracks for isolation criteria
ISOL_Cone = 0.5; Cone for isolation criteria
ISOL_Calo_ET = 1E99;
minimal tower energy for isolation criteria. Default off = 1E99
ISOL_Calo_Grid = 3; Grid size (N x N) for calorimetric isolation -- should be odd

General jet variable
JET_coneradius = 0.7;
generic jet radius ; not for tau's !!!
JET_jetalgo = 1; 1 for Cone algorithm, 2 for MidPoint algorithm, 3 for SIScone algorithm, 4 for kt algorithm
JET_seed = 1.0;
minimum seed to start jet reconstruction
JET_Eflow = 1; 1 for Energy flow in jets reco ; 0 if not

Tagging definition
BTAG_b = 40.;
BTAG_mistag_c = 10.;
BTAG_mistag_l = 1.;

FLAGS
FLAG_bfield = 1;
1 to run the bfield propagation else 0
FLAG_vfd = 1; 1 to run the very forward detectors else 0
FLAG_RP = 1;
1 to run the zero degree calorimeter else 0
FLAG_trigger = 1; 1 to run the trigger selection else 0
FLAG_frog = 1;
1 to run the FROG event display
FLAG_lhco = 1;

In case BField propagation allowed
TRACK_radius = 129;
radius of the BField coverage
TRACK_length = 300; length of the BField coverage
TRACK_bfield_x = 0;
X composant of the BField
TRACK_bfield_y = 0; Y composant of the BField
TRACK_bfield_z = 3.8;
Z composant of the BField

In case Very forward detectors allowed
VFD_min_calo_vfd = 5.2;
very forward calorimeter (if any) like CASTOR
VFD_max_calo_vfd = 6.6;
VFD_min_zdc = 8.3;
VFD_s_zdc = 140; distance of the Zero Degree Calorimeter, from the Interaction poin, in [m]

RP_220_s = 220; distance of the RP to the IP, in meters
RP_220_x = 0.002;
distance of the RP to the beam, in meters
RP_420_s = 420; distance of the RP to the IP, in meters
RP_420_x = 0.004;
distance of the RP to the beam, in meters
RP_IP_name = "IP5";
RP_beam1Card = "data/LHCB1IR5_v6.500.tfs";
RP_beam2Card = "data/LHCB1IR5_v6.500.tfs";

In case FROG event display allowed
NEvents_Frog = 10;

Number of events to be processed
NEvents = -1;


jet stuffs not defined in the input datacard


JET_overlap = 0.75;
MidPoint algorithm definition
JET_M_coneareafraction = 0.25;
JET_M_maxpairsize = 2;
JET_M_maxiterations = 100;
Define Cone algorithm.
JET_C_adjacencycut = 2;
JET_C_maxiterations = 100;
JET_C_iratch = 1;
Define SISCone algorithm.
JET_S_npass = 0;
JET_S_protojet_ptmin= 0.0;


For Tau-jet definition
TAU_energy_scone = 0.15;
radius R of the cone for tau definition, based on energy threshold
TAU_track_scone = 0.4; radius R of the cone for tau definition, based on track number
TAU_track_pt = 2;
minimal pt [GeV] for tracks to be considered in tau definition
TAU_energy_frac = 0.95; fraction of energy required in the central part of the cone, for tau jets


PT_QUARKS_MIN = 2.0 ; minimal pt needed by quarks to do b-tag

for very forward detectors
RP_offsetEl_s = 120;
distance of beam separation point, from IP
RP_offsetEl_x = -0.097; half distance of separation of beams in horizontal plan, in m
RP_offsetEl_y = 0;
half distance of separation of beams in vertical plan, in m
RP_cross_x = -500; IP offset in horizontal plane, in micrometers
RP_cross_y = 0.0;
IP offset in vertical plane, in micrometers
RP_cross_ang_x = 142.5; half-crossing angle in horizontal plane, in microrad
RP_cross_ang_y = 0.0;
half-crossing angle in vertical plane, in microrad

PdgTableFilename = "data/particle.tbl";
inputfilelist = "";
detectorcard = "";
triggercard = "";

grandom = new TRandom3(0); a new seed is set everytime Delphes is run

}

RESOLution::RESOLution(const RESOLution & DET) {

Detector characteristics
CEN_max_tracker = DET.CEN_max_tracker;
CEN_max_calo_cen = DET.CEN_max_calo_cen;
CEN_max_calo_ec = DET.CEN_max_calo_ec;
CEN_max_calo_fwd = DET.CEN_max_calo_fwd;
CEN_max_mu = DET.CEN_max_mu;


Energy resolution for electron/photon
ELG_Scen = DET.ELG_Scen;
ELG_Ncen = DET.ELG_Ncen;
ELG_Ccen = DET.ELG_Ccen;
ELG_Sec = DET.ELG_Sec;
ELG_Nec = DET.ELG_Nec;
ELG_Cec = DET.ELG_Cec;
ELG_Cfwd = DET.ELG_Cfwd;
ELG_Sfwd = DET.ELG_Sfwd;
ELG_Nfwd = DET.ELG_Nfwd;
ELG_Czdc = DET.ELG_Czdc;
ELG_Szdc = DET.ELG_Szdc;
ELG_Nzdc = DET.ELG_Nzdc;

Energy resolution for hadrons in ecal/hcal/fwd/zdc
HAD_Scen = DET.HAD_Scen;
HAD_Ncen = DET.HAD_Ncen;
HAD_Ccen = DET.HAD_Ccen;
HAD_Sec = DET.HAD_Sec;
HAD_Nec = DET.HAD_Nec;
HAD_Cec = DET.HAD_Cec;
HAD_Sfwd = DET.HAD_Sfwd;
HAD_Nfwd = DET.HAD_Nfwd;
HAD_Cfwd = DET.HAD_Cfwd;
HAD_Szdc = DET.HAD_Szdc;
HAD_Nzdc = DET.HAD_Nzdc;
HAD_Czdc = DET.HAD_Czdc;

time resolution
ZDC_T_resolution = DET.ZDC_T_resolution;
resolution for time measurement [s]
RP220_T_resolution = DET.RP220_T_resolution;
RP420_T_resolution = DET.RP420_T_resolution;

Muon smearing
MU_SmearPt = DET.MU_SmearPt;

Tracking efficiencies
TRACK_ptmin = DET.TRACK_ptmin;
TRACK_eff = DET.TRACK_eff;

Calorimetric towers
TOWER_number = DET.TOWER_number;
TOWER_eta_edges = new float[TOWER_number+1];
for(unsigned int i=0; i<TOWER_number +1; i++) TOWER_eta_edges[i] = DET.TOWER_eta_edges[i];

TOWER_dphi = new float[TOWER_number];
for(unsigned int i=0; i<TOWER_number; i++) TOWER_dphi[i] = DET.TOWER_dphi[i];

Thresholds for reconstructed objetcs
PTCUT_elec = DET.PTCUT_elec;
PTCUT_muon = DET.PTCUT_muon;
PTCUT_jet = DET.PTCUT_jet;
PTCUT_gamma = DET.PTCUT_gamma;
PTCUT_taujet = DET.PTCUT_taujet;

ZDC_gamma_E = DET.ZDC_gamma_E;
ZDC_n_E = DET.ZDC_n_E;

Isolation
ISOL_PT = DET.ISOL_PT;
tracking isolation
ISOL_Cone = DET.ISOL_Cone;
ISOL_Calo_ET = DET.ISOL_Calo_ET; calorimeter isolation, defaut off
ISOL_Calo_Grid = DET.ISOL_Calo_Grid;

General jet variable
JET_coneradius = DET.JET_coneradius;
JET_jetalgo = DET.JET_jetalgo;
JET_seed = DET.JET_seed;
JET_Eflow = DET.JET_Eflow;

Tagging definition
BTAG_b = DET.BTAG_b;
BTAG_mistag_c = DET.BTAG_mistag_c;
BTAG_mistag_l = DET.BTAG_mistag_l;

FLAGS
FLAG_bfield = DET.FLAG_bfield;
FLAG_vfd = DET.FLAG_vfd;
FLAG_RP = DET.FLAG_RP;
FLAG_trigger = DET.FLAG_trigger;
FLAG_frog = DET.FLAG_frog;
FLAG_lhco = DET.FLAG_lhco;

In case BField propagation allowed
TRACK_radius = DET.TRACK_radius;
TRACK_length = DET.TRACK_length;
TRACK_bfield_x = DET.TRACK_bfield_x;
TRACK_bfield_y = DET.TRACK_bfield_y;
TRACK_bfield_z = DET.TRACK_bfield_z;

In case Very forward detectors allowed
VFD_min_calo_vfd = DET.VFD_min_calo_vfd;
VFD_max_calo_vfd = DET.VFD_max_calo_vfd;
VFD_min_zdc = DET.VFD_min_zdc;
VFD_s_zdc = DET.VFD_s_zdc;

RP_220_s = DET.RP_220_s;
RP_220_x = DET.RP_220_x;
RP_420_s = DET.RP_420_s;
RP_420_x = DET.RP_420_x;
RP_beam1Card = DET.RP_beam1Card;
RP_beam2Card = DET.RP_beam2Card;
RP_offsetEl_s = DET.RP_offsetEl_s;
RP_offsetEl_x = DET.RP_offsetEl_x;
RP_offsetEl_y = DET.RP_offsetEl_y;
RP_cross_x = DET.RP_cross_x;
RP_cross_y = DET.RP_cross_y;
RP_cross_ang_x = DET.RP_cross_ang_x;
RP_cross_ang_y = DET.RP_cross_ang_y;
RP_IP_name = DET.RP_IP_name;

In case FROG event display allowed
NEvents_Frog = DET.NEvents_Frog;

Number of events to be processed
NEvents = DET.NEvents;

JET_overlap = DET.JET_overlap;
MidPoint algorithm definition
JET_M_coneareafraction = DET.JET_M_coneareafraction;
JET_M_maxpairsize = DET.JET_M_maxpairsize;
JET_M_maxiterations = DET.JET_M_maxiterations;
Define Cone algorithm.
JET_C_adjacencycut = DET.JET_C_adjacencycut;
JET_C_maxiterations = DET.JET_C_maxiterations;
JET_C_iratch = DET.JET_C_iratch;
Define SISCone algorithm.
JET_S_npass = DET.JET_S_npass;
JET_S_protojet_ptmin = DET.JET_S_protojet_ptmin;

For Tau-jet definition
TAU_energy_scone = DET.TAU_energy_scone;
TAU_track_scone = DET.TAU_track_scone;
TAU_track_pt = DET.TAU_track_pt;
TAU_energy_frac = DET.TAU_energy_frac;

PT_QUARKS_MIN = DET.PT_QUARKS_MIN;
PdgTableFilename = DET.PdgTableFilename;
PDGtable = DET.PDGtable;
inputfilelist = DET.inputfilelist;
detectorcard = DET.detectorcard;
triggercard = DET.triggercard;

grandom = new TRandom3(*(DET.grandom));

}

RESOLution& RESOLution::operator=(const RESOLution& DET) {

if(this==&DET) return *this;
Detector characteristics
CEN_max_tracker = DET.CEN_max_tracker;
CEN_max_calo_cen = DET.CEN_max_calo_cen;
CEN_max_calo_ec = DET.CEN_max_calo_ec;
CEN_max_calo_fwd = DET.CEN_max_calo_fwd;
CEN_max_mu = DET.CEN_max_mu;


Energy resolution for electron/photon
ELG_Scen = DET.ELG_Scen;
ELG_Ncen = DET.ELG_Ncen;
ELG_Ccen = DET.ELG_Ccen;
ELG_Sec = DET.ELG_Sec;
ELG_Nec = DET.ELG_Nec;
ELG_Cec = DET.ELG_Cec;
ELG_Cfwd = DET.ELG_Cfwd;
ELG_Sfwd = DET.ELG_Sfwd;
ELG_Nfwd = DET.ELG_Nfwd;
ELG_Czdc = DET.ELG_Czdc;
ELG_Szdc = DET.ELG_Szdc;
ELG_Nzdc = DET.ELG_Nzdc;

Energy resolution for hadrons in ecal/hcal/fwd/zdc
HAD_Scen = DET.HAD_Scen ;
HAD_Ncen = DET.HAD_Ncen;
HAD_Ccen = DET.HAD_Ccen;
HAD_Sec = DET.HAD_Sec;
HAD_Nec = DET.HAD_Nec;
HAD_Cec = DET.HAD_Cec;
HAD_Sfwd = DET.HAD_Sfwd;
HAD_Nfwd = DET.HAD_Nfwd;
HAD_Cfwd = DET.HAD_Cfwd;
HAD_Szdc = DET.HAD_Szdc;
HAD_Nzdc = DET.HAD_Nzdc;
HAD_Czdc = DET.HAD_Czdc;

time resolution
ZDC_T_resolution = DET.ZDC_T_resolution;
resolution for time measurement [s]
RP220_T_resolution = DET.RP220_T_resolution;
RP420_T_resolution = DET.RP420_T_resolution;

Muon smearing
MU_SmearPt = DET.MU_SmearPt;

Tracking efficiencies
TRACK_ptmin = DET.TRACK_ptmin;
TRACK_eff = DET.TRACK_eff;

Calorimetric towers
TOWER_number = DET.TOWER_number;
TOWER_eta_edges = new float[TOWER_number+1];
for(unsigned int i=0; i<TOWER_number +1; i++) TOWER_eta_edges[i] = DET.TOWER_eta_edges[i];

TOWER_dphi = new float[TOWER_number];
for(unsigned int i=0; i<TOWER_number; i++) TOWER_dphi[i] = DET.TOWER_dphi[i];

Thresholds for reconstructed objetcs
PTCUT_elec = DET.PTCUT_elec;
PTCUT_muon = DET.PTCUT_muon;
PTCUT_jet = DET.PTCUT_jet;
PTCUT_gamma = DET.PTCUT_gamma;
PTCUT_taujet = DET.PTCUT_taujet;

ZDC_gamma_E = DET.ZDC_gamma_E;
ZDC_n_E = DET.ZDC_n_E;

Isolation
ISOL_PT = DET.ISOL_PT;
tracking isolation
ISOL_Cone = DET.ISOL_Cone;
ISOL_Calo_ET = DET.ISOL_Calo_ET; calorimeter isolation, defaut off
ISOL_Calo_Grid = DET.ISOL_Calo_Grid;

General jet variable
JET_coneradius = DET.JET_coneradius;
JET_jetalgo = DET.JET_jetalgo;
JET_seed = DET.JET_seed;
JET_Eflow = DET.JET_Eflow;

Tagging definition
BTAG_b = DET.BTAG_b;
BTAG_mistag_c = DET.BTAG_mistag_c;
BTAG_mistag_l = DET.BTAG_mistag_l;

FLAGS
FLAG_bfield = DET.FLAG_bfield;
FLAG_vfd = DET.FLAG_vfd;
FLAG_RP = DET.FLAG_RP;
FLAG_trigger = DET.FLAG_trigger;
FLAG_frog = DET.FLAG_frog;
FLAG_lhco = DET.FLAG_lhco;

In case BField propagation allowed
TRACK_radius = DET.TRACK_radius;
TRACK_length = DET.TRACK_length;
TRACK_bfield_x = DET.TRACK_bfield_x;
TRACK_bfield_y = DET.TRACK_bfield_y;
TRACK_bfield_z = DET.TRACK_bfield_z;

In case Very forward detectors allowed
VFD_min_calo_vfd = DET.VFD_min_calo_vfd;
VFD_max_calo_vfd = DET.VFD_max_calo_vfd;
VFD_min_zdc = DET.VFD_min_zdc;
VFD_s_zdc = DET.VFD_s_zdc;

RP_220_s = DET.RP_220_s;
RP_220_x = DET.RP_220_x;
RP_420_s = DET.RP_420_s;
RP_420_x = DET.RP_420_x;
RP_offsetEl_s = DET.RP_offsetEl_s;
RP_offsetEl_x = DET.RP_offsetEl_x;
RP_offsetEl_y = DET.RP_offsetEl_y;
RP_beam1Card = DET.RP_beam1Card;
RP_beam2Card = DET.RP_beam2Card;
RP_cross_x = DET.RP_cross_x;
RP_cross_y = DET.RP_cross_y;
RP_cross_ang_x = DET.RP_cross_ang_x;
RP_cross_ang_y = DET.RP_cross_ang_y;
RP_IP_name = DET.RP_IP_name;

In case FROG event display allowed
NEvents_Frog = DET.NEvents_Frog;

Number of events to be processed
NEvents = DET.NEvents;

JET_overlap = DET.JET_overlap;
MidPoint algorithm definition
JET_M_coneareafraction = DET.JET_M_coneareafraction;
JET_M_maxpairsize = DET.JET_M_maxpairsize;
JET_M_maxiterations = DET.JET_M_maxiterations;
Define Cone algorithm.
JET_C_adjacencycut = DET.JET_C_adjacencycut;
JET_C_maxiterations = DET.JET_C_maxiterations;
JET_C_iratch = DET.JET_C_iratch;
Define SISCone algorithm.
JET_S_npass = DET.JET_S_npass;
JET_S_protojet_ptmin = DET.JET_S_protojet_ptmin;

For Tau-jet definition
TAU_energy_scone = DET.TAU_energy_scone;
TAU_track_scone = DET.TAU_track_scone;
TAU_track_pt = DET.TAU_track_pt;
TAU_energy_frac = DET.TAU_energy_frac;

PT_QUARKS_MIN = DET.PT_QUARKS_MIN;

PdgTableFilename = DET.PdgTableFilename;
PDGtable = DET.PDGtable;

inputfilelist = DET.inputfilelist;
detectorcard = DET.detectorcard;
triggercard = DET.triggercard;

grandom = new TRandom3(*(DET.grandom));

return *this;

}

void RESOLution::setNames(const string& list, const string& det, const string& trig) {

inputfilelist = list;
detectorcard = det;
triggercard = trig;

}

------------------------------------------------------------------------------
void RESOLution::ReadDataCard(const string datacard) {

string temp_string;
istringstream curstring;


ifstream fichier_a_lire(datacard.c_str());
if(!fichier_a_lire.good()) {

cout <<" WARNING: Datadard not found, use default values " << endl;
return;

}
bool CEN_max_calo_ec_flag = false;


while (getline(fichier_a_lire,temp_string)) {

curstring.clear(); needed when using several times istringstream::str(string)
curstring.str(temp_string);
string varname;
float value; int ivalue; string svalue;

if(strstr(temp_string.c_str(),"#")) { }
else if(strstr(temp_string.c_str(),"CEN_max_tracker")) {curstring >> varname >> value; CEN_max_tracker = value;}
else if(strstr(temp_string.c_str(),"CEN_max_calo_cen")) {curstring >> varname >> value; CEN_max_calo_cen = value;}
else if(strstr(temp_string.c_str(),"CEN_max_calo_ec")) {CEN_max_calo_ec_flag=true; curstring >> varname >> value; CEN_max_calo_ec = value;}
else if(strstr(temp_string.c_str(),"CEN_max_calo_fwd")) {curstring >> varname >> value; CEN_max_calo_fwd = value;}
else if(strstr(temp_string.c_str(),"CEN_max_mu")) {curstring >> varname >> value; CEN_max_mu = value;}

else if(strstr(temp_string.c_str(),"VFD_min_calo_vfd")) {curstring >> varname >> value; VFD_min_calo_vfd = value;}
else if(strstr(temp_string.c_str(),"VFD_max_calo_vfd")) {curstring >> varname >> value; VFD_max_calo_vfd = value;}
else if(strstr(temp_string.c_str(),"VFD_min_zdc")) {curstring >> varname >> value; VFD_min_zdc = value;}
else if(strstr(temp_string.c_str(),"VFD_s_zdc")) {curstring >> varname >> value; VFD_s_zdc = value;}


else if(strstr(temp_string.c_str(),"RP_220_s")) {curstring >> varname >> value; RP_220_s = value;}
else if(strstr(temp_string.c_str(),"RP_220_x")) {curstring >> varname >> value; RP_220_x = value;}
else if(strstr(temp_string.c_str(),"RP_420_s")) {curstring >> varname >> value; RP_420_s = value;}
else if(strstr(temp_string.c_str(),"RP_420_x")) {curstring >> varname >> value; RP_420_x = value;}
else if(strstr(temp_string.c_str(),"RP_beam1Card")) {curstring >> varname >> svalue;RP_beam1Card = svalue;}
else if(strstr(temp_string.c_str(),"RP_beam2Card")) {curstring >> varname >> svalue;RP_beam2Card = svalue;}
else if(strstr(temp_string.c_str(),"RP_IP_name")) {curstring >> varname >> svalue;RP_IP_name = svalue;}

else if(strstr(temp_string.c_str(),"RP_offsetEl_s")) {curstring >> varname >> value; RP_offsetEl_s = value;}
else if(strstr(temp_string.c_str(),"RP_offsetEl_x")) {curstring >> varname >> value; RP_offsetEl_x = value;}
else if(strstr(temp_string.c_str(),"RP_offsetEl_y")) {curstring >> varname >> value; RP_offsetEl_y = value;}
else if(strstr(temp_string.c_str(),"RP_cross_x")) {curstring >> varname >> value; RP_cross_x = value;}
else if(strstr(temp_string.c_str(),"RP_cross_y")) {curstring >> varname >> value; RP_cross_y = value;}
else if(strstr(temp_string.c_str(),"RP_cross_ang_x")) {curstring >> varname >> value; RP_cross_ang_x = value;}
else if(strstr(temp_string.c_str(),"RP_cross_ang_y")) {curstring >> varname >> value; RP_cross_ang_y = value;}


else if(strstr(temp_string.c_str(),"ELG_Scen")) {curstring >> varname >> value; ELG_Scen = value;}
else if(strstr(temp_string.c_str(),"ELG_Ncen")) {curstring >> varname >> value; ELG_Ncen = value;}
else if(strstr(temp_string.c_str(),"ELG_Ccen")) {curstring >> varname >> value; ELG_Ccen = value;}
else if(strstr(temp_string.c_str(),"ELG_Sec")) {curstring >> varname >> value; ELG_Sec = value;}
else if(strstr(temp_string.c_str(),"ELG_Nec")) {curstring >> varname >> value; ELG_Nec = value;}
else if(strstr(temp_string.c_str(),"ELG_Cec")) {curstring >> varname >> value; ELG_Cec = value;}
else if(strstr(temp_string.c_str(),"ELG_Sfwd")) {curstring >> varname >> value; ELG_Sfwd = value;}
else if(strstr(temp_string.c_str(),"ELG_Cfwd")) {curstring >> varname >> value; ELG_Cfwd = value;}
else if(strstr(temp_string.c_str(),"ELG_Nfwd")) {curstring >> varname >> value; ELG_Nfwd = value;}
else if(strstr(temp_string.c_str(),"ELG_Szdc")) {curstring >> varname >> value; ELG_Szdc = value;}
else if(strstr(temp_string.c_str(),"ELG_Czdc")) {curstring >> varname >> value; ELG_Czdc = value;}
else if(strstr(temp_string.c_str(),"ELG_Nzdc")) {curstring >> varname >> value; ELG_Nzdc = value;}

else if(strstr(temp_string.c_str(),"HAD_Shcal")) {warning("HAD_Shcal","HAD_Scen"); curstring >> varname >> value; HAD_Scen = value;}
else if(strstr(temp_string.c_str(),"HAD_Nhcal")) {warning("HAD_Nhcal","HAD_Ncen"); curstring >> varname >> value; HAD_Ncen = value;}
else if(strstr(temp_string.c_str(),"HAD_Chcal")) {warning("HAD_Chcal","HAD_Ccen"); curstring >> varname >> value; HAD_Ccen = value;}
else if(strstr(temp_string.c_str(),"HAD_Shf")) {warning("HAD_Shf","HAD_Sfwd"); curstring >> varname >> value; HAD_Sfwd = value;}
else if(strstr(temp_string.c_str(),"HAD_Nhf")) {warning("HAD_Nhf","HAD_Nfwd"); curstring >> varname >> value; HAD_Nfwd = value;}
else if(strstr(temp_string.c_str(),"HAD_Chf")) {warning("HAD_Chf","HAD_Cfwd"); curstring >> varname >> value; HAD_Cfwd = value;}

else if(strstr(temp_string.c_str(),"HAD_Scen")) {curstring >> varname >> value; HAD_Scen = value;}
else if(strstr(temp_string.c_str(),"HAD_Ncen")) {curstring >> varname >> value; HAD_Ncen = value;}
else if(strstr(temp_string.c_str(),"HAD_Ccen")) {curstring >> varname >> value; HAD_Ccen = value;}
else if(strstr(temp_string.c_str(),"HAD_Sec")) {curstring >> varname >> value; HAD_Sec = value;}
else if(strstr(temp_string.c_str(),"HAD_Nec")) {curstring >> varname >> value; HAD_Nec = value;}
else if(strstr(temp_string.c_str(),"HAD_Cec")) {curstring >> varname >> value; HAD_Cec = value;}
else if(strstr(temp_string.c_str(),"HAD_Sfwd")) {curstring >> varname >> value; HAD_Sfwd = value;}
else if(strstr(temp_string.c_str(),"HAD_Nfwd")) {curstring >> varname >> value; HAD_Nfwd = value;}
else if(strstr(temp_string.c_str(),"HAD_Cfwd")) {curstring >> varname >> value; HAD_Cfwd = value;}
else if(strstr(temp_string.c_str(),"HAD_Szdc")) {curstring >> varname >> value; HAD_Szdc = value;}
else if(strstr(temp_string.c_str(),"HAD_Nzdc")) {curstring >> varname >> value; HAD_Nzdc = value;}
else if(strstr(temp_string.c_str(),"HAD_Czdc")) {curstring >> varname >> value; HAD_Czdc = value;}

else if(strstr(temp_string.c_str(),"ZDC_T_resolution")) {curstring >> varname >> value; ZDC_T_resolution = value;}
else if(strstr(temp_string.c_str(),"RP220_T_resolution")) {curstring >> varname >> value; RP220_T_resolution = value;}
else if(strstr(temp_string.c_str(),"RP420_T_resolution")) {curstring >> varname >> value; RP420_T_resolution = value;}
else if(strstr(temp_string.c_str(),"MU_SmearPt")) {curstring >> varname >> value; MU_SmearPt = value;}


else if(strstr(temp_string.c_str(),"TRACK_radius")) {curstring >> varname >> ivalue;TRACK_radius = ivalue;}
else if(strstr(temp_string.c_str(),"TRACK_length")) {curstring >> varname >> ivalue;TRACK_length = ivalue;}
else if(strstr(temp_string.c_str(),"TRACK_bfield_x")) {curstring >> varname >> value; TRACK_bfield_x = value;}
else if(strstr(temp_string.c_str(),"TRACK_bfield_y")) {curstring >> varname >> value; TRACK_bfield_y = value;}
else if(strstr(temp_string.c_str(),"TRACK_bfield_z")) {curstring >> varname >> value; TRACK_bfield_z = value;}
else if(strstr(temp_string.c_str(),"FLAG_bfield")) {curstring >> varname >> ivalue; FLAG_bfield = ivalue;}
else if(strstr(temp_string.c_str(),"TRACK_ptmin")) {curstring >> varname >> value; TRACK_ptmin = value;}
else if(strstr(temp_string.c_str(),"TRACK_eff")) {curstring >> varname >> value; TRACK_eff = value;}

else if(strstr(temp_string.c_str(),"TOWER_number")) {curstring >> varname >> ivalue;TOWER_number = ivalue;}
else if(strstr(temp_string.c_str(),"TOWER_eta_edges")){

curstring >> varname; for(unsigned int i=0; i<TOWER_number+1; i++) {curstring >> value; TOWER_eta_edges[i] = value;} }

else if(strstr(temp_string.c_str(),"TOWER_dphi")){

curstring >> varname; for(unsigned int i=0; i<TOWER_number; i++) {curstring >> value; TOWER_dphi[i] = value;} }

else if(strstr(temp_string.c_str(),"PTCUT_elec")) {curstring >> varname >> value; PTCUT_elec = value;}
else if(strstr(temp_string.c_str(),"PTCUT_muon")) {curstring >> varname >> value; PTCUT_muon = value;}
else if(strstr(temp_string.c_str(),"PTCUT_jet")) {curstring >> varname >> value; PTCUT_jet = value;}
else if(strstr(temp_string.c_str(),"PTCUT_gamma")) {curstring >> varname >> value; PTCUT_gamma = value;}
else if(strstr(temp_string.c_str(),"PTCUT_taujet")) {curstring >> varname >> value; PTCUT_taujet = value;}
else if(strstr(temp_string.c_str(),"ZDC_gamma_E")) {curstring >> varname >> value; ZDC_gamma_E = value;}
else if(strstr(temp_string.c_str(),"ZDC_n_E")) {curstring >> varname >> value; ZDC_n_E = value;}

else if(strstr(temp_string.c_str(),"ISOL_PT")) {curstring >> varname >> value; ISOL_PT = value;}
else if(strstr(temp_string.c_str(),"ISOL_Cone")) {curstring >> varname >> value; ISOL_Cone = value;}
else if(strstr(temp_string.c_str(),"ISOL_Calo_ET")) {curstring >> varname >> value; ISOL_Calo_ET = value;}
else if(strstr(temp_string.c_str(),"ISOL_Calo_Grid")) {curstring >> varname >> ivalue; ISOL_Calo_Grid = ivalue;}

else if(strstr(temp_string.c_str(),"JET_coneradius")) {curstring >> varname >> value; JET_coneradius = value;}
else if(strstr(temp_string.c_str(),"JET_jetalgo")) {curstring >> varname >> ivalue;JET_jetalgo = ivalue;}
else if(strstr(temp_string.c_str(),"JET_seed")) {curstring >> varname >> value; JET_seed = value;}
else if(strstr(temp_string.c_str(),"JET_Eflow")) {curstring >> varname >> ivalue; JET_Eflow = ivalue;}


else if(strstr(temp_string.c_str(),"BTAG_b")) {curstring >> varname >> value;BTAG_b = value;}
else if(strstr(temp_string.c_str(),"BTAG_mistag_c")) {curstring >> varname >> value;BTAG_mistag_c = value;}
else if(strstr(temp_string.c_str(),"BTAG_mistag_l")) {curstring >> varname >> value;BTAG_mistag_l = value;}

else if(strstr(temp_string.c_str(),"FLAG_vfd")) {curstring >> varname >> ivalue; FLAG_vfd = ivalue;}
else if(strstr(temp_string.c_str(),"FLAG_RP")) {curstring >> varname >> ivalue; FLAG_RP = ivalue;}
else if(strstr(temp_string.c_str(),"FLAG_trigger")) {curstring >> varname >> ivalue; FLAG_trigger = ivalue;}
else if(strstr(temp_string.c_str(),"FLAG_frog")) {curstring >> varname >> ivalue; FLAG_frog = ivalue;}
else if(strstr(temp_string.c_str(),"FLAG_lhco")) {curstring >> varname >> ivalue; FLAG_lhco = ivalue;}
else if(strstr(temp_string.c_str(),"NEvents_Frog")) {curstring >> varname >> ivalue; NEvents_Frog = ivalue;}
else if(strstr(temp_string.c_str(),"NEvents")) {curstring >> varname >> ivalue; NEvents = ivalue;}

else if(strstr(temp_string.c_str(),"PdgTableFilename")) {curstring >> varname >> svalue; PdgTableFilename = svalue;}

}

for compatibility with old data cards
if(!CEN_max_calo_ec_flag) {

cout << " Warning \'CEN_max_calo_ec\' not found in datacard. "<< endl;
cout << " Same values will be applied for calorimeter endcaps "<< endl;
cout << " as for central calorimeters "<< endl;
string text = " Please update your card ("+ datacard +")";
cout << left << setw(67) << text << right << setw(2) << "
" << endl;
cout << " This change is 100\% backward compatibly with older DetectorCard. " << endl;
cout << " However, please update your DetectorCard. " << endl;
CEN_max_calo_ec = CEN_max_calo_cen;
CEN_max_calo_cen = CEN_max_calo_cen/2;
ELG_Sec = ELG_Scen;
ELG_Nec = ELG_Ncen;
ELG_Cec = ELG_Ccen;
HAD_Sec = HAD_Scen;
HAD_Nec = HAD_Ncen;
HAD_Cec = HAD_Ccen;

}


if(ISOL_Calo_Grid%2 ==0) {

ISOL_Calo_Grid++;
cout <<" WARNING: ISOL_Calo_Grid is not odd. Set it to "<< ISOL_Calo_Grid << " " << endl;

}


jet stuffs not defined in the input datacard
JET_overlap = 0.75;
MidPoint algorithm definition
JET_M_coneareafraction = 0.25;
JET_M_maxpairsize = 2;
JET_M_maxiterations = 100;
Define Cone algorithm.
JET_C_adjacencycut = 2;
JET_C_maxiterations = 100;
JET_C_iratch = 1;
Define SISCone algorithm.
JET_S_npass = 0;
JET_S_protojet_ptmin= 0.0;


For Tau-jet definition
TAU_energy_scone = 0.15;
radius R of the cone for tau definition, based on energy threshold
TAU_track_scone = 0.4; radius R of the cone for tau definition, based on track number
TAU_track_pt = 2;
minimal pt [GeV] for tracks to be considered in tau definition
TAU_energy_frac = 0.95; fraction of energy required in the central part of the cone, for tau jets


}

void RESOLution::Logfile(const string& LogName) {

creates the list of good input files
this list is vector<string> inputfiles.
ifstream infile(inputfilelist.c_str());
vector<string> inputfiles;
string filename;
while(1) {

infile >> filename; reads the first line of the list
if(!infile.good()) break;
quits when at the end of the list
ifstream checking_the_file(filename.c_str()); try to open the file
if(!checking_the_file.good()) continue;
skips bad/unknown files
else checking_the_file.close(); close file if found
inputfiles.push_back(filename);
append the name to the vector

}
infile.close();

ofstream f_out(LogName.c_str());

f_out <<""<< endl;
f_out <<"
"<< endl;
f_out <<" "<< endl;
f_out <<" Welcome to "<< endl;
f_out <<" "<< endl;
f_out <<" "<< endl;
f_out <<" .ddddddd- lL hH "<< endl;
f_out <<" -Dd dD: Ll hH` "<< endl;
f_out <<" dDd dDd eeee. lL .pp+pp Hh+hhh -eeee- sssss "<< endl;
f_out <<" -Dd `DD ee. ee Ll .Pp. PP Hh. HH. ee. ee sSs "<< endl;
f_out <<" dD dDd eEeee: lL. pP. pP hH hH eEeee:` -sSSSs. "<< endl;
f_out <<" .Dd :dd eE. LlL PpppPP Hh Hh eE sSS "<< endl;
f_out <<" dddddd:. eee+: lL. pp. hh. hh eee+ sssssS "<< endl;
f_out <<" Pp "<< endl;
f_out <<" "<< endl;
f_out <<" Delphes, a framework for the fast simulation "<< endl;
f_out <<" of a generic collider experiment "<< endl;
f_out <<" "<< endl;
f_out <<" --- Version 1.8 of Delphes --- "<< endl;
f_out <<" Last date of change: 16 August 2009 "<< endl;
f_out <<" "<< endl;
f_out <<" "<< endl;
f_out <<" This package uses: "<< endl;
f_out <<" ------------------ "<< endl;
f_out <<" FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] "<< endl;
f_out <<" Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] "<< endl;
f_out <<" FROG: L. Quertenmont, V. Roberfroid [hep-ex/0901.2718v1] "<< endl;
f_out <<" "<< endl;
f_out <<" ---------------------------------------------------------------- "<< endl;
f_out <<" "<< endl;
f_out <<" Main authors: "<< endl;
f_out <<" ------------- "<< endl;
f_out <<" "<< endl;
f_out <<" Séverine Ovyn Xavier Rouby "<< endl;
f_out <<" severine.ovyn@… xavier.rouby@cern "<< endl;
f_out <<" Center for Particle Physics and Phenomenology (CP3) "<< endl;
f_out <<" Universite Catholique de Louvain (UCL) "<< endl;
f_out <<" Louvain-la-Neuve, Belgium "<< endl;
f_out <<" "<< endl;
f_out <<" ---------------------------------------------------------------- "<< endl;
f_out <<" "<< endl;
f_out <<" Former Delphes versions and documentation can be found on : "<< endl;
f_out <<" http://www.fynu.ucl.ac.be/delphes.html "<< endl;
f_out <<" "<< endl;
f_out <<" "<< endl;
f_out <<" Disclaimer: this program comes without guarantees. "<< endl;
f_out <<" Beware of errors and please give us "<< endl;
f_out <<" your feedbacks about potential bugs. "<< endl;
f_out <<" "<< endl;
f_out <<""<< endl;
f_out <<"
"<< endl;
f_out<<"#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<"\n";
f_out <<"* *"<< endl;
f_out <<"#
*"<<"\n";
f_out <<"# Input files *"<<"\n";
f_out <<"#
*"<<"\n";
f_out << left << setw(22) <<"* Input list "<<""

<< left << setw(39) << inputfilelist << "" << right << setw(9) << "*"<<"\n";

for (unsigned int i =0; i<inputfiles.size(); i++) {

f_out << left << setw(22) <<"* - file "<<""

<< left << setw(43) << inputfiles[i] << "" << right << setw(5) << "*"<<"\n";

}
if(detectorcard != "")

f_out << left << setw(22) <<"* Detector card "<<""

<< left << setw(39) << detectorcard << "" << right << setw(9) << "*"<<"\n";

if(triggercard != "")

f_out << left << setw(22) <<"* Trigger card "<<""

<< left << setw(39) << triggercard << "" << right << setw(9) << "*"<<"\n";

f_out<<"* Beam optics : *"<<"\n";
f_out << left << setw(22) <<"* - beam 1 "<<""

<< left << setw(33) << RP_beam1Card << "" << right << setw(15) << "*"<<"\n";

f_out << left << setw(22) <<"* - beam 2 "<<""

<< left << setw(33) << RP_beam2Card << "" << right << setw(15) << "*"<<"\n";

f_out << left << setw(22) <<"* Input PDG table " << ""

<< left << setw(39) << PdgTableFilename << "" << right << setw(9) << "*"<<"\n";

f_out<<"* *"<<"\n";
f_out<<"* *"<<"\n";
f_out<<"# *"<<"\n";
f_out<<"# Central detector caracteristics *"<<"\n";
f_out<<"# *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(30) <<"* Maximum tracking system: "<<""

<< left << setw(10) <<CEN_max_tracker <<""<< right << setw(15)<<"*"<<"\n";

f_out << left << setw(30) <<"* Maximum central calorimeter: "<<""

<< left << setw(10) <<CEN_max_calo_cen <<""<< right << setw(15)<<"*"<<"\n";

f_out << left << setw(30) <<"* Maximum endcap calorimeter: "<<""

<< left << setw(10) <<CEN_max_calo_ec <<""<< right << setw(15)<<"*"<<"\n";

f_out << left << setw(30) <<"* Maximum central calorimeter: "<<""

<< left << setw(10) <<CEN_max_calo_fwd <<""<< right << setw(15)<<"*"<<"\n";

f_out << left << setw(30) <<"* Muon chambers coverage: "<<""

<< left << setw(10) <<CEN_max_mu <<""<< right << setw(15)<<"*"<<"\n";

f_out<<"* *"<<"\n";
if(FLAG_RP==1){

f_out<<"# *"<<"\n";
f_out<<"# Very forward Roman Pots switched on *"<<"\n";
f_out<<"# *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(55) <<"* Distance of the 220 RP to the IP in meters:"<<""

<< left << setw(5) <<RP_220_s <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Distance of the 220 RP to the beam in meters:"<<""

<< left << setw(5) <<RP_220_x <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Distance of the 420 RP to the IP in meters:"<<""

<< left << setw(5) <<RP_420_s <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Distance of the 420 RP to the beam in meters:"<<""

<< left << setw(5) <<RP_420_x <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Interaction point at the LHC named: "<<""

<< left << setw(5) <<RP_IP_name <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(35) <<"* Datacard for beam 1: "<<""

<< left << setw(25) <<RP_beam1Card <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(35) <<"* Datacard for beam 2: "<<""

<< left << setw(25) <<RP_beam2Card <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* Beam separation, in meters(hor):"<<""

<< left << setw(6) << RP_offsetEl_x <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* Beam separation, in meters(ver):"<<""

<< left << setw(6) << RP_offsetEl_y <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* Distance from IP for Beam separation (m):"<<""

<< left << setw(6) <<RP_offsetEl_s <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* X offset of beam crossing in micrometers:"<<""

<< left << setw(6) <<RP_cross_x <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* Y offset of beam crossing in micrometers:"<<""

<< left << setw(6) <<RP_cross_y <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* X Angle of beam crossing:"<<""

<< left << setw(6) <<RP_cross_ang_x <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(54) <<"* Y Angle of beam crossing:"<<""

<< left << setw(6) <<RP_cross_ang_y <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";

}
else {

f_out<<"#* *"<<"\n";
f_out<<"# Very forward Roman Pots switched off *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"* *"<<"\n";

}
if(FLAG_vfd==1){

f_out<<"# *"<<"\n";
f_out<<"# Very forward calorimeters switched on *"<<"\n";
f_out<<"#
*"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(55) <<"* Minimum very forward calorimeter: "<<""

<< left << setw(5) <<VFD_min_calo_vfd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Maximum very forward calorimeter: "<<""

<< left << setw(5) <<VFD_max_calo_vfd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Minimum coverage zero_degree calorimeter "<<""

<< left << setw(5) <<VFD_min_zdc <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Distance of the ZDC to the IP, in meters: "<<""

<< left << setw(5) <<VFD_s_zdc <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";

}
else {

f_out<<"#* *"<<"\n";
f_out<<"# Very forward calorimeters switched off *"<<"\n";
f_out<<"#
* *"<<"\n";
f_out<<"* *"<<"\n";

}

f_out<<"# *"<<"\n";
f_out<<"# Electromagnetic smearing parameters *"<<"\n";
f_out<<"# *"<<"\n";
f_out<<"* *"<<"\n";
# \sigma/E = C + N/E + S/\sqrt{E}
f_out << left << setw(30) <<"* S term for central ECAL: "<<""

<< left << setw(30) <<ELG_Scen <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for central ECAL: "<<""

<< left << setw(30) <<ELG_Ncen <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for central ECAL: "<<""

<< left << setw(30) <<ELG_Ccen <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* S term for ECAL end-cap: "<<""

<< left << setw(30) <<ELG_Sec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for ECAL end-cap: "<<""

<< left << setw(30) <<ELG_Nec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for ECAL end-cap: "<<""

<< left << setw(30) <<ELG_Cec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* S term for FCAL: "<<""

<< left << setw(30) <<ELG_Sfwd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for FCAL: "<<""

<< left << setw(30) <<ELG_Nfwd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for FCAL: "<<""

<< left << setw(30) <<ELG_Cfwd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* S term for ZDC: "<<""

<< left << setw(30) <<ELG_Szdc <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for ZDC: "<<""

<< left << setw(30) <<ELG_Nzdc <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for ZDC: "<<""

<< left << setw(30) <<ELG_Czdc <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"# Hadronic smearing parameters *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(30) <<"* S term for central HCAL: "<<""

<< left << setw(30) <<HAD_Scen <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for central HCAL: "<<""

<< left << setw(30) <<HAD_Ncen <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for central HCAL: "<<""

<< left << setw(30) <<HAD_Ccen <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* S term for HCAL endcap: "<<""

<< left << setw(30) <<HAD_Sec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for HCAL endcap: "<<""

<< left << setw(30) <<HAD_Nec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for HCAL endcap: "<<""

<< left << setw(30) <<HAD_Cec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* S term for FCAL: "<<""

<< left << setw(30) <<HAD_Sfwd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for FCAL: "<<""

<< left << setw(30) <<HAD_Nfwd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for FCAL: "<<""

<< left << setw(30) <<HAD_Cfwd <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* S term for ZDC: "<<""

<< left << setw(30) <<HAD_Szdc <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* N term for ZDC: "<<""

<< left << setw(30) <<HAD_Nzdc <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(30) <<"* C term for ZDC: "<<""

<< left << setw(30) <<HAD_Czdc <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"# Time smearing parameters *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(55) <<"* Time resolution for ZDC : "<<""

<< left << setw(5) <<ZDC_T_resolution <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Time resolution for RP220 : "<<""

<< left << setw(5) <<RP220_T_resolution <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Time resolution for RP420 : "<<""

<< left << setw(5) <<RP420_T_resolution <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";

f_out<<"* *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"# Muon smearing parameters *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(55) <<"* PT resolution for muons : "<<""

<< left << setw(5) <<MU_SmearPt <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";
if(FLAG_bfield==1){

f_out<<"#* *"<<"\n";
f_out<<"# Magnetic field switched on *"<<"\n";
f_out<<"#
* *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(55) <<"* Radius of the BField coverage: "<<""

<< left << setw(5) <<TRACK_radius <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Length of the BField coverage: "<<""

<< left << setw(5) <<TRACK_length <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* BField X component: "<<""

<< left << setw(5) <<TRACK_bfield_x <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* BField Y component: "<<""

<< left << setw(5) <<TRACK_bfield_y <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* BField Z component: "<<""

<< left << setw(5) <<TRACK_bfield_z <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Minimal pT needed to reach the calorimeter [GeV]: "<<""

<< left << setw(10) <<TRACK_ptmin <<""<< right << setw(5)<<"*"<<"\n";

f_out << left << setw(55) <<"* Efficiency associated to the tracking: "<<""

<< left << setw(10) <<TRACK_eff <<""<< right << setw(5)<<"*"<<"\n";

f_out<<"* *"<<"\n";

}
else {

f_out<<"# *"<<"\n";
f_out<<"# Magnetic field switched off *"<<"\n";
f_out<<"# *"<<"\n";
f_out << left << setw(55) <<"* Minimal pT needed to reach the calorimeter [GeV]: "<<""

<< left << setw(10) <<TRACK_ptmin <<""<< right << setw(5)<<"*"<<"\n";

f_out << left << setw(55) <<"* Efficiency associated to the tracking: "<<""

<< left << setw(10) <<TRACK_eff <<""<< right << setw(5)<<"*"<<"\n";

f_out<<"* *"<<"\n";

}
f_out<<"# *"<<"\n";
f_out<<"# Calorimetric Towers *"<<"\n";
f_out<<"# *"<<"\n";
f_out << left << setw(55) <<"* Number of calorimetric towers in eta, for eta>0: "<<""

<< left << setw(5) << TOWER_number <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(55) <<"* Tower edges in eta, for eta>0: "<<"" << right << setw(15)<<"*"<<"\n";
f_out << "* ";
for (unsigned int i=0; i<TOWER_number+1; i++) {

f_out << left << setw(7) << TOWER_eta_edges[i];
if(!( (i+1) %9 )) f_out << right << setw(3) << "*" << "\n" << "* ";

}
for (unsigned int i=(TOWER_number+1)%9; i<9; i++) f_out << left << setw(7) << "";
f_out << right << setw(3)<<"*"<<"\n";
f_out << left << setw(55) <<"* Tower sizes in phi, for eta>0 [degree]:"<<"" << right << setw(15)<<"*"<<"\n";
f_out << "* ";
for (unsigned int i=0; i<TOWER_number; i++) {

f_out << left << setw(7) << TOWER_dphi[i];
if(!( (i+1) %9 )) f_out << right << setw(3) << "*" << "\n" << "* ";

}
for (unsigned int i=(TOWER_number)%9; i<9; i++) f_out << left << setw(7) << "";
f_out << right << setw(3)<<"*"<<"\n";
f_out<<"* *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"# Minimum pT's [GeV] *"<<"\n";
f_out<<"#
* *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(40) <<"* Minimum pT for electrons: "<<""

<< left << setw(20) <<PTCUT_elec <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Minimum pT for muons: "<<""

<< left << setw(20) <<PTCUT_muon <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Minimum pT for jets: "<<""

<< left << setw(20) <<PTCUT_jet <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Minimum pT for Tau-jets: "<<""

<< left << setw(20) <<PTCUT_taujet <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Minimum pT for photons: "<<""

<< left << setw(20) <<PTCUT_gamma <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Minimum E for photons in ZDC: "<<""

<< left << setw(20) <<ZDC_gamma_E <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Minimum E for neutrons in ZDC: "<<""

<< left << setw(20) <<ZDC_n_E <<""<< right << setw(10)<<"*"<<"\n";

f_out<<"* *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"# Isolation criteria *"<<"\n";
f_out<<"#
* *"<<"\n";
f_out<<"* *"<<"\n";
f_out << left << setw(40) <<"* Minimum pT for tracks [GeV]: "<<""

<< left << setw(20) <<ISOL_PT <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Cone for isolation criteria: "<<""

<< left << setw(20) <<ISOL_Cone <<""<< right << setw(10)<<"*"<<"\n";

if(ISOL_Calo_ET > 1E98) f_out<<"# No Calorimetric isolation applied *"<<"\n";
else {

f_out << left << setw(40) <<"* Minimum ET for towers [GeV]: "<<""

<< left << setw(20) <<ISOL_Calo_ET <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* Grid size (NxN) for calorimetric isolation: "<<""

<< left << setw(20) <<ISOL_Calo_Grid <<""<< right << setw(4)<<"*"<<"\n";

}

f_out<<"* *"<<"\n";
f_out<<"#* *"<<"\n";
f_out<<"# Jet definition *"<<"\n";
f_out<<"#
* *"<<"\n";
if(JET_Eflow)

{

f_out<<"#* *"<<"\n";
f_out<<"#* Running considering perfect energy flow on the tracker coverage *"<<"\n";

}

else

{

f_out<<"#* Running considering no energy flow on the tracker coverage *"<<"\n";
f_out<<"#* --> jet algo applied on the calorimetric towers *"<<"\n";

}

f_out<<"* *"<<"\n";
f_out<<"* Six algorithms are currently available: *"<<"\n";
f_out<<"* - 1) CDF cone algorithm, *"<<"\n";
f_out<<"* - 2) CDF MidPoint algorithm, *"<<"\n";
f_out<<"* - 3) SIScone algorithm, *"<<"\n";
f_out<<"* - 4) kt algorithm, *"<<"\n";
f_out<<"* - 5) Cambrigde/Aachen algorithm, *"<<"\n";
f_out<<"* - 6) Anti-kt algorithm. *"<<"\n";
f_out<<"* *"<<"\n";
f_out<<"* You have chosen *"<<"\n";
switch(JET_jetalgo) {
default:
case 1: {

f_out<<"* CDF JetClu jet algorithm with parameters: *"<<"\n";
f_out << left << setw(40) <<"* - Seed threshold: "<<""

<< left << setw(10) <<JET_seed <<""<< right << setw(20)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Cone radius: "<<""

<< left << setw(10) <<JET_coneradius <<""<< right << setw(20)<<"*"<<"\n";

f_out << left << setw(40) <<"* - Adjacency cut: "<<""

<< left << setw(10) <<JET_C_adjacencycut <<""<< right << setw(20)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Max iterations: "<<""

<< left << setw(10) <<JET_C_maxiterations <<""<< right << setw(20)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Iratch: "<<""

<< left << setw(10) <<JET_C_iratch <<""<< right << setw(20)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Overlap threshold: "<<""

<< left << setw(10) <<JET_overlap <<""<< right << setw(20)<<"! not in datacard *"<<"\n";

}

break;

case 2: {

f_out<<"* CDF midpoint jet algorithm with parameters: *"<<"\n";
f_out << left << setw(40) <<"* - Seed threshold: "<<""

<< left << setw(20) <<JET_seed <<""<< right << setw(10)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Cone radius: "<<""

<< left << setw(20) <<JET_coneradius <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* - Cone area fraction:"<<""

<< left << setw(20) <<JET_M_coneareafraction <<""<< right << setw(10)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Maximum pair size: "<<""

<< left << setw(20) <<JET_M_maxpairsize <<""<< right << setw(10)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Max iterations: "<<""

<< left << setw(20) <<JET_M_maxiterations <<""<< right << setw(10)<<"! not in datacard *"<<"\n";

f_out << left << setw(40) <<"* - Overlap threshold: "<<""

<< left << setw(20) <<JET_overlap <<""<< right << setw(10)<<"! not in datacard *"<<"\n";

}

break;

case 3: {

f_out <<"* SISCone jet algorithm with parameters: *"<<"\n";
f_out << left << setw(40) <<"* - Cone radius: "<<""

<< left << setw(20) <<JET_coneradius <<""<< right << setw(10)<<"*"<<"\n";

f_out << left << setw(40) <<"* - Overlap threshold: "<<""

<< left << setw(20) <<JET_overlap <<""<< right << setw(10)<<"! not in data

File size: 36.3 KB
Line 
1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \------------- arXiv:0903.2225v1 ------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86 **
12** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
13** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
14** FROG: [hep-ex/0901.2718v1] **
15** HepMC: Comput. Phys. Commun.134 (2001) 41 **
16** **
17** ------------------------------------------------------------------ **
18** **
19** Main authors: **
20** ------------- **
21** **
22** Severine Ovyn Xavier Rouby **
23** severine.ovyn@uclouvain.be xavier.rouby@cern **
24** **
25** Center for Particle Physics and Phenomenology (CP3) **
26** Universite catholique de Louvain (UCL) **
27** Louvain-la-Neuve, Belgium **
28** **
29** Copyright (C) 2008-2009, **
30** All rights reserved. **
31** **
32***********************************************************************/
33
34/// \file Delphes.cpp
35/// \brief Executable for Delphes
36
37#include "TChain.h"
38#include "TApplication.h"
39#include "TStopwatch.h"
40#include "TFile.h"
41
42#include "ExRootTreeReader.h"
43#include "ExRootTreeWriter.h"
44#include "ExRootTreeBranch.h"
45#include "ExRootProgressBar.h"
46
47#include "DataConverter.h"
48#include "LHEFConverter.h"
49#include "HepMCConverter.h"
50#include "HEPEVTConverter.h"
51#include "STDHEPConverter.h"
52#include "LHCOConverter.h"
53#include "DelphesRootConverter.h"
54
55#include "SmearUtil.h"
56#include "CaloUtil.h"
57#include "BFieldProp.h"
58#include "TriggerUtil.h"
59#include "VeryForward.h"
60#include "JetsUtil.h"
61#include "FrogUtil.h"
62
63#include <vector>
64#include <iostream>
65#include <cstdlib> // abs(int)
66
67using namespace std;
68
69//------------------------------------------------------------------------------
70
71int main(int argc, char *argv[])
72{
73
74 int appargc = 2;
75 char *appName= new char[20];
76 char *appOpt= new char[20];
77 sprintf(appName,"Delphes");
78 sprintf(appOpt,"-b");
79 char *appargv[] = {appName,appOpt};
80 TApplication app(appName, &appargc, appargv);
81 delete [] appName;
82 delete [] appOpt;
83
84 if(argc != 3 && argc != 4 && argc != 5) {
85 cout << " Usage: " << argv[0] << " input_file output_file [detector_card] [trigger_card] " << endl;
86 cout << " input_list - list of files in Ntpl, StdHep, HepMC or LHEF format," << endl;
87 cout << " output_file - output file." << endl;
88 cout << " detector_card - Datacard containing resolution variables for the detector simulation (optional) "<<endl;
89 cout << " trigger_card - Datacard containing the trigger algorithms (optional) "<<endl;
90 exit(1);
91 }
92
93 print_header();
94
95 // 1. ********** initialisation ***********
96
97 srand (time (NULL)); /* Initialisation du générateur */
98 TRandom3 * grandom = new TRandom3();
99 TStopwatch globalwatch, loopwatch, triggerwatch, frogwatch, lhcowatch;
100 globalwatch.Start();
101
102
103 //read the output TROOT file
104 string inputFileList(argv[1]), outputfilename(argv[2]);
105 if(outputfilename.find(".root") > outputfilename.length()) {
106 cout <<"** ERROR: 'output_file' should be a .root file. Exiting... **"<< endl;
107 exit(1);
108 }
109 //create output log-file name
110 string forLog = outputfilename;
111 string LogName = forLog.erase(forLog.find(".root"));
112 LogName = LogName+"_run.log";
113
114 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
115 outputFile->Close();
116
117 string line;
118 ifstream infile(inputFileList.c_str());
119 if(!infile.good()) {
120 cout << "** ERROR: Input list (" << left << setw(13) << inputFileList << ") not found. Exiting... **"<< endl;
121 cout <<"*********************************************************************"<< endl;
122 exit(1);
123 }
124 infile >> line; // the first line determines the type of input files
125
126 //read the datacard input file
127 string DetDatacard("data/DetectorCard.dat"); //for detector smearing parameters
128 string TrigDatacard("data/TriggerCard.dat"); //for trigger selection
129
130 string lineCard1,lineCard2;
131 bool detecCard=false,trigCard=false;
132 if(argv[3])
133 {
134 ifstream infile1(argv[3]);
135 infile1 >> lineCard1; // the first line determines the type of input files
136 if(strstr(lineCard1.c_str(),"DETECTOR") && detecCard==true)
137 cerr <<"** ERROR: A DETECTOR card has already been loaded **"<< endl;
138 else if(strstr(lineCard1.c_str(),"DETECTOR") && detecCard==false){DetDatacard =argv[3]; detecCard=true;}
139 else if(strstr(lineCard1.c_str(),"TRIGGER") && trigCard==true)
140 cerr <<"** ERROR: A TRIGGER card has already been loaded **"<< endl;
141 else if(strstr(lineCard1.c_str(),"TRIGGER") && trigCard==false){TrigDatacard =argv[3]; trigCard=true;}
142 }
143 if(argv[4])
144 {
145 ifstream infile2(argv[4]);
146 infile2 >> lineCard2; // the first line determines the type of input files
147 if(strstr(lineCard2.c_str(),"DETECTOR") && detecCard==true)
148 cerr <<"** ERROR: A DETECTOR card has already been loaded **"<< endl;
149 else if(strstr(lineCard2.c_str(),"DETECTOR") && detecCard==false){DetDatacard =argv[4]; detecCard=true;}
150 else if(strstr(lineCard2.c_str(),"TRIGGER") && trigCard==true)
151 cerr <<"** ERROR: A TRIGGER card has already been loaded **"<< endl;
152 else if(strstr(lineCard2.c_str(),"TRIGGER") && trigCard==false){TrigDatacard =argv[4]; trigCard=true;}
153 }
154
155 //Smearing information
156 RESOLution *DET = new RESOLution();
157
158 cout <<"** **"<< endl;
159 cout <<"** ####### Start reading DETECTOR parameters ####### **"<< endl;
160 cout << left << setw(40) <<"** Opening configuration card: "<<""
161 << left << setw(27) << DetDatacard <<""
162 << right << setw(2) <<"**"<<""<<endl;
163 DET->ReadDataCard(DetDatacard);
164 cout << left << setw(40) <<"** Parameters summarised in: "<<""
165 << left << setw(27) << LogName <<""
166 << right << setw(2) <<"**"<<""<<endl;
167 cout <<"** **"<< endl;
168 DET->ReadParticleDataGroupTable();
169 //DET->PDGtable.print();
170
171 //Trigger information
172 cout <<"** ########### Start reading TRIGGER card ########## **"<< endl;
173 if(trigCard==false)
174 {
175 cout <<"** WARNING: Datacard not found, use default card **" << endl;
176 TrigDatacard="data/TriggerCard.dat";
177 }
178 TriggerTable *TRIGT = new TriggerTable();
179 TRIGT->TriggerCardReader(TrigDatacard.c_str());
180 TRIGT->PrintTriggerTable(LogName);
181 if(DET->FLAG_trigger == 1)
182 {
183 cout << left << setw(40) <<"** Opening configuration card: "<<""
184 << left << setw(27) << TrigDatacard <<""
185 << right << setw(2) <<"**"<<""<<endl;
186 cout <<"** **"<< endl;
187 }
188
189 // Logfile
190 DET->setNames(inputFileList,DetDatacard,TrigDatacard);
191 DET->Logfile(LogName);
192
193 //Propagation of tracks in the B field
194 TrackPropagation *TRACP = new TrackPropagation(DET);
195
196 //Jet information
197 JetsUtil *JETRUN = new JetsUtil(DET);
198
199 //VFD information
200 VeryForward * VFD = new VeryForward(DET);
201
202 // data converters
203 cout <<"** **"<<endl;
204 cout <<"** ####### Start conversion to TRoot format ######## **"<< endl;
205
206 if(line.rfind(".hepmc") < line.length())
207 {
208 cout <<"** HepMC ASCII file format detected **"<<endl;
209 cout <<"** This can take several minutes **"<< endl;
210 HepMCConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
211 }
212 else if(line.rfind(".hep") < line.length())
213 {
214 cout <<"** StdHEP file format detected **"<<endl;
215 cout <<"** This can take several minutes **"<< endl;
216 STDHEPConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
217 }
218 else if(line.rfind(".lhe") < line.length())
219 {
220 cout <<"** LHEF file format detected **"<<endl;
221 cout <<"** This can take several minutes **"<< endl;
222 LHEFConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
223 }
224 else if(line.rfind(".root") < line.length())
225 // can be either a root file from h2root (i.e. with "h101" tree)
226 // or a root file from Delphes (i.e. with "GEN" tree)
227 {
228 TFile f(line.c_str());
229 if (f.FindKey("GEN")) {
230 cout <<"** Delphes ROOT file format detected **"<<endl;
231 cout <<"** This can take several minutes **"<< endl;
232 DelphesRootConverter converter(inputFileList,outputfilename,DET->NEvents);
233 }
234 else
235 if (f.FindKey("h101")) {
236 cout <<"** h2root file format detected **"<<endl;
237 cout <<"** This can take several minutes **"<< endl;
238 HEPEVTConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
239 }
240 else {
241 cerr << left << setw(4) <<"** "<<""
242 << left << setw(63) << line.c_str() <<""
243 << right << setw(2) <<"**"<<endl;
244 cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl;
245 cout <<"** **"<< endl;
246 cout <<"*********************************************************************"<< endl;
247 return -1;
248 } // not found any interesting input tree
249 f.Close();
250 } // .root file
251 else {
252 cerr << left << setw(4) <<"** "<<""
253 << left << setw(63) << line.c_str() <<""
254 << right << setw(2) <<"**"<<endl;
255 cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl;
256 cout <<"** **"<< endl;
257 cout <<"*********************************************************************"<< endl;
258 return -1;};
259 cout <<"** Exiting conversion... **"<< endl;
260
261 TChain chain("GEN");
262 chain.Add(outputfilename.c_str());
263 ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
264 const TClonesArray *branchGen = treeReader->UseBranch("Particle");
265
266 TIter itGen((TCollection*)branchGen);
267
268 //Output file : contents of the analysis object data
269 ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
270 ExRootTreeBranch *branchTauJet = treeWriter->NewBranch("TauJet", TRootTauJet::Class());
271 ExRootTreeBranch *branchJet = treeWriter->NewBranch("Jet", TRootJet::Class());
272 ExRootTreeBranch *branchElectron = treeWriter->NewBranch("Electron", TRootElectron::Class());
273 ExRootTreeBranch *branchMuon = treeWriter->NewBranch("Muon", TRootMuon::Class());
274 ExRootTreeBranch *branchPhoton = treeWriter->NewBranch("Photon", TRootPhoton::Class());
275 ExRootTreeBranch *branchTrack = treeWriter->NewBranch("Tracks", TRootTracks::Class());
276 ExRootTreeBranch *branchETmis = treeWriter->NewBranch("ETmis", TRootETmis::Class());
277 ExRootTreeBranch *branchCalo = treeWriter->NewBranch("CaloTower", TRootCalo::Class());
278 ExRootTreeBranch *branchZDC = treeWriter->NewBranch("ZDChits", TRootZdcHits::Class());
279 ExRootTreeBranch *branchRP220 = treeWriter->NewBranch("RP220hits", TRootRomanPotHits::Class());
280 //ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootForwardTaggerHits::Class());
281 ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootRomanPotHits::Class());
282
283 TRootETmis *elementEtmis;
284 TRootElectron *elementElec;
285 TRootMuon *elementMu;
286 TRootPhoton *elementPhoton;
287 TRootTracks * elementTrack;
288 TRootCalo *elementCalo;
289
290 TLorentzVector genMomentum(0,0,0,0); // four-momentum at the vertex
291 TLorentzVector genMomentumBfield(0,0,0,0); // four-momentum at the exit of the tracks
292 TLorentzVector momentumCaloSegmentation(0,0,0,0); // four-momentum in the calo, after applying the calo segmentation
293 LorentzVector jetMomentum;
294
295 vector<fastjet::PseudoJet> input_particles;//for FastJet algorithm
296 vector<fastjet::PseudoJet> sorted_jets;
297 vector<TRootTracks> TrackCentral;
298 vector<PhysicsTower> towers;
299 vector<D_Particle> electron;
300 vector<D_Particle> muon;
301 vector<D_Particle> gamma;
302
303 vector<int> NTrackJet;
304
305 TSimpleArray<TRootC::GenParticle> NFCentralQ;
306
307 D_CaloList list_of_calorimeters;
308 D_CaloElement CentralCalo("centralcalo",
309 -DET->CEN_max_calo_cen, DET->CEN_max_calo_cen,
310 DET->ELG_Ccen, DET->ELG_Ncen, DET->ELG_Scen,
311 DET->HAD_Ccen, DET->HAD_Ncen, DET->HAD_Scen);
312 D_CaloElement ForwardECCalo("forwardendcapcalo",
313 DET->CEN_max_calo_cen, DET->CEN_max_calo_ec,
314 DET->ELG_Cec, DET->ELG_Nec, DET->ELG_Sec,
315 DET->HAD_Cec, DET->HAD_Nec, DET->HAD_Sec );
316 D_CaloElement BackwardECCalo("backwardendcapcalo",
317 -DET->CEN_max_calo_ec, -DET->CEN_max_calo_cen,
318 DET->ELG_Cec, DET->ELG_Nec, DET->ELG_Sec,
319 DET->HAD_Cec, DET->HAD_Nec, DET->HAD_Sec );
320 D_CaloElement ForwardCalo("forwardcalo",
321 DET->CEN_max_calo_ec, DET->CEN_max_calo_fwd,
322 DET->ELG_Cfwd, DET->ELG_Nfwd, DET->ELG_Sfwd,
323 DET->HAD_Cfwd, DET->HAD_Nfwd, DET->HAD_Sfwd );
324 D_CaloElement BackwardCalo("backwardcalo",
325 -DET->CEN_max_calo_fwd, -DET->CEN_max_calo_ec,
326 DET->ELG_Cfwd, DET->ELG_Nfwd, DET->ELG_Sfwd,
327 DET->HAD_Cfwd, DET->HAD_Nfwd, DET->HAD_Sfwd );
328 //D_CaloElement CastorCalo("castor",5.5,6.6,1,0,0,1,0,0);
329 list_of_calorimeters.addElement(CentralCalo);
330 list_of_calorimeters.addElement(ForwardECCalo);
331 list_of_calorimeters.addElement(ForwardCalo);
332 list_of_calorimeters.addElement(BackwardECCalo);
333 list_of_calorimeters.addElement(BackwardCalo);
334 //list_of_calorimeters.addElement(CastorCalo);
335 list_of_calorimeters.sortElements();
336
337
338 // 2. ********** Loop over all events ***********
339 Long64_t entry, allEntries = treeReader->GetEntries();
340 cout <<"** **"<<endl;
341 cout <<"** ####### Start fast detector simulation ######## **"<< endl;
342 cout << left << setw(52) <<"** Total number of events to run: "<<""
343 << left << setw(15) << allEntries <<""
344 << right << setw(2) <<"**"<<endl;
345
346 ExRootProgressBar *Progress = new ExRootProgressBar(allEntries);
347
348 loopwatch.Start();
349
350 // loop on all events
351 for(entry = 0; entry < allEntries; ++entry)
352 {
353 Progress->Update(entry);
354 TLorentzVector PTmis(0,0,0,0);
355 treeReader->ReadEntry(entry);
356 treeWriter->Clear();
357
358 electron.clear();
359 muon.clear();
360 gamma.clear();
361 NFCentralQ.Clear();
362
363 TrackCentral.clear();
364 towers.clear();
365 input_particles.clear();
366 NTrackJet.clear();
367
368 // 'list_of_active_towers' contains the exact list of calorimetric towers which have some deposits inside (E>0).
369 // The towers of this list will be smeared according to the calo resolution, afterwards
370 D_CaloTowerList list_of_active_towers;
371
372 // 'list_of_towers_with_photon' and 'list_of_centowers_with_neutrals' are list of towers, whose energy is **not** computed.
373 // They are only used to store the eta/phi of some towers, in order to search later inside 'list_of_active_towers'.
374 // 'list_of_towers_with_photon' contains the towers hit by photons only
375 // 'list_of_centowers_with_neutrals' is used to the jet-E-flow calculation: contains the towers with eta < CEN_max_tracker,
376 // i.e. towers behind the tracker.
377 D_CaloTowerList list_of_towers_with_photon; // to speed up the code: will only look in interesting towers for gamma candidates
378
379 D_CaloTowerList list_of_centowers_with_neutrals; // list of towers with neutral particles : for jet E-flow
380 float etamax_calocoverage_behindtracker = DET->CEN_max_tracker; // finds the extension in eta of the furthest
381 for (unsigned int i=1; i< DET->TOWER_number+1; i++) { // cell (at least) partially behind the tracker
382 if(DET->TOWER_eta_edges[i] > DET->CEN_max_tracker) break;
383 etamax_calocoverage_behindtracker = DET->TOWER_eta_edges[i];
384 }
385 // 2.1a Loop over all particles in event, to fill the towers
386 itGen.Reset();
387 TRootC::GenParticle *particleG;
388 while( (particleG = (TRootC::GenParticle*) itGen.Next()) )
389 {
390 TRootGenParticle *particle = new TRootGenParticle(particleG);
391 PdgParticle pdg_part = DET->PDGtable[particle->PID];
392 particle->Charge = pdg_part.charge();
393 particle->M = pdg_part.mass();
394 //particle->Charge=ChargeVal(particle->PID);
395 particle->setFractions(); // init
396 int pid = abs(particle->PID);
397
398 // 2.1a.1********************* preparation for the b-tagging
399 //// This subarray is needed for the B-jet algorithm
400 // optimization for speed : put first PID condition, then ETA condition, then either pt or status
401 if( (pid <= pB || pid == pGLUON) &&// is it a light quark or a gluon, i.e. is it one of these : u,d,c,s,b,g ?
402 fabs(particle->Eta) < DET->CEN_max_tracker &&
403 particle->Status != 1 &&
404 particle->PT > DET->PT_QUARKS_MIN )
405 {
406 NFCentralQ.Add(particleG);
407 }
408
409 // 2.1a.2********************* visible particles only
410 if( (particle->Status == 1) && (! pdg_part.invisible() ) )
411 {
412 // 2.1a.2.1 Central solenoidal magnetic field
413 TRACP->bfield(particle); // fills in particle->EtaCalo et particle->PhiCalo
414 // 2.1a.2.2 Filling the calorimetric towers -- includes also forward detectors ?
415 // first checks if the charged particles reach the calo!
416 if( DET->FLAG_bfield ||
417 particle->Charge==0 ||
418 (!DET->FLAG_bfield && particle->Charge!=0 && particle->PT > DET->TRACK_ptmin))
419 if(
420 (particle->EtaCalo > list_of_calorimeters.getEtamin() ) &&
421 (particle->EtaCalo < list_of_calorimeters.getEtamax() )
422 )
423 {
424 float iEta=UNDEFINED, iPhi=UNDEFINED;
425 DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
426 if (iEta != UNDEFINED && iPhi != UNDEFINED)
427 {
428 D_CaloTower tower(iEta,iPhi); // new tower
429 tower.Set_Eem_Ehad_E_ET(particle->E*particle->getFem() , particle->E*particle->getFhad() );
430 list_of_active_towers.addTower(tower);
431 // this list may contain several times the same calotower, as several particles
432 // may leave some energy in the same calotower
433 // After the loop on particles, identical cells in the list should be merged
434 } // iEta and iPhi must be defined
435 }
436
437 // 2.1a.2.3 charged particles in tracker: energy flow
438 // if bfield not simulated, pt should be high enough to be taken into account
439 // it is supposed here that DET->MAX_calo > DET->CEN_max_tracker > DET->CEN_max_mu > 0
440 if( particle->Charge !=0 &&
441 fabs(particle->EtaCalo)< DET->CEN_max_tracker && // stays in the tracker -> track available
442 ( DET->FLAG_bfield ||
443 (!DET->FLAG_bfield && particle->PT > DET->TRACK_ptmin)
444 )
445 )
446 {
447 // 2.1a.2.3.1 Filling the particle properties + smearing
448 // Hypothesis: the final eta/phi are the ones from the generator, thanks to the track reconstruction
449 // This is the EnergyFlow hypothesis
450 particle->SetEtaPhi(particle->Eta,particle->Phi);
451 float sET=UNDEFINED; // smeared ET, computed from the smeared E -> needed for the tracks
452
453 // 2.1a.2.3.2 Muons
454 if (pid == pMU && fabs(particle->EtaCalo)< DET->CEN_max_mu)
455 {
456 TLorentzVector p;
457 float sPT = gRandom->Gaus(particle->PT, DET->MU_SmearPt*particle->PT );
458 if (sPT > 0 && sPT > DET->PTCUT_muon)
459 {
460 p.SetPtEtaPhiE(sPT,particle->Eta,particle->Phi,sPT*cosh(particle->Eta));
461 muon.push_back(D_Particle(p,particle->PID,particle->EtaCalo,particle->PhiCalo));
462 }
463 sET = (sPT >0)? sPT : 0;
464 }
465 // 2.1a.2.3.3 Electrons
466 else if (pid == pE)
467 {
468 // Finds in which calorimeter the particle has gone, to know its resolution
469
470 D_CaloElement currentCalo = list_of_calorimeters.getElement(particle->EtaCalo);
471 if(currentCalo.getName() == dummyCalo.getName())
472 {
473 cout << "** Warning: the calo coverage behind the tracker is not complete! **" << endl;
474 }
475
476 // final smeared EM energy // electromagnetic fraction F_em =1 for electrons;
477 float sE = currentCalo.getElectromagneticResolution().Smear(particle->E);
478 if (sE>0)
479 {
480 sET = sE/cosh(particle->Eta);
481 // NB: ET is found via the calorimetry and not via the track curvature
482
483 TLorentzVector p;
484 p.SetPtEtaPhiE(sET,particle->Eta,particle->Phi,sE);
485 if (sET > DET->PTCUT_elec)
486 electron.push_back(D_Particle(p,particle->PID,particle->EtaCalo,particle->PhiCalo));
487 //if(DET->JET_Eflow) input_particles.push_back(fastjet::PseudoJet(p.Px(),p.Py(),p.Pz(),p.E()));
488 }
489 else { sET=0;} // if negative smeared energy -- needed for the tracks
490 }
491 // 2.1a.2.3.4 Other charged particles : smear them for the tracks!
492 else
493 { //other particles
494 D_CaloElement currentCalo = list_of_calorimeters.getElement(particle->EtaCalo);
495 float sEem = currentCalo.getElectromagneticResolution().Smear(particle->E * particle->getFem());
496 float sEhad = currentCalo.getHadronicResolution().Smear(particle->E * particle->getFhad());
497 float sE = ( (sEem>0)? sEem : 0 ) + ( (sEhad>0)? sEhad : 0 );
498 sET = sE/cosh(particle->EtaCalo);
499 }
500
501 // 2.1a.2.3.5 Tracks
502 //if( (rand()%100) < DET->TRACK_eff && sET!=0)
503 if( (grandom->Uniform()*100.) < DET->TRACK_eff && sET!=0)
504 {
505 elementTrack = (TRootTracks*) branchTrack->NewEntry();
506 elementTrack->Set(particle->Eta, particle->Phi, particle->EtaCalo, particle->PhiCalo, sET, particle->Charge);
507 elementTrack->Vx=particle->X;
508 elementTrack->Vy=particle->Y;
509 elementTrack->Vz=particle->Z;
510 TrackCentral.push_back(*elementTrack); // tracks at vertex!
511 if(DET->JET_Eflow)
512 input_particles.push_back(fastjet::PseudoJet(particle->Px,particle->Py,particle->Pz,particle->E));
513 // TODO!!! apply a smearing on the position of the origin of the track
514 // TODO!!! elementTracks->SetPositionOut(Xout,Yout,Zout);
515 }
516 } // 2.1a.2.3 : if tracker/energy-flow
517 // 2.1a.2.4 Photons
518 // stays in the tracker -> track available -> gamma ID
519 else if( (pid == pGAMMA) && fabs(particle->EtaCalo)< DET->CEN_max_tracker )
520 {
521 float iEta=UNDEFINED, iPhi=UNDEFINED;
522 DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
523 D_CaloTower tower(iEta,iPhi);
524 // stores the list of towers where to apply the photon ID algorithm. Just a trick for a faster search
525 list_of_towers_with_photon.addTower(tower);
526 }
527 // 2.1a.2.5 Neutrals within tracker -- for jet energy flow
528 else if( particle->Charge ==0 && fabs(particle->EtaCalo)< etamax_calocoverage_behindtracker)
529 {
530 float iEta=UNDEFINED, iPhi=UNDEFINED;
531 DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
532 D_CaloTower tower(iEta,iPhi);
533 list_of_centowers_with_neutrals.addTower(tower);
534 }
535 // 2.1a.2.6 : very forward detectors
536 else
537 {
538 if (DET->FLAG_RP==1)
539 {
540 // for the moment, only protons are transported
541 // BUT !!! could be a beam of other particles! (heavy ions?)
542 // BUT ALSO !!! if very forward muons, or others!
543 VFD->RomanPots(treeWriter,branchRP220,branchFP420,particle);
544 }
545 // 2.1a.2.6: Zero degree calorimeter
546 if(DET->FLAG_vfd==1)
547 {
548 VFD->ZDC(treeWriter,branchZDC,particle);
549 }
550 }
551
552 } // 2.1a.2 : if visible particle
553 delete particle;
554 }// loop on all particles 2.1a
555
556 // 2.1b loop on all (activated) towers
557 // at this stage, list_of_active_towers may contain several times the same tower
558 // first step is to merge identical towers, by matching their (iEta,iPhi)
559
560 list_of_active_towers.sortElements();
561 list_of_active_towers.mergeDuplicates();
562
563 // Calotower smearing
564 list_of_active_towers.smearTowers(list_of_calorimeters);
565
566 for(unsigned int i=0; i<list_of_active_towers.size(); i++)
567 {
568 float iEta = list_of_active_towers[i].getEta();
569 float iPhi = list_of_active_towers[i].getPhi();
570 float e = list_of_active_towers[i].getE();
571 if(iEta != UNDEFINED && iPhi != UNDEFINED && e!=0)
572 {
573 elementCalo = (TRootCalo*) branchCalo->NewEntry();
574 elementCalo->set(list_of_active_towers[i]);
575 // not beautiful : should be improved!
576 TLorentzVector p;
577 p.SetPtEtaPhiE(list_of_active_towers[i].getET(), iEta, iPhi, e );
578 PhysicsTower Tower(LorentzVector(p.Px(),p.Py(),p.Pz(),p.E()));
579 towers.push_back(Tower);
580 }
581 } // loop on towers
582
583 // 2.1c photon ID
584 // list_of_towers_with_photon is the list of towers with photon candidates
585 // already smeared !
586 // sorts the vector and smears duplicates
587 list_of_towers_with_photon.mergeDuplicates();
588 for(unsigned int i=0; i<list_of_towers_with_photon.size(); i++) {
589 float eta = list_of_towers_with_photon[i].getEta();
590 float phi = list_of_towers_with_photon[i].getPhi();
591 D_CaloTower cal(list_of_active_towers.getElement(eta,phi)); //// <---------- buh???????
592 if(cal.getEta() != UNDEFINED && cal.getPhi() != UNDEFINED && cal.getE() > 0)
593 {
594 TLorentzVector p;
595 p.SetPtEtaPhiE(cal.getET(), eta,phi,cal.getE() );
596 if (cal.getET() > DET->PTCUT_gamma) { gamma.push_back(D_Particle(p,pGAMMA,p.Eta(),p.Phi())); }
597 }
598 } // for -- list of photons
599
600 // 2.1d jet-E-flow -- taking into account the neutrals within tracker
601 if(DET->JET_Eflow) {
602 list_of_centowers_with_neutrals.mergeDuplicates();
603 for(unsigned int i=0; i<list_of_centowers_with_neutrals.size(); i++) {
604 float eta = list_of_centowers_with_neutrals[i].getEta();
605 float phi = list_of_centowers_with_neutrals[i].getPhi();
606 D_CaloTower cal(list_of_active_towers.getElement(eta,phi));
607 if(cal.getEta() != UNDEFINED && cal.getPhi() != UNDEFINED && cal.getE() > 0)
608 {
609 TLorentzVector p;
610 p.SetPtEtaPhiE(cal.getET(), eta,phi,cal.getE() );
611 //cout << "**************list: " << p.Px() << " " << p.Py() << " " << p.Pz() << " " << p.E() << endl;
612 input_particles.push_back(fastjet::PseudoJet(p.Px(),p.Py(),p.Pz(),p.E()));
613 }
614 } // for - list_of_centowers
615 } // JET_Eflow
616
617 // 2.2 ********** Output preparation & complex objects ***********
618 // 2.2.1 ********************* sorting collections by decreasing pt
619 DET->SortedVector(electron);
620 float iPhiEl=0,iEtaEl=0,ptisoEl=0;
621 for(unsigned int i=0; i < electron.size(); i++)
622 {
623 elementElec = (TRootElectron*) branchElectron->NewEntry();
624 elementElec->Set(electron[i].Px(),electron[i].Py(),electron[i].Pz(),electron[i].E());
625 elementElec->EtaCalo = electron[i].EtaCalo();
626 elementElec->PhiCalo = electron[i].PhiCalo();
627 elementElec->Charge = - sign(electron[i].PID());
628 elementElec->IsolFlag = DET->Isolation(electron[i],TrackCentral,DET->ISOL_PT,DET->ISOL_Cone,ptisoEl);
629
630 int electron_tower_index = DET->BinEtaPhi(elementElec->PhiCalo,elementElec->EtaCalo,iPhiEl,iEtaEl);
631 D_CaloTower calElec(list_of_active_towers.getElement(iEtaEl,iPhiEl));
632 elementElec->EHoverEE = calElec.getEhad()/calElec.getEem();
633 elementElec->EtRatio = DET->CaloIsolation(electron[i], list_of_active_towers,iPhiEl,iEtaEl,electron_tower_index);
634 elementElec->SumEt = DET->IsolationSumEt(iPhiEl,iEtaEl, list_of_active_towers);
635 elementElec->SumPt = ptisoEl;
636
637 }
638
639 DET->SortedVector(muon);
640 float iPhiMu=0,iEtaMu=0,ptisoMu=0;
641 for(unsigned int i=0; i < muon.size(); i++)
642 {
643 elementMu = (TRootMuon*) branchMuon->NewEntry();
644 elementMu->Charge = - sign(muon[i].PID());
645 elementMu->Set(muon[i].Px(),muon[i].Py(),muon[i].Pz(),muon[i].E());
646 elementMu->EtaCalo = muon[i].EtaCalo();
647 elementMu->PhiCalo = muon[i].PhiCalo();
648 elementMu->IsolFlag = DET->Isolation(muon[i],TrackCentral,DET->ISOL_PT,DET->ISOL_Cone,ptisoMu);
649 elementMu->SumPt = ptisoMu;
650 elementMu->SumEt = DET->IsolationSumEt(iPhiMu,iEtaMu, list_of_active_towers);
651
652 int muon_tower_index = DET->BinEtaPhi(elementMu->PhiCalo,elementMu->EtaCalo,iPhiMu,iEtaMu);
653 D_CaloTower calMuon(list_of_active_towers.getElement(iEtaMu,iPhiMu));
654 if( calMuon.getEem() !=0 ) elementMu->EHoverEE = calMuon.getEhad()/calMuon.getEem();
655 else elementMu->EHoverEE = UNDEFINED;
656 elementMu->EtRatio = DET->CaloIsolation(muon[i], list_of_active_towers,iPhiMu,iEtaMu,muon_tower_index);
657 }
658
659 DET->SortedVector(gamma);
660 for(unsigned int i=0; i < gamma.size(); i++)
661 {
662 elementPhoton = (TRootPhoton*) branchPhoton->NewEntry();
663 elementPhoton->Set(gamma[i].Px(),gamma[i].Py(),gamma[i].Pz(),gamma[i].E());
664 D_CaloTower calGamma(list_of_active_towers.getElement(gamma[i].EtaCalo(),gamma[i].PhiCalo()));
665 elementPhoton->EHoverEE = calGamma.getEhad()/calGamma.getEem();
666 }
667
668 // 2.2.2 ************* computes the Missing Transverse Momentum
669 TLorentzVector Att(0.,0.,0.,0.);
670 for(unsigned int i=0; i < towers.size(); i++)
671 {
672 Att.SetPxPyPzE(towers[i].fourVector.px, towers[i].fourVector.py, towers[i].fourVector.pz, towers[i].fourVector.E);
673 if(fabs(Att.Eta()) < DET->CEN_max_calo_fwd)
674 {
675 PTmis = PTmis + Att;
676 // create a fastjet::PseudoJet with these components and put it onto
677 // back of the input_particles vector
678 if(!DET->JET_Eflow)
679 input_particles.push_back(fastjet::PseudoJet(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E));
680 else { if(fabs(Att.Eta()) > DET->CEN_max_tracker)
681 input_particles.push_back(fastjet::PseudoJet(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E));
682 }
683 }
684 }
685 elementEtmis = (TRootETmis*) branchETmis->NewEntry();
686 elementEtmis->ET = (PTmis).Pt();
687 elementEtmis->Phi = (-PTmis).Phi();
688 elementEtmis->Px = (-PTmis).Px();
689 elementEtmis->Py = (-PTmis).Py();
690
691 // 2.2.3 ************* jets, B-tag, tau jets
692 vector<int> NTrackJet; //for number of tracks
693 vector<float> EHADEEM; //for energyHad over energyEm
694 sorted_jets=JETRUN->RunJets(input_particles, TrackCentral,NTrackJet,EHADEEM,list_of_active_towers);
695 JETRUN->RunJetBtagging(treeWriter, branchJet,sorted_jets,NFCentralQ,NTrackJet,EHADEEM);
696 JETRUN->RunTauJets(treeWriter,branchTauJet,sorted_jets,towers, TrackCentral,NTrackJet,EHADEEM);
697
698 treeWriter->Fill();
699 } // 2. Loop over all events ('for' loop)
700
701 cout <<"** Exiting detector simulation... **"<< endl;
702
703
704 treeWriter->Write();
705 delete treeWriter;
706 loopwatch.Stop();
707
708
709
710 // 3. ********** Trigger & Frog ***********
711 // 3.1 ************ running the trigger in case the FLAG trigger is put to 1 in the datacard
712 triggerwatch.Start();
713 if(DET->FLAG_trigger == 1)
714 {
715 cout <<"** **"<<endl;
716 cout <<"** ########### Start Trigger selection ########### **"<< endl;
717
718 // input
719 TChain chainT("Analysis");
720 chainT.Add(outputfilename.c_str());
721 ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chainT);
722
723 // output
724 TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
725 TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
726 TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
727 TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
728 TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
729 TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
730
731 ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(outputfilename, "Trigger");
732 ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
733
734
735 Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
736 // loop on all entries
737 for(entryT = 0; entryT < allEntriesT; ++entryT) {
738 treeWriterT->Clear();
739 treeReaderT->ReadEntry(entryT);
740 TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
741 treeWriterT->Fill();
742 } // loop on all entries
743 cout <<"** Exiting trigger simulation... **"<< endl;
744
745 treeWriterT->Write();
746 delete treeWriterT;
747 delete treeReaderT;
748 } // trigger
749 triggerwatch.Stop();
750
751
752 // 3.2 ************** FROG display
753 frogwatch.Start();
754 if(DET->FLAG_frog == 1) {
755 cout <<"** **"<<endl;
756 cout <<"** ################## Start FROG ################# **"<< endl;
757
758 FrogDisplay *FROG = new FrogDisplay(DET);
759 FROG->BuildEvents(outputfilename);
760 FROG->BuildGeom();
761 delete FROG;
762 cout <<"** Exiting FROG preparation... **"<< endl;
763 }
764 frogwatch.Stop();
765
766 // 3.3 *************** LHCO output
767 lhcowatch.Start();
768 if(DET->FLAG_lhco == 1){
769 cout <<"** **"<<endl;
770 cout <<"** ############ Start LHCO conversion ############ **"<< endl;
771
772 //LHCOConverter *LHCO = new LHCOConverter(outputfilename,LogNameLHCO);
773 LHCOConverter *LHCO = new LHCOConverter(outputfilename,"");
774 LHCO->CopyRunLogFile();
775 LHCO->ConvertExRootAnalysisToLHCO();
776 delete LHCO;
777 cout <<"** Exiting LHCO conversion... **"<< endl;
778 }
779 lhcowatch.Stop();
780
781
782
783 // 4. ********** End & Exit ***********
784
785 globalwatch.Stop();
786 time_report(globalwatch,loopwatch,triggerwatch,frogwatch,lhcowatch,DET->FLAG_frog,DET->FLAG_trigger,DET->FLAG_lhco,LogName,allEntries);
787
788 cout << left << setw(16) << "** " << ""
789 << left << setw(51) << get_time_date() << "**" << endl;
790
791 cout <<"** **"<< endl;
792 cout <<"** Exiting Delphes ... **"<< endl;
793 cout <<"** **"<< endl;
794 cout <<"*********************************************************************"<< endl;
795 cout <<"*********************************************************************"<< endl;
796
797 delete treeReader;
798 delete DET;
799 delete TRIGT;
800 delete TRACP;
801 delete JETRUN;
802 delete VFD;
803 delete grandom; // TRandom3
804
805}
Note: See TracBrowser for help on using the repository browser.