All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
NewLDCCaloDigi.cc
Go to the documentation of this file.
1 // Calorimeter digitiser for the LDC ECAL and HCAL
2 // For other detectors/models SimpleCaloDigi should be used
3 #include "NewLDCCaloDigi.h"
4 #include <EVENT/LCCollection.h>
5 #include <EVENT/SimCalorimeterHit.h>
6 #include <IMPL/CalorimeterHitImpl.h>
7 #include <IMPL/LCCollectionVec.h>
8 #include <IMPL/LCFlagImpl.h>
9 #include <IMPL/LCRelationImpl.h>
10 #include <marlin/Global.h>
11 #include <gear/GEAR.h>
12 #include <gear/GearParameters.h>
13 #include <gear/CalorimeterParameters.h>
14 #include <gear/LayerLayout.h>
15 #include <EVENT/LCParameters.h>
16 #include <UTIL/CellIDDecoder.h>
17 #include <iostream>
18 #include <cmath>
19 
20 #include "CalorimeterHitType.h"
21 
22 using namespace std;
23 using namespace lcio ;
24 using namespace marlin ;
25 
26 // protect agains rounding errors
27 // will not find caps smaller than this
28 const float slop = 0.25; // (mm)
29 const float pi = acos(-1.0);
30 const float twopi = 2.0*pi;
31 
33 
34 NewLDCCaloDigi::NewLDCCaloDigi() : Processor("NewLDCCaloDigi") {
35 
36  _description = "Performs simple digitization of sim calo hits..." ;
37 
38  std::vector<std::string> ecalCollections;
39  ecalCollections.push_back(std::string("EcalBarrelCollection"));
40  ecalCollections.push_back(std::string("EcalEndcapCollection"));
41  ecalCollections.push_back(std::string("EcalRingCollection"));
42  registerInputCollections( LCIO::SIMCALORIMETERHIT,
43  "ECALCollections" ,
44  "ECAL Collection Names" ,
46  ecalCollections);
47 
48  std::vector<std::string> hcalCollections;
49  hcalCollections.push_back(std::string("HcalBarrelRegCollection"));
50  hcalCollections.push_back(std::string("HcalEndcapRingsCollection"));
51  hcalCollections.push_back(std::string("HcalEndcapsCollection"));
52  registerInputCollections( LCIO::SIMCALORIMETERHIT,
53  "HCALCollections" ,
54  "HCAL Collection Names" ,
56  hcalCollections);
57 
58  _outputEcalCollections.push_back(std::string("ECALBarrel"));
59  _outputEcalCollections.push_back(std::string("ECALEndcap"));
60  _outputEcalCollections.push_back(std::string("ECALOther"));
61  _outputHcalCollections.push_back(std::string("HCALBarrel"));
62  _outputHcalCollections.push_back(std::string("HCALEndcap"));
63  _outputHcalCollections.push_back(std::string("HCALOther"));
64 
65  registerOutputCollection( LCIO::CALORIMETERHIT,
66  "ECALOutputCollection0" ,
67  "ECAL Collection of real Hits" ,
69  std::string("ECALBarrel") );
70 
71 
72  registerOutputCollection( LCIO::CALORIMETERHIT,
73  "ECALOutputCollection1" ,
74  "ECAL Collection of real Hits" ,
76  std::string("ECALEndcap") );
77 
78  registerOutputCollection( LCIO::CALORIMETERHIT,
79  "ECALOutputCollection2" ,
80  "ECAL Collection of real Hits" ,
82  std::string("ECALOther") ) ;
83 
84  registerOutputCollection( LCIO::CALORIMETERHIT,
85  "HCALOutputCollection0" ,
86  "HCAL Collection of real Hits" ,
88  std::string("HCALBarrel") );
89 
90  registerOutputCollection( LCIO::CALORIMETERHIT,
91  "HCALOutputCollection1" ,
92  "HCAL Collection of real Hits" ,
94  std::string("HCALEndcap") );
95 
96  registerOutputCollection( LCIO::CALORIMETERHIT,
97  "HCALOutputCollection2" ,
98  "HCAL Collection of real Hits" ,
100  std::string("HCALOther") ) ;
101 
102  registerOutputCollection( LCIO::LCRELATION,
103  "RelationOutputCollection" ,
104  "CaloHit Relation Collection" ,
106  std::string("RelationCaloHit")) ;
107 
108  registerProcessorParameter("ECALThreshold" ,
109  "Threshold for ECAL Hits in GeV" ,
111  (float)5.0e-5);
112 
113 
114 
115  std::vector<float> hcalThresholds;
116  hcalThresholds.push_back(0.00004);
117  registerProcessorParameter("HCALThreshold" ,
118  "Threshold for HCAL Hits in GeV" ,
120  hcalThresholds);
121 
122 
123  std::vector<int> ecalLayers;
124  ecalLayers.push_back(20);
125  ecalLayers.push_back(100);
126 
127 
128  registerProcessorParameter("ECALLayers" ,
129  "Index of ECal Layers" ,
130  _ecalLayers,
131  ecalLayers);
132 
133 
134 
135  std::vector<int> hcalLayers;
136  hcalLayers.push_back(100);
137 
138  registerProcessorParameter("HCALLayers" ,
139  "Index of HCal Layers" ,
140  _hcalLayers,
141  hcalLayers);
142 
143 
144  std::vector<float> calibrEcal;
145  calibrEcal.push_back(40.91);
146  calibrEcal.push_back(81.81);
147 
148 
149  registerProcessorParameter("CalibrECAL" ,
150  "Calibration coefficients for ECAL" ,
152  calibrEcal);
153 
154 
155  std::vector<float> calibrHcal;
156  calibrHcal.push_back(34.8);
157 
158  registerProcessorParameter("CalibrHCAL" ,
159  "Calibration coefficients for HCAL" ,
161  calibrHcal);
162 
163 
164  registerProcessorParameter("IfDigitalEcal" ,
165  "Digital Ecal" ,
166  _digitalEcal ,
167  0);
168 
169 
170  registerProcessorParameter("IfDigitalHcal" ,
171  "Digital Hcal" ,
172  _digitalHcal ,
173  0);
174 
175  registerProcessorParameter("ECALGapCorrection" ,
176  "Correct for ECAL gaps" ,
178  (int)1);
179 
180  registerProcessorParameter("ECALEndcapCorrectionFactor" ,
181  "Energy correction for ECAL endcap" ,
183  (float)1.025);
184 
185  registerProcessorParameter("HCALEndcapCorrectionFactor" ,
186  "Energy correction for HCAL endcap" ,
188  (float)1.025);
189 
190  registerProcessorParameter("ECALGapCorrectionFactor" ,
191  "Factor applied to gap correction" ,
193  (float)1.0);
194 
195  registerProcessorParameter("ECALModuleGapCorrectionFactor" ,
196  "Factor applied to module gap correction" ,
198  (float)0.5);
199 
200 
201 
202  registerProcessorParameter("CellIDLayerString" ,
203  "name of the part of the cellID that holds the layer" ,
205  std::string("K-1")
206  );
207 
208  registerProcessorParameter("CellIDModuleString" ,
209  "name of the part of the cellID that holds the module" ,
211  std::string("M")
212  );
213  registerProcessorParameter("CellIDStaveString" ,
214  "name of the part of the cellID that holds the stave" ,
216  std::string("S-1")
217  );
218 
219 
220 }
221 
223 
224  _nRun = -1;
225  _nEvt = 0;
226 
227  //fg: need to set default encoding in for reading old files...
228  CellIDDecoder<SimCalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
229 
230  // Calorimeter geometry from GEAR
231  const gear::CalorimeterParameters& pEcalBarrel = Global::GEAR->getEcalBarrelParameters();
232  const gear::CalorimeterParameters& pEcalEndcap = Global::GEAR->getEcalEndcapParameters();
233  // const gear::CalorimeterParameters& pHcalBarrel = Global::GEAR->getHcalBarrelParameters();
234  // const gear::CalorimeterParameters& pHcalEndcap = Global::GEAR->getHcalEndcapParameters();
235  const gear::LayerLayout& ecalBarrelLayout = pEcalBarrel.getLayerLayout();
236  const gear::LayerLayout& ecalEndcapLayout = pEcalEndcap.getLayerLayout();
237  // const gear::LayerLayout& hcalBarrelLayout = pHcalBarrel.getLayerLayout();
238  // const gear::LayerLayout& hcalEndcapLayout = pHcalEndcap.getLayerLayout();
239 
240  // determine geometry of ECAL
241  int symmetry = pEcalBarrel.getSymmetryOrder();
242  _zOfEcalEndcap = (float)pEcalEndcap.getExtent()[2];
243 
244  // Determine ECAL polygon angles
245  // Store radial vectors perpendicular to stave layers in _ecalBarrelStaveDir
246  // ASSUMES Mokka Stave numbering 0 = top, then numbering increases anti-clockwise
247  if(symmetry>1){
248  float nFoldSymmetry = static_cast<float>(symmetry);
249  float phi0 = pEcalBarrel.getPhi0();
250  for(int i=0;i<symmetry;++i){
251  float phi = phi0 + i*twopi/nFoldSymmetry;
252  _barrelStaveDir[i][0] = cos(phi);
253  _barrelStaveDir[i][1] = sin(phi);
254  }
255  }
256 
257  for(int i=0;i<ecalBarrelLayout.getNLayers();++i){
258  _barrelPixelSizeT[i] = ecalBarrelLayout.getCellSize0(i);
259  _barrelPixelSizeZ[i] = ecalBarrelLayout.getCellSize1(i);
260  }
261 
262  for(int i=0;i<ecalEndcapLayout.getNLayers();++i){
263  _endcapPixelSizeX[i] = ecalEndcapLayout.getCellSize0(i);
264  _endcapPixelSizeY[i] = ecalEndcapLayout.getCellSize1(i);
265  }
266 
267 }
268 
269 
270 void NewLDCCaloDigi::processRunHeader( LCRunHeader* /*run*/) {
271 
272  _nRun++ ;
273  _nEvt = 0;
274 
275 }
276 
277 void NewLDCCaloDigi::processEvent( LCEvent * evt ) {
278 
279 
280  // create the output collections
281  LCCollectionVec *relcol = new LCCollectionVec(LCIO::LCRELATION);
282 
283  // copy the flags from the input collection
284  LCFlagImpl flag;
285  flag.setBit(LCIO::CHBIT_LONG);
286 
287  //
288  // * Reading Collections of ECAL Simulated Hits *
289  //
290  for (unsigned int i(0); i < _ecalCollections.size(); ++i) {
291 
292  std::string colName = _ecalCollections[i] ;
293 
294  //fg: need to establish the subdetetcor part here
295  // use collection name as cellID does not seem to have that information
296  CHT::Layout caloLayout = layoutFromString( colName ) ;
297 
298  try{
299  LCCollection * col = evt->getCollection( _ecalCollections[i].c_str() ) ;
300  string initString = col->getParameters().getStringVal(LCIO::CellIDEncoding);
301 
302  CellIDDecoder<SimCalorimeterHit> idDecoder( col );
303 
304  // create new collection
305  LCCollectionVec *ecalcol = new LCCollectionVec(LCIO::CALORIMETERHIT);
306  ecalcol->setFlag(flag.getFlag());
307 
308  // if making gap corrections clear the vectors holding pointers to calhits
309  if(_ecalGapCorrection!=0){
310  for(int is=0;is<MAX_STAVES;is++){
311  for(int il=0;il<MAX_LAYERS;il++){
312  _calHitsByStaveLayer[is][il].clear();
313  _calHitsByStaveLayerModule[is][il].clear();
314  }
315  }
316  }
317 
318  int layerIndex=0 ;
319  int staveIndex=0 ;
320  int moduleIndex=0 ;
321 
322 
323  int numElements = col->getNumberOfElements();
324  for (int j(0); j < numElements; ++j) {
325  SimCalorimeterHit * hit = dynamic_cast<SimCalorimeterHit*>( col->getElementAt( j ) ) ;
326 
327  if( j == 0 ){
328  layerIndex = idDecoder( hit ).index( _cellIDLayerString ) ;
329  staveIndex = idDecoder( hit ).index( _cellIDStaveString ) ;
330  moduleIndex = idDecoder( hit ).index( _cellIDModuleString ) ;
331  }
332 
333  float energy = hit->getEnergy();
334 
335  streamlog_out( DEBUG0 ) << " Hit energy " << energy << " in cellID : " << idDecoder( hit ).valueString() << std::endl;
336 
337  // apply threshold cut
338  if (energy > _thresholdEcal) {
339  CalorimeterHitImpl * calhit = new CalorimeterHitImpl();
340  int cellid = hit->getCellID0();
341  int cellid1 = hit->getCellID1();
342  float calibr_coeff(1.);
343  int layer = idDecoder(hit)[ layerIndex ];
344  int stave = idDecoder(hit)[ staveIndex ];
345  int module= idDecoder(hit)[ moduleIndex ];
346  // save hits by module/stave/layer if required later
347  if(_ecalGapCorrection!=0){
348  _calHitsByStaveLayer[stave][layer].push_back(calhit);
349  _calHitsByStaveLayerModule[stave][layer].push_back(module);
350  }
351 
352  // retrieve calibration constants
353  for (unsigned int k(0); k < _ecalLayers.size(); ++k) {
354  int min,max;
355  if (k == 0){
356  min = 0;
357  }else{
358  min = _ecalLayers[k-1];
359  }
360  max = _ecalLayers[k];
361  if (layer >= min && layer < max) {
362  calibr_coeff = _calibrCoeffEcal[k];
363  break;
364  }
365  }
366  // apply calibration
367  if (_digitalEcal) {
368  calhit->setEnergy(calibr_coeff);
369  }
370  else {
371  // if in endcap apply additional factor to calibration to account for
372  // the difference in response due to the orientation of B wrt absorber
373  if(fabs(hit->getPosition()[2])>=_zOfEcalEndcap)energy=energy*_ecalEndcapCorrectionFactor;
374  calhit->setEnergy(calibr_coeff*energy);
375  }
376  // set other ECAL quanties
377  calhit->setPosition(hit->getPosition());
378 
379  calhit->setType( CHT( CHT::em, CHT::ecal, caloLayout , layer ) );
380 
381  calhit->setRawHit(hit);
382  calhit->setCellID0(cellid);
383  calhit->setCellID1(cellid1);
384  ecalcol->addElement(calhit);
385  // make relation between hit and sim hit
386  LCRelationImpl *rel = new LCRelationImpl(calhit,hit,1.);
387  relcol->addElement( rel );
388  }
389  }
390  // if requested apply gap corrections in ECAL ?
391  if(_ecalGapCorrection!=0)this->fillECALGaps();
392  // add ECAL collection to event
393  ecalcol->parameters().setValue(LCIO::CellIDEncoding,initString);
394  evt->addCollection(ecalcol,_outputEcalCollections[i].c_str());
395  }
396  catch(DataNotAvailableException &e){
397  }
398  }
399 
400 
401  //
402  // * Reading HCAL Collections of Simulated Hits *
403  //
404 
405  for (unsigned int i(0); i < _hcalCollections.size(); ++i) {
406 
407  std::string colName = _hcalCollections[i] ;
408 
409  CHT::Layout caloLayout = layoutFromString( colName ) ;
410 
411  int layerIndex=0 ;
412 
413  try{
414  LCCollection * col = evt->getCollection( _hcalCollections[i].c_str() ) ;
415  string initString = col->getParameters().getStringVal(LCIO::CellIDEncoding);
416  int numElements = col->getNumberOfElements();
417  CellIDDecoder<SimCalorimeterHit> idDecoder(col);
418  LCCollectionVec *hcalcol = new LCCollectionVec(LCIO::CALORIMETERHIT);
419  hcalcol->setFlag(flag.getFlag());
420  for (int j(0); j < numElements; ++j) {
421 
422  SimCalorimeterHit * hit = dynamic_cast<SimCalorimeterHit*>( col->getElementAt( j ) ) ;
423 
424  layerIndex = idDecoder( hit ).index( _cellIDLayerString ) ;
425  float energy = hit->getEnergy();
426 
427  streamlog_out( DEBUG0 ) << " Hit energy " << energy << " in cellID : " << idDecoder( hit ).valueString() << std::endl;
428 
429  if (energy > _thresholdHcal[0]) {
430  CalorimeterHitImpl * calhit = new CalorimeterHitImpl();
431  int cellid = hit->getCellID0();
432  int cellid1 = hit->getCellID1();
433  float calibr_coeff(1.);
434 
435  int layer =idDecoder(hit)[ layerIndex ];
436 
437 
438  // NOTE : for a digital HCAL this does not allow for varying layer thickness
439  // with depth - would need a simple mod to make response proportional to layer thickness
440  if(_digitalHcal){
441  unsigned ilevel = 0;
442  for(unsigned int ithresh=1;ithresh<_thresholdHcal.size();ithresh++){
443  // Assume!!! hit energies are stored as floats, i.e. 1, 2 or 3
444  if(energy>_thresholdHcal[ithresh])ilevel=ithresh; // ilevel = 0 , 1, 2
445  }
446  if(ilevel>_calibrCoeffHcal.size()-1){
447  streamlog_out(ERROR) << " Semi-digital level " << ilevel << " greater than number of HCAL Calibration Constants (" <<_calibrCoeffHcal.size() << ")" << std::endl;
448  }else{
449  calibr_coeff = _calibrCoeffHcal[ilevel];
450  }
451  }else{
452  for (unsigned int k(0); k < _hcalLayers.size(); ++k) {
453  int min,max;
454  if (k == 0)
455  min = 0;
456  else
457  min = _hcalLayers[k-1];
458  max = _hcalLayers[k];
459  if (layer >= min && layer < max) {
460  calibr_coeff = _calibrCoeffHcal[k];
461  break;
462  }
463  }
464  }
465 
466  calhit->setCellID0(cellid);
467  calhit->setCellID1(cellid1);
468  if (_digitalHcal) {
469  calhit->setEnergy(calibr_coeff);
470  } else{
471  if(fabs(hit->getPosition()[2])>=_zOfEcalEndcap)energy=energy*_hcalEndcapCorrectionFactor;
472  calhit->setEnergy(calibr_coeff*energy);
473  }
474 
475 
476 
477  calhit->setPosition(hit->getPosition());
478 
479  calhit->setType( CHT( CHT::had, CHT::hcal , caloLayout , layer ) );
480 
481 
482  calhit->setRawHit(hit);
483  hcalcol->addElement(calhit);
484  LCRelationImpl *rel = new LCRelationImpl(calhit,hit,1.0);
485  relcol->addElement( rel );
486  }
487 
488  }
489  // add HCAL collection to event
490  hcalcol->parameters().setValue(LCIO::CellIDEncoding,initString);
491  evt->addCollection(hcalcol,_outputHcalCollections[i].c_str());
492  }
493  catch(DataNotAvailableException &e){
494  }
495  }
496 
497  // add relation collection for ECAL/HCAL to event
498  evt->addCollection(relcol,_outputRelCollection.c_str());
499 
500  _nEvt++;
501 
502 }
503 
504 
505 void NewLDCCaloDigi::check( LCEvent * /*evt*/ ) { }
506 
508 
509 
511 
512  // Loop over hits in the Barrel
513  // For each layer calculated differences in hit positions
514  // Look for gaps based on expected separation of adjacent hits
515  // loop over staves and layers
516 
517  for (int is=0; is < MAX_STAVES; ++is) {
518  for (int il=0; il < MAX_LAYERS; ++il) {
519 
520  if(_calHitsByStaveLayer[is][il].size()>1){
521  // compare all pairs of hits just once (j>i)
522 
523  for (unsigned int i=0;i<_calHitsByStaveLayer[is][il].size()-1;++i){
524  CalorimeterHitImpl* hiti = _calHitsByStaveLayer[is][il][i];
525  int modulei = _calHitsByStaveLayerModule[is][il][i];
526  float xi = hiti->getPosition()[0];
527  float yi = hiti->getPosition()[1];
528  float zi = hiti->getPosition()[2];
529 
530  for (unsigned int j=i+1;j<_calHitsByStaveLayer[is][il].size();++j){
531  CalorimeterHitImpl* hitj = _calHitsByStaveLayer[is][il][j];
532  int modulej = _calHitsByStaveLayerModule[is][il][j];
533  float xj = hitj->getPosition()[0];
534  float yj = hitj->getPosition()[1];
535  float zj = hitj->getPosition()[2];
536  float dz = fabs(zi-zj);
537  // *** BARREL CORRECTION ***
538  if( fabs(zi)<_zOfEcalEndcap && fabs(zj)<_zOfEcalEndcap){
539  // account for stave directions using normals
540  // calculate difference in hit postions in z and along stave
541  float dx = xi-xj;
542  float dy = yi-yj;
543  float dt = fabs(dx*_barrelStaveDir[is][0] + dy*_barrelStaveDir[is][1]);
544  // flags for evidence for gaps
545  bool zgap = false; // in z direction
546  bool tgap = false; // along stave
547  bool ztgap = false; // in both z and along stave
548  bool mgap = false; // gaps between ECAL modules
549 
550  // criteria gaps in the z and t direction
551  float zminm = 1.0*_barrelPixelSizeZ[il]-slop;
552  float zmin = 1.0*_barrelPixelSizeZ[il]+slop;
553  float zmax = 2.0*_barrelPixelSizeZ[il]-slop;
554  float tminm = 1.0*_barrelPixelSizeT[il]-slop;
555  float tmin = 1.0*_barrelPixelSizeT[il]+slop;
556  float tmax = 2.0*_barrelPixelSizeT[il]-slop;
557 
558  // criteria for gaps
559  // WOULD BE BETTER TO USE GEAR TO CHECK GAPS ARE OF EXPECTED SIZE
560  if( dz > zmin && dz < zmax && dt < tminm )zgap = true;
561  if( dz < zminm && dt > tmin && dt < tmax )tgap = true;
562  if( dz > zmin && dz < zmax && dt > tmin && dt < tmax )ztgap=true;
563 
564  if(modulei!=modulej){
565  if( dz > zmin && dz < 3.0*_barrelPixelSizeZ[il]-slop && dt < tmin)mgap = true;
566  }
567 
568 
569 
570 
571  // found a gap now apply a correction based on area of gap/area of pixel
572  if(zgap||tgap||ztgap||mgap){
573  float ecor = 1.;
574  float f = _ecalGapCorrectionFactor; // fudge
575  if(mgap)f = _ecalModuleGapCorrectionFactor;
576  if(zgap||mgap)ecor = 1.+f*(dz - _barrelPixelSizeZ[il])/2./_barrelPixelSizeZ[il];
577  if(tgap)ecor = 1.+f*(dt - _barrelPixelSizeT[il])/2./_barrelPixelSizeT[il];
578  if(ztgap)ecor= 1.+f*(dt - _barrelPixelSizeT[il])*(dz - _barrelPixelSizeZ[il])/4./_barrelPixelSizeT[il]/_barrelPixelSizeZ[il];
579  float ei = hiti->getEnergy()*ecor;
580  float ej = hitj->getEnergy()*ecor;
581  hiti->setEnergy(ei);
582  hitj->setEnergy(ej);
583  }
584 
585  // *** ENDCAP CORRECTION ***
586  }else if(fabs(zi)>_zOfEcalEndcap && fabs(zj)>_zOfEcalEndcap&&dz<100){
587  float dx = fabs(xi-xj);
588  float dy = fabs(yi-yj);
589  bool xgap = false;
590  bool ygap = false;
591  bool xygap = false;
592  // criteria gaps in the z and t direction
593 
594  // x and y need to be swapped in different staves of endcap.
595  float pixsizex, pixsizey;
596  if ( is%2 == 1 ) {
597  pixsizex = _endcapPixelSizeY[il];
598  pixsizey = _endcapPixelSizeX[il];
599  } else {
600  pixsizex = _endcapPixelSizeX[il];
601  pixsizey = _endcapPixelSizeY[il];
602  }
603 
604  float xmin = 1.0*pixsizex+slop;
605  float xminm = 1.0*pixsizex-slop;
606  float xmax = 2.0*pixsizex-slop;
607  float ymin = 1.0*pixsizey+slop;
608  float yminm = 1.0*pixsizey-slop;
609  float ymax = 2.0*pixsizey-slop;
610  // look for gaps
611  if(dx > xmin && dx < xmax && dy < yminm )xgap = true;
612  if(dx < xminm && dy > ymin && dy < ymax )ygap = true;
613  if(dx > xmin && dx < xmax && dy > ymin && dy < ymax )xygap=true;
614 
615  if(xgap||ygap||xygap){
616 
617  streamlog_out( DEBUG0 ) <<"NewLDCCaloDigi found endcap gap, adjusting energy! " << xgap << " " << ygap << " " << xygap << " , " << il << endl;
618  streamlog_out( DEBUG0 ) << "stave " << is << " layer " << il << endl;
619  streamlog_out( DEBUG0 ) << " dx, dy " << dx<< " " << dy << " , sizes = " << pixsizex << " " << pixsizey << endl;
620  streamlog_out( DEBUG0 ) << " xmin... " << xmin << " " << xminm << " " << xmax << " ymin... " << ymin << " " << yminm << " " << ymax << endl;
621 
622  // found a gap make correction
623  float ecor = 1.;
624  float f = _ecalGapCorrectionFactor; // fudge
625  if(xgap)ecor = 1.+f*(dx - pixsizex)/2./pixsizex;
626  if(ygap)ecor = 1.+f*(dy - pixsizey)/2./pixsizey;
627  if(xygap)ecor= 1.+f*(dx - pixsizex)*(dy - pixsizey)/4./pixsizex/pixsizey;
628 
629  streamlog_out( DEBUG0 ) << "correction factor = " << ecor << endl;
630 
631  hiti->setEnergy( hiti->getEnergy()*ecor );
632  hitj->setEnergy( hitj->getEnergy()*ecor );
633  }
634  }
635  }
636  }
637  }
638  }
639  }
640 
641  return;
642 
643 }
644 
const int MAX_STAVES
Definition: ILDCaloDigi.h:21
float _barrelStaveDir[MAX_STAVES][2]
float _barrelPixelSizeT[MAX_LAYERS]
float _ecalEndcapCorrectionFactor
const float pi
Definition: G2CD.cc:34
std::string _cellIDStaveString
virtual void init()
float _hcalEndcapCorrectionFactor
virtual void processRunHeader(LCRunHeader *run)
std::vector< std::string > _outputEcalCollections
std::vector< int > _ecalLayers
virtual void end()
static const float k
std::vector< CalorimeterHitImpl * > _calHitsByStaveLayer[MAX_STAVES][MAX_LAYERS]
float _endcapPixelSizeY[MAX_LAYERS]
virtual void processEvent(LCEvent *evt)
std::string _cellIDModuleString
float _ecalModuleGapCorrectionFactor
std::vector< int > _hcalLayers
float _endcapPixelSizeX[MAX_LAYERS]
virtual void fillECALGaps()
std::vector< int > _calHitsByStaveLayerModule[MAX_STAVES][MAX_LAYERS]
const float twopi
Definition: ILDCaloDigi.cc:38
static const float e
std::string _cellIDLayerString
const int MAX_LAYERS
Definition: ILDCaloDigi.h:20
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
virtual void check(LCEvent *evt)
float _ecalGapCorrectionFactor
std::vector< std::string > _ecalCollections
std::vector< float > _calibrCoeffHcal
const float slop
Definition: ILDCaloDigi.cc:36
NewLDCCaloDigi aNewLDCCaloDigi
std::vector< std::string > _hcalCollections
float _barrelPixelSizeZ[MAX_LAYERS]
std::string _outputRelCollection
std::vector< float > _calibrCoeffEcal
std::vector< std::string > _outputHcalCollections
std::vector< float > _thresholdHcal