~cheid001/maus/SingleSationDistro

« back to all changes in this revision

Viewing changes to src/reduce/ReduceCppTracker/ReduceCppTracker.cc

  • Committer: Summer Blot
  • Date: 2012-07-12 21:53:48 UTC
  • mfrom: (794.1.3 tracker_devel)
  • Revision ID: blotsd@orion-20120712215348-yhwreyhmdayirrvr
disabled full helix fit

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
  //
41
41
  // Canvases
42
42
  //
43
 
  // TCanvas *c1 = new TCanvas("c1", "Plane Profile (tracker 0)", 200, 10, 700, 500);
44
 
  // TCanvas *c2 = new TCanvas("c2", "Plane Profile (tracker 1)", 200, 10, 700, 500);
45
 
  TCanvas *c3 = new TCanvas("c3", "SpacePoints", 200, 10, 700, 500);
46
 
  // TCanvas *c4 = new TCanvas("c4", "Cluster NPE", 200, 10, 700, 500);
47
 
  // TCanvas *c5 = new TCanvas("c5", "Digits Time", 200, 10, 700, 500);
48
 
 
49
 
  // c1->Divide(3, 5);
50
 
  // c2->Divide(3, 5);
51
 
  c3->Divide(7, 2);
52
 
  // c4->Divide(3, 1);
53
 
  // c5->Divide(1, 1);
 
43
  TCanvas *c1 = new TCanvas("c1", "SpacePoints", 200, 10, 700, 500);
 
44
  c1->Divide(7, 2);
54
45
 
55
46
  gStyle->SetLabelSize(0.07, "xyz");
56
47
  gStyle->SetTitleSize(0.07, "xy");
64
55
  duplets  = new TH2F("duplets",  "Current Spill (x, y)", 300, -150, 150, 300, -150, 150);
65
56
  triplets_copy = new TH2F("triplets_copy", "All Spills (x, y)", 300, -150, 150, 300, -150, 150);
66
57
  duplets_copy  = new TH2F("duplets_copy", "All Spills (x, y)", 300, -150, 150, 300, -150, 150);
67
 
  triplets->SetMarkerStyle(20);
68
 
  triplets->SetMarkerColor(kBlue);
69
 
  triplets_copy->SetMarkerStyle(20);
70
 
  triplets_copy->SetMarkerColor(kBlue);
71
 
  duplets->SetMarkerStyle(20);
72
 
  duplets->SetMarkerColor(kRed);
73
 
  duplets_copy->SetMarkerStyle(20);
74
 
  duplets_copy->SetMarkerColor(kRed);
75
 
 
76
 
/*
77
 
  // Clusters
78
 
  _hist_plane0 = new TH1F("_hist_plane0", "plane 0", 215, 0, 214);
79
 
  _hist_plane1 = new TH1F("_hist_plane1", "plane 1", 215, 0, 214);
80
 
  _hist_plane2 = new TH1F("_hist_plane2", "plane 2", 215, 0, 214);
81
 
  _chan_sum = new TH1F("_hist_plane2", "Sum Of Channel Numb", 641, 0, 640);
82
 
  _npe_plane0 = new TH1F("_npe_plane0", "plane 0", 31, 0, 30);
83
 
  _npe_plane1 = new TH1F("_npe_plane1", "plane 1", 31, 0, 30);
84
 
  _npe_plane2 = new TH1F("_npe_plane2", "plane 2", 31, 0, 30);
85
 
 
86
 
  // Digits
87
 
  _adc_plane0 = new TH1F("_adc_plane0", "plane 0 (ADC-PEDESTAL)", 256, 0, 255);
88
 
  _adc_plane1 = new TH1F("_adc_plane1", "plane 1 (ADC-PEDESTAL)", 256, 0, 255);
89
 
  _adc_plane2 = new TH1F("_adc_plane2", "plane 2 (ADC-PEDESTAL)", 256, 0, 255);
90
 
  _dig_npe_plane0 = new TH1F("_dig_npe_plane0", "plane 0 (NPE)", 31, 0, 30);
91
 
  _dig_npe_plane1 = new TH1F("_dig_npe_plane1", "plane 1 (NPE)", 31, 0, 30);
92
 
  _dig_npe_plane2 = new TH1F("_dig_npe_plane2", "plane 2 (NPE)", 31, 0, 30);
93
 
*/
 
58
 
94
59
  //
95
60
  // Trees
96
61
  //
108
73
  _digits.Branch("channel", &_channel_dig, "channel/D");
109
74
  _digits.Branch("npe", &_npe_dig, "npe/D");
110
75
  _digits.Branch("time", &_time, "time/D");
111
 
  _digits.Branch("adc", &_adc_dig, "adc/I");
112
76
 
113
77
  _doublet_clusters.SetNameTitle("clusters", "clusters");
114
78
  _doublet_clusters.Branch("tracker", &_tracker, "tracker/I");
122
86
  _spacepoints.Branch("x", &_x, "x/D");
123
87
  _spacepoints.Branch("y", &_y, "y/D");
124
88
  _spacepoints.Branch("z", &_z, "z/D");
125
 
  _spacepoints.Branch("tracker", &_tracker_cop, "tracker/I");
126
 
  _spacepoints.Branch("station", &_station_cop, "station/I");
 
89
  _spacepoints.Branch("tracker", &_tracker_sp, "tracker/I");
 
90
  _spacepoints.Branch("station", &_station_sp, "station/I");
127
91
  _spacepoints.Branch("type", &_type, "type/I");
128
92
 
129
 
  _spacepointscopy.SetNameTitle("spacepoints_copy", "spacepoints_copy");
130
 
  _spacepointscopy.Branch("pe", &_pe, "pe/D");
131
 
  _spacepointscopy.Branch("x", &_x, "x/D");
132
 
  _spacepointscopy.Branch("y", &_y, "y/D");
133
 
  _spacepointscopy.Branch("z", &_z, "z/D");
134
 
  _spacepointscopy.Branch("tracker", &_tracker_cop, "tracker/I");
135
 
  _spacepointscopy.Branch("station", &_station_cop, "station/I");
136
 
  _spacepointscopy.Branch("type", &_type, "type/I");
137
 
/*
138
 
  c1->SetFillColor(21);
139
 
  c1->GetFrame()->SetFillColor(42);
140
 
  c1->GetFrame()->SetBorderSize(6);
141
 
  c1->GetFrame()->SetBorderMode(-1);
142
 
 
143
 
  c2->SetFillColor(21);
144
 
  c2->GetFrame()->SetFillColor(42);
145
 
  c2->GetFrame()->SetBorderSize(6);
146
 
  c2->GetFrame()->SetBorderMode(-1);
147
 
 
148
 
  gStyle->SetLabelSize(0.07, "xyz");
149
 
  gStyle->SetTitleSize(0.07, "xy");
150
 
  gStyle->SetTitleOffset(0.6, "x");
151
 
  gStyle->SetTitleOffset(0.4, "y");
152
 
*/
153
93
  // JsonCpp setup
154
94
  Json::Value configJSON;
155
95
  try {
166
106
}
167
107
 
