30 #include <Event/Event.h>
31 #include <Event/EventTypes.h>
32 #include <Event/packet.h>
48 , _filename(
"./outputfile.root")
50 std::cout <<
"TpcRawDataDecoder::TpcRawDataDecoder(const std::string &name)" << std::endl;
105 std::cout <<
"TpcRawDataDecoder::~TpcRawDataDecoder() Calling dtor" << std::endl;
111 std::cout <<
"TpcRawDataDecoder::Init(PHCompositeNode *topNode) Initializing" << std::endl;
116 if (calibdir[0] ==
'/')
124 std::cout <<
"TpcRawDataDecoder::::InitRun No calibration file found" << std::endl;
134 _h_hit_XY =
new TH2F(
"_h_hit_XY" ,
"_h_hit_XY;X, [mm];Y, [mm]", 400, -800, 800, 400, -800, 800);
135 _h_hit_XY_ADCcut =
new TH2F(
"_h_hit_XY_ADCcut" ,
"_h_hit_XY_ADCcut;X, [mm];Y, [mm]", 400, -800, 800, 400, -800, 800);
156 std::cout <<
"TpcRawDataDecoder::InitRun - DST Node missing, doing nothing." << std::endl;
161 auto hitsetcontainer = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
162 if (!hitsetcontainer)
164 std::cout <<
"TpcRawDataDecoder::InitRun - creating TRKR_HITSET." << std::endl;
172 dstNode->addNode(trkrnode);
178 trkrnode->addNode(newNode);
199 auto trkrhitsetcontainer = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
200 assert(trkrhitsetcontainer);
203 findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode,
"CYLINDERCELLGEOM_SVTX");
206 std::cout <<
PHWHERE <<
"ERROR: Can't find node CYLINDERCELLGEOM_SVTX" << std::endl;
211 Event *_event = findNode::getClass<Event>(topNode,
"PRDF");
214 if (_event ==
nullptr)
216 std::cout <<
"TpcRawDataDecoder::Process_Event - Event not found" << std::endl;
225 for(
int ep=0;ep<2;ep++){
226 for (
int sector = 0; sector<24; sector++)
228 const int packet = 4000 + sector*10 + ep;
235 if(sector>11) side=1;
238 snprintf(buff,
sizeof(buff),
"./outputfile_%i.root",sector );
243 std::cout <<
"My Own TpcRawDataDecoder:: Event getPacket: "<< packet <<
"| Sector"<< sector <<
"| EndPoint "<< ep << std::endl;
248 uint64_t triggerBCO = 0;
249 int n_tagger = p->
lValue(0,
"N_TAGGER");
250 for (
int t = 0;
t < n_tagger;
t++){
253 const auto is_lvl1 =
static_cast<uint8_t
>(p->
lValue(
t,
"IS_LEVEL1_TRIGGER"));
254 const auto bco =
static_cast<uint64_t
>(p->
lValue(
t,
"BCO"));
265 std::cout <<
" is_lvl1: " << (bool) (is_lvl1)
272 int nr_of_waveforms = p->
iValue(0,
"NR_WF");
283 int earliest_BCO = INT_MAX;
285 for (wf = 0; wf < nr_of_waveforms; wf++){
286 int current_BCO = p->
iValue(wf,
"BCO");
287 if(current_BCO < earliest_BCO) earliest_BCO = current_BCO;
296 std::cout <<
" _ievent: " <<
_ievent <<
" earliest BCO: " << earliest_BCO <<
" ep: " << ep <<
" sector " << sector <<
" trigBCO: " << triggerBCO <<
" diff " << triggerBCO - earliest_BCO << std::endl;
298 for (wf = 0; wf < nr_of_waveforms; wf++){
323 int sampa_nr = p->
iValue(wf,
"SAMPAADDRESS");
326 int fee = p->
iValue(wf,
"FEE");
327 int samples = p->
iValue( wf,
"SAMPLES" );
330 int FEE_R[26]={2, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 2, 2, 1, 2, 2, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3};
334 int FEE_map[26] = { 4, 5, 0, 2, 1, 11, 9, 10, 8, 7, 6, 0, 1, 3, 7, 6, 5, 4, 3, 2, 0, 2, 1, 3, 5, 4};
336 int feeM = FEE_map[fee];
337 if(FEE_R[fee]==2) feeM += 6;
338 if(FEE_R[fee]==3) feeM += 14;
339 unsigned int key = 256 * (feeM) + channel;
345 if(layer==0)
continue;
376 int mc_sectors[12] = { 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6};
385 int sampaAddress = p->
iValue(wf,
"SAMPAADDRESS");
386 int sampaChannel = p->
iValue(wf,
"SAMPACHANNEL");
387 int checksum = p->
iValue(wf,
"CHECKSUM");
388 int checksumError = p->
iValue(wf,
"CHECKSUMERROR");
389 std::cout <<
"TpcRawDataDecoder::Process_Event Samples "<< samples
391 <<
" layer: " << layer
392 <<
" sampa: "<< sampa_nr
394 <<
" Mapped fee: "<< feeM
395 <<
" sampaAddress: "<< sampaAddress
396 <<
" sampaChannel: "<< sampaChannel
397 <<
" checksum: "<< checksum
398 <<
" checksumError: "<< checksumError
399 <<
" hitsetkey "<< tpcHitSetKey
406 for (
int s = 0;
s < 5;
s++)
412 for (
int s = 0;
s < samples;
s++)
418 _h_hit_XY->Fill(R*cos(phi),R*sin(phi),
float(adc)-pedestal);
422 if(
float(adc)-pedestal>2){
430 auto hit = hitsetit->second->getHit(hitkey);
438 hit->setAdc(
float(adc)-pedestal);
443 hitsetit->second->addHitSpecificKey(hitkey, hit);
450 if(adc - pedestal > 15){
470 std::cout <<
"TpcRawDataDecoder:: done" << std::endl;
491 std::cout <<
"TpcRawDataDecoder::End(PHCompositeNode *topNode) This is the End..." << std::endl;