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.
12 
13 #include <set>
14 #include <map>
15 
17 public:
18  bool operator()(const PCaloHit * a,
19  const PCaloHit * b) const {
20  return a->time()<b->time();
21  }
22 };
23 
25  const CaloVShape * shape) :
26  CaloHitResponse(parameterMap, shape), theSiPM(0), theRecoveryTime(250.) {
27  theSiPM = new HcalSiPM(14000);
28 }
29 
31  if (theSiPM)
32  delete theSiPM;
33 }
34 
36 
37  typedef std::multiset <const PCaloHit *, PCaloHitCompareTimes> SortedHitSet;
38 
39  std::map< DetId, SortedHitSet > sortedhits;
40  for (MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
41  hitItr != hits.end(); ++hitItr) {
42  if (!((hitItr.bunch() < theMinBunch) || (hitItr.bunch() > theMaxBunch)) &&
43  !(isnan(hitItr->time())) &&
44  ((theHitFilter == 0) || (theHitFilter->accepts(*hitItr)))) {
45  DetId id(hitItr->id());
46  if (sortedhits.find(id)==sortedhits.end())
47  sortedhits.insert(std::pair<DetId, SortedHitSet>(id, SortedHitSet()));
48  sortedhits[id].insert(&(*hitItr));
49  }
50  }
51  int pixelIntegral, oldIntegral;
52  HcalSiPMRecovery pixelHistory(theRecoveryTime);
53  const PCaloHit * hit;
54  for (std::map<DetId, SortedHitSet>::iterator i = sortedhits.begin();
55  i!=sortedhits.end(); ++i) {
56  pixelHistory.clearHistory();
57  for (SortedHitSet::iterator itr = i->second.begin();
58  itr != i->second.end(); ++itr) {
59  hit = *itr;
60  pixelIntegral = pixelHistory.getIntegral(hit->time());
61  oldIntegral = pixelIntegral;
62  CaloSamples signal(makeSiPMSignal(*hit, pixelIntegral));
63  pixelHistory.addToHistory(hit->time(), pixelIntegral-oldIntegral);
64  add(signal);
65  }
66  }
67 }
68 
69 
70 void HcalSiPMHitResponse::setRandomEngine(CLHEP::HepRandomEngine & engine)
71 {
72  theSiPM->initRandomEngine(engine);
74 }
75 
76 
78  int & integral ) const {
79  PCaloHit hit = inHit;
80  if (theHitCorrection != 0)
82 
83  DetId id(hit.id());
84  const HcalSimParameters& pars = dynamic_cast<const HcalSimParameters&>(theParameterMap->simParameters(id));
85  theSiPM->setNCells(pars.pixels());
86 
87  double signal = analogSignalAmplitude(hit, pars);
88  int photons = static_cast<int>(signal + 0.5);
89  int pixels = theSiPM->hitCells(photons, integral);
90  integral += pixels;
91  signal = double(pixels);
92 
94 
95  if(pixels > 0)
96  {
97  double jitter = hit.time() - timeOfFlight(id);
98 
99  const double tzero = pars.timePhase() - jitter -
100  BUNCHSPACE*(pars.binOfMaximum() - thePhaseShift_);
101  double binTime = tzero;
102 
103  for (int bin = 0; bin < result.size(); bin++) {
104  result[bin] += (*theShape)(binTime)*signal;
105  binTime += BUNCHSPACE;
106  }
107  }
108 
109  return result;
110 }
111 
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
HcalSiPMHitResponse(const CaloVSimParameterMap *parameterMap, const CaloVShape *shape)
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
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
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)