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