13 #include "CLHEP/Random/RandFlat.h"
44 ATH_MSG_DEBUG (
"MuonDetectorManager retrieved from StoreGate.");
73 return StatusCode::FAILURE;
85 return StatusCode::SUCCESS;
97 return StatusCode::SUCCESS;
114 ATH_CHECK(cscSimData.
record(std::make_unique<CscSimDataCollection>()));
119 if (StatusCode::FAILURE ==
sc) {
130 for (
size_t coll_hash = 0; coll_hash < collections.size(); ++coll_hash) {
131 if (collections[coll_hash]) {
136 return StatusCode::SUCCESS;
141 std::map <IdentifierHash,deposits> myDeposits;
143 csc_newmap data_SampleMap, data_SampleMapOddPhase;
150 return StatusCode::FAILURE;
167 double globalHitTime(
hitTime(phit));
168 double bunchTime(globalHitTime - hit.
globalTime());
172 ATH_MSG_DEBUG (
"bunch time (ns) " << bunchTime <<
"globalHitTime (ns) " << globalHitTime <<
" hit Time (ns) " <<
hitTime(phit) );
175 std::vector<IdentifierHash> hashVec;
177 ?
m_cscDigitizer->digitize_hit(&hit, hashVec, data_SampleMap, data_SampleMapOddPhase, rndmEngine)
178 :
m_cscDigitizer->digitize_hit(&hit, hashVec, data_map, rndmEngine);
185 std::vector<IdentifierHash>::const_iterator vecBeg = hashVec.begin();
186 std::vector<IdentifierHash>::const_iterator vecEnd = hashVec.end();
190 float ypos = -99999.9;
201 if (
dx>0.0 && xi<=0.0 && xf>=0.0 ) {
213 for (; vecBeg != vecEnd; ++vecBeg) {
214 myDeposits[(*vecBeg)].emplace_back(trackLink,cscd);
229 double flat = CLHEP::RandFlat::shoot(rndmEngine, 0.0,1.0);
230 bool phaseToSet = flat<0.5;
243 std::map<IdentifierHash,deposits>& myDeposits,
254 csc_newmap::const_iterator cscMap = data_SampleMap.begin();
255 csc_newmap::const_iterator cscMapEnd = data_SampleMap.end();
257 for (; cscMap != cscMapEnd; ++cscMap) {
259 IdentifierHash hashId = (*cscMap).first;
260 if (
m_idHelperSvc->cscIdHelper().get_id( hashId, digitId, &context ) ) {
261 ATH_MSG_ERROR (
"cannot get CSC channel identifier from hash " << hashId );
262 return StatusCode::FAILURE;
266 IdentifierHash coll_hash;
267 if (
m_idHelperSvc->cscIdHelper().get_hash(elementId, coll_hash, &cscContext)) {
268 ATH_MSG_ERROR (
"Unable to get CSC hash id from CSC Digit collection "
269 <<
"context begin_index = " << cscContext.
begin_index()
270 <<
" context end_index = " << cscContext.
end_index()
271 <<
" the identifier is " );
277 double stripCharge = 0.0;
279 const std::vector<float> samples = (*cscMap).second;
281 unsigned int samplingPhase =0;
282 double samplingTime =
m_pcalib->getSamplingTime();
283 m_pcalib->findCharge(samplingTime, samplingPhase, samples, stripCharge,
driftTime);
293 int phisec =
m_idHelperSvc->cscIdHelper().stationPhi(digitId);
294 int istation =
m_idHelperSvc->cscIdHelper().stationName(digitId) - 49;
297 int measphi =
m_idHelperSvc->cscIdHelper().measuresPhi(digitId);
300 int sector = zsec*(2*phisec-istation+1);
302 auto depositsForHash = myDeposits.find(hashId);
303 if (depositsForHash != myDeposits.end() && !depositsForHash->second.empty()) {
304 depositsForHash->second[0].second.setCharge(stripCharge);
305 cscSimData->insert ( std::make_pair(digitId,
CscSimData(depositsForHash->second,0)) );
311 ATH_MSG_DEBUG (
"NEWDigit sec:measphi:wlay:istr:chg:t(w/latency) "
312 <<
m_idHelperSvc->cscIdHelper().show_to_string(digitId,&context)
313 <<
" hash:eleId = " << hashId <<
" " << elementId <<
" " << prevId <<
" "
314 << sector <<
" " << measphi <<
" " << wlay <<
" " << istrip <<
" "
315 <<
int(stripCharge+1) <<
" " <<
float(
driftTime)
316 <<
" phase=" << phaseToSet
317 <<
" samps: " << samples[0] <<
" " << samples[1] <<
" "
318 << samples[2] <<
" " << samples[3]
321 if (prevId != elementId) {
322 if (coll_hash >= collections.size()) {
323 collections.resize (coll_hash+1);
325 collection = collections[coll_hash].
get();
326 if (
nullptr == collection) {
327 collections[coll_hash] = std::make_unique<CscDigitCollection>(elementId,coll_hash);
328 collection = collections[coll_hash].
get();
331 collection->
push_back (std::make_unique<CscDigit>(digitId, samples));
338 return StatusCode::FAILURE;
342 collection->
push_back (std::make_unique<CscDigit>(digitId, samples));
345 return StatusCode::SUCCESS;
357 csc_map::const_iterator cscMap = data_map.begin();
358 csc_map::const_iterator cscMapEnd = data_map.end();
359 for (; cscMap != cscMapEnd; ++cscMap) {
361 IdentifierHash hashId = (*cscMap).first;
362 if (
m_idHelperSvc->cscIdHelper().get_id( hashId, digitId, &context ) ) {
363 ATH_MSG_ERROR (
"cannot get CSC channel identifier from hash " << hashId );
364 return StatusCode::FAILURE;
368 double stripCharge = 0.0;
379 <<
" hash = " << hashId
380 <<
" charge = " <<
int (stripCharge+1) );
383 int phisec =
m_idHelperSvc->cscIdHelper().stationPhi(digitId);
384 int istation =
m_idHelperSvc->cscIdHelper().stationName(digitId) - 49;
387 int measphi =
m_idHelperSvc->cscIdHelper().measuresPhi(digitId);
390 int sector = zsec*(2*phisec-istation+1);
392 auto depositsForHash = myDeposits.find(hashId);
393 if (depositsForHash != myDeposits.end() && !depositsForHash->second.empty()) {
394 depositsForHash->second[0].second.setCharge(stripCharge);
395 cscSimData->insert ( std::make_pair(digitId,
CscSimData(depositsForHash->second,0)) );
401 auto newDigit = std::make_unique<CscDigit>(digitId,
int(stripCharge+1),
float(
driftTime) );
404 ATH_MSG_DEBUG (
"CSC Digit sector:measphi:wlay:istrip:charge "
406 << measphi <<
" " << wlay <<
" " << istrip
407 <<
" " <<
int(stripCharge+1) <<
" " <<
float(
driftTime) <<
" " << (newDigit->sampleCharges()).size());
410 IdentifierHash coll_hash;
411 if (
m_idHelperSvc->cscIdHelper().get_hash(elementId, coll_hash, &cscContext)) {
412 ATH_MSG_ERROR (
"Unable to get CSC hash id from CSC Digit collection "
413 <<
"context begin_index = " << cscContext.
begin_index()
414 <<
" context end_index = " << cscContext.
end_index()
415 <<
" the identifier is " );
419 if (prevId != elementId) {
420 if (coll_hash >= collections.size()) {
421 collections.resize (coll_hash+1);
423 collection = collections[coll_hash].
get();
424 if (
nullptr == collection) {
425 collections[coll_hash] = std::make_unique<CscDigitCollection>(elementId,coll_hash);
426 collection = collections[coll_hash].
get();
428 collection->
push_back(std::move(newDigit));
433 collection->
push_back(std::move(newDigit));
435 ATH_MSG_ERROR(
"Trying to push back NULL CscDigitCollection");
436 return StatusCode::FAILURE;
440 return StatusCode::SUCCESS;
454 if (!hitCollection.
isValid()) {
455 ATH_MSG_ERROR(
"Could not get CSCSimHitCollection container " << hitCollection.
name() <<
" from store " << hitCollection.
store());
456 return StatusCode::FAILURE;
462 ATH_MSG_DEBUG(
"CSCSimHitCollection found with " << hitCollection->
size() <<
" hits");
464 return StatusCode::SUCCESS;
468 TimedHitCollList hitCollList;
472 return StatusCode::FAILURE;
474 if (hitCollList.empty()) {
476 return StatusCode::FAILURE;
489 while (iColl != endColl) {
493 << p_collection->
size() <<
" hits" );
496 return StatusCode::SUCCESS;
506 ATH_MSG_DEBUG(
"CscDigitizationTool::processBunchXing() " << bunchXing);
509 TimedHitCollList hitCollList;
512 bSubEvents, eSubEvents).isSuccess()) &&
513 hitCollList.empty()) {
515 return StatusCode::FAILURE;
517 ATH_MSG_VERBOSE(hitCollList.size() <<
" CSCSimHitCollection with key " <<
525 for( ; iColl != endColl; ++iColl){
533 <<
" index: " << timeIndex.
index()
534 <<
" type: " << timeIndex.
type());
541 return StatusCode::SUCCESS;
556 ATH_CHECK(cscSimData.
record(std::make_unique<CscSimDataCollection>()));
563 for (
size_t coll_hash = 0; coll_hash < collections.size(); ++coll_hash) {
564 if (collections[coll_hash]) {
572 while(cscHitColl!=cscHitCollEnd)
574 delete (*cscHitColl);
579 return StatusCode::SUCCESS;