17 #include <JANA/JApplication.h>
18 #include <JANA/JFactory.h>
52 l3tree =
new TTree(
"l3tree",
"L3 tree for BDT");
55 #define AddNBranch(A) l3tree->Branch("N" #A, &bdt.N##A, #A "/F");
59 #define AddBranch(A) l3tree->Branch(#A, &bdt.A, #A "/F");
81 #define GetObjs(A) vector<const A*> v##A; loop->Get(v##A);
86 Int_t fp_trig_mask = 0;
90 if(!vDL1Trigger.empty()){
91 auto trig = vDL1Trigger[0];
92 trig_mask =
trig->trig_mask;
93 fp_trig_mask =
trig->fp_trig_mask;
94 if(trig_mask&0x01) trig1 = 1.0;
95 if(trig_mask&0x04) trig3 = 1.0;
96 if(trig_mask&0x08) trig4 = 1.0;
100 Int_t NCDC_superlayer[5] = {0,0,0,0,0};
101 vector<int> superlayer_maxring = { 4, 12, 16, 24, 28 };
102 for(
auto hit : vDCDCDigiHit){
103 for(
int superlayer=0; superlayer<5; superlayer++){
104 if(hit->ring <= superlayer_maxring[superlayer]){
105 NCDC_superlayer[superlayer]++;
112 Int_t NFDCWire_package[4] = {0,0,0,0};
113 for(
auto hit : vDFDCWireDigiHit){
114 if(hit->package>=1 && hit->package<=4) NFDCWire_package[hit->package-1]++;
118 Int_t NFDCCathodes_package[4] = {0,0,0,0};
119 for(
auto hit : vDFDCCathodeDigiHit){
120 if(hit->package>=1 && hit->package<=4) NFDCCathodes_package[hit->package-1]++;
124 Int_t NTOF_half_length = 0;
125 Int_t NTOF_half_width = 0;
126 for(
auto hit : vDTOFDigiHit){
127 auto &bar = hit->bar;
128 if(bar==22 || bar==23 || bar==45 || bar==46) NTOF_half_length++;
129 if(bar==20 || bar==21 || bar==24 || bar==25) NTOF_half_width++;
133 Float_t Esc_tot = 0.0;
134 Float_t Etof_tot = 0.0;
135 Float_t Ebcal_points = 0.0;
136 Float_t Ebcal_clusters = 0.0;
137 Float_t Efcal_clusters = 0.0;
138 for(
auto sc : vDSCHit ) Esc_tot += sc->dE;
139 for(
auto th : vDTOFPoint ) Etof_tot += th->dE;
140 for(
auto bp : vDBCALPoint ) Ebcal_points += bp->E();
141 for(
auto bc : vDBCALCluster) Ebcal_clusters += bc->E();
142 for(
auto fc : vDFCALCluster) Efcal_clusters += fc->getEnergy();
145 Float_t Rfcal_min = 10000.0;
146 Float_t Rfcal_max = 0.0;
147 for(
auto fc : vDFCALCluster){
148 Float_t r = fc->getCentroid().Perp();
149 if( r < Rfcal_min ) Rfcal_min = r;
150 if( r > Rfcal_max ) Rfcal_max = r;
154 Int_t Nbeam_photons_coherent = 0.0;
155 vector<Int_t> Nbeam_photons(13, 0.0);
156 double Eelectron = 11.668;
157 double Ecoherent_min = 8.4*Eelectron/12.0;
158 double Ecoherent_max = 9.0*Eelectron/12.0;
159 for(
auto p : vDBeamPhoton){
160 double Ephoton = p->energy();
161 int idx = floor(Ephoton);
162 if(idx>=0 && idx<=12) Nbeam_photons[idx]++;
163 if( (Ephoton>=Ecoherent_min) && (Ephoton<=Ecoherent_max) ) Nbeam_photons_coherent++;
167 double Ptot_candidates = 0.0;
168 for(
auto tc : vDTrackCandidate) Ptot_candidates += tc->momentum().Mag();
171 Float_t Evisible_neutrals = 0.0;
172 Float_t Evisible_tracks = 0.0;
173 Float_t Evisible_charged_Kaons = 0.0;
174 Float_t Evisible_charged_pions = 0.0;
175 Float_t Evisible_protons = 0.0;
176 Float_t Evisible = 0.0;
177 for(
auto ct : vDChargedTrack){
178 auto cth = ct->Get_BestTrackingFOM();
179 double confidence_level = TMath::Prob((
double)cth->dChiSq, (
double)cth->dNDF);
180 if(confidence_level > 0.0001){
181 Float_t E = cth->energy();
185 Evisible_charged_pions += E;
189 Evisible_charged_Kaons += E;
192 Evisible -= cth->mass();
194 Evisible_protons += E;
200 Evisible_tracks += E;
206 for(
auto ns : vDNeutralShower){
207 Evisible_neutrals += ns->dEnergy;
208 Evisible += ns->dEnergy;
213 japp->RootWriteLock();
216 #define CopyNobjs(A) bdt.N##A = (Float_t)v##A.size();
220 bdt.trig_mask = (Float_t)trig_mask;
221 bdt.fp_trig_mask = (Float_t)fp_trig_mask;
227 bdt.NCDC_superlayer1 = (Float_t)NCDC_superlayer[0];
228 bdt.NCDC_superlayer2 = (Float_t)NCDC_superlayer[1];
229 bdt.NCDC_superlayer3 = (Float_t)NCDC_superlayer[2];
230 bdt.NCDC_superlayer4 = (Float_t)NCDC_superlayer[3];
231 bdt.NCDC_superlayer5 = (Float_t)NCDC_superlayer[4];
234 bdt.NFDCwires_package1 = (Float_t)NFDCWire_package[0];
235 bdt.NFDCwires_package2 = (Float_t)NFDCWire_package[1];
236 bdt.NFDCwires_package3 = (Float_t)NFDCWire_package[2];
237 bdt.NFDCwires_package4 = (Float_t)NFDCWire_package[3];
240 bdt.NFDCCathodes_package1 = (Float_t)NFDCCathodes_package[0];
241 bdt.NFDCCathodes_package2 = (Float_t)NFDCCathodes_package[1];
242 bdt.NFDCCathodes_package3 = (Float_t)NFDCCathodes_package[2];
243 bdt.NFDCCathodes_package4 = (Float_t)NFDCCathodes_package[3];
246 bdt.NTOF_half_length = (Float_t)NTOF_half_length;
247 bdt.NTOF_half_width = (Float_t)NTOF_half_width;
250 bdt.Esc_tot = Esc_tot;
251 bdt.Etof_tot = Etof_tot;
252 bdt.Ebcal_points = Ebcal_points;
253 bdt.Ebcal_clusters = Ebcal_clusters;
254 bdt.Efcal_clusters = Efcal_clusters;
257 bdt.Rfcal_min = Rfcal_min;
258 bdt.Rfcal_max = Rfcal_max;
261 bdt.Nbeam_photons_coherent = Nbeam_photons_coherent;
262 bdt.Nbeam_photons_3_4 = (Float_t)Nbeam_photons[ 3];
263 bdt.Nbeam_photons_4_5 = (Float_t)Nbeam_photons[ 4];
264 bdt.Nbeam_photons_5_6 = (Float_t)Nbeam_photons[ 5];
265 bdt.Nbeam_photons_6_7 = (Float_t)Nbeam_photons[ 6];
266 bdt.Nbeam_photons_7_8 = (Float_t)Nbeam_photons[ 7];
267 bdt.Nbeam_photons_8_9 = (Float_t)Nbeam_photons[ 8];
268 bdt.Nbeam_photons_9_10 = (Float_t)Nbeam_photons[ 9];
269 bdt.Nbeam_photons_10_11 = (Float_t)Nbeam_photons[10];
270 bdt.Nbeam_photons_11_12 = (Float_t)Nbeam_photons[11];
273 bdt.Ptot_candidates = Ptot_candidates;
276 bdt.Evisible_neutrals = Evisible_neutrals;
277 bdt.Evisible_tracks = Evisible_tracks;
278 bdt.Evisible_charged_Kaons = Evisible_charged_Kaons;
279 bdt.Evisible_charged_pions = Evisible_charged_pions;
280 bdt.Evisible_protons = Evisible_protons;
281 bdt.Evisible = Evisible;
300 japp->RootWriteLock();
301 l3tree->FlushBaskets();
312 japp->RootWriteLock();
313 l3tree->FlushBaskets();
jerror_t init(void)
Called once at program start.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
~JEventProcessor_L3BDTtree()
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
JEventProcessor_L3BDTtree()
#define MyDerivedTypes(X)
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.