Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ll1setup.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ll1setup.cc
1 #include "LL1HEADER.h"
2 
3 #include <onlmon/OnlMon.h>
4 
5 // Event library
6 
7 #include <Event/Event.h>
8 #include <Event/EventTypes.h>
9 #include <Event/msg_profile.h>
10 
11 // ROOT
12 
13 #include <TFile.h>
14 #include <TTree.h>
15 #include <TSystem.h>
16 
17 #include <cstdlib>
18 #include <cmath>
19 #include <iostream>
20 #include <fstream>
21 #include <sstream>
22 
23 void ll1setup(Event *evt, LL1HEADER *&ll1h)
24 {
25  for ( Int_t ixmit = 0; ixmit < NXMIT; ixmit++ ) {
26 
27  Packet* p;
28  p = evt->getPacket( PACKET[ixmit] );
29  if ( p ) {
30  ll1h->runnumber = evt->getRunNumber();
31  ll1h->evtnr = p->iValue(0,"EVTNR");
32  ll1h->clock = p->iValue(0,"CLOCK");
33 
34  int indx1=0; int inhit1=0;
35  int indx2=0; int inhit2=0;
36  for(int is = 0; is < NRSAM; is++){
37  ll1h->nhit_s1[is] = p->iValue(is,NHITCHANNEL+NADCSH*0);
38  ll1h->nhit_s2[is] = p->iValue(is,NHITCHANNEL+NADCSH*1);
39  ll1h->nhit_n1[is] = p->iValue(is,NHITCHANNEL+NADCSH*2);
40  ll1h->nhit_n2[is] = p->iValue(is,NHITCHANNEL+NADCSH*3);
41 
42  ll1h->nhit_n[is] = ll1h->nhit_n1[is] + ll1h->nhit_n2[is];
43  ll1h->nhit_s[is] = ll1h->nhit_s1[is] + ll1h->nhit_s2[is];
44 
45  ll1h->timesum_s1[is] = p->iValue(is,NHITCHANNEL+1+NADCSH*0);
46  ll1h->timesum_s2[is] = p->iValue(is,NHITCHANNEL+2+NADCSH*1);
47  ll1h->timesum_n1[is] = p->iValue(is,NHITCHANNEL+3+NADCSH*2);
48  ll1h->timesum_n2[is] = p->iValue(is,NHITCHANNEL+4+NADCSH*3);
49 
50  ll1h->timesum_s[is] = ll1h->timesum_n1[is] + ll1h->timesum_n2[is];
51  ll1h->timesum_n[is] = ll1h->timesum_s1[is] + ll1h->timesum_s2[is];
52 
53  if( ll1h->nhit_n[is]>0){
54  if(inhit1 < ll1h->nhit_n[is]){
55  indx1 = is;
56  inhit1 = ll1h->nhit_n[is];
57  }
58  }
59 
60  if( ll1h->nhit_s[is]>0){
61  if(inhit2 < ll1h->nhit_s[is]){
62  indx2 = is;
63  inhit2 = ll1h->nhit_s[is];
64  }
65  }
66 
67  ll1h->chargesum_n1[is] = 0;
68  ll1h->chargesum_n2[is] = 0;
69  ll1h->chargesum_s1[is] = 0;
70  ll1h->chargesum_s2[is] = 0;
71  ll1h->chargesum_s[is] = 0;
72  ll1h->chargesum_n[is] = 0;
73 
74  for(int ic = 0; ic <NCH; ic++) {
75  ll1h->channel[ic][is] = p->iValue(is,ic);
76  if(ic<NHITCHANNEL) ll1h->chargesum_s1[is] += p->iValue(is,ic);
77  else if(ic>=NADCSH*1 && ic<NHITCHANNEL+NADCSH*1) ll1h->chargesum_s2[is] += p->iValue(is,ic);
78  else if(ic>=NADCSH*2 && ic<NHITCHANNEL+NADCSH*2) ll1h->chargesum_n1[is] += p->iValue(is,ic);
79  else if(ic>=NADCSH*3 && ic<NHITCHANNEL+NADCSH*3) ll1h->chargesum_n2[is] += p->iValue(is,ic);
80  ll1h->chargesum_n[is] = ll1h->chargesum_n1[is] + ll1h->chargesum_n2[is];
81  ll1h->chargesum_s[is] = ll1h->chargesum_s1[is] + ll1h->chargesum_s2[is];
82  }
83  for(int it=NCH; it<(NCH+NTRIGWORDS); it++){
84  ll1h->triggerwords[it - NCH][is] = p->iValue(is,it);
85  }
86  }
87  ll1h->idxhitn = indx1;
88  ll1h->idxhits = indx2;
89 
90  ll1h->idxsample = (ll1h->idxhitn==ll1h->idxhits) ? ll1h->idxhitn : -1;
91 
92  delete p;
93  }
94  }
95 }