ATLAS Offline Software
Loading...
Searching...
No Matches
PRDHandle_CSC_Strip.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "VP1Base/VP1Msg.h"
10
13
15
16#include <Inventor/nodes/SoSeparator.h>
17#include <Inventor/nodes/SoTranslation.h>
18#include <Inventor/nodes/SoMaterial.h>
19
20#include <sstream>
21#include <algorithm>
22
23
24//____________________________________________________________________
30
31//____________________________________________________________________
32void PRDHandle_CSC_Strip::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed)
33{
34 const CscIdHelper * idhelper = VP1DetInfo::cscIDHelper();
35 if (!idhelper)
36 return;
37
38 Identifier id = m_csc->identify();
39
40 SoSeparator * errDetailed = new SoSeparator;
41 SoSeparator * errSimple = new SoSeparator;
42 shape_simple = errSimple;
43
44 double striplength = m_csc->detectorElement()->stripLength( id );
45 if (static_cast<PRDCollHandle_CSC_Strip*>(collHandle())->project())
46 striplength += 300.0;//Fixme: Rough extension for now
47 SoNode* line = common()->nodeManager()->getShapeNode_Strip(striplength);
48 errSimple->addChild(line);
49 errSimple->addChild(common()->nodeManager()->getShapeNode_Cross(10));
50 const double maxCharge = 1e5;
51 //Thickness of highlighed strip
52 //FIXME: the maxCharge/3 is just a quick fix to get a nice presentation
53 // maybe this should go like sqrt(charge/maxCharge) so that it
54 // is clear for small charges.
55 //const double stripHeight = (1 + 4*sqrt(m_csc->charge()/maxCharge))*CLHEP::mm; // [1,5]
56 //
57 // The minimum is chosen equal to the neighbouring strips, such
58 // that a zero charge will give the same stirp height
59 const double stripHeight = 1*CLHEP::mm; // [1,5]
60
61 const std::vector< float > charges = m_csc->sampleCharges();
62 if (charges.size() == 0 )
63 {
64 // Add arbitrary strip height & draw entire length of strip.
65 errDetailed->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,
66 m_csc->detectorElement()->cathodeReadoutPitch(idhelper->chamberLayer( id ),
67 idhelper->measuresPhi( id )), stripHeight));
68 } else {
69 SoSeparator * rdos = new SoSeparator;
70
71 Amg::Vector2D localposCharge;
72
73 // SoTransparency * transparent = new SoTransparency;
74 // transparent->transparency.setValue(0.5);
75 // rdos->addChild( transparent );
76 double chargeLength=striplength/static_cast<double>(charges.size()); // size of one charge cell
77 // std::cout<<"Number of charges="<<charges.size()<<", chargeLength="<<chargeLength<<" striplength="<<striplength<<std::endl;
78 unsigned int i=0;
79 double ypos=(chargeLength-striplength)/2.0;
80 std::vector<float>::const_iterator st = charges.begin();
81 std::vector<float>::const_iterator en = charges.end();
82 double stripPitch=m_csc->detectorElement()->cathodeReadoutPitch(idhelper->chamberLayer( id ),idhelper->measuresPhi( id ));
83 SoTranslation * localtrans = new SoTranslation;
84 localtrans->translation.setValue(0.0,ypos,0.0);
85 rdos->addChild(localtrans);
86
87 for( std::vector<float>::const_iterator it = st; it!=en; ++it, ++i){
88 // std::cout<<"Charge: "<<i<<" \ty="<<ypos<<" has charge=:"<<*it<<std::endl;
89 float charge = std::max(1.0f,(*it)); // keep charges positive until I understand if it is okay to be -ve
90 const double stripHeightCharge = (1.0 + 4*sqrt(charge/maxCharge))*CLHEP::mm;
91 // std::cout<<"stripHeightCharge: "<<stripHeightCharge<<std::endl;
92 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(chargeLength, stripPitch, stripHeightCharge));
93 // ypos+=chargeLength;
94 SoTranslation * localtrans2 = new SoTranslation;
95 localtrans2->translation.setValue(0.0,chargeLength,0.0);
96 rdos->addChild(localtrans2);
97
98 }
99 errDetailed->addChild(rdos);
100 }
101 SoMaterial * mat = new SoMaterial;
102 mat->diffuseColor.setValue(1.0,0,0);
103 errDetailed->addChild(mat);
104 errDetailed->addChild(common()->nodeManager()->getShapeNode_Cross(10));
105
106 shape_detailed = errDetailed;
107}
108
109//____________________________________________________________________
111{
112 //Unique for each station.
113 const MuonGM::MuonStation* station = m_csc->detectorElement()->parentMuonStation();
114 return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
115}
116
117//____________________________________________________________________
119{
120
121 if (!m_csc)
122 return QStringList("Null PRD");
123 const CscIdHelper * idhelper = VP1DetInfo::cscIDHelper();
124 if (!idhelper)
125 return QStringList("Null PRD");
126
127 Identifier id = m_csc->identify();
128 std::ostringstream os;
129 os << "CscStripPrepData with Identifier ["<<id<<"] = ["<<idhelper->print_to_string(id)
130 <<"] at global position = "<<m_csc->globalPosition()<<", local position = "<<m_csc->localPosition();
131 os << ". Samples = [";
132 for( unsigned int i=0;i<m_csc->sampleCharges().size();++i) os << m_csc->sampleCharges()[i] << " , ";
133
134 os << "]. Time of first sample= "<<m_csc->timeOfFirstSample() << ", sampling time (CLHEP::ns) "
135 << m_csc->samplingTime() << ", sampling phase " << m_csc->samplingPhase();
136 os << ". RDO list= [";
137 for( unsigned int i=0;i<m_csc->rdoList().size();++i) os << m_csc->rdoList()[i] << " , ";
138 os << "].";
139 // os <<"\n Dump follows:";
140 // os <<"\n--------------";
141 //os << *(m_csc);
142 return QString(os.str().c_str()).split("\n");
143}
144
145
double charge(const T &p)
Definition AtlasPID.h:997
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
int chamberLayer(const Identifier &id) const
bool measuresPhi(const Identifier &id) const override
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
int getEtaIndex() const
a la AMDB
int getPhiIndex() const
a la AMDB
Class representing the raw data of one CSC strip (for clusters look at Muon::CscPrepData).
PRDHandleBase(PRDCollHandleBase *)
PRDSysCommonData * common() const
PRDCollHandleBase * collHandle() const
const Muon::CscStripPrepData * csc() const
PRDHandle_CSC_Strip(PRDCollHandle_CSC_Strip *, const Muon::CscStripPrepData *)
const Muon::CscStripPrepData * m_csc
virtual QStringList clicked() const
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
HitsSoNodeManager * nodeManager() const
static void initClass()
static const CscIdHelper * cscIDHelper()
Eigen::Matrix< double, 2, 1 > Vector2D