Hall C ROOT/C++ Analyzer (hcana)
THcShower.cxx
Go to the documentation of this file.
1 
8 #include "THcShower.h"
9 #include "THcHallCSpectrometer.h"
10 #include "THaEvData.h"
11 #include "THaDetMap.h"
12 #include "THcDetectorMap.h"
13 #include "THcGlobals.h"
14 #include "THaCutList.h"
15 #include "THcParmList.h"
16 #include "VarDef.h"
17 #include "VarType.h"
18 #include "THaTrack.h"
19 #include "TClonesArray.h"
20 #include "THaTrackProj.h"
21 #include "TMath.h"
22 #include "Helper.h"
23 
24 #include <cstring>
25 #include <cstdio>
26 #include <cstdlib>
27 #include <iostream>
28 #include <numeric>
29 #include <cassert>
30 
31 using namespace std;
32 
33 //_____________________________________________________________________________
34 THcShower::THcShower( const char* name, const char* description,
35  THaApparatus* apparatus ) :
36  THaNonTrackingDetector(name,description,apparatus),
37  fPosAdcTimeWindowMin(0), fNegAdcTimeWindowMin(0),
38  fPosAdcTimeWindowMax(0), fNegAdcTimeWindowMax(0),
39  fPedPosDefault(0),fPedNegDefault(0),
40  fShPosPedLimit(0), fShNegPedLimit(0), fPosGain(0), fNegGain(0),
41  fClusterList(0), fLayerNames(0), fLayerZPos(0), BlockThick(0),
42  fNBlocks(0), fXPos(0), fYPos(0), fZPos(0), fPlanes(0), fArray(0)
43 {
44  // Constructor
45  fNLayers = 0; // No layers until we make them
46  fNTotLayers = 0;
47  fHasArray = 0;
48 
50 }
51 
52 //_____________________________________________________________________________
54  THaNonTrackingDetector(),
55  fPosAdcTimeWindowMin(0), fNegAdcTimeWindowMin(0),
56  fPosAdcTimeWindowMax(0), fNegAdcTimeWindowMax(0),
57  fPedPosDefault(0),fPedNegDefault(0),
58  fShPosPedLimit(0), fShNegPedLimit(0), fPosGain(0), fNegGain(0),
59  fClusterList(0), fLayerNames(0), fLayerZPos(0), BlockThick(0),
60  fNBlocks(0), fXPos(0), fYPos(0), fZPos(0), fPlanes(0), fArray(0)
61 {
62  // Constructor
63 }
64 
65 //_____________________________________________________________________________
66 void THcShower::Setup(const char* name, const char* description)
67 {
68  char prefix[2];
69 
70  prefix[0] = tolower(GetApparatus()->GetName()[0]);
71  prefix[1] = '\0';
72 
73 
74  string layernamelist;
75  fHasArray = 0; // Flag for presence of fly's eye array
76  DBRequest list[]={
77  {"cal_num_layers", &fNLayers, kInt},
78  {"cal_layer_names", &layernamelist, kString},
79  {"cal_array",&fHasArray, kInt,0, 1},
80  {"cal_adcrefcut", &fADC_RefTimeCut, kInt, 0, 1},
81  {0}
82  };
83 
84  fADC_RefTimeCut = 0;
85  gHcParms->LoadParmValues((DBRequest*)&list,prefix);
86  fNTotLayers = (fNLayers+(fHasArray!=0?1:0));
87  vector<string> layer_names = Podd::vsplit(layernamelist);
88 
89  if(layer_names.size() != fNTotLayers) {
90  cout << "THcShower::Setup ERROR: Number of layers " << fNTotLayers
91  << " doesn't agree with number of layer names "
92  << layer_names.size() << endl;
93  // Should quit. Is there an official way to quit?
94  }
95 
96  fLayerNames = new char* [fNTotLayers];
97  for(UInt_t i=0;i<fNTotLayers;i++) {
98  fLayerNames[i] = new char[layer_names[i].length()+1];
99  strcpy(fLayerNames[i], layer_names[i].c_str());
100  }
101 
102  char *desc = new char[strlen(description)+100];
104 
105  for(UInt_t i=0;i < fNLayers;i++) {
106  strcpy(desc, description);
107  strcat(desc, " Plane ");
108  strcat(desc, fLayerNames[i]);
109 
110  fPlanes[i] = new THcShowerPlane(fLayerNames[i], desc, i+1, this);
111 
112  }
113  if(fHasArray) {
114  strcpy(desc, description);
115  strcat(desc, " Array ");
116  strcat(desc, fLayerNames[fNTotLayers-1]);
117 
118  fArray = new THcShowerArray(fLayerNames[fNTotLayers-1], desc, fNTotLayers,
119  this);
120  } else {
121  fArray = 0;
122  }
123 
124  delete [] desc;
125 
126  // cout << "---------------------------------------------------------------\n";
127 
128  cout << "From THcShower::Setup: created Shower planes for "
129  << GetApparatus()->GetName() << ": ";
130 
131  for(UInt_t i=0;i < fNTotLayers;i++) {
132  cout << fLayerNames[i];
133  i < fNTotLayers-1 ? cout << ", " : cout << ".\n";
134  }
135 
136  // if(fHasArray)
137  // cout << fLayerNames[fNTotLayers-1] << " has fly\'s eye configuration\n";
138 
139  // cout << "---------------------------------------------------------------\n";
140 
141 }
142 
143 
144 //_____________________________________________________________________________
145 THaAnalysisObject::EStatus THcShower::Init( const TDatime& date )
146 {
147  Setup(GetName(), GetTitle());
148 
149  char EngineDID[] = "xCAL";
150  EngineDID[0] = toupper(GetApparatus()->GetName()[0]);
151  if( gHcDetectorMap->FillMap(fDetMap, EngineDID) < 0 ) {
152  static const char* const here = "Init()";
153  Error( Here(here), "Error filling detectormap for %s.", EngineDID );
154  return kInitError;
155  }
156 
157  // Should probably put this in ReadDatabase as we will know the
158  // maximum number of hits after setting up the detector map
159 
160  InitHitList(fDetMap, "THcRawShowerHit", fDetMap->GetTotNumChan()+1,
161  0, fADC_RefTimeCut);
162 
163  EStatus status;
164  if( (status = THaNonTrackingDetector::Init( date )) )
165  return fStatus=status;
166 
167  for(UInt_t ip=0;ip<fNLayers;ip++) {
168  if((status = fPlanes[ip]->Init( date ))) {
169  return fStatus=status;
170  }
171  }
172  if(fHasArray) {
173  if((status = fArray->Init( date ))) {
174  return fStatus = status;
175  }
176  }
177 
178  if(fHasArray) {
179  // cout << "THcShower::Init: adjustment of fiducial volume limits to the fly's eye part." << endl;
180  // cout << " Old limits:" << endl;
181  // cout << " Xmin = " << fvXmin << " Xmax = " << fvXmax << endl;
182  // cout << " Ymin = " << fvYmin << " Ymax = " << fvYmax << endl;
184  fvXmax = TMath::Min(fvXmax, fArray->fvXmax());
185  fvYmin = TMath::Max(fvYmin, fArray->fvYmin());
186  fvYmax = TMath::Min(fvYmax, fArray->fvYmax());
187  // cout << " New limits:" << endl;
188  // cout << " Xmin = " << fvXmin << " Xmax = " << fvXmax << endl;
189  // cout << " Ymin = " << fvYmin << " Ymax = " << fvYmax << endl;
190  }
191 
192  // cout << "---------------------------------------------------------------\n";
193  // cout << "From THcShower::Init: initialized " << GetApparatus()->GetName()
194  // << GetName() << endl;
195  // cout << "---------------------------------------------------------------\n";
196 
197  fPresentP = 0;
198  THaVar* vpresent = gHaVars->Find(Form("%s.present",GetApparatus()->GetName()));
199  if(vpresent) {
200  fPresentP = (Bool_t *) vpresent->GetValuePointer();
201  }
202  return fStatus = kOK;
203 }
204 
205 //_____________________________________________________________________________
207 {
208  // Read this detector's parameters from the database file 'fi'.
209  // This function is called by THaDetectorBase::Init() once at the
210  // beginning of the analysis.
211  // 'date' contains the date/time of the run being analyzed.
212 
213  // static const char* const here = "ReadDatabase()";
214  char prefix[2];
215 
216  // Read data from database
217  // Pull values from the THcParmList instead of reading a database
218  // file like Hall A does.
219 
220  // We will probably want to add some kind of method to gHcParms to allow
221  // bulk retrieval of parameters of interest.
222 
223  // Will need to determine which spectrometer in order to construct
224  // the parameter names (e.g. hscin_1x_nr vs. sscin_1x_nr)
225 
226  prefix[0]=tolower(GetApparatus()->GetName()[0]);
227  prefix[1]='\0';
228 
229  CreateMissReportParms(Form("%scal",prefix));
230 
231  fNegCols = fNLayers; // If not defined assume tube on each end
232  // for every layer
233  {
234  DBRequest list[]={
235  {"cal_num_neg_columns", &fNegCols, kInt, 0, 1},
236  {"cal_slop", &fSlop, kDouble,0,1},
237  {"cal_fv_test", &fvTest, kInt,0,1},
238  {"cal_fv_delta", &fvDelta, kDouble,0,1},
239  {"cal_ADCMode", &fADCMode, kInt, 0, 1},
240  {"cal_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1},
241  {"dbg_raw_cal", &fdbg_raw_cal, kInt, 0, 1},
242  {"dbg_decoded_cal", &fdbg_decoded_cal, kInt, 0, 1},
243  {"dbg_sparsified_cal", &fdbg_sparsified_cal, kInt, 0, 1},
244  {"dbg_clusters_cal", &fdbg_clusters_cal, kInt, 0, 1},
245  {"dbg_tracks_cal", &fdbg_tracks_cal, kInt, 0, 1},
246  {"dbg_init_cal", &fdbg_init_cal, kInt, 0, 1},
247  {0}
248  };
249  fvTest = 0; // Default if not defined
250  fdbg_raw_cal = 0; // Debugging off by default
251  fdbg_decoded_cal = 0;
253  fdbg_clusters_cal = 0;
254  fdbg_tracks_cal = 0;
255  fdbg_init_cal = 0;
256  fAdcTdcOffset=0.0;
258  gHcParms->LoadParmValues((DBRequest*)&list, prefix);
259  }
260 
261  // Debug output.
262  if (fdbg_init_cal) {
263  cout << "---------------------------------------------------------------\n";
264  cout << "Debug output from THcShower::ReadDatabase for "
265  << GetApparatus()->GetName() << endl;
266 
267  cout << " Number of neg. columns = " << fNegCols << endl;
268  cout << " Slop parameter = " << fSlop << endl;
269  cout << " Fiducial volume test flag = " << fvTest << endl;
270  cout << " Fiducial volume excl. width = " << fvDelta << endl;
271  cout << " Initialize debug flag = " << fdbg_init_cal << endl;
272  cout << " Raw hit debug flag = " << fdbg_raw_cal << endl;
273  cout << " Decode debug flag = " << fdbg_decoded_cal << endl;
274  cout << " Sparsify debug flag = " << fdbg_sparsified_cal << endl;
275  cout << " Cluster debug flag = " << fdbg_clusters_cal << endl;
276  cout << " Tracking debug flag = " << fdbg_tracks_cal << endl;
277  }
278 
279  {
280  DBRequest list[]={
281  {"cal_a_cor", &fAcor, kDouble},
282  {"cal_b_cor", &fBcor, kDouble},
283  {"cal_c_cor", fCcor, kDouble, 2},
284  {"cal_d_cor", fDcor, kDouble, 2},
285  {0}
286  };
287  gHcParms->LoadParmValues((DBRequest*)&list, prefix);
288  }
289 
290  // Debug output.
291  if (fdbg_init_cal) {
292  cout << " Coordinate correction constants:\n";
293  cout << " fAcor = " << fAcor << endl;
294  cout << " fBcor = " << fBcor << endl;
295  cout << " fCcor = " << fCcor[0] << ", " << fCcor[1] << endl;
296  cout << " fDcor = " << fDcor[0] << ", " << fDcor[1] << endl;
297  }
298 
299  BlockThick = new Double_t [fNLayers];
300  fNBlocks = new UInt_t [fNLayers];
301  fLayerZPos = new Double_t [fNLayers];
302  fYPos = new Double_t [2*fNLayers];
303 
304  for(UInt_t i=0;i<fNLayers;i++) {
305  DBRequest list[]={
306  {Form("cal_%s_thick",fLayerNames[i]), &BlockThick[i], kDouble},
307  {Form("cal_%s_nr",fLayerNames[i]), &fNBlocks[i], kInt},
308  {Form("cal_%s_zpos",fLayerNames[i]), &fLayerZPos[i], kDouble},
309  {Form("cal_%s_right",fLayerNames[i]), &fYPos[2*i], kDouble},
310  {Form("cal_%s_left",fLayerNames[i]), &fYPos[2*i+1], kDouble},
311  {0}
312  };
313  gHcParms->LoadParmValues((DBRequest*)&list, prefix);
314  }
315 
316  //Caution! Z positions (fronts) are off in hcal.param! Correct later on.
317 
318  fXPos = new Double_t* [fNLayers];
319  for(UInt_t i=0;i<fNLayers;i++) {
320  fXPos[i] = new Double_t [fNBlocks[i]];
321  DBRequest list[]={
322  {Form("cal_%s_top",fLayerNames[i]),fXPos[i], kDouble, fNBlocks[i]},
323  {0}
324  };
325  gHcParms->LoadParmValues((DBRequest*)&list, prefix);
326  }
327 
328  // Debug output.
329  if (fdbg_init_cal) {
330  for(UInt_t i=0;i<fNLayers;i++) {
331  cout << " Plane " << fLayerNames[i] << ":" << endl;
332  cout << " Block thickness: " << BlockThick[i] << endl;
333  cout << " NBlocks : " << fNBlocks[i] << endl;
334  cout << " Z Position : " << fLayerZPos[i] << endl;
335  cout << " Y Positions : " << fYPos[2*i] << ", " << fYPos[2*i+1]
336  <<endl;
337  cout << " X Positions :";
338  for(UInt_t j=0; j<fNBlocks[i]; j++) {
339  cout << " " << fXPos[i][j];
340  }
341  cout << endl;
342  }
343  }
344 
345  // Fiducial volume limits, based on Plane 1 positions.
346  //
347 
348  fvXmin = fXPos[0][0] + fvDelta;
349  fvXmax = fXPos[0][fNBlocks[0]-1] + BlockThick[0] - fvDelta;
350  fvYmin = fYPos[0] + fvDelta;
351  fvYmax = fYPos[1] - fvDelta;
352 
353  // Debug output.
354  if (fdbg_init_cal) {
355  cout << " Fiducial volume limits:" << endl;
356  cout << " Xmin = " << fvXmin << " Xmax = " << fvXmax << endl;
357  cout << " Ymin = " << fvYmin << " Ymax = " << fvYmax << endl;
358  }
359 
360  //Calibration related parameters (from h(s)cal.param).
361 
362  fNTotBlocks=0; //total number of blocks in the layers
363  for (UInt_t i=0; i<fNLayers; i++) fNTotBlocks += fNBlocks[i];
364 
365  // Debug output.
366  if (fdbg_init_cal)
367  cout << " Total number of blocks in the layers of calorimeter: " << dec
368  << fNTotBlocks << endl;
369 
370  //Pedestal limits from hcal.param.
373  for (UInt_t i=0; i<fNTotBlocks; i++) {
374  fShPosPedLimit[i]=0.;
375  fShNegPedLimit[i]=0.;
376  }
377 
378  //Calibration constants
379  fPosGain = new Double_t [fNTotBlocks];
380  fNegGain = new Double_t [fNTotBlocks];
381 
382  //Read in parameters from hcal.param
383  Double_t hcal_pos_cal_const[fNTotBlocks];
384  Double_t hcal_pos_gain_cor[fNTotBlocks];
385 
386  Double_t hcal_neg_cal_const[fNTotBlocks];
387  Double_t hcal_neg_gain_cor[fNTotBlocks];
388 
395 
396  DBRequest list[]={
397  {"cal_pos_cal_const", hcal_pos_cal_const, kDouble, fNTotBlocks},
398  {"cal_pos_ped_limit", fShPosPedLimit, kInt, fNTotBlocks,1},
399  {"cal_pos_gain_cor", hcal_pos_gain_cor, kDouble, fNTotBlocks},
400  {"cal_neg_cal_const", hcal_neg_cal_const, kDouble, fNTotBlocks},
401  {"cal_neg_ped_limit", fShNegPedLimit, kInt, fNTotBlocks,1},
402  {"cal_neg_gain_cor", hcal_neg_gain_cor, kDouble, fNTotBlocks},
403  {"cal_pos_AdcTimeWindowMin", fPosAdcTimeWindowMin, kDouble, static_cast<UInt_t>(fNTotBlocks),1},
404  {"cal_neg_AdcTimeWindowMin", fNegAdcTimeWindowMin, kDouble, static_cast<UInt_t>(fNTotBlocks),1},
405  {"cal_pos_AdcTimeWindowMax", fPosAdcTimeWindowMax, kDouble, static_cast<UInt_t>(fNTotBlocks),1},
406  {"cal_neg_AdcTimeWindowMax", fNegAdcTimeWindowMax, kDouble, static_cast<UInt_t>(fNTotBlocks),1},
407  {"cal_PedNegDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNTotBlocks),1},
408  {"cal_PedPosDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNTotBlocks),1},
409  {"cal_min_peds", &fShMinPeds, kInt,0,1},
410  {0}
411  };
412  fShMinPeds=0.;
413 
414  for(UInt_t ip=0;ip<fNTotBlocks;ip++) {
415  fPosAdcTimeWindowMin[ip] = -1000.;
416  fNegAdcTimeWindowMin[ip] = -1000.;
417  fPosAdcTimeWindowMax[ip] = 1000.;
418  fNegAdcTimeWindowMax[ip] = 1000.;
419  fPedNegDefault[ip] = 0;
420  fPedPosDefault[ip] = 0;
421  }
422 
423  gHcParms->LoadParmValues((DBRequest*)&list, prefix);
424 
425  // Debug output.
426  if (fdbg_init_cal) {
427 
428  cout << " hcal_pos_cal_const:" << endl;
429  for (UInt_t j=0; j<fNLayers; j++) {
430  cout << " ";
431  for (UInt_t i=0; i<fNBlocks[j]; i++) {
432  cout << hcal_pos_cal_const[j*fNBlocks[j]+i] << " ";
433  };
434  cout << endl;
435  };
436 
437  cout << " fShPosPedLimit:" << endl;
438  for (UInt_t j=0; j<fNLayers; j++) {
439  cout << " ";
440  for (UInt_t i=0; i<fNBlocks[j]; i++) {
441  cout << fShPosPedLimit[j*fNBlocks[j]+i] << " ";
442  };
443  cout << endl;
444  };
445 
446  cout << " hcal_pos_gain_cor:" << endl;
447  for (UInt_t j=0; j<fNLayers; j++) {
448  cout << " ";
449  for (UInt_t i=0; i<fNBlocks[j]; i++) {
450  cout << hcal_pos_gain_cor[j*fNBlocks[j]+i] << " ";
451  };
452  cout << endl;
453  };
454 
455  cout << " hcal_neg_cal_const:" << endl;
456  for (UInt_t j=0; j<fNLayers; j++) {
457  cout << " ";
458  for (UInt_t i=0; i<fNBlocks[j]; i++) {
459  cout << hcal_neg_cal_const[j*fNBlocks[j]+i] << " ";
460  };
461  cout << endl;
462  };
463 
464  cout << " fShNegPedLimit:" << endl;
465  for (UInt_t j=0; j<fNLayers; j++) {
466  cout << " ";
467  for (UInt_t i=0; i<fNBlocks[j]; i++) {
468  cout << fShNegPedLimit[j*fNBlocks[j]+i] << " ";
469  };
470  cout << endl;
471  };
472 
473  cout << " hcal_neg_gain_cor:" << endl;
474  for (UInt_t j=0; j<fNLayers; j++) {
475  cout << " ";
476  for (UInt_t i=0; i<fNBlocks[j]; i++) {
477  cout << hcal_neg_gain_cor[j*fNBlocks[j]+i] << " ";
478  };
479  cout << endl;
480  };
481 
482  } // end of debug output
483 
484  // Calibration constants (GeV / ADC channel).
485 
486  for (UInt_t i=0; i<fNTotBlocks; i++) {
487  fPosGain[i] = hcal_pos_cal_const[i] * hcal_pos_gain_cor[i];
488  fNegGain[i] = hcal_neg_cal_const[i] * hcal_neg_gain_cor[i];
489  }
490 
491  // Debug output.
492  if (fdbg_init_cal) {
493 
494  cout << " fPosGain:" << endl;
495  for (UInt_t j=0; j<fNLayers; j++) {
496  cout << " ";
497  for (UInt_t i=0; i<fNBlocks[j]; i++) {
498  cout << fPosGain[j*fNBlocks[j]+i] << " ";
499  };
500  cout << endl;
501  };
502 
503  cout << " fNegGain:" << endl;
504  for (UInt_t j=0; j<fNLayers; j++) {
505  cout << " ";
506  for (UInt_t i=0; i<fNBlocks[j]; i++) {
507  cout << fNegGain[j*fNBlocks[j]+i] << " ";
508  };
509  cout << endl;
510  };
511 
512  }
513 
514  // Origin of the calorimeter, at the centre of the face of the detector,
515  // or at the centre of the front of the 1-st layer.
516  //
517  Double_t xOrig = (fXPos[0][0] + fXPos[0][fNBlocks[0]-1])/2 + BlockThick[0]/2;
518  Double_t yOrig = (fYPos[0] + fYPos[1])/2;
519  Double_t zOrig = fLayerZPos[0];
520 
521  fOrigin.SetXYZ(xOrig, yOrig, zOrig);
522 
523  // Debug output.
524  if (fdbg_init_cal) {
525  cout << " Origin of the Calorimeter:" << endl;
526  cout << " Xorig = " << GetOrigin().X() << endl;
527  cout << " Yorig = " << GetOrigin().Y() << endl;
528  cout << " Zorig = " << GetOrigin().Z() << endl;
529  cout << "---------------------------------------------------------------\n";
530  }
531 
532  // Detector axes. Assume no rotation.
533  //
534  DefineAxes(0.);
535 
536  fIsInit = true;
537 
538  return kOK;
539 }
540 
541 
542 //_____________________________________________________________________________
544 {
545  // Initialize global variables and lookup table for decoder
546 
547  if( mode == kDefine && fIsSetup ) return kOK;
548  fIsSetup = ( mode == kDefine );
549 
550  // Register variables in global list
551 
552  RVarDef vars[] = {
553  { "nhits", "Number of hits", "fNhits" },
554  { "nclust", "Number of layer clusters", "fNclust" },
555  { "nclusttrack", "Number of layer cluster which matched best track","fNclustTrack" },
556  { "xclusttrack", "X pos of layer cluster which matched best track","fXclustTrack" },
557  { "xtrack", "X pos of track which matched layer cluster", "fXTrack" },
558  { "yclusttrack", "Y pos of layer cluster which matched best track","fYclustTrack" },
559  { "ytrack", "Y pos of track which matched layer cluster", "fYTrack" },
560  { "etot", "Total energy", "fEtot" },
561  { "etotnorm", "Total energy divided by Central Momentum", "fEtotNorm" },
562  { "etrack", "Track energy", "fEtrack" },
563  { "etracknorm", "Total energy divided by track momentum", "fEtrackNorm" },
564  { "eprtrack", "Track Preshower energy", "fEPRtrack" },
565  { "eprtracknorm", "Preshower energy divided by track momentum", "fEPRtrackNorm" },
566  { "etottracknorm", "Total energy divided by track momentum", "fETotTrackNorm" },
567  { "ntracks", "Number of shower tracks", "fNtracks" },
568  { 0 }
569  };
570 
571  if(fHasArray) {
572 
573  RVarDef array_vars[] = {
574  { "sizeclustarray", "Number of block in array cluster that matches track", "fSizeClustArray" },
575  { "nclustarraytrack", "Number of cluster for Fly's eye which matched best track","fNclustArrayTrack" },
576  { "nblock_high_ene", "Block number in array with highest energy which matched best track","fNblockHighEnergy" },
577  { "xclustarraytrack", "X pos of cluster which matched best track","fXclustArrayTrack" },
578  { "xtrackarray", "X pos of track which matched cluster", "fXTrackArray" },
579  { "yclustarraytrack", "Y pos of cluster which matched best track","fYclustArrayTrack" },
580  { "ytrackarray", "Y pos of track which matched cluster", "fYTrackArray" },
581  { 0 }
582  };
583 
584  DefineVarsFromList( array_vars, mode );
585  }
586  return DefineVarsFromList( vars, mode );
587 
588 }
589 
590 //_____________________________________________________________________________
592 {
593  // Destructor. Remove variables from global list.
594 
595  Clear();
596  if( fIsSetup )
597  RemoveVariables();
598  if( fIsInit )
599  DeleteArrays();
600 
601  for (THcShowerClusterListIt i=fClusterList->begin(); i!=fClusterList->end();
602  ++i) {
603  Podd::DeleteContainer(**i);
604  delete *i;
605  }
606  delete fClusterList; fClusterList = 0;
607 
608  for( UInt_t i = 0; i<fNLayers; ++i) {
609  delete fPlanes[i];
610  }
611  delete [] fPlanes; fPlanes = 0;
612  delete fArray; fArray = 0;
613 }
614 
615 //_____________________________________________________________________________
617 {
618  // Delete member arrays. Used by destructor.
619 
620  for (UInt_t i = 0; i<fNTotLayers; ++i)
621  delete [] fLayerNames[i];
622  delete [] fLayerNames; fLayerNames = 0;
623 
628  delete [] fPedNegDefault; fPedNegDefault = 0;
629  delete [] fPedPosDefault; fPedPosDefault = 0;
630  delete [] fShPosPedLimit; fShPosPedLimit = 0;
631  delete [] fShNegPedLimit; fShNegPedLimit = 0;
632  delete [] fPosGain; fPosGain = 0;
633  delete [] fNegGain; fNegGain = 0;
634  delete [] BlockThick; BlockThick = NULL;
635  delete [] fNBlocks; fNBlocks = NULL;
636  delete [] fLayerZPos; fLayerZPos = NULL;
637  for (UInt_t i = 0; i<fNLayers; ++i)
638  delete [] fXPos[i];
639  delete [] fXPos; fXPos = NULL;
640  delete [] fYPos; fYPos = NULL;
641  delete [] fZPos; fZPos = NULL;
642 }
643 
644 //_____________________________________________________________________________
645 inline
647 {
648 
649 // Reset per-event data.
650 
651  for(UInt_t ip=0;ip<fNLayers;ip++) {
652  fPlanes[ip]->Clear(opt);
653  }
654  if(fHasArray) {
655  fArray->Clear(opt);
656  }
657 
658  fNhits = 0;
659  fNclust = 0;
660  fNclustTrack = -2;
661  fXclustTrack = -1000;
662  fXTrack = -1000;
663  fYclustTrack = -1000;
664  fYTrack = -1000;
665  fNclustArrayTrack = -2;
666  fXclustArrayTrack = -1000;
667  fXTrackArray = -1000;
668  fYclustArrayTrack = -1000;
669  fYTrackArray = -1000;
670  fNtracks = 0;
671  fEtot = 0.;
672  fEtotNorm = 0.;
673  fEtrack = 0.;
674  fEtrackNorm = 0.;
675  fEPRtrack = 0.;
676  fEPRtrackNorm = 0.;
677  fETotTrackNorm = 0.;
678  fSizeClustArray = 0;
679  fNblockHighEnergy = 0.;
680 
681  // Purge cluster list
682 
683  for (THcShowerClusterListIt i=fClusterList->begin(); i!=fClusterList->end();
684  ++i) {
685  Podd::DeleteContainer(**i);
686  delete *i;
687  }
688  fClusterList->clear();
689 }
690 
691 //_____________________________________________________________________________
693 {
694 
695  Clear();
696 
697  // Get the Hall C style hitlist (fRawHitList) for this event
698  Bool_t present = kTRUE; // Suppress reference time warnings
699  if(fPresentP) { // if this spectrometer not part of trigger
700  present = *fPresentP;
701  }
702  Int_t nhits = DecodeToHitList(evdata, !present);
703 
704  fEvent = evdata.GetEvNum();
705 
706  if(gHaCuts->Result("Pedestal_event")) {
707  Int_t nexthit = 0;
708  for(UInt_t ip=0;ip<fNLayers;ip++) {
709  nexthit = fPlanes[ip]->AccumulatePedestals(fRawHitList, nexthit);
710  }
711  if(fHasArray) {
712  nexthit = fArray->AccumulatePedestals(fRawHitList, nexthit);
713  }
714  fAnalyzePedestals = 1; // Analyze pedestals first normal events
715  return(0);
716  }
717 
718  if(fAnalyzePedestals) {
719  for(UInt_t ip=0;ip<fNLayers;ip++) {
721  }
722  if(fHasArray) {
724  }
725  fAnalyzePedestals = 0; // Don't analyze pedestals next event
726  }
727 
728  Int_t nexthit = 0;
729  for(UInt_t ip=0;ip<fNLayers;ip++) {
730  nexthit = fPlanes[ip]->ProcessHits(fRawHitList, nexthit);
731  }
732  if(fHasArray) {
733  nexthit = fArray->ProcessHits(fRawHitList, nexthit);
734  }
735 
736  return nhits;
737 }
738 
739 //_____________________________________________________________________________
741 {
742  // Calculation of coordinates of particle track cross point with shower
743  // plane in the detector coordinate system. For this, parameters of track
744  // reconstructed in THaVDC::CoarseTrack() are used.
745  //
746  // Apply corrections and reconstruct the complete hits.
747 
748  // Clustering of hits.
749  //
750 
751  // Fill set of unclustered hits.
752  for(UInt_t ip=0;ip<fNLayers;ip++) {
753  fPlanes[ip]->CoarseProcessHits();
754  fEtot += fPlanes[ip]->GetEplane();
755  }
756  if(fHasArray) {
758  fEtot += fArray->GetEarray();
759  }
760  THcHallCSpectrometer *app = static_cast<THcHallCSpectrometer*>(GetApparatus());
761  fEtotNorm=fEtot/(app->GetPcentral());
762  //
763  THcShowerHitSet HitSet;
764 
765  for(UInt_t j=0; j < fNLayers; j++) {
766 
767  for (UInt_t i=0; i<fNBlocks[j]; i++) {
768 
769  //
770  if (fPlanes[j]->GetAposP(i) > 0 || fPlanes[j]->GetAnegP(i) >0) { //hit
771 
772  Double_t Edep = fPlanes[j]->GetEmean(i);
773  Double_t Epos = fPlanes[j]->GetEpos(i);
774  Double_t Eneg = fPlanes[j]->GetEneg(i);
775  Double_t x = fXPos[j][i] + BlockThick[j]/2.; //top + thick/2
776  Double_t y=-1000;
777  if (fHasArray) {
778  if (Eneg>0) y = fYPos[2*j]/2 ;
779  if (Epos>0) y = fYPos[2*j+1]/2 ;
780  if (Epos>0 && Eneg>0) y = 0. ;
781  } else {
782  y=0.;
783  }
784  Double_t z = fLayerZPos[j] + BlockThick[j]/2.; //front + thick/2
785 
786  THcShowerHit* hit = new THcShowerHit(i,j,x,y,z,Edep,Epos,Eneg);
787 
788  HitSet.insert(hit); //<set> version
789  }
790 
791  }
792  }
793 
794  fNhits = HitSet.size();
795 
796  //Debug output, print out hits before clustering.
797 
798  if (fdbg_clusters_cal) {
799  cout << "---------------------------------------------------------------\n";
800  cout << "Debug output from THcShower::CoarseProcess for "
801  << GetApparatus()->GetName() << endl;
802 
803  cout << " event = " << fEvent << endl;
804  cout << " List of unclustered hits. Total hits: " << fNhits << endl;
805  THcShowerHitIt it = HitSet.begin(); //<set> version
806  for (Int_t i=0; i!=fNhits; i++) {
807  cout << " hit " << i << ": ";
808  (*(it++))->show();
809  }
810  }
811 
812  // Fill list of clusters.
813 
814  ClusterHits(HitSet, fClusterList);
815  assert( HitSet.empty() ); // else bug in ClusterHits()
816 
817  fNclust = (*fClusterList).size(); //number of clusters
818 
819  //Debug output, print out the cluster list.
820 
821  if (fdbg_clusters_cal) {
822 
823  cout << " event = " << fEvent << " Clustered hits. Number of clusters: " << fNclust << endl;
824 
825  UInt_t i = 0;
826  for (THcShowerClusterListIt ppcl = (*fClusterList).begin();
827  ppcl != (*fClusterList).end(); ++ppcl) {
828 
829  cout << " Cluster #" << i++
830  <<": E=" << clE(*ppcl)
831  << " Epr=" << clEpr(*ppcl)
832  << " X=" << clX(*ppcl)
833  << " Z=" << clZ(*ppcl)
834  << " size=" << (**ppcl).size()
835  << endl;
836 
837  Int_t j=0;
838  for (THcShowerClusterIt pph=(**ppcl).begin(); pph!=(**ppcl).end();
839  ++pph) {
840  cout << " hit " << j++ << ": ";
841  (**pph).show();
842  }
843 
844  }
845 
846  cout << "---------------------------------------------------------------\n";
847  }
848 
849  // Do same for Array.
850 
851  if(fHasArray) fArray->CoarseProcess(tracks);
852 
853  //
854  Int_t Ntracks = tracks.GetLast()+1; // Number of reconstructed tracks
855  Double_t save_energy=0;
856  for (Int_t itrk=0; itrk<Ntracks; itrk++) {
857 
858  THaTrack* theTrack = static_cast<THaTrack*>( tracks[itrk] );
859  // save_energy = GetShEnergy(theTrack);
860  save_energy = GetShEnergy(theTrack, fNLayers);
861  if (fHasArray) save_energy += fArray->GetShEnergy(theTrack);
862  theTrack->SetEnergy(save_energy);
863  } //over tracks
864 
865  //
866  return 0;
867 }
868 
869 //-----------------------------------------------------------------------------
870 
872  THcShowerClusterList* ClusterList) {
873 
874  // Collect hits from the HitSet into the clusters. The resultant clusters
875  // of hits are saved in the ClusterList.
876 
877  while (HitSet.size() != 0) {
878 
879  THcShowerCluster* cluster = new THcShowerCluster;
880 
881  THcShowerHitIt it = HitSet.end();
882  (*cluster).insert(*(--it)); //Move the last hit from the hit list
883  HitSet.erase(it); //into the 1st cluster
884 
885  bool clustered = true;
886 
887  while (clustered) { //Proceed while a hit is clustered
888 
889  clustered = false;
890 
891  for (THcShowerHitIt i=HitSet.begin(); i!=HitSet.end(); ++i) {
892 
893  for (THcShowerClusterIt k=(*cluster).begin(); k!=(*cluster).end();
894  ++k) {
895 
896  if ((**i).isNeighbour(*k)) {
897  (*cluster).insert(*i); //If the hit #i is neighbouring a hit
898  HitSet.erase(i); //in the cluster, then move it
899  //into the cluster.
900  clustered = true;
901  }
902 
903  if (clustered) break;
904  } //k
905 
906  if (clustered) break;
907  } //i
908 
909  } //while clustered
910 
911  ClusterList->push_back(cluster); //Put the cluster in the cluster list
912 
913  } //While hit_list not exhausted
914 
915 };
916 
917 //-----------------------------------------------------------------------------
918 
919 // Various helper functions to accumulate hit related quantities.
920 
922  return x + h->hitE();
923 }
924 
926  return x + h->hitE() * h->hitX();
927 }
928 
930  return x + h->hitE() * h->hitY();
931 }
932 
934  return x + h->hitE() * h->hitZ();
935 }
936 
938  return h->hitColumn() == 0 ? x + h->hitE() : x;
939 }
940 
942  return x + h->hitEpos();
943 }
944 
946  return x + h->hitEneg();
947 }
948 
949 // Y coordinate of center of gravity of cluster, calculated as hit energy
950 // weighted average. Put X out of the calorimeter (-100 cm), if there is no
951 // energy deposition in the cluster.
952 //
954  Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,addE);
955  return (Etot != 0. ?
956  accumulate((*cluster).begin(),(*cluster).end(),0.,addY)/Etot : -100.);
957 }
958 // X coordinate of center of gravity of cluster, calculated as hit energy
959 // weighted average. Put X out of the calorimeter (-100 cm), if there is no
960 // energy deposition in the cluster.
961 //
963  Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,addE);
964  return (Etot != 0. ?
965  accumulate((*cluster).begin(),(*cluster).end(),0.,addX)/Etot : -100.);
966 }
967 
968 // Z coordinate of center of gravity of cluster, calculated as a hit energy
969 // weighted average. Put Z out of the calorimeter (0 cm), if there is no energy
970 // deposition in the cluster.
971 //
973  Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,addE);
974  return (Etot != 0. ?
975  accumulate((*cluster).begin(),(*cluster).end(),0.,addZ)/Etot : 0.);
976 }
977 
978 //Energy depostion in a cluster
979 //
981  return accumulate((*cluster).begin(),(*cluster).end(),0.,addE);
982 }
983 
984 //Energy deposition in the Preshower (1st plane) for a cluster
985 //
987  return accumulate((*cluster).begin(),(*cluster).end(),0.,addEpr);
988 }
989 
990 //Cluster energy deposition in plane iplane=0,..,3:
991 // side=0 -- from positive PMTs only;
992 // side=1 -- from negative PMTs only;
993 // side=2 -- from postive and negative PMTs.
994 //
995 
996 Double_t clEplane(THcShowerCluster* cluster, Int_t iplane, Int_t side) {
997 
998  if (side!=0&&side!=1&&side!=2) {
999  cout << "*** Wrong Side in clEplane:" << side << " ***" << endl;
1000  return -1;
1001  }
1002 
1003  THcShowerHitSet pcluster;
1004  for (THcShowerHitIt it=(*cluster).begin(); it!=(*cluster).end(); ++it) {
1005  if ((*it)->hitColumn() == iplane) pcluster.insert(*it);
1006  }
1007 
1008  Double_t Eplane;
1009  switch (side) {
1010  case 0 :
1011  Eplane = accumulate(pcluster.begin(),pcluster.end(),0.,addEpos);
1012  break;
1013  case 1 :
1014  Eplane = accumulate(pcluster.begin(),pcluster.end(),0.,addEneg);
1015  break;
1016  case 2 :
1017  Eplane = accumulate(pcluster.begin(),pcluster.end(),0.,addE);
1018  break;
1019  default :
1020  Eplane = 0. ;
1021  }
1022 
1023  return Eplane;
1024 }
1025 
1026 //-----------------------------------------------------------------------------
1027 
1029  Double_t& XTrFront, Double_t& YTrFront)
1030 {
1031  // Match a cluster to a given track. Return the cluster number,
1032  // and track coordinates at the front of calorimeter.
1033 
1034  XTrFront = kBig;
1035  YTrFront = kBig;
1036  Double_t pathl = kBig;
1037 
1038  // Track interception with face of the calorimeter. The coordinates are
1039  // in the calorimeter's local system.
1040 
1041  fOrigin = fPlanes[0]->GetOrigin();
1042 
1043  CalcTrackIntercept(Track, pathl, XTrFront, YTrFront);
1044 
1045  // Transform coordiantes to the spectrometer's coordinate system.
1046 
1047  XTrFront += GetOrigin().X();
1048  YTrFront += GetOrigin().Y();
1049 
1050  Bool_t inFidVol = true; // In Fiducial Volume flag
1051 
1052  // Re-evaluate Fid. Volume Flag if fid. volume test is requested
1053 
1054  if (fvTest) {
1055 
1056  // Track coordinates at the back of the detector.
1057 
1058  // Origin at the front of the last layer.
1059  fOrigin = fPlanes[fNLayers-1]->GetOrigin();
1060 
1061  Double_t XTrBack = kBig;
1062  Double_t YTrBack = kBig;
1063 
1064  CalcTrackIntercept(Track, pathl, XTrBack, YTrBack);
1065 
1066  XTrBack += GetOrigin().X(); // from local coord. system
1067  YTrBack += GetOrigin().Y(); // to the spectrometer system
1068 
1069  inFidVol = (XTrFront <= fvXmax) && (XTrFront >= fvXmin) &&
1070  (YTrFront <= fvYmax) && (YTrFront >= fvYmin) &&
1071  (XTrBack <= fvXmax) && (XTrBack >= fvXmin) &&
1072  (YTrBack <= fvYmax) && (YTrBack >= fvYmin);
1073 
1074  }
1075 
1076  // Match a cluster to the track.
1077 
1078  Int_t mclust = -1; // The match cluster #, initialize with a bogus value.
1079  Double_t deltaX = kBig; // Track to cluster distance
1080 
1081  if (inFidVol) {
1082 
1083  // Since hits and clusters are in reverse order (with respect to Engine),
1084  // search backwards to be consistent with Engine.
1085  //
1086  for (Int_t i=fNclust-1; i>-1; i--) {
1087 
1088  THcShowerCluster* cluster = *(fClusterList->begin()+i);
1089 
1090  Double_t dx = TMath::Abs( clX(cluster) - XTrFront );
1091 
1092  if (dx <= (0.5*BlockThick[0] + fSlop)) {
1093  fNtracks++; // lumber of shower tracks (Consistent with engine)
1094  if (dx < deltaX) {
1095  mclust = i;
1096  deltaX = dx;
1097  }
1098  }
1099  }
1100  }
1101 
1102  //Debug output.
1103 
1104  if (fdbg_tracks_cal) {
1105  cout << "---------------------------------------------------------------\n";
1106  cout << "Debug output from THcShower::MatchCluster for "
1107  << GetApparatus()->GetName() << endl;
1108  cout << " event = " << fEvent << endl;
1109 
1110  cout << " Track at DC:"
1111  << " X = " << Track->GetX()
1112  << " Y = " << Track->GetY()
1113  << " Theta = " << Track->GetTheta()
1114  << " Phi = " << Track->GetPhi()
1115  << endl;
1116  cout << " Track at the front of Calorimeter:"
1117  << " X = " << XTrFront
1118  << " Y = " << YTrFront
1119  << " Pathl = " << pathl
1120  << endl;
1121  if (fvTest)
1122  cout << " Fiducial volume test: inFidVol = " << inFidVol << endl;
1123 
1124  cout << " Matched cluster #" << mclust << ", delatX= " << deltaX
1125  << endl;
1126  cout << "---------------------------------------------------------------\n";
1127  }
1128 
1129  return mclust;
1130 }
1131 
1132 //_____________________________________________________________________________
1134 
1135  // Get part of energy deposited in the cluster matched to the given
1136  // spectrometer Track, limited by range of layers from L0 to L0+NLayers-1.
1137 
1138  // Track coordinates at front of the calorimeter, initialize out of
1139  // acceptance.
1140  Double_t Xtr = -100.;
1141  Double_t Ytr = -100.;
1142 
1143  // Associate a cluster to the track.
1144 
1145  Int_t mclust = MatchCluster(Track, Xtr, Ytr);
1146 
1147  // Coordinate corrected total energy deposition in the cluster.
1148 
1149  Float_t Etrk = 0.;
1150  if (mclust >= 0) { // if there is a matched cluster
1151 
1152  // Get matched cluster.
1153 
1154  THcShowerCluster* cluster = *(fClusterList->begin()+mclust);
1155 
1156  char prefix = GetApparatus()->GetName()[0];
1157 
1158  // Correct track energy depositions for the impact coordinate.
1159 
1160  // for (UInt_t ip=0; ip<fNLayers; ip++) {
1161  for (UInt_t ip=L0; ip<L0+NLayers; ip++) {
1162 
1163  // Coordinate correction factors for positive and negative sides,
1164  // different for double PMT counters in the 1-st two HMS layes,
1165  // single PMT counters in the rear two HMS layers, and in the SHMS
1166  // Preshower.
1167  Float_t corpos = 1.;
1168  Float_t corneg = 1.;
1169 
1170  if (ip < fNegCols) {
1171  if (prefix == 'H') { //HMS 1-st 2 layers
1172  corpos = Ycor(Ytr,0);
1173  corneg = Ycor(Ytr,1);
1174  }
1175  else { //SHMS Preshower
1176  corpos = YcorPr(Ytr,0);
1177  corneg = YcorPr(Ytr,1);
1178  }
1179  }
1180  else {
1181  corpos = Ycor(Ytr);
1182  corneg = 0.;
1183  }
1184 
1185  // cout << ip << " clust energy pos = " << clEplane(cluster,ip,0)<< " clust energy neg = " << clEplane(cluster,ip,1) << endl;
1186  Etrk += clEplane(cluster,ip,0) * corpos;
1187  Etrk += clEplane(cluster,ip,1) * corneg;
1188 
1189  } //over planes
1190 
1191  } //mclust>=0
1192 
1193  //Debug output.
1194 
1195  if (fdbg_tracks_cal) {
1196  cout << "---------------------------------------------------------------\n";
1197  cout << "Debug output from THcShower::GetShEnergy for "
1198  << GetApparatus()->GetName() << endl;
1199  cout << " event = " << fEvent << endl;
1200 
1201  cout << " Track at the calorimeter: X = " << Xtr << " Y = " << Ytr;
1202  if (mclust >= 0)
1203  cout << ", matched cluster #" << mclust << "." << endl;
1204  else
1205  cout << ", no matched cluster found." << endl;
1206 
1207  cout << " Layers from " << L0+1 << " to " << L0+NLayers << ".\n";
1208  cout << " Coordinate corrected track energy = " << Etrk << "." << endl;
1209  cout << "---------------------------------------------------------------\n";
1210  }
1211 
1212  return Etrk;
1213 }
1214 
1215 //_____________________________________________________________________________
1217 {
1218 
1219  // Shower energy assignment to the spectrometer tracks.
1220  //
1221 
1222  Int_t Ntracks = tracks.GetLast()+1; // Number of reconstructed tracks
1223  Double_t Xtr = -100.;
1224  Double_t Ytr = -100.;
1225  for (Int_t itrk=0; itrk<Ntracks; itrk++) {
1226  THaTrack* theTrack = static_cast<THaTrack*>( tracks[itrk] );
1227  if (theTrack->GetIndex()==0) {
1228  fEtrack=theTrack->GetEnergy();
1229  fEtrackNorm=fEtrack/theTrack->GetP();
1230  fEPRtrack=GetShEnergy(theTrack,1);
1231  fEPRtrackNorm=fEPRtrack/theTrack->GetP();
1232  fETotTrackNorm=fEtot/theTrack->GetP();
1233  Xtr = -100.;
1234  Ytr = -100.;
1235  fNclustTrack = MatchCluster(theTrack, Xtr, Ytr);
1236  fXTrack=Xtr;
1237  fYTrack=Ytr;
1238  if (fNclustTrack>=0) {
1239  THcShowerCluster* cluster = *(fClusterList->begin()+fNclustTrack);
1240  fXclustTrack=clX(cluster);
1241  fYclustTrack=clY(cluster);
1242  }
1243  if (fHasArray) {
1244  fNclustArrayTrack = fArray->MatchCluster(theTrack,Xtr,Ytr);
1245  if (fNclustArrayTrack>=0) {
1250  fXTrackArray=Xtr;
1251  fYTrackArray=Ytr;
1252  }
1253  }
1254  }
1255  } //over tracks
1256 
1257  if (Ntracks>0) {
1258  for(UInt_t ip=0;ip<fNLayers;ip++) {
1259  fPlanes[ip]-> AccumulateStat(tracks);
1260  }
1261  if(fHasArray) fArray->AccumulateStat(tracks);
1262  }
1263 
1264  //Debug output.
1265 
1266  if (fdbg_tracks_cal) {
1267  cout << "---------------------------------------------------------------\n";
1268  cout << "Debug output from THcShower::FineProcess for "
1269  << GetApparatus()->GetName() << endl;
1270  cout << " event = " << fEvent << endl;
1271  cout << " Number of tracks = " << Ntracks << endl;
1272  if (fNclustTrack>=0) {
1273  cout << " matching cluster info " << endl;
1274  cout << " X info = " << fXclustTrack << " " << Xtr << " " << fXclustTrack-Xtr << endl;
1275  cout << " Y info = " << fYclustTrack << " " << Ytr << " " << fYclustTrack-Ytr << endl;
1276  }
1277 
1278  for (Int_t itrk=0; itrk<Ntracks; itrk++) {
1279  THaTrack* theTrack = static_cast<THaTrack*>( tracks[itrk] );
1280  cout << " Track " << itrk << ": "
1281  << " X = " << theTrack->GetX()
1282  << " Y = " << theTrack->GetY()
1283  << " Theta = " << theTrack->GetTheta()
1284  << " Phi = " << theTrack->GetPhi()
1285  << " Energy = " << theTrack->GetEnergy()
1286  << " Energy/Ptrack = " << fEtrackNorm << endl;
1287  }
1288 
1289  cout << "---------------------------------------------------------------\n";
1290  }
1291 
1292  return 0;
1293 }
1294 
1296  return fEtotNorm;
1297 }
1298 //_____________________________________________________________________________
1299 Int_t THcShower::End(THaRunBase* run)
1300 {
1301  MissReport(Form("%s.%s", GetApparatus()->GetName(), GetName()));
1302  return 0;
1303 }
1304 
Int_t fdbg_sparsified_cal
Definition: THcShower.h:270
Double_t * fPosGain
Definition: THcShower.h:212
std::string GetName(const std::string &scope_name)
Double_t fvXmax
Definition: THcShower.h:264
void DeleteArrays()
Definition: THcShower.cxx:616
virtual EStatus Init(const TDatime &run_time)
UInt_t fNTotBlocks
Definition: THcShower.h:254
virtual Int_t FillMap(THaDetMap *detmap, const char *detectorname)
Double_t fEPRtrackNorm
Definition: THcShower.h:238
Double_t fEPRtrack
Definition: THcShower.h:237
Int_t * fPedPosDefault
Definition: THcShower.h:201
Double_t GetEneg(Int_t i)
Double_t addE(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:921
Double_t fAcor
Definition: THcShower.h:276
Double_t GetClSize()
Double_t fAdcTdcOffset
Definition: THcShower.h:203
float Float_t
Double_t fXTrackArray
Definition: THcShower.h:228
Int_t GetLast() const
const char Option_t
Double_t addEneg(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:945
virtual void Clear(Option_t *opt="")
Definition: THcShower.cxx:646
void MissReport(const char *name)
Definition: THcHitList.cxx:557
THcShowerClusterList::iterator THcShowerClusterListIt
Definition: THcShowerHit.h:89
Double_t GetClMaxEnergyBlock()
Double_t * fNegAdcTimeWindowMax
Definition: THcShower.h:200
Int_t fNclust
Definition: THcShower.h:218
Double_t addY(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:929
Double_t * fLayerZPos
Definition: THcShower.h:250
Double_t clEplane(THcShowerCluster *cluster, Int_t iplane, Int_t side)
Definition: THcShower.cxx:996
Double_t GetEplane()
Double_t fETotTrackNorm
Definition: THcShower.h:239
vector< THcShowerCluster * > THcShowerClusterList
Definition: THcShowerHit.h:88
Double_t fEtot
Definition: THcShower.h:233
UInt_t GetEvNum() const
Float_t Ycor(Double_t y)
Definition: THcShower.h:139
Short_t Min(Short_t a, Short_t b)
int Int_t
bool Bool_t
Double_t fCcor[2]
Definition: THcShower.h:278
virtual Int_t Decode(const THaEvData &)
Definition: THcShower.cxx:692
Double_t GetNormETot()
Definition: THcShower.cxx:1295
Int_t fADCMode
Definition: THcShower.h:189
STL namespace.
Int_t fNtracks
Definition: THcShower.h:231
virtual Int_t ProcessHits(TClonesArray *rawhits, Int_t nexthit)
Double_t * fYPos
Definition: THcShower.h:256
TClonesArray * fRawHitList
Definition: THcHitList.h:51
friend class THcShowerPlane
Definition: THcShower.h:298
virtual Int_t AccumulatePedestals(TClonesArray *rawhits, Int_t nexthit)
Int_t fdbg_clusters_cal
Definition: THcShower.h:271
Short_t Abs(Short_t d)
Int_t * fShPosPedLimit
Definition: THcShower.h:207
UInt_t fNegCols
Definition: THcShower.h:258
Double_t fvYmax
Definition: THcShower.h:266
Double_t GetAnegP(Int_t i)
Double_t ** fXPos
Definition: THcShower.h:255
THcShowerCluster::iterator THcShowerClusterIt
Definition: THcShowerHit.h:82
THcShowerClusterList * fClusterList
Definition: THcShower.h:241
friend class THcShowerArray
Definition: THcShower.h:299
virtual Int_t CoarseProcess(TClonesArray &tracks)
Definition: THcShower.cxx:740
Double_t x[n]
Double_t fEtotNorm
Definition: THcShower.h:234
Double_t fYclustArrayTrack
Definition: THcShower.h:229
Double_t clEpr(THcShowerCluster *cluster)
Definition: THcShower.cxx:986
Double_t GetEmean(Int_t i)
Int_t fdbg_init_cal
Definition: THcShower.h:273
Double_t * fPosAdcTimeWindowMax
Definition: THcShower.h:199
Double_t * fNegGain
Definition: THcShower.h:213
virtual Int_t CoarseProcessHits()
Double_t * fZPos
Definition: THcShower.h:257
Int_t MatchCluster(THaTrack *, Double_t &, Double_t &)
Double_t fvYmin
Definition: THcShower.h:265
Float_t GetShEnergy(THaTrack *)
Float_t GetShEnergy(THaTrack *, UInt_t NLayers, UInt_t L0=0)
Definition: THcShower.cxx:1133
Double_t hitY()
Definition: THcShowerHit.h:46
tuple app
Bool_t * fPresentP
Definition: THcShower.h:187
virtual Int_t ProcessHits(TClonesArray *rawhits, Int_t nexthit)
virtual Int_t DefineVariables(EMode mode=kDefine)
Definition: THcShower.cxx:543
Double_t fDcor[2]
Definition: THcShower.h:279
Double_t * BlockThick
Definition: THcShower.h:252
Double_t clZ(THcShowerCluster *cluster)
Definition: THcShower.cxx:972
void Error(const char *location, const char *msgfmt,...)
char ** fLayerNames
Definition: THcShower.h:246
static const Int_t kADCDynamicPedestal
Definition: THcShower.h:194
Double_t fBcor
Definition: THcShower.h:277
Double_t fvDelta
Definition: THcShower.h:261
Int_t fShMinPeds
Definition: THcShower.h:210
virtual Int_t FineProcess(TClonesArray &tracks)
Definition: THcShower.cxx:1216
void InitHitList(THaDetMap *detmap, const char *hitclass, Int_t maxhits, Int_t tdcref_cut=0, Int_t adcref_cut=0)
Save the electronics module to detector mapping and initialize a hit array of hits of class hitclass...
Definition: THcHitList.cxx:65
Double_t clY(THcShowerCluster *cluster)
Definition: THcShower.cxx:953
Int_t fNclustArrayTrack
Definition: THcShower.h:220
Double_t addEpos(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:941
TVector3 GetOrigin()
Double_t GetClY()
Double_t fYTrack
Definition: THcShower.h:226
Double_t fvXmin
Definition: THcShower.h:263
void Setup(const char *name, const char *description)
Definition: THcShower.cxx:66
UInt_t * fNBlocks
Definition: THcShower.h:253
unsigned int UInt_t
char * Form(const char *fmt,...)
void CreateMissReportParms(const char *prefix)
Definition: THcHitList.cxx:544
UInt_t fNLayers
Definition: THcShower.h:247
virtual Int_t ReadDatabase(const TDatime &date)
Definition: THcShower.cxx:206
Float_t YcorPr(Double_t y, Int_t side)
Definition: THcShower.h:159
Int_t fvTest
Definition: THcShower.h:260
tuple list
Definition: SConscript.py:9
Double_t * fNegAdcTimeWindowMin
Definition: THcShower.h:198
virtual void Clear(Option_t *opt="")
Double_t * fPosAdcTimeWindowMin
Definition: THcShower.h:197
R__EXTERN class THcDetectorMap * gHcDetectorMap
Definition: THcGlobals.h:12
THcShowerHitSet THcShowerCluster
Definition: THcShowerHit.h:81
Int_t AccumulateStat(TClonesArray &tracks)
virtual void CalculatePedestals()
THcShowerArray * fArray
Definition: THcShower.h:282
Double_t fSlop
Definition: THcShower.h:259
virtual void CalculatePedestals()
Int_t fdbg_tracks_cal
Definition: THcShower.h:272
Int_t fdbg_decoded_cal
Definition: THcShower.h:269
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
double Double_t
UInt_t fHasArray
Definition: THcShower.h:249
Double_t GetEpos(Int_t i)
Double_t hitZ()
Definition: THcShowerHit.h:50
Int_t fSizeClustArray
Definition: THcShower.h:221
virtual Int_t End(THaRunBase *r=0)
Definition: THcShower.cxx:1299
Double_t y[n]
Int_t fEvent
Definition: THcShower.h:188
Double_t clX(THcShowerCluster *cluster)
Definition: THcShower.cxx:962
Double_t fYclustTrack
Definition: THcShower.h:225
Generic segmented shower detector.
Definition: THcShower.h:18
virtual Int_t AccumulatePedestals(TClonesArray *rawhits, Int_t nexthit)
ClassImp(THcDCLookupTTDConv) THcDCLookupTTDConv
you should not use this method at all Int_t Int_t z
Double_t fEtrackNorm
Definition: THcShower.h:236
Double_t GetClX()
Double_t GetEarray()
Double_t hitE()
Definition: THcShowerHit.h:54
One plane of shower blocks with side readout.
Double_t addEpr(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:937
Short_t Max(Short_t a, Short_t b)
UInt_t fNTotLayers
Definition: THcShower.h:248
THcShowerPlane ** fPlanes
Definition: THcShower.h:281
Int_t hitColumn()
Definition: THcShowerHit.h:34
Double_t fXclustTrack
Definition: THcShower.h:223
virtual Int_t CoarseProcessHits()
Int_t fNclustTrack
Definition: THcShower.h:219
set< THcShowerHit * > THcShowerHitSet
Definition: THcShowerHit.h:78
Int_t fdbg_raw_cal
Definition: THcShower.h:268
Int_t * fShNegPedLimit
Definition: THcShower.h:208
Int_t fNhits
Definition: THcShower.h:217
Double_t hitEpos()
Definition: THcShowerHit.h:58
Int_t * fPedNegDefault
Definition: THcShower.h:202
Int_t MatchCluster(THaTrack *, Double_t &, Double_t &)
Definition: THcShower.cxx:1028
Int_t fNblockHighEnergy
Definition: THcShower.h:222
Double_t hitX()
Definition: THcShowerHit.h:42
R__EXTERN class THcParmList * gHcParms
Definition: THcGlobals.h:11
Double_t fYTrackArray
Definition: THcShower.h:230
Double_t hitEneg()
Definition: THcShowerHit.h:62
static const Double_t kBig
Definition: THcFormula.cxx:31
virtual ~THcShower()
Definition: THcShower.cxx:591
Double_t clE(THcShowerCluster *cluster)
Definition: THcShower.cxx:980
const Bool_t kTRUE
Double_t fXTrack
Definition: THcShower.h:224
Int_t fAnalyzePedestals
Definition: THcShower.h:205
Double_t fXclustArrayTrack
Definition: THcShower.h:227
void ClusterHits(THcShowerHitSet &HitSet, THcShowerClusterList *ClusterList)
Definition: THcShower.cxx:871
Double_t fEtrack
Definition: THcShower.h:235
Int_t fADC_RefTimeCut
Definition: THcHitList.h:48
virtual Int_t CoarseProcess(TClonesArray &tracks)
virtual Int_t DecodeToHitList(const THaEvData &evdata, Bool_t suppress=kFALSE)
Populate the hitlist from the raw event data.
Definition: THcHitList.cxx:191
Double_t addX(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:925
THcShowerHitSet::iterator THcShowerHitIt
Definition: THcShowerHit.h:79
virtual void Clear(Option_t *opt="")
virtual EStatus Init(const TDatime &run_time)
Definition: THcShower.cxx:145
Double_t addZ(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:933
A standard Hall C spectrometer apparatus.