42 void getGainsPedsFromHistos(uint32_t detid,
int rocId,
int index, std::vector<double>&peds,std::vector<double>&gains,std::map<int,int> & myindxmap,
int nrocs);
43 void setDummyFullPlane(std::vector<float>&peds,std::vector<float>&gains,
int npixplane);
64 m_record(iConfig.getUntrackedParameter<
std::
string>(
"record",
"CTPPSPixelGainCalibrationsRcd")),
67 npfitmin(iConfig.getUntrackedParameter<
int>(
"minimumNpfit",3)),
68 gainlow(iConfig.getUntrackedParameter<double>(
"gainLowLimit",0.0)),
69 gainhigh(iConfig.getUntrackedParameter<double>(
"gainHighLimit",100.0))
130 int sector[2] = {45,56};
137 for(
int i=0 ;
i<nsec ;
i++)
138 for(
int st=0 ; st < nst ; st ++)
139 for(
int pot = 0 ; pot < npt ; pot++){
143 char temppathrp[100];
144 sprintf(temppathrp,
"CTPPS/CTPPS_SEC%d/CTPPS_SEC%d_RP%d%d%d",sector[
i],sector[i],arm,station[st],pot);
147 for(
int plane=0 ; plane<6 ; plane++){
150 char temppathplane[100];
151 sprintf(temppathplane,
"CTPPS/CTPPS_SEC%d/CTPPS_SEC%d_RP%d%d%d/CTPPS_SEC%d_RP%d%d%d_PLN%d",sector[i],sector[i],arm,station[st],pot,sector[i],arm,station[st],pot,plane);
158 std::vector<std::string> histnamevec;
159 std::vector<int> listrocs;
160 for(
int roc=0 ; roc<6 ; roc++){
161 char temppathhistos[200];
163 sprintf(temppathhistos,
"CTPPS/CTPPS_SEC%d/CTPPS_SEC%d_RP%d%d%d/CTPPS_SEC%d_RP%d%d%d_PLN%d/CTPPS_SEC%d_RP%d%d%d_PLN%d_ROC%d",
164 sector[i],sector[i],arm,station[st],pot,sector[i],arm,station[st],pot,plane,sector[i],arm,station[st],pot,plane,roc);
168 std::string pathintercept= pathhistos +
"_Intercept2D";
170 histnamevec.push_back(pathhistos);
171 listrocs.push_back(roc);
176 edm::LogInfo(
"CTPPSPixGainsCalibrationWriter") <<
"Raw DetId = "<< mytempid.
rawId() <<
" Arm = "<< arm <<
" Sector = "<< sector[
arm] <<
" Station = "<< station[st] <<
" Pot = "<<pot <<
" Plane = "<<plane ;
194 uint32_t tempdetid= it->first;
195 std::vector<int> rocs = it->second;
196 unsigned int nrocs = rocs.size();
197 std::map<int,int> mapIPixIndx ;
199 std::vector<double> gainsFromHistos;
200 std::vector<double> pedsFromHistos;
204 for (
unsigned int i = 0;
i<nrocs ;
i++){
209 std::vector<float> orderedGains;
210 std::vector<float> orderedPeds;
211 for (
unsigned int k = 0 ;
k < nrocs*52*80 ;
k++){
212 int indx = mapIPixIndx[
k];
213 float tmpped = pedsFromHistos[indx];
214 float tmpgain = gainsFromHistos[indx];
215 orderedGains.push_back(tmpgain);
216 orderedPeds.push_back(tmpped);
217 tempPGCalib.
putData(
k,tmpped,tmpgain);
221 edm::LogWarning(
"CTPPSPixGainsCalibrationWriter")<<
" plane with detID ="<<tempdetid<<
" is empty";
234 edm::LogError(
"CTPPSPixGainsCalibrationWriter")<<
"Db Service Unavailable";
243 for (
int i = 0 ;
i<npixplane ; ++
i){
245 gains.push_back(0.5);
260 TH2D * tempintrcpt = (TH2D*)
m_inputRootFile->Get(tmpitcpname.c_str());
262 TH2D * tempnpfit = (TH2D*)
m_inputRootFile->Get(tmpnpfitsname.c_str());
263 int ncols = tempslope->GetNbinsX();
264 int nrows = tempslope->GetNbinsY();
265 if (nrows != 80 || ncols != 52 )
266 edm::LogWarning(
"CTPPSPixGainsCalibrationWriter")<<
"Something wrong ncols = "<< ncols <<
" and nrows = " << nrows;
268 for (
int jrow = 0; jrow < nrows ; ++jrow)
269 for (
int icol = 0 ; icol <
ncols ; ++icol){
270 double tmpslp = tempslope->GetBinContent(icol+1,jrow+1);
271 double tmpgain = (tmpslp == 0.0) ? 0.0 : 1.0/tmpslp;
272 double tmpped = tempintrcpt->GetBinContent(icol+1,jrow+1);
274 int tmpnpfit = tempnpfit -> GetBinContent(icol+1,jrow+1);
287 gains.push_back(tmpgain);
288 peds.push_back(tmpped);
292 int indx = gains.size()-1;
293 int pixIndx = modCol + modRow * (52*nrocs/2);
std::string m_inputHistosFileName
constexpr uint32_t rawId() const
get the raw id
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
std::map< uint32_t, std::vector< std::string > > detidHistoNameMap
void setGainCalibration(const uint32_t &DetId, const CTPPSPixelGainCalibration &PixGains)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
void analyze(const edm::Event &, const edm::EventSetup &) override
~WriteCTPPSPixGainCalibrations() override
void getGainsPedsFromHistos(uint32_t detid, int rocId, int index, std::vector< double > &peds, std::vector< double > &gains, std::map< int, int > &myindxmap, int nrocs)
int transformToModule(const int colROC, const int rowROC, const int rocId, int &col, int &row) const
WriteCTPPSPixGainCalibrations(const edm::ParameterSet &)
void setDummyFullPlane(std::vector< float > &peds, std::vector< float > &gains, int npixplane)
cond::Time_t currentTime() const
void putData(uint32_t ipix, float ped, float gain)
std::map< uint32_t, std::vector< int > > detidROCsPresent