168
108
std::string  ReduceCppTracker::process(std::string document) {
169
 
  // TFile hfile("Event.root","RECREATE");
170
 
  // TFile root_file("cosmics.root","RECREATE");
171
109
  //  JsonCpp setup
172
110
  Json::FastWriter writer;
173
111
  Json::Value root;
174
112
  Json::Value xEventType;
175
113
 
176
 
  std::ofstream file1;
177
 
  std::ofstream file2;
178
 
  std::ofstream file3;
179
 
  std::ofstream file4;
180
 
 
181
114
  Squeak::activateCout(1);
182
115
  // Check if the JSON document can be parsed, else return error only
183
116
  try {
192
125
  }
193
126
  try {
194
127
    if ( is_physics_daq_event(root) ) {
195
 
      unpacked_data_histograms(root);
196
 
 
197
 
      digits_histograms(root);
198
 
 
199
 
      doublet_clusters_histograms(root);
200
 
 
201
 
      _spacepoints.Reset();
202
 
      draw_spacepoints(root);
203
 
 
204
 
      compute_stations_efficiencies(root);
205
 
      // save_efficiency(root);
 
128
      unpacked_data_tree(root);
 
129
 
 
130
      // Find number of recon events.
 
131
      int n_events = root["recon_events"].size();
 
132
      for ( int event_i = 0; event_i < n_events; ++event_i ) {
 
133
        _this_is_tracker0_event = false;
 
134
        _this_is_tracker1_event = false;
 
135
        Json::Value event = root["recon_events"][event_i];
 
136
        if ( event.isNull() ) continue;
 
137
        // std::cerr << "Merging..." << std::endl;
 
138
        merge_tracker_events(event);
 
139
        if ( !is_good_event() ) continue;
 
140
        // std::cerr << "Digits..." << std::endl;
 
141
        digits_tree();
 
142
 
 
143
        // std::cerr << "Clusters..." << std::endl;
 
144
        doublet_clusters_tree();
 
145
 
 
146
        // std::cerr << "Spacepoints..." << std::endl;
 
147
        spacepoints_tree();
 
148
        // _spacepoints.Reset();
 
149
        // draw_spacepoints(root);
 
150
 
 
151
        compute_stations_efficiencies();
 
152
        show_efficiency();
 
153
        json_daq.clear();
 
154
        json_digits.clear();
 
155
        json_clusters.clear();
 
156
        json_spacepoints.clear();
 
157
        // save_efficiency(root);
 
158
      }
206
159
    }
207
160
  } catch(Squeal squee) {
208
161
     Squeak::mout(Squeak::error) << squee.GetMessage() << std::endl;
211
164
    Squeak::mout(Squeak::error) << exc.what() << std::endl;
212
165
    root = MAUS::CppErrorHandler::getInstance()->HandleStdExc(root, exc, _classname);
213
166
  }
214
 
  // tree->Fill();
 
167
 
215
168
  _nSpills++;
216
 
  // hfile.Close();
217
 
  if (!(_nSpills%100)) {
218
 
    file1.open("efficiency_plane0.txt");
219
 
    file2.open("efficiency_plane1.txt");
220
 
    file3.open("efficiency_plane2.txt");
221
 
    for ( int i = 0; i < 214; ++i ) {
222
 
      file1 << i << " " << _plane_0_map[i][0] << " " << _plane_0_map[i][1] << "\n";
223
 
      file2 << i << " " << _plane_1_map[i][0] << " " << _plane_1_map[i][1] << "\n";
224
 
      file3 << i << " " << _plane_2_map[i][0] << " " << _plane_2_map[i][1] << "\n";
225
 
    }
226
 
    file1.close();
227
 
    file2.close();
228
 
    file3.close();
229
 
    file4.open("efficiency_station.txt");
230
 
    file4 << 0 << " " << _plane_0_hits << " " << _plane_0_counter << "\n";
231
 
    file4 << 1 << " " << _plane_1_hits << " " << _plane_1_counter << "\n";
232
 
    file4 << 2 << " " << _plane_2_hits << " " << _plane_2_counter << "\n";
233
 
    file4.close();
234
169
 
 
170
  if ( !(_nSpills%100) ) {
235
171
    save();
236
172
  }
237
173
 
238
 
  display_histograms();
 
174
  // display_histograms();
239
175
  return document;
240
176
}
241
177
 
242
178
bool ReduceCppTracker::death()  {
 
179
  save();
243
180
  return true;
244
181
}
245
182
 
246
183
void ReduceCppTracker::save()  {
 
184
  std::ofstream file1;
 
185
  file1.open("efficiency_fibres.txt");
 
186
  for ( int plane_i = 0; plane_i < 30; ++plane_i ) {
 
187
    for ( int fibre_j = 0; fibre_j < 214; ++fibre_j ) {
 
188
      file1 << plane_i << " " << fibre_j << " "
 
189
            << _map_planes_total[plane_i][fibre_j] << " "
 
190
            << _map_planes_hit[plane_i][fibre_j] << "\n";
 
191
    }
 
192
  }
 
193
  file1.close();
 
194
 
 
195
  std::ofstream file2;
 
196
  file2.open("efficiency_station.txt");
 
197
  for ( int tr_i = 0; tr_i < 2; ++tr_i ) {
 
198
    for ( int station_j = 1; station_j < 6; ++station_j ) {
 
199
      file2 << tr_i << " " << station_j << " "
 
200
            << map_stations_total[tr_i][station_j] << " "
 
201
            << map_stations_hits[tr_i][station_j] << "\n";
 
202
    }
 
203
  }
 
204
  file2.close();
 
205
 
247
206
  TFile root_file("cosmics.root", "RECREATE");
248
207
  _unpacked.Write();
249
208
  _digits.Write();
250
209
  _doublet_clusters.Write();
251
 
  // _spacepoints.Write();
 
210
  _spacepoints.Write();
252
211
  root_file.Close();
253
212
}
254
213
 
263
222
  }
264
223
}
265
224
 
266
 
