CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSiPMHitResponse.cc
Go to the documentation of this file.
13 
14 #include <set>
15 #include <map>
16 
18 public:
19  bool operator()(const PCaloHit * a,
20  const PCaloHit * b) const {
21  return a->time()<b->time();
22  }
23 };
24 
26  const CaloShapes * shapes) :
27  CaloHitResponse(parameterMap, shapes), theSiPM(0), theRecoveryTime(250.) {
28  theSiPM = new HcalSiPM(14000);
29 }
30 
32  if (theSiPM)
33  delete theSiPM;
34 }
35 
37 
38  typedef std::multiset <const PCaloHit *, PCaloHitCompareTimes> SortedHitSet;
39 
40  std::map< DetId, SortedHitSet > sortedhits;
41  for (MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
42  hitItr != hits.end(); ++hitItr) {
43  if (!((hitItr.bunch() < theMinBunch) || (hitItr.bunch() > theMaxBunch)) &&
44  !(isnan(hitItr->time())) &&
45  ((theHitFilter == 0) || (theHitFilter->accepts(*hitItr)))) {
46  DetId id(hitItr->id());
47  if (sortedhits.find(id)==sortedhits.end())
48  sortedhits.insert(std::pair<DetId, SortedHitSet>(id, SortedHitSet()));
49  sortedhits[id].insert(&(*hitItr));
50  }
51  }
52  int pixelIntegral, oldIntegral;
53  HcalSiPMRecovery pixelHistory(theRecoveryTime);
54  const PCaloHit * hit;
55  for (std::map<DetId, SortedHitSet>::iterator i = sortedhits.begin();
56  i!=sortedhits.end(); ++i) {
57  pixelHistory.clearHistory();
58  for (SortedHitSet::iterator itr = i->second.begin();
59  itr != i->second.end(); ++itr) {
60  hit = *itr;
61  pixelIntegral = pixelHistory.getIntegral(hit->time());
62  oldIntegral = pixelIntegral;
63  CaloSamples signal(makeSiPMSignal(*hit, pixelIntegral));
64  pixelHistory.addToHistory(hit->time(), pixelIntegral-oldIntegral);
65  add(signal);
66  }
67  }
68 }
69 
70 
71 void HcalSiPMHitResponse::setRandomEngine(CLHEP::HepRandomEngine & engine)
72 {
73  theSiPM->initRandomEngine(engine);
75 }
76 
77 
79  int & integral ) const {
80  PCaloHit hit = inHit;
81  if (theHitCorrection != 0)
83 
84  DetId id(hit.id());
85  const HcalSimParameters& pars = dynamic_cast<const HcalSimParameters&>(theParameterMap->simParameters(id));
86  theSiPM->setNCells(pars.pixels());
87 
88  double signal = analogSignalAmplitude(hit, pars);
89  int photons = static_cast<int>(signal + 0.5);
90  int pixels = theSiPM->hitCells(photons, integral);
91  integral += pixels;
92  signal = double(pixels);
93 
95 
96  if(pixels > 0)
97  {
98  const CaloVShape * shape = theShapes->shape(id);
99  double jitter = hit.time() - timeOfFlight(id);
100 
101  const double tzero = pars.timePhase() - jitter -
102  BUNCHSPACE*(pars.binOfMaximum() - thePhaseShift_);
103  double binTime = tzero;
104 
105  for (int bin = 0; bin < result.size(); bin++) {
106  result[bin] += (*shape)(binTime)*signal;
107  binTime += BUNCHSPACE;
108  }
109  }
110 
111  return result;
112 }
113 
int i
Definition: DBlmapReader.cc:9
A general implementation for the response of a SiPM.
Definition: HcalSiPM.h:17
CaloSamples makeBlankSignal(const DetId &detId) const
creates an empty signal for this DetId
double time() const
Definition: PCaloHit.h:34
bool operator()(const PCaloHit *a, const PCaloHit *b) const
Electronic response of the preamp.
Definition: CaloVShape.h:11
iterator end()
virtual CaloSamples makeSiPMSignal(const PCaloHit &inHit, int &integral) const
int getIntegral(double time)
Creates electronics signals from hits.
virtual void correct(PCaloHit &hit) const =0
bool isnan(float x)
Definition: math.h:13
void setNCells(int nCells)
Definition: HcalSiPM.cc:65
tuple result
Definition: query.py:137
virtual void add(const PCaloHit &hit)
process a single SimHit
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
virtual bool accepts(const PCaloHit &hit) const =0
void initRandomEngine(CLHEP::HepRandomEngine &engine)
Definition: HcalSiPM.cc:70
unsigned int id() const
Definition: PCaloHit.h:40
double timeOfFlight(const DetId &detId) const
const CaloVHitCorrection * theHitCorrection
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
Definition: DetId.h:20
iterator begin()
double analogSignalAmplitude(const PCaloHit &hit, const CaloSimParameters &parameters) const
const CaloShapes * theShapes
virtual int hitCells(int photons, int integral=0) const
Definition: HcalSiPM.cc:21
virtual void setRandomEngine(CLHEP::HepRandomEngine &engine)
const CaloVSimParameterMap * theParameterMap
int size() const
get the size
Definition: CaloSamples.h:24
double b
Definition: hdecay.h:120
HcalSiPMHitResponse(const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes)
double a
Definition: hdecay.h:121
virtual void run(MixCollection< PCaloHit > &hits)
Complete cell digitization.
static const double tzero[3]
const CaloVHitFilter * theHitFilter
virtual void setRandomEngine(CLHEP::HepRandomEngine &engine)
void addToHistory(double time, int pixels)
virtual const CaloVShape * shape(const DetId &detId) const
Definition: CaloShapes.h:15