CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ViewTranslator.cc
Go to the documentation of this file.
8 #include <iostream>
9 #include <sstream>
10 #include <fstream>
11 
12 using namespace sistrip;
13 
14 // -----------------------------------------------------------------------------
15 //
17  Mapping& det_to_fec,
18  Mapping& fed_to_fec ) {
19 
20 // if ( !cabling ) {
21 // edm::LogWarning(mlCabling_)
22 // << "[ViewTranslator::" << __func__ << "]"
23 // << " NULL pointer to FED cabling object!";
24 // return;
25 // }
26 
27  // Iterator through cabling, construct keys and push back into std::map
28  std::vector<uint16_t>::const_iterator ifed = cabling.feds().begin();
29  for ( ; ifed != cabling.feds().end(); ifed++ ) {
30 
31  const std::vector<FedChannelConnection>& conns = cabling.connections( *ifed );
32  std::vector<FedChannelConnection>::const_iterator ichan;
33  for( ichan = conns.begin(); ichan != conns.end(); ichan++ ) {
34  if( ichan->fedId() ) {
35 
36  uint32_t fed = SiStripFedKey( *ifed,
37  SiStripFedKey::feUnit(ichan->fedCh()),
38  SiStripFedKey::feChan(ichan->fedCh()) ).key();
39 
40  uint32_t fec = SiStripFecKey( ichan->fecCrate(),
41  ichan->fecSlot(),
42  ichan->fecRing(),
43  ichan->ccuAddr(),
44  ichan->ccuChan(),
45  ichan->lldChannel() ).key();
46 
47  SiStripDetId det_id( ichan->detId(),
48  ichan->apvPairNumber() );
49  uint32_t det = SiStripDetKey( det_id ).key();
50 
51  det_to_fec[det] = fec;
52  fed_to_fec[fed] = fec;
53 
54  }
55  }
56  }
57 
59  << "[ViewTranslator::" << __func__ << "]"
60  << " Size of FedToFec std::map: " << fed_to_fec.size()
61  << ", size of DetToFec std::map: " << det_to_fec.size();
62 
63 }
64 
65 
66 // -----------------------------------------------------------------------------
67 //
68 uint32_t ViewTranslator::fedToFec( const uint32_t& fed_key_mask,
69  const Mapping& input,
70  Mapping& output ) {
71 
72  if( input.empty() ) {
74  << "[ViewTranslator::" << __func__ << "]"
75  << " Input std::map is empty!";
76  return 0;
77  }
78 
79 // Mapping::iterator iter;
80 // SiStripFedKey fed_key( fed_key_mask );
81 
82 // if( fed_key.detId() == sistrip::invalid_ ||
83 // fed_key.apvPair() == sistrip::invalid_ ) {
84 // edm::LogWarning(mlCabling_)
85 // << "[ViewTranslator::" << __func__ << "]"
86 // << " DetKey is not defined!";
87 // output = input;
88 // return output.size();
89 // }
90 
91 // if( fed_key.detId() != sistrip::invalid_ &&
92 // fed_key.apvPair() != sistrip::invalid_ ) {
93 // iter=input->find( fed_key_mask );
94 // output[ (*iter).first ] = (*iter).second;
95 // LogTrace(mlSummaryPlots_) << "both are not masked";
96 // }
97 
98 // if( fed_key.detId()!=0xFFFFFFFF && fed_key.apvPair()==0xFFFF ) {
99 // LogTrace(mlSummaryPlots_) << "apv is masked";
100 // for(iter=input->begin() ; iter!=input->end() ; iter++) {
101 // DetKey = SiStripFedKey( (*iter).first );
102 // if(fed_key.detId()==DetKey.detId())
103 // output[ (*iter).first ]=( (*iter).second );
104 // } //for(iter=input->begin() ; iter!=input->end() ; iter++)
105 // }//if( fed_key.detId_!=0xFFFFFFFF && fed_key.apvPair_==0xFFFF )
106 // else LogTrace(mlSummaryPlots_) << "Cannot find the det to fec std::map in the root file. ";
107 
108  return 0;
109 
110 }
111 
112 // -----------------------------------------------------------------------------
113 //
114 uint32_t ViewTranslator::detToFec( const uint32_t& det_key_mask,
115  const Mapping& input,
116  Mapping& output ) {
117 
118 // if( input.empty() ) {
119 // edm::LogWarning(mlCabling_)
120 // << "[ViewTranslator::" << __func__ << "]"
121 // << " Input std::map is empty!";
122 // return 0 ;
123 // }
124 
125 // Mapping::iterator iter;
126 // SiStripDetKey::Path det_key = SiStripDetKey::path( det_key_mask );
127 
128 // if( det_key.detId_ == sistrip::invalid_ ||
129 // det_key.apvPair_ == sistrip::invalid_ ) {
130 // edm::LogWarning(mlCabling_)
131 // << "[ViewTranslator::" << __func__ << "]"
132 // << " DetKey is not defined!";
133 // output = input;
134 // return output.size();
135 // }
136 
137 // if( det_key.detId_ != sistrip::invalid_ &&
138 // det_key.apvPair_ != sistrip::invalid_ ) {
139 // iter=input->find( det_key_mask );
140 // output[ (*iter).first ] = (*iter).second;
141 // LogTrace(mlSummaryPlots_) << "both are not masked";
142 // }
143 
144 // if( det_key.detId_!=0xFFFFFFFF && det_key.apvPair_==0xFFFF ) {
145 // LogTrace(mlSummaryPlots_) << "apv is masked";
146 // for(iter=input->begin() ; iter!=input->end() ; iter++) {
147 // DetKey = SiStripDetKey::path( (*iter).first );
148 // if(det_key.detId_==DetKey.detId_)
149 // output[ (*iter).first ]=( (*iter).second );
150 // } //for(iter=input->begin() ; iter!=input->end() ; iter++)
151 // }//if( det_key.detId_!=0xFFFFFFFF && det_key.apvPair_==0xFFFF )
152 // else LogTrace(mlSummaryPlots_) << "Cannot find the det to fec std::map in the root file. ";
153 
154  return 0; //@@ temp!
155 
156 }
157 
158 // -----------------------------------------------------------------------------
159 //
160 // void ViewTranslator::fedToFec( const uint32_t& fed_key_mask,
161 // const Mapping& input,
162 // Mapping& output ) {
163 
164 
165 // Mapping::iterator iter;
166 // uint16_t fedId=0; //fedId
167 // uint16_t feUnit=0; //Front End Unit
168 // uint16_t feChan=0; //Front End Channel
169 // uint16_t fedApv=0;
170 
171 // //unpack the FED key to tranlsate into the corresponding FEC key(s)
172 // SiStripFedKey::Path FedKey = SiStripFedKey::path(fed_key_mask);
173 // fedId=FedKey.fedId_;
174 // feUnit=FedKey.feUnit_;
175 // feChan=FedKey.feChan_;
176 // fedApv=FedKey.fedApv_;
177 
178 
179 // if(fedId==0 && feUnit==0 && feChan==0 && fedApv == sistrip::invalid_ ) {
180 // output=*(input);
181 // }
182 
183 // if(fedId!=0 && feUnit!=0 && feChan!=0 && fedApv == sistrip::invalid_) {
184 // iter=input->find(fed_key_mask);
185 // output[fed_key_mask]=(*iter).second;
186 // }
187 
188 
189 // if(fedId!=0 && feUnit!=0 && feChan==0 && fedApv == sistrip::invalid_ ) {
190 // for(iter=input->begin(); iter!=input->end(); iter++) {
191 // FedKey = SiStripFedKey::path( (*iter).first );
192 // if(fedId==FedKey.fedId_ && feUnit==FedKey.feUnit_) {
193 // output[ (*iter).first ] = (*iter).second;
194 // }// if
195 // }// for
196 // }// if
197 
198 // if(fedId!=0 && feUnit==0 && feChan==0) {
199 // for(iter=input->begin(); iter!=input->end(); iter++) {
200 // FedKey = SiStripFedKey::path( (*iter).first ); //FedKey is the key from the std::map
201 // if( fedId==FedKey.fedId_ ) {
202 // output[ (*iter).first ] = (*iter).second;
203 // } else LogTrace(mlSummaryPlots_) << "The fedId cannot be found. Please check readout path";
204 // } //for
205 // }//if
206 
207 
208 
209 // } else LogTrace(mlSummaryPlots_) << "The fed to fec std::map could not be found in the root file" << endl << "Please load the ViewTranslator module to create the requisite std::maps";
210 
211 
212 // f->Close();
213 
214 // } //if(TFile::Open(fname.cstr())
215 // else LogTrace(mlSummaryPlots_) << "Error:Cannot open root file.";
216 
217 // }
218 
219 // -----------------------------------------------------------------------------
220 //
222  Mapping& det,
223  Mapping& fed ) {
224 
225 // Mapping *det_to_fec;
226 // Mapping *fed_to_fec;
227 
228 // det_to_fec = &det;
229 // fed_to_fec = &fed;
230 
231 // if(TFile::Open(fname.c_str())!=NULL) {
232 // TFile *f=TFile::Open(fname.c_str(), "UPDATE");
233 // gDirectory->cd();
234 // TDirectory *std::mapdir = gDirectory;
235 // gDirectory->cd("/DQMData/SiStrip");
236 // std::mapdir=gDirectory;
237 // std::mapdir->WriteObject(det_to_fec, "det_to_fec");
238 // std::mapdir->WriteObject(fed_to_fec, "fed_to_fec");
239 // LogTrace(mlSummaryPlots_) << "Wrote the std::maps";
240 // f->Close();
241 // } else LogTrace(mlSummaryPlots_) << "Cannot find root file. Maps not written.";
242 
243 }
244 
const std::vector< uint16_t > & feds() const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:57
std::map< uint32_t, uint32_t > Mapping
uint32_t fedToFec(const uint32_t &fed_key_mask, const Mapping &input, Mapping &output)
uint32_t detToFec(const uint32_t &det_key_mask, const Mapping &input, Mapping &output)
const uint32_t & key() const
Definition: SiStripKey.h:126
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:46
static const char mlCabling_[]
static void buildMaps(const SiStripFedCabling &, Mapping &det_to_fec, Mapping &fed_to_fec)
#define LogTrace(id)
Utility class that identifies a position within the strip tracker geometrical structure, down to the level of an APV25 chip.
Definition: SiStripDetKey.h:29
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
const uint16_t & feUnit() const
void writeMapsToFile(std::string root_filename, Mapping &det_to_fec, Mapping &fed_to_fec)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
string fname
main script
list key
Definition: combine.py:13
const uint16_t & feChan() const
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const