1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: EEventFrontEndDataAdder.cc 2238 2005-10-20 12:44:18Z pesce $ |
---|
3 | // A.Thea created Oct, 26 2003 |
---|
4 | |
---|
5 | #include "EEventFrontEndDataAdder.hh" |
---|
6 | #include "EEvent.hh" |
---|
7 | #include "EDetector.hh" |
---|
8 | #include "Photomultiplier.hh" |
---|
9 | #include "ChipGtuData.hh" |
---|
10 | #include "FrontEndChip.hh" |
---|
11 | #include "MacroCell.hh" |
---|
12 | |
---|
13 | #include "EFee.hh" |
---|
14 | #include "EAFee.hh" |
---|
15 | |
---|
16 | ClassImp(EEventFrontEndDataAdder) |
---|
17 | |
---|
18 | using namespace TMath; |
---|
19 | |
---|
20 | //______________________________________________________________________________ |
---|
21 | EEventFrontEndDataAdder::EEventFrontEndDataAdder( ChipGtuData* chip) |
---|
22 | : EFiller("EDetector") { |
---|
23 | // ctor |
---|
24 | |
---|
25 | fChip = chip; |
---|
26 | } |
---|
27 | //______________________________________________________________________________ |
---|
28 | EEventFrontEndDataAdder::~EEventFrontEndDataAdder() { |
---|
29 | // dtor |
---|
30 | |
---|
31 | } |
---|
32 | |
---|
33 | //______________________________________________________________________________ |
---|
34 | void EEventFrontEndDataAdder::Fill( EFillable* f) { |
---|
35 | // filler |
---|
36 | // copy data related to Front End chip into root file |
---|
37 | // both DFEE and AFEE data are copied |
---|
38 | // there are two objects: EFee and EAFee |
---|
39 | // EFee contains both digital electronics data (counts for each channel |
---|
40 | // and for each GTU) and FULL AFEE (charge per channel and per GTU) |
---|
41 | // AFee contains the minimal analog info (dynode charge) and |
---|
42 | // possibly the Cerenkov trigger signals simulation |
---|
43 | |
---|
44 | EDetector *det = (EDetector*)f; |
---|
45 | if (!fChip) { |
---|
46 | Msg(EsafMsg::Panic) << "Invalid ChipGtuData. Null pointer!" << MsgDispatch; |
---|
47 | } |
---|
48 | |
---|
49 | if ( fChip->IsEmpty() && !det->IsNightGlowFillable() ) return; |
---|
50 | |
---|
51 | if ( fChip->GetTotalCounts() == 0) return; |
---|
52 | |
---|
53 | FrontEndChip *fe = fChip->FrontEnd(); |
---|
54 | |
---|
55 | if (!fe) { |
---|
56 | Msg(EsafMsg::Panic) << "Invalid ChipGtuData. No Front End attached!" << MsgDispatch; |
---|
57 | } |
---|
58 | |
---|
59 | // FIXME! to be changed to take into account many pmts mapping... |
---|
60 | // right now not dangerous |
---|
61 | Photomultiplier *pmt = fe->Pmt(); |
---|
62 | if (!pmt) { |
---|
63 | Msg(EsafMsg::Panic) << "Invalid ChipGtuData. No Pmt attached!" << MsgDispatch; |
---|
64 | return; |
---|
65 | } |
---|
66 | |
---|
67 | // get the detector status |
---|
68 | EDetStatus *status = &(det->fStatus); |
---|
69 | |
---|
70 | Int_t size = (status->fMaxSignals).GetSize(); |
---|
71 | Int_t gtu = fChip->Gtu(); |
---|
72 | if ( (gtu+1)>size ) { |
---|
73 | (status->fMaxSignals).Set(gtu+1); |
---|
74 | (status->fMaxHits).Set(gtu+1); |
---|
75 | (status->fMaxBkg).Set(gtu+1); |
---|
76 | size = gtu+1; |
---|
77 | } |
---|
78 | Int_t *maxsign = (status->fMaxSignals).GetArray(); |
---|
79 | Int_t *maxhits = (status->fMaxHits).GetArray(); |
---|
80 | Int_t *maxbkg = (status->fMaxBkg).GetArray(); |
---|
81 | |
---|
82 | // for each channel one EFee object is created |
---|
83 | for( int nch=0; nch<fe->Channels(); nch++) { |
---|
84 | |
---|
85 | if ( fChip->GetCounter(nch) == 0 ) continue; |
---|
86 | |
---|
87 | // creates a new EFee object and store it into the TClonesArray |
---|
88 | new ( (*(det->fFee))[det->fNumFee] ) EFee(); |
---|
89 | EFee *pFee = (EFee*) (*(det->fFee))[det->fNumFee]; |
---|
90 | |
---|
91 | // fill data |
---|
92 | pFee->SetGtu(gtu); // gtu id |
---|
93 | pFee->SetFEId(fe->Id()); // front end chip id |
---|
94 | pFee->SetChUId(fe->UniqueChanId(nch)); // pixel identifier |
---|
95 | pFee->SetNumSignals(fChip->GetPureSignal(nch)); // number of signal photons |
---|
96 | pFee->SetNumHits(fChip->GetCounter(nch)); // number of detected photons |
---|
97 | pFee->SetHasTriggered(fChip->CheckCounter(nch)); // above threshold ? |
---|
98 | if ( pFee->fHasTriggered ) |
---|
99 | pFee->SetChCharge(fChip->Charge(nch)); // full AFEE charge for this channel/gtu |
---|
100 | else |
---|
101 | pFee->SetChCharge(-1.); |
---|
102 | |
---|
103 | det->fNumFee++; |
---|
104 | |
---|
105 | // fill detector status |
---|
106 | Int_t nbkg = fChip->GetCounter(nch) - fChip->GetPureSignal(nch); |
---|
107 | if ( fChip->GetPureSignal(nch) ) { |
---|
108 | status->fNumHits += fChip->GetCounter(nch); |
---|
109 | status->fNumSignals += fChip->GetPureSignal(nch); |
---|
110 | |
---|
111 | maxsign[gtu] = Max(maxsign[gtu], fChip->GetPureSignal(nch)); |
---|
112 | maxhits[gtu] = Max(maxhits[gtu], fChip->GetCounter(nch)); |
---|
113 | maxbkg[gtu] = Max(maxbkg[gtu], nbkg); |
---|
114 | } |
---|
115 | status->fNumBkg += nbkg; |
---|
116 | |
---|
117 | } |
---|
118 | |
---|
119 | (status->fMaxSignals).Set(size, maxsign); |
---|
120 | (status->fMaxHits).Set(size, maxhits); |
---|
121 | (status->fMaxBkg).Set(size, maxbkg); |
---|
122 | |
---|
123 | // fill the number of active gtus |
---|
124 | Int_t numgtu = 0; |
---|
125 | for( Int_t i(0); i<size; i++ ) |
---|
126 | if (maxsign[i]) numgtu++; |
---|
127 | status->fNumGtu = numgtu; |
---|
128 | |
---|
129 | // analog front end data (gtu related, dynode charge and trigger if any) |
---|
130 | // this is minimal AFEE |
---|
131 | // FULL AFEE is in the EFee object above |
---|
132 | new ( (*(det->fAFee))[det->fNumAFee] ) EAFee(); |
---|
133 | EAFee *pa = (EAFee*) (*(det->fAFee))[det->fNumAFee]; |
---|
134 | pa->SetMCId(pmt->Cell()->Id()); // macrocell id |
---|
135 | pa->SetGtu(fChip->Gtu()); // gtu id |
---|
136 | pa->SetFEId(fe->Id()); // front end fChip id |
---|
137 | pa->SetDyCharge(fChip->DynodeCharge()); // dynode charge |
---|
138 | pa->SetCherTrigg(kFALSE); // Cerenkov trigger to be done |
---|
139 | det->fNumAFee++; |
---|
140 | } |
---|
141 | |
---|