void ReduceCppTracker::compute_stations_efficiencies(Json::Value root) {
267
 
  int n_events = root["recon_events"].size();
268
 
 
269
 
  for ( int event_i = 0; event_i < n_events; event_i++ ) {
270
 
    if ( root["recon_events"][event_i]["sci_fi_event"]
271
 
             ["sci_fi_space_points"]["tracker0"].isNull() )
272
 
      continue;
273
 
    Json::Value spacepoints = JsonWrapper::GetProperty(
274
 
          root["recon_events"][event_i]["sci_fi_event"]["sci_fi_space_points"],
275
 
          "tracker0" ,
276
 
          JsonWrapper::arrayValue);
277
 
 
278
 
    int numb_spacepoints = spacepoints.size();
279
 
    for ( int sp_j = 0; sp_j < numb_spacepoints; sp_j++ ) {
280
 
      // looping over spacepoints in an event.
281
 
      bool plane_0_is_hit = false;
282
 
      bool plane_1_is_hit = false;
283
 
      bool plane_2_is_hit = false;
284
 
      double chan_0 = -10.;
285
 
      double chan_1 = -10.;
286
 
      double chan_2 = -10.;
287
 
 
288
 
      int numb_clusters = spacepoints[sp_j]["channels"].size();
289
 
      for ( int clust_k = 0; clust_k < numb_clusters; ++clust_k ) {
290
 
        if ( spacepoints[sp_j]["channels"][clust_k]["plane_number"].asInt() == 0 ) {
291
 
          plane_0_is_hit = true;
292
 
          chan_0 = spacepoints[sp_j]["channels"][clust_k]["channel_number"].asDouble();
293
 
        }
294
 
        if ( spacepoints[sp_j]["channels"][clust_k]["plane_number"].asInt() == 1 ) {
295
 
          plane_1_is_hit = true;
296
 
          chan_1 = spacepoints[sp_j]["channels"][clust_k]["channel_number"].asDouble();
297
 
        }
298
 
        if ( spacepoints[sp_j]["channels"][clust_k]["plane_number"].asInt() == 2 ) {
299
 
          plane_2_is_hit = true;
300
 
          chan_2 = spacepoints[sp_j]["channels"][clust_k]["channel_number"].asDouble();
301
 
        }
302
 
      }
303
 
      // Plane 0 efficiencies.
304
 
      if ( plane_1_is_hit && plane_2_is_hit ) {
305
 
        _plane_0_counter += 1;
306
 
        if ( plane_0_is_hit ) {
307
 
          _plane_0_hits += 1;
308
 
          _plane_0_map[static_cast<int>(chan_0+0.5)][0] += 1;
309
 
          _plane_0_map[static_cast<int>(chan_0+0.5)][1] += 1;
310
 
        } else {
311
 
          int chan = 318-chan_1-chan_2;
312
 
          _plane_0_map[chan][1] += 1;
313
 
        }
314
 
      }
315
 
      // Plane 1 efficiencies.
316
 
      if ( plane_0_is_hit && plane_2_is_hit ) {
317
 
        _plane_1_counter += 1;
318
 
        if ( plane_1_is_hit ) {
319
 
          _plane_1_hits += 1;
320
 
          _plane_1_map[static_cast<int>(chan_1+0.5)][0] += 1;
321
 
          _plane_1_map[static_cast<int>(chan_1+0.5)][1] += 1;
322
 
        } else {
323
 
          int chan = 318-chan_0-chan_2;
324
 
          _plane_1_map[chan][1] += 1;
325
 
        }
326
 
      }
327
 
      // Plane 2 efficiencies.
328
 
      if ( plane_0_is_hit && plane_1_is_hit ) {
329
 
        _plane_2_counter += 1;
330
 
        if ( plane_2_is_hit ) {
331
 
          _plane_2_hits += 1;
332
 
          _plane_2_map[static_cast<int>(chan_2+0.5)][0] += 1;
333
 
          _plane_2_map[static_cast<int>(chan_2+0.5)][1] += 1;
334
 
        } else {
335
 
          int chan = 318-chan_0-chan_1;
336
 
          _plane_2_map[chan][1] += 1;
337
 
        }
 
225
bool ReduceCppTracker::is_good_event() {
 
226
  int numb_spacepoints = json_spacepoints.size();
 
227
  bool st1_tracker0 = false;
 
228
  bool st5_tracker0 = false;
 
229
  bool st1_tracker1 = false;
 
230
  bool st5_tracker1 = false;
 
231
  for ( int sp_i = 0; sp_i < numb_spacepoints; ++sp_i ) {
 
232
    int tracker = json_spacepoints[sp_i]["tracker"].asInt();
 
233
    int station = json_spacepoints[sp_i]["station"].asInt();
 
234
    if ( station == 1 && tracker == 0 ) st1_tracker0 = true;
 
235
    if ( station == 5 && tracker == 0 ) st5_tracker0 = true;
 
236
    if ( station == 1 && tracker == 1 ) st1_tracker1 = true;
 
237
    if ( station == 5 && tracker == 1 ) st5_tracker1 = true;
 
238
  }
 
239
  if ( st1_tracker0 && st5_tracker0 ) {
 
240
    _this_is_tracker0_event = true;
 
241
  } else if ( st1_tracker1 && st5_tracker1 )  {
 
242
    _this_is_tracker1_event = true;
 
243
  }
 
244
 
 
245
  if ( _this_is_tracker0_event || _this_is_tracker1_event ) {
 
246
    return true;
 
247
  } else {
 
248
    return false;
 
249
  }
 
250
}
 
251
 
 
252
void ReduceCppTracker::merge_tracker_events(Json::Value &event) {
 
253
  // --------------------------------------------------------------
 
254
  //
 
255
  // Collect digits.
 
256
  //
 
257
  Json::Value digits = event["sci_fi_event"]["sci_fi_digits"];
 
258
  if ( digits.isMember("tracker0") && !digits["tracker0"].isNull() ) {
 
259
    json_digits = JsonWrapper::GetProperty(digits,
 
260
                                           "tracker0",
 
261
                                           JsonWrapper::arrayValue);
 
262
  }
 
263
  if ( digits.isMember("tracker1") && !digits["tracker1"].isNull() ) {
 
264
    Json::Value tracker1_digits = JsonWrapper::GetProperty(digits,
 
265
                                                           "tracker1",
 
266
                                                           JsonWrapper::arrayValue);
 
267
    for ( unsigned int idig = 0; idig < tracker1_digits.size(); ++idig ) {
 
268
      json_digits[json_digits.size()] = tracker1_digits[idig];
 
269
    }
 
270
  }
 
271
  // --------------------------------------------------------------
 
272
  //
 
273
  // Collect clusters.
 
274
  //
 
275
  Json::Value clusters = event["sci_fi_event"]["sci_fi_clusters"];
 
276
  if ( clusters.isMember("tracker0") && !clusters["tracker0"].isNull() ) {
 
277
    json_clusters = JsonWrapper::GetProperty(clusters,
 
278
                                             "tracker0" ,
 
279
                                             JsonWrapper::arrayValue);
 
280
  }
 
281
  if ( clusters.isMember("tracker1") && !clusters["tracker1"].isNull() ) {
 
282
    Json::Value tracker1_clusters = JsonWrapper::GetProperty(clusters,
 
283
                                                             "tracker1",
 
284
                                                             JsonWrapper::arrayValue);
 
285
    for ( unsigned int iclust = 0; iclust < tracker1_clusters.size(); ++iclust ) {
 
286
      json_clusters[json_clusters.size()] = tracker1_clusters[iclust];
 
287
    }
 
288
  }
 
289
  // --------------------------------------------------------------
 
290
  //
 
291
  // Collect spacepoints.
 
292
  //
 
293
  Json::Value spacepoints = event["sci_fi_event"]["sci_fi_space_points"];
 
294
  if ( spacepoints.isMember("tracker0") && !spacepoints["tracker0"].isNull() ) {
 
295
    json_spacepoints = JsonWrapper::GetProperty(spacepoints,
 
296
                                                "tracker0" ,
 
297
                                                JsonWrapper::arrayValue);
 
298
  }
 
299
  if ( spacepoints.isMember("tracker1") && !spacepoints["tracker1"].isNull() ) {
 
300
    Json::Value tracker1_spacepoints = JsonWrapper::GetProperty(spacepoints,
 
301
                                                                "tracker1",
 
302
                                                                JsonWrapper::arrayValue);
 
303
    for ( unsigned int i_sp = 0; i_sp < tracker1_spacepoints.size(); ++i_sp ) {
 
304
      json_spacepoints[json_spacepoints.size()] = tracker1_spacepoints[i_sp];
 
305
    }
 
306
  }
 
307
  // --------------------------------------------------------------
 
308
  // std::cerr << "Sizes: " << json_digits.size() << " "
 
309
  //                       << json_clusters.size() << " " << json_spacepoints.size() << std::endl;
 
310
}
 
311
 
 
312
void ReduceCppTracker::show_efficiency() {
 
313
  int numb_spacepoints = json_spacepoints.size();
 
314
 
 
315
  bool station_hit[2][6] = { {false, false, false, false, false, false},
 
316
                             {false, false, false, false, false, false}};
 
317
 
 
318
  for ( int sp_i = 0; sp_i < numb_spacepoints; sp_i++ ) {
 
319
    // Fill station number.
 
320
    int tracker = json_spacepoints[sp_i]["tracker"].asInt();
 
321
    int station = json_spacepoints[sp_i]["station"].asInt();
 
322
    // _station = station;
 
323
 
 
324
    station_hit[tracker][station]=true;
 
325
    /*
 
326
    // Fill type.
 
327
    std::string type = json_spacepoints[sp_i][sp_i]["type"].asString();
 
328
    if ( type == "triplet" ) {
 
329
      _type = 3;
 
330
    }
 
331
    if ( type == "duplet" ) {
 
332
      _type = 2;
 
333
    }
 
334
     */
 
335
    // _x = spacepoints_tracker0[sp_i]["position"]["x"].asDouble();
 
336
    // _y = spacepoints_tracker0[sp_i]["position"]["y"].asDouble();
 
337
    // _z = spacepoints_tracker0[sp_i]["position"]["z"].asDouble();
 
338
    // _spacepoints.Fill();
 
339
  }
 
340
 
 
341
  for ( int tr = 0; tr < 2; ++tr ) {
 
342
    if ( station_hit[tr][1] && station_hit[tr][3] ) {
 
343
      if ( station_hit[tr][2] ) {
 
344
        map_stations_total[tr][2] += 1;
 
345
        map_stations_hits[tr][2]  += 1;
 
346
      } else {
 
347
        map_stations_total[tr][2] += 1;
 
348
      }
 
349
    }
 
350
    if ( station_hit[tr][2] && station_hit[tr][4] ) {
 
351
      if ( station_hit[tr][3] ) {
 
352
        map_stations_total[tr][3] += 1;
 
353
        map_stations_hits[tr][3]  += 1;
 
354
      } else {
 
355
        map_stations_total[tr][3] += 1;
 
356
      }
 
357
    }
 
358
    if ( station_hit[tr][3] && station_hit[tr][5] ) {
 
359
      if ( station_hit[tr][4] ) {
 
360
        map_stations_total[tr][4] += 1;
 
361
        map_stations_hits[tr][4]  += 1;
 
362
      } else {
 
363
        map_stations_total[tr][4] += 1;
 
364
      }
 
365
    }
 
366
  }
 
367
/*
 
368
    // Fill EVENT tree.
 
369
    for ( int tr = 0; tr < 2; tr++ ) {
 
370
    int hit_counter = 0;
 
371
    if ( station_hit[tr][1] && station_hit[tr][5] ) {
 
372
      for ( int i = 2; i < 5; i++ ) {
 
373
        if ( station_hit[tr][i] )
 
374
          hit_counter+=1;
 
375
        }
 
376
        _station_hits = hit_counter+2;
 
377
        _tracker_event = tr;
 
378
        _events.Fill();
 
379
      }
 
380
    }
 
381
*/
 
382
}
 
383
 
 
384
void ReduceCppTracker::compute_stations_efficiencies() {
 
385
  int numb_spacepoints = json_spacepoints.size();
 
386
  for ( int sp_j = 0; sp_j < numb_spacepoints; sp_j++ ) {
 
387
    // looping over spacepoints in an event.
 
388
    bool plane_0_is_hit = false;
 
389
    bool plane_1_is_hit = false;
 
390
    bool plane_2_is_hit = false;
 
391
    int chan_0 = -10.;
 
392
    int chan_1 = -10.;
 
393
    int chan_2 = -10.;
 
394
    int plane_0_id = 99;
 
395
    int plane_1_id = 99;
 
396
    int plane_2_id = 99;
 
397
 
 
398
    int tracker = json_spacepoints[sp_j]["tracker"].asInt();
 
399
    int station = json_spacepoints[sp_j]["station"].asInt();
 
400
 
 
401
    //
 
402
    //  Fibre efficiencies
 
403
    //
 
404
    int numb_clusters = json_spacepoints[sp_j]["channels"].size();
 
405
    for ( int clust_k = 0; clust_k < numb_clusters; ++clust_k ) {
 
406
      if ( json_spacepoints[sp_j]["channels"][clust_k]["plane_number"].asInt() == 0 ) {
 
407
        plane_0_id = 15*tracker + 3*(station-1) + (0);
 
408
        plane_0_is_hit = true;
 
409
        chan_0 = json_spacepoints[sp_j]["channels"][clust_k]["channel_number"].asDouble();
 
410
      }
 
411
      if ( json_spacepoints[sp_j]["channels"][clust_k]["plane_number"].asInt() == 1 ) {
 
412
        plane_1_id = 15*tracker + 3*(station-1) + (1);
 
413
        plane_1_is_hit = true;
 
414
        chan_1 = json_spacepoints[sp_j]["channels"][clust_k]["channel_number"].asDouble();
 
415
      }
 
416
      if ( json_spacepoints[sp_j]["channels"][clust_k]["plane_number"].asInt() == 2 ) {
 
417
        plane_2_id = 15*tracker + 3*(station-1) + (2);
 
418
        plane_2_is_hit = true;
 
419
        chan_2 = json_spacepoints[sp_j]["channels"][clust_k]["channel_number"].asDouble();
 
420
      }
 
421
    }
 
422
    // Plane 0 efficiencies.
 
423
    if ( plane_1_is_hit && plane_2_is_hit ) {
 
424
      if ( plane_0_is_hit ) {
 
425
        _map_planes_total[plane_0_id][chan_0] += 1;
 
426
        _map_planes_hit[plane_0_id][chan_0]   += 1;
 
427
        // _plane_0_map[static_cast<int>(chan_0+0.5)][0] += 1;
 
428
        // _plane_0_map[static_cast<int>(chan_0+0.5)][1] += 1;
 
429
      } else {
 
430
        int chan = 318-chan_1-chan_2;
 
431
        plane_0_id = 15*tracker + 3*(station-1) + (0);
 
432
        _map_planes_total[plane_0_id][chan] += 1;
 
433
      }
 
434
    }
 
435
    // Plane 1 efficiencies.
 
436
    if ( plane_0_is_hit && plane_2_is_hit ) {
 
437
      if ( plane_1_is_hit ) {
 
438
        _map_planes_total[plane_1_id][chan_1] += 1;
 
439
        _map_planes_hit[plane_1_id][chan_1]   += 1;
 
440
      } else {
 
441
        int chan = 318-chan_0-chan_2;
 
442
        plane_1_id = 15*tracker + 3*(station-1) + (1);
 
443
        _map_planes_total[plane_1_id][chan] += 1;
 
444
      }
 
445
    }
 
446
    // Plane 2 efficiencies.
 
447
    if ( plane_0_is_hit && plane_1_is_hit ) {
 
448
      if ( plane_2_is_hit ) {
 
449
        _map_planes_total[plane_2_id][chan_2] += 1;
 
450
        _map_planes_hit[plane_2_id][chan_2]   += 1;
 
451
      } else {
 
452
        int chan = 318-chan_0-chan_1;
 
453
        plane_2_id = 15*tracker + 3*(station-1) + (2);
 
454
        _map_planes_total[plane_2_id][chan] += 1;
338
455
      }
339
456
    }
340
457
  }
341
458
}
342
459
 
343
460
void ReduceCppTracker::draw_spacepoints(Json::Value root) {
 
461
/*
344
462
  int n_events = root["recon_events"].size();
345
463
 
346
 
  // root["recon_events"][5]["sci_fi_event"]["sci_fi_space_points"]["single_station"][0];
347
 
  // std::cerr << n_events << std::endl;
348
464
  for ( int event_i = 0; event_i < n_events; event_i++ ) {
349
465
    // Process tracker 0.
350
 
    if ( root["recon_events"][event_i]["sci_fi_event"]
351
 
             ["sci_fi_space_points"]["tracker0"].isNull() ) continue;
352
466
    Json::Value spacepoints_tracker0 = JsonWrapper::GetProperty(
353
467
          root["recon_events"][event_i]["sci_fi_event"]["sci_fi_space_points"],
354
468
          "tracker0" ,
355
469
          JsonWrapper::arrayValue);
356
 
    // std::cerr << spacepoints.size() << std::endl;
 
470
    if ( spacepoints_tracker0.isNull() ) continue;
357
471
    int numb_spacepoints_tracker0 = spacepoints_tracker0.size();
358
472
    for ( int sp_j = 0; sp_j < numb_spacepoints_tracker0; sp_j++ ) {
 
473
        if ( spacepoints_tracker0[sp_j].isNull() ) continue;
359
474
        _x =  spacepoints_tracker0[sp_j]["position"]["x"].asDouble();
360
475
        _y =  spacepoints_tracker0[sp_j]["position"]["y"].asDouble();
361
476
        _z =  spacepoints_tracker0[sp_j]["position"]["z"].asDouble();
362
477
        _pe = spacepoints_tracker0[sp_j]["npe"].asDouble();
363
 
        _tracker_cop = spacepoints_tracker0[sp_j]["tracker"].asInt();
364
 
        _station_cop = spacepoints_tracker0[sp_j]["station"].asInt();
 
478
        _tracker_sp = spacepoints_tracker0[sp_j]["tracker"].asInt();
 
479
        _station_sp = spacepoints_tracker0[sp_j]["station"].asInt();
365
480
        std::string type = spacepoints_tracker0[sp_j]["type"].asString();
366
481
        if ( type == "triplet" ) {
367
482
          _type = 3;
379
494
          root["recon_events"][event_i]["sci_fi_event"]["sci_fi_space_points"],
380
495
          "tracker1" ,
381
496
          JsonWrapper::arrayValue);
382
 
    // std::cerr << spacepoints.size() << std::endl;
383
497
    int numb_spacepoints_tracker1 = spacepoints_tracker1.size();
384
498
    for ( int sp_j = 0; sp_j < numb_spacepoints_tracker1; sp_j++ ) {
385
499
        _x =  spacepoints_tracker1[sp_j]["position"]["x"].asDouble();
386
500
        _y =  spacepoints_tracker1[sp_j]["position"]["y"].asDouble();
387
501
        _z =  spacepoints_tracker1[sp_j]["position"]["z"].asDouble();
388
502
        _pe = spacepoints_tracker1[sp_j]["npe"].asDouble();
389
 
        _tracker_cop = spacepoints_tracker1[sp_j]["tracker"].asInt();
390
 
        _station_cop = spacepoints_tracker1[sp_j]["station"].asInt();
 
503
        _tracker_sp = spacepoints_tracker1[sp_j]["tracker"].asInt();
 
504
        _station_sp = spacepoints_tracker1[sp_j]["station"].asInt();
391
505
        std::string type = spacepoints_tracker1[sp_j]["type"].asString();
392
506
        if ( type == "triplet" ) {
393
507
          _type = 3;
404
518
  //        std::string("SpacePoints branch is corrupted!"),
405
519
  //        "ReduceCppSingleStation::draw_spacepoints"));
406
520
  // }
407
 
}
408
 
 
409
 
void ReduceCppTracker::doublet_clusters_histograms(Json::Value root) {
410
 
  int n_events = root["recon_events"].size();
411
 
 
412
 
  for ( int event_i = 0; event_i < n_events; event_i++ ) {
413
 
    if ( root["recon_events"][event_i]["sci_fi_event"]
414
 
             ["sci_fi_clusters"]["tracker0"].isNull() ) continue;
415
 
    Json::Value clusters = JsonWrapper::GetProperty(
416
 
          root["recon_events"][event_i]["sci_fi_event"]["sci_fi_clusters"],
417
 
          "tracker0" ,
418
 
          JsonWrapper::arrayValue);
419
 
 
420
 
    int numb_clusters = clusters.size();
421
 
 
422
 
    double chan_sum = 0;
423
 
    for ( int clust_j = 0; clust_j < numb_clusters; clust_j++ ) {
424
 
      _plane   = clusters[clust_j]["plane"].asInt();
425
 
      _channel = clusters[clust_j]["channel"].asDouble();
426
 
      _npe     = clusters[clust_j]["npe"].asDouble();
427
 
      _doublet_clusters.Fill();
428
 
      chan_sum += _channel;
429
 
      if ( _plane == 0 ) {
430
 
        _hist_plane0->Fill(_channel);
431
 
        _npe_plane0->Fill(_npe);
432
 
      } else if ( _plane == 1 ) {
433
 
        _hist_plane1->Fill(_channel);
434
 
        _npe_plane1->Fill(_npe);
435
 
      } else if ( _plane == 2 ) {
436
 
        _hist_plane2->Fill(_channel);
437
 
        _npe_plane2->Fill(_npe);
438
 
      }
439
 
    }
440
 
    _chan_sum->Fill(chan_sum);
441
 
  }
442
 
  // } else {
443
 
  //  throw(Squeal(Squeal::recoverable,
444
 
  //        std::string("Digits branch is corrupted!"),
445
 
  //        "ReduceCppSingleStation::digits_histograms"));
446
 
  // }
447
 
}
448
 
 
449
 
void ReduceCppTracker::digits_histograms(Json::Value root) {
450
 
  int n_events = root["recon_events"].size();
451
 
 
452
 
  for ( int event_i = 0; event_i < n_events; event_i++ ) {
453
 
    Json::Value tracker1 = root["recon_events"][event_i]["sci_fi_event"]
454
 
                               ["sci_fi_digits"]["tracker1"];
455
 
    // if ( tracker0.isNull() ) continue;
456
 
    Json::Value digits = JsonWrapper::GetProperty(
457
 
          root["recon_events"][event_i]["sci_fi_event"]["sci_fi_digits"],
458
 
          "tracker0" ,
459
 
          JsonWrapper::arrayValue);
460
 
 
461
 
    for ( unsigned int idig = 0; idig < tracker1.size(); ++idig ) {
462
 
      digits[digits.size()] = tracker1[idig];
463
 
    }
464
 
 
465
 
    int numb_digits = digits.size();
466
 
 
467
 
    double chan_sum = 0;
468
 
    for ( int digit_j = 0; digit_j < numb_digits; digit_j++ ) {
469
 
      _tracker_dig   = digits[digit_j]["tracker"].asInt();
470
 
      _station_dig   = digits[digit_j]["station"].asInt();
471
 
      _plane_dig   = digits[digit_j]["plane"].asInt();
472
 
      _channel_dig = digits[digit_j]["channel"].asDouble();
473
 
      _npe_dig     = digits[digit_j]["npe"].asDouble();
474
 
      _adc_dig     = digits[digit_j]["adc"].asInt();
475
 
      _time        = digits[digit_j]["time"].asDouble();
476
 
      _digits.Fill();
477
 
      if ( _plane_dig == 0 ) {
 
521
*/
 
522
}
 
523
 
 
524
void ReduceCppTracker::spacepoints_tree() {
 
525
  Json::Value spacepoint_event = json_spacepoints;
 
526
  int numb_spacepoints = spacepoint_event.size();
 
527
 
 
528
  double chan_sum = 0;
 
529
  for ( int sp_j = 0; sp_j < numb_spacepoints; sp_j++ ) {
 
530
    Json::Value a_spacepoint = spacepoint_event[sp_j];
 
531
    if ( a_spacepoint.isNull() ) continue;
 
532
      _x =  a_spacepoint["position"]["x"].asDouble();
 
533
      _y =  a_spacepoint["position"]["y"].asDouble();
 
534
      _z =  a_spacepoint["position"]["z"].asDouble();
 
535
      _pe = a_spacepoint["npe"].asDouble();
 
536
      _tracker_sp = a_spacepoint["tracker"].asInt();
 
537
      _station_sp = a_spacepoint["station"].asInt();
 
538
      std::string type = a_spacepoint["type"].asString();
 
539
      if ( type == "triplet" ) {
 
540
        _type = 3;
 
541
      }
 
542
      if ( type == "duplet" ) {
 
543
        _type = 2;
 
544
      }
 
545
      _spacepoints.Fill();
 
546
/*
 
547
      if ( _plane == 0 ) {
 
548
        _hist_plane0->Fill(_channel);
 
549
        _npe_plane0->Fill(_npe);
 
550
      } else if ( _plane == 1 ) {
 
551
        _hist_plane1->Fill(_channel);
 
552
        _npe_plane1->Fill(_npe);
 
553
      } else if ( _plane == 2 ) {
 
554
        _hist_plane2->Fill(_channel);
 
555
        _npe_plane2->Fill(_npe);
 
556
      }
 
557
*/
 
558
  }
 
559
  // _chan_sum->Fill(chan_sum);
 
560
  // }
 
561
  // } else {
 
562
  //  throw(Squeal(Squeal::recoverable,
 
563
  //        std::string("Digits branch is corrupted!"),
 
564
  //        "ReduceCppSingleStation::digits_histograms"));
 
565
  // }
 
566
}
 
567
 
 
568
void ReduceCppTracker::doublet_clusters_tree() {
 
569
  Json::Value cluster_event = json_clusters;
 
570
  // if ( cluster_event.isNull() ) continue;
 
571
  int numb_clusters = cluster_event.size();
 
572
 
 
573
  // double chan_sum = 0;
 
574
  for ( int clust_j = 0; clust_j < numb_clusters; clust_j++ ) {
 
575
    Json::Value a_cluster = cluster_event[clust_j];
 
576
    if ( a_cluster.isNull() ) continue;
 
577
    _tracker = a_cluster["tracker"].asInt();
 
578
    _station = a_cluster["station"].asInt();
 
579
    _plane   = a_cluster["plane"].asInt();
 
580
    _channel = a_cluster["channel"].asDouble();
 
581
    _npe     = a_cluster["npe"].asDouble();
 
582
    _doublet_clusters.Fill();
 
583
      // chan_sum += _channel;
 
584
/*
 
585
      if ( _plane == 0 ) {
 
586
        _hist_plane0->Fill(_channel);
 
587
        _npe_plane0->Fill(_npe);
 
588
      } else if ( _plane == 1 ) {
 
589
        _hist_plane1->Fill(_channel);
 
590
        _npe_plane1->Fill(_npe);
 
591
      } else if ( _plane == 2 ) {
 
592
        _hist_plane2->Fill(_channel);
 
593
        _npe_plane2->Fill(_npe);
 
594
      } */
 
595
  }
 
596
  // _chan_sum->Fill(chan_sum);
 
597
  // }
 
598
  // } else {
 
599
  //  throw(Squeal(Squeal::recoverable,
 
600
  //        std::string("Digits branch is corrupted!"),
 
601
  //        "ReduceCppSingleStation::digits_histograms"));
 
602
  // }
 
603
}
 
604
 
 
605
void ReduceCppTracker::digits_tree() {
 
606
  Json::Value digit_event = json_digits;
 
607
 
 
608
  int numb_digits = digit_event.size();
 
609
  assert(digit_event.isArray());
 
610
  double chan_sum = 0;
 
611
  for ( int digit_j = 0; digit_j < numb_digits; digit_j++ ) {
 
612
    Json::Value a_digit = digit_event[digit_j];
 
613
    if ( a_digit.isNull() ) continue;
 
614
    assert(a_digit.isMember("tracker"));
 
615
    assert(a_digit.isMember("station"));
 
616
    assert(a_digit.isMember("plane"));
 
617
    assert(a_digit.isMember("channel"));
 
618
    assert(a_digit.isMember("npe"));
 
619
    assert(a_digit.isMember("time"));
 
620
    _tracker_dig   = a_digit["tracker"].asInt();
 
621
    _station_dig   = a_digit["station"].asInt();
 
622
    _plane_dig   = a_digit["plane"].asInt();
 
623
    _channel_dig = a_digit["channel"].asDouble();
 
624
    _npe_dig     = a_digit["npe"].asDouble();
 
625
    _time        = a_digit["time"].asDouble();
 
626
    _digits.Fill();
 
627
/*      if ( _plane_dig == 0 ) {
478
628
        _adc_plane0->Fill(_adc_dig);
479
629
        _dig_npe_plane0->Fill(_npe_dig);
480
630
      } else if ( _plane_dig == 1 ) {
483
633
      } else if ( _plane_dig == 2 ) {
484
634
        _adc_plane2->Fill(_adc_dig);
485
635
        _dig_npe_plane2->Fill(_npe_dig);
486
 
      }
487
 
    }
 
636
      } */
488
637
  }
 
638
  // }
489
639
  // } else {
490
640
  //  throw(Squeal(Squeal::recoverable,
491
641
  //        std::string("Digits branch is corrupted!"),
492
642
  //        "ReduceCppSingleStation::digits_histograms"));
493
643
  // }
494
644
}
495
 
/*
496
 
void ReduceCppTracker::show_light_yield(Json::Value const &root) {
497
 
  int n_events = root["recon_events"].size();
498
 
 
499
 
  for (int event_i = 0; event_i < n_events; event_i++) {
500
 
    Json::Value spacepoints_tracker0 = root["recon_events"][event_i]["sci_fi_event"]
501
 
                                           ["sci_fi_space_points"]["tracker0"];
502
 
 
503
 
    Json::Value spacepoints_tracker1 = root["recon_events"][event_i]["sci_fi_event"]
504
 
                                           ["sci_fi_space_points"]["tracker1"];
505
 
 
506
 
    int n_sp_tracker0 = spacepoints_tracker0.size();
507
 
    int n_sp_tracker1 = spacepoints_tracker1.size();
508
 
 
509
 
    for ( int sp_i = 0; sp_i < n_sp_tracker0; sp_i++ ) {
510
 
      int n_digits = spacepoints_tracker0[sp_i]["channels"].size();
511
 
      for ( int digit_j = 0; digit_j < n_digits; digit_j++ ) {
512
 
        _npe = spacepoints_tracker0[sp_i]["channels"][digit_j]["npe"].asDouble();
513
 
        _tracker_dig = 0;
514
 
        _digits.Fill();
515
 
      }
516
 
    }
517
 
 
518
 
    for ( int sp_i = 0; sp_i < n_sp_tracker1; sp_i++ ) {
519
 
      int n_digits = spacepoints_tracker1[sp_i]["channels"].size();
520
 
      for ( int digit_j = 0; digit_j < n_digits; digit_j++ ) {
521
 
        _npe = spacepoints_tracker1[sp_i]["channels"][digit_j]["npe"].asDouble();
522
 
        _tracker_dig = 1;
523
 
        _digits.Fill();
524
 
      }
525
 
    }
526
 
  }
527
 
}
528
 
*/
529
 
void ReduceCppTracker::unpacked_data_histograms(Json::Value root) {
530
 
/*  for ( int event_i = 0; event_i < n_events; event_i++ ) {
531
 
    // Json::Value tracker0 = root["recon_events"][event_i]["sci_fi_event"]["sci_fi_digits"]["tracker0"];
532
 
    Json::Value tracker1 = root["recon_events"][event_i]["sci_fi_event"]["sci_fi_digits"]["tracker1"];
533
 
    // if ( tracker0.isNull() ) continue;
534
 
    Json::Value digits = JsonWrapper::GetProperty(
535
 
          root["recon_events"][event_i]["sci_fi_event"]["sci_fi_digits"],
536
 
          "tracker0" ,
537
 
          JsonWrapper::arrayValue);
538
 
 
539
 
    for ( unsigned int idig = 0; idig < tracker1.size(); ++idig ) {
540
 
      digits[digits.size()] = tracker1[idig];
541
 
    }
542
 
 
543
 
 
544
 
 
545
 
*/
 
645
 
 
646
void ReduceCppTracker::unpacked_data_tree(Json::Value root) {
546
647
  Json::Value daq_data = JsonWrapper::GetProperty(root,
547
648
                                                  "daq_data",
548
649
                                                  JsonWrapper::objectValue);
549
 
  int n_events = daq_data["tracker1"].size();
 
650
  int n_daq_events = daq_data["tracker1"].size();
 
651
  Json::Value tracker2 = daq_data["tracker2"];
550
652
  // Loop over events.
551
 
  for (int event_i = 0; event_i < n_events; event_i++) {
 
653
  for (int event_i = 0; event_i < n_daq_events; event_i++) {
552
654
    if ( daq_data["tracker1"][event_i].isNull() ) continue;
553
 
    Json::Value i_PartEvent = daq_data["tracker1"][event_i];
554
 
    int number_channels_within = i_PartEvent["VLSB_C"].size();
555
 
    for ( int i = 0; i < number_channels_within; i++ ) {
556
 
      _tdc  = i_PartEvent["VLSB_C"][i]["tdc"].asInt();
557
 
      _adc  = i_PartEvent["VLSB_C"][i]["adc"].asInt();
558
 
      _bank = i_PartEvent["VLSB_C"][i]["bank_id"].asInt();
559
 
      _chan = i_PartEvent["VLSB_C"][i]["channel"].asInt();
560
 
      int dicrim = _chan = i_PartEvent["VLSB_C"][i]["discriminator"].asInt();
 
655
    Json::Value daq = daq_data["tracker1"][event_i]["VLSB_C"];
 
656
    if ( !daq_data["tracker2"][event_i].isNull() ) {
 
657
      for ( int i = 0; i < daq_data["tracker2"][event_i]["VLSB_C"].size(); ++i ) {
 
658
        daq[daq.size()] = daq_data["tracker2"][event_i]["VLSB_C"][i];
 
659
      }
 
660
    }
 
661
    json_daq.append(daq);
 
662
  }
 
663
 
 
664
  int n_events = json_daq.size();
 
665
  // Loop over events.
 
666
  for (int event_i = 0; event_i < n_events; event_i++) {
 
667
    Json::Value daq_event = JsonWrapper::GetItem(json_daq,
 
668
                                                 event_i,
 
669
                                                 JsonWrapper::arrayValue);
 
670
    if ( daq_event.isNull() ) continue;
 
671
    int number_channels_within = daq_event.size();
 
672
    // std::cerr << number_channels_within << std::endl;
 
673
    for ( int hit_i = 0; hit_i < number_channels_within; hit_i++ ) {
 
674
      Json::Value a_hit = daq_event[(Json::Value::ArrayIndex)hit_i];
 
675
      if ( a_hit.isNull() ) continue;
 
676
      assert(a_hit.isMember("tdc"));
 
677
      assert(a_hit.isMember("adc"));
 
678
      assert(a_hit.isMember("bank"));
 
679
      assert(a_hit.isMember("channel"));
 
680
      assert(a_hit.isMember("geo"));
 
681
      assert(a_hit.isMember("discriminator"));
 
682
      _tdc  = a_hit["tdc"].asInt();
 
683
      _adc  = a_hit["adc"].asInt();
 
684
      _bank = a_hit["bank"].asInt();
 
685
      _chan = a_hit["channel"].asInt();
 
686
      _board =a_hit["geo"].asInt()-1;
 
687
      _unpacked.Fill();
 
688
/*      int dicrim = a_hit["discriminator"].asInt();
561
689
      if ( dicrim != 0 ) {
562
690
        std::cerr << "*************** DISCRIMINATOR != 0 ***************" << std::endl;
563
691
      }
564
692
      _unpacked.Fill();
565
693
      // SciFiEvent_DAQ *daq = new SciFiEvent_DAQ(_bank,7,_chan);
566
694
      // event->set_daq(daq);
 
695
*/
567
696
    }
568
697
  }
569
698
}
570
699
 
571
 
/*
572
 
void ReduceCppTracker::show_efficiency(Json::Value const &root) {
573
 
  int n_events = root["recon_events"].size();
574
 
 
575
 
  for (int event_i = 0; event_i < n_events; event_i++) {
576
 
    Json::Value spacepoints_tracker0 = root["recon_events"][event_i]["sci_fi_event"]
577
 
                                           ["sci_fi_space_points"]["tracker0"];
578
 
 
579
 
    Json::Value spacepoints_tracker1 = root["recon_events"][event_i]["sci_fi_event"]
580
 
                                           ["sci_fi_space_points"]["tracker1"];
581
 
 
582
 
    int n_sp_tracker0 = spacepoints_tracker0.size();
583
 
    int n_sp_tracker1 = spacepoints_tracker1.size();
584
 
 
585
 
    bool station_hit[2][6] = { {false, false, false, false, false, false},
586
 
                               {false, false, false, false, false, false}};
587
 
 
588
 
    for ( int sp_i = 0; sp_i < n_sp_tracker0; sp_i++ ) {
589
 
      // Fill station number.
590
 
      int station = spacepoints_tracker0[sp_i]["station"].asInt();
591
 
      _station = station;
592
 
      station_hit[0][station]=true;
593
 
      // Fill type.
594
 
      std::string type = spacepoints_tracker0[sp_i]["type"].asString();
595
 
      if ( type == "triplet" ) {
596
 
        _type = 3;
597
 
      }
598
 
      if ( type == "duplet" ) {
599
 
        _type = 2;
600
 
      }
601
 
      _tracker = 0;
602
 
      _x = spacepoints_tracker0[sp_i]["position"]["x"].asDouble();
603
 
      _y = spacepoints_tracker0[sp_i]["position"]["y"].asDouble();
604
 
      _z = spacepoints_tracker0[sp_i]["position"]["z"].asDouble();
605
 
      _spacepoints.Fill();
606
 
    }
607
 
 
608
 
    for ( int sp_i = 0; sp_i < n_sp_tracker1; sp_i++ ) {
609
 
      // Fill station number.
610
 
      int station = spacepoints_tracker1[sp_i]["station"].asInt();
611
 
      _station = station;
612
 
      station_hit[1][station]=true;
613
 
      // Fill type.
614
 
      std::string type = spacepoints_tracker1[sp_i]["type"].asString();
615
 
      if ( type == "triplet" ) {
616
 
        _type = 3;
617
 
      }
618
 
      if ( type == "duplet" ) {
619
 
        _type = 2;
620
 
      }
621
 
      _tracker = 1;
622
 
      _x = spacepoints_tracker1[sp_i]["position"]["x"].asDouble();
623
 
      _y = spacepoints_tracker1[sp_i]["position"]["y"].asDouble();
624
 
      _z = spacepoints_tracker1[sp_i]["position"]["z"].asDouble();
625
 
      _spacepoints.Fill();
626
 
    }
627
 
 
628
 
    // Fill EVENT tree.
629
 
    for ( int tr = 0; tr < 2; tr++ ) {
630
 
    int hit_counter = 0;
631
 
    if ( station_hit[tr][1] && station_hit[tr][5] ) {
632
 
      for ( int i = 2; i < 5; i++ ) {
633
 
        if ( station_hit[tr][i] )
634
 
          hit_counter+=1;
635
 
        }
636
 
        _station_hits = hit_counter+2;
637
 
        _tracker_event = tr;
638
 
        _events.Fill();
639
 
      }
640
 
    }
641
 
  } // ends loop over particle events
642
 
}
643
 
*/
644
 
 
645
700
void ReduceCppTracker::display_histograms() {
646
 
  // TCanvas *c1 = reinterpret_cast<TCanvas*> (gROOT->GetListOfCanvases()->FindObject("c1"));
647
 
  // TCanvas *c2 = reinterpret_cast<TCanvas*> (gROOT->GetListOfCanvases()->FindObject("c2"));
648
 
  TCanvas *c3 = reinterpret_cast<TCanvas*> (gROOT->GetListOfCanvases()->FindObject("c3"));
649
 
  // TCanvas *c4 = reinterpret_cast<TCanvas*> (gROOT->GetListOfCanvases()->FindObject("c4"));
650
 
  // TCanvas *c5 = reinterpret_cast<TCanvas*> (gROOT->GetListOfCanvases()->FindObject("c5"));
651
701
/*
 
702
  TCanvas *c1 = reinterpret_cast<TCanvas*> (gROOT->GetListOfCanvases()->FindObject("c1"));
 
703
 
 
704
  triplets->SetMarkerStyle(20);
 
705
  triplets->SetMarkerColor(kBlue);
 
706
  triplets_copy->SetMarkerStyle(20);
 
707
  triplets_copy->SetMarkerColor(kBlue);
 
708
  duplets->SetMarkerStyle(20);
 
709
  duplets->SetMarkerColor(kRed);
 
710
  duplets_copy->SetMarkerStyle(20);
 
711
  duplets_copy->SetMarkerColor(kRed);
 
712
 
652
713
  c1->cd(1);
653
 
  _digits.Draw("channel","tracker==0 && station==1 && plane==0");
 
714
  _spacepoints.Draw("x:y>>duplets", "type==2 && tracker==0");
 
715
  duplets->Draw("same");
 
716
  _spacepoints.Draw("x:y>>triplets", "type==3 && tracker==0", "same");
 
717
  triplets->Draw("same");
 
718
  duplets->Reset();
 
719
  triplets->Reset();
 
720
  // draw all stations...
654
721
  c1->cd(2);
655
 
  _digits.Draw("channel","tracker==0 && station==1 && plane==1");
 
722
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==1");
 
723
  duplets_copy->Draw("same");
 
724
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==1", "same");
 
725
  triplets_copy->Draw("same");
 
726
  duplets_copy->Reset();
 
727
  triplets_copy->Reset();
656
728
  c1->cd(3);
657
 
  _digits.Draw("channel","tracker==0 && station==1 && plane==2");
 
729
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==2");
 
730
  duplets_copy->Draw("same");
 
731
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==2", "same");
 
732
  triplets_copy->Draw("same");
 
733
  duplets_copy->Reset();
 
734
  triplets_copy->Reset();
658
735
  c1->cd(4);
659
 
  _digits.Draw("channel","tracker==0 && station==2 && plane==0");
 
736
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==3");
 
737
  duplets_copy->Draw("same");
 
738
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==3", "same");
 
739
  triplets_copy->Draw("same");
 
740
  duplets_copy->Reset();
 
741
  triplets_copy->Reset();
660
742
  c1->cd(5);
661
 
  _digits.Draw("channel","tracker==0 && station==2 && plane==1");
 
743
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==4");
 
744
  duplets_copy->Draw("same");
 
745
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==4", "same");
 
746
  triplets_copy->Draw("same");
 
747
  duplets_copy->Reset();
 
748
  triplets_copy->Reset();
662
749
  c1->cd(6);
663
 
  _digits.Draw("channel","tracker==0 && station==2 && plane==2");
 
750
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==5");
 
751
  duplets_copy->Draw("same");
 
752
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==5", "same");
 
753
  triplets_copy->Draw("same");
 
754
  duplets_copy->Reset();
 
755
  triplets_copy->Reset();
 
756
*/
 
757
/*
664
758
  c1->cd(7);
665
 
  _digits.Draw("channel","tracker==0 && station==3 && plane==0");
 
759
  _spacepointscopy.Draw("type", "tracker==0");
 
760
*/
 
761
/*
666
762
  c1->cd(8);
667
 
  _digits.Draw("channel","tracker==0 && station==3 && plane==1");
 
763
  _spacepoints.Draw("x:y>>duplets", "type==2 && tracker==1");
 
764
  duplets->Draw("same");
 
765
  _spacepoints.Draw("x:y>>triplets", "type==3 && tracker==1", "same");
 
766
  triplets->Draw("same");
 
767
 
668
768
  c1->cd(9);
669
 
  _digits.Draw("channel","tracker==0 && station==3 && plane==2");
 
769
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==1");
 
770
  duplets_copy->Draw("same");
 
771
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==1", "same");
 
772
  triplets_copy->Draw("same");
 
773
  duplets_copy->Reset();
 
774
  triplets_copy->Reset();
670
775
  c1->cd(10);
671
 
  _digits.Draw("channel","tracker==0 && station==4 && plane==0");
 
776
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==2");
 
777
  duplets_copy->Draw("same");
 
778
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==2", "same");
 
779
  triplets_copy->Draw("same");
 
780
  duplets_copy->Reset();
 
781
  triplets_copy->Reset();
672
782
  c1->cd(11);
673
 
  _digits.Draw("channel","tracker==0 && station==4 && plane==1");
 
783
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==3");
 
784
  duplets_copy->Draw("same");
 
785
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==3", "same");
 
786
  triplets_copy->Draw("same");
 
787
  duplets_copy->Reset();
 
788
  triplets_copy->Reset();
674
789
  c1->cd(12);
675
 
  _digits.Draw("channel","tracker==0 && station==4 && plane==2");
 
790
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==4");
 
791
  duplets_copy->Draw("same");
 
792
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==4", "same");
 
793
  triplets_copy->Draw("same");
 
794
  duplets_copy->Reset();
 
795
  triplets_copy->Reset();
676
796
  c1->cd(13);
677
 
  _digits.Draw("channel","tracker==0 && station==5 && plane==0");
 
797
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==5");
 
798
  duplets_copy->Draw("same");
 
799
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==5", "same");
 
800
  triplets_copy->Draw("same");
 
801
  duplets_copy->Reset();
 
802
  triplets_copy->Reset();
 
803
  c1->Update();
 
804
*/
 
805
/*  c1->cd(14);
 
806
  _spacepointscopy.Draw("type", "tracker==1");
 
807
  c1->Update();
 
808
  triplets_copy->Draw("same");
 
809
 
678
810
  c1->cd(14);
679
 
  _digits.Draw("channel","tracker==0 && station==5 && plane==1");
680
 
  c1->cd(15);
681
 
  _digits.Draw("channel","tracker==0 && station==5 && plane==2");
682
 
  c1->Update();
683
 
 
684
 
  c2->cd(1);
685
 
  _digits.Draw("channel","tracker==1 && station==1 && plane==0");
686
 
  c2->cd(2);
687
 
  _digits.Draw("channel","tracker==1 && station==1 && plane==1");
688
 
  c2->cd(3);
689
 
  _digits.Draw("channel","tracker==1 && station==1 && plane==2");
690
 
  c2->cd(4);
691
 
  _digits.Draw("channel","tracker==1 && station==2 && plane==0");
692
 
  c2->cd(5);
693
 
  _digits.Draw("channel","tracker==1 && station==2 && plane==1");
694
 
  c2->cd(6);
695
 
  _digits.Draw("channel","tracker==1 && station==2 && plane==2");
696
 
  c2->cd(7);
697
 
  _digits.Draw("channel","tracker==1 && station==3 && plane==0");
698
 
  c2->cd(8);
699
 
  _digits.Draw("channel","tracker==1 && station==3 && plane==1");
700
 
  c2->cd(9);
701
 
  _digits.Draw("channel","tracker==1 && station==3 && plane==2");
702
 
  c2->cd(10);
703
 
  _digits.Draw("channel","tracker==1 && station==4 && plane==0");
704
 
  c2->cd(11);
705
 
  _digits.Draw("channel","tracker==1 && station==4 && plane==1");
706
 
  c2->cd(12);
707
 
  _digits.Draw("channel","tracker==1 && station==4 && plane==2");
708
 
  c2->cd(13);
709
 
  _digits.Draw("channel","tracker==1 && station==5 && plane==0");
710
 
  c2->cd(14);
711
 
  _digits.Draw("channel","tracker==1 && station==5 && plane==1");
712
 
  c2->cd(15);
713
 
  _digits.Draw("channel","tracker==1 && station==5 && plane==2");
714
 
  c2->Update();
715
 
*/
716
 
  c3->cd(1);
717
 
  _spacepoints.Draw("x:y>>duplets", "type==2 && tracker==0");
718
 
  duplets->Draw("same");
719
 
  _spacepoints.Draw("x:y>>triplets", "type==3 && tracker==0", "same");
720
 
  triplets->Draw("same");
721
 
  // draw all stations...
722
 
  c3->cd(2);
723
 
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==1");
724
 
  duplets_copy->Draw("same");
725
 
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==1", "same");
726
 
  triplets_copy->Draw("same");
727
 
  c3->cd(3);
728
 
  _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==2");
729
 
  duplets_copy->Draw("same");
730
 
  _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==2", "same");
731
 
  triplets_copy->Draw("same");
732
 
  c3->cd(4);
733
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==3");
734
 
    duplets_copy->Draw("same");
735
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==3", "same");
736
 
    triplets_copy->Draw("same");
737
 
    c3->cd(5);
738
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==4");
739
 
    duplets_copy->Draw("same");
740
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==4", "same");
741
 
    triplets_copy->Draw("same");
742
 
    c3->cd(6);
743
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==0 && station==5");
744
 
    duplets_copy->Draw("same");
745
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==0 && station==5", "same");
746
 
    triplets_copy->Draw("same");
747
 
 
748
 
    c3->cd(7);
749
 
    _spacepointscopy.Draw("type", "tracker==0");
750
 
 
751
 
    c3->cd(8);
752
 
    _spacepoints.Draw("x:y>>duplets", "type==2 && tracker==1");
753
 
    duplets->Draw("same");
754
 
    _spacepoints.Draw("x:y>>triplets", "type==3 && tracker==1", "same");
755
 
    triplets->Draw("same");
756
 
 
757
 
    c3->cd(9);
758
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==1");
759
 
    duplets_copy->Draw("same");
760
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==1", "same");
761
 
    triplets_copy->Draw("same");
762
 
    c3->cd(10);
763
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==2");
764
 
    duplets_copy->Draw("same");
765
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==2", "same");
766
 
    triplets_copy->Draw("same");
767
 
    c3->cd(11);
768
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==3");
769
 
    duplets_copy->Draw("same");
770
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==3", "same");
771
 
    triplets_copy->Draw("same");
772
 
    c3->cd(12);
773
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==4");
774
 
    duplets_copy->Draw("same");
775
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==4", "same");
776
 
    triplets_copy->Draw("same");
777
 
    c3->cd(13);
778
 
    _spacepointscopy.Draw("x:y>>duplets_copy", "type==2 && tracker==1 && station==5");
779
 
    duplets_copy->Draw("same");
780
 
    _spacepointscopy.Draw("x:y>>triplets_copy", "type==3 && tracker==1 && station==5", "same");
781
 
    triplets_copy->Draw("same");
782
 
    c3->cd(14);
783
 
    _spacepointscopy.Draw("type", "tracker==1");
784
 
    c3->Update();
785
 
/*
786
 
    c4->cd(1);
787
 
    _npe_plane0->Draw();
788
 
    c4->cd(2);
789
 
    _npe_plane1->Draw();
790
 
    c4->cd(3);
791
 
    _npe_plane2->Draw();
792
 
    c4->Update();
793
 
 
794
 
    c5->cd(1);
795
 
    _digits.Draw("time");
796
 
    // c5_1->SetLogy(1);
797
 
    // c5_1->SetGrid(1,1);
798
 
    // _unpacked.Draw("adc", "bank==0 || bank==2 || bank==5 ||
799
 
    // bank==7 || bank==9|| bank==10|| bank==11 ||bank==12 ||
800
 
    // bank==13|| bank==14");
801
 
    c5->Update();
802
 
 
803
 
    c6->cd(1);
804
 
    _adc_plane0->Draw();
805
 
    c6->cd(2);
806
 
    _adc_plane1->Draw();
807
 
    c6->cd(3);
808
 
    _adc_plane2->Draw();
809
 
    c6->cd(4);
810
 
    _dig_npe_plane0->Draw();
811
 
    c6->cd(5);
812
 
    _dig_npe_plane1->Draw();
813
 
    c6->cd(6);
814
 
    _dig_npe_plane2->Draw();
815
 
    c6->Update();
816
 
 
817
 
  // Display spacepoints type.
818
 
    c2->cd(1);
819
 
    _spacepoints.Draw("type", "tracker==0 && station==1 ");
820
 
    c2->Update();
821
 
    c2->cd(2);
822
 
    _spacepoints.Draw("type", "tracker==0 && station==2 ");
823
 
    c2->Update();
824
 
    c2->cd(3);
825
 
    _spacepoints.Draw("type", "tracker==0 && station==3 ");
826
 
    c2->Update();
827
 
    c2->cd(4);
828
 
    _spacepoints.Draw("type", "tracker==0 && station==4 ");
829
 
    c2->Update();
830
 
    c2->cd(5);
831
 
    _spacepoints.Draw("type", "tracker==0 && station==5 ");
832
 
    c2->Update();
833
 
    // tracker 1
834
 
    c2->cd(6);
835
 
    _spacepoints.Draw("type", "tracker==1 && station==1 ");
836
 
    c2->Update();
837
 
    c2->cd(7);
838
 
    _spacepoints.Draw("type", "tracker==1 && station==2 ");
839
 
    c2->Update();
840
 
    c2->cd(8);
841
 
    _spacepoints.Draw("type", "tracker==1 && station==3 ");
842
 
    c2->Update();
843
 
    c2->cd(9);
844
 
    _spacepoints.Draw("type", "tracker==1 && station==4 ");
845
 
    c2->Update();
846
 
    c2->cd(10);
847
 
    _spacepoints.Draw("type", "tracker==1 && station==5 ");
848
 
    c2->Update();
849
 
 
850
 
  // Display efficiency.
851
 
 
852
 
    c3->cd(1);
853
 
    _events.Draw("station_hits", "tracker==0");
854
 
    c3->cd(2);
855
 
    _events.Draw("station_hits", "tracker==1");
856
 
*/
 
811
  _spacepointscopy.Draw("type", "tracker==1");
 
812
*/
 
813
  // c1->Update();
857
814
}
858