CMS 3D CMS Logo

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