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