-
Notifications
You must be signed in to change notification settings - Fork 1
/
DistToTargetSel.C
98 lines (81 loc) · 2.71 KB
/
DistToTargetSel.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Anthony Hillairet, April 2008
///
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Includes here
class DistToTargetSel : public ModuleClass{
public :
DistToTargetSel() {};
~DistToTargetSel() {};
bool Init(EventClass &E, HistogramFactory &H, ConfigFile &Conf, log4cpp::Category *TmpLog) ;
bool Process(EventClass &E, HistogramFactory &H);
private :
log4cpp::Category *Log;
string Name;
};
bool DistToTargetSel::Init(EventClass &E, HistogramFactory &H, ConfigFile &Conf, log4cpp::Category *TmpLog)
{
Log = TmpLog;
Log->info( "Register Distance to target selection");
// -------- Name of the cut --------- //
Name = "Select: dplane to tgt";
// --------- Special list of cut in this class for the global histograms --------- //
H.AddCut(Name);
if (not Conf.read<bool>("DistToTargetSel/Do"))
{
Log->info( "Distance to target selection turned OFF");
return false ;
}
// --------- Histograms initialization --------- //
H.DefineTH1D( "DistToTargetSel", "pstart-trgt_before", "First plane of the helices before the closest track to target cut",44,0.5,44.5);
H.DefineTH1D( "DistToTargetSel", "pstart-trgt_after", "First plane of the helices after the closest track to target cut",44,0.5,44.5);
// --------- Parameters initialization --------- //
return true;
}
bool DistToTargetSel::Process(EventClass &E, HistogramFactory &H)
{
// ____ ____ //
H.NbCandidateTracks(Name,E);
int d;
// Skip the cut if there is only one track left
if ( E.seltrack.size() > 1)
{
// KEEP only the closest tracks to the target
int MinDistToTarget = 99;
for(vector<int>::iterator t = E.seltrack.begin(); t != E.seltrack.end(); t++)
{
if ( E.is_upstreamdk)
H.Fill("pstart-trgt_before",E.dcmax[*t]);
else
H.Fill("pstart-trgt_before",E.dcmin[*t]);
// Distance of the track to the target
d = DistanceToTarget( E, *t);
if ( d < MinDistToTarget)
MinDistToTarget = d;
}
for(vector<int>::iterator t = E.seltrack.begin(); t != E.seltrack.end(); t++)
{
if (DistanceToTarget( E, *t) > MinDistToTarget)
{
E.seltrack.erase(t); // First erase
t--; // then decrement to avoid to skip the following track
}
else
{
if (E.is_upstreamdk)
H.Fill("pstart-trgt_after",E.dcmax[*t]);
else
H.Fill("pstart-trgt_after",E.dcmin[*t]);
}
}
}
// This should never happen but it is safer to check.
if ( E.seltrack.size() < 1)
{
Log->warn("DistToTargetSel: In event %i, the number of tracks after the selection was %i",E.nevt,E.seltrack.size());
H.CutApplied(Name);
return false;
}
return true;
}