CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalTPGParamBuilder Class Reference

#include <EcalTPGParamBuilder.h>

Inheritance diagram for EcalTPGParamBuilder:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void beginJob () override
 
bool checkIfOK (EcalPedestals::Item item)
 
 EcalTPGParamBuilder (edm::ParameterSet const &pSet)
 
 ~EcalTPGParamBuilder () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void computeFineGrainEBParameters (uint &lowRatio, uint &highRatio, uint &lowThreshold, uint &highThreshold, uint &lut)
 
void computeFineGrainEEParameters (uint &threshold, uint &lut_strip, uint &lut_tower)
 
bool computeLinearizerParam (double theta, double gainRatio, double calibCoeff, std::string subdet, int &mult, int &shift)
 
void computeLUT (int *lut, std::string det="EB")
 
std::vector< unsigned int > computeWeights (EcalShapeBase &shape, TH1F *histo)
 
void create_header ()
 
void getCoeff (coeffStruc &coeff, const EcalGainRatioMap &gainMap, uint rawId)
 
void getCoeff (coeffStruc &coeff, const EcalPedestalsMap &pedMap, uint rawId)
 
void getCoeff (coeffStruc &coeff, const std::map< EcalLogicID, MonPedestalsDat > &pedMap, const EcalLogicID &logicId)
 
void getCoeff (coeffStruc &coeff, const EcalIntercalibConstantMap &calibMap, const EcalLaserAlphaMap &laserAlphaMap, uint rawId, std::string &ss)
 
std::pair< std::string, int > getCrate (int tcc)
 
std::string getDet (int tcc)
 
int getEtaSlice (int tccId, int towerInTCC)
 
int getGCTRegionEta (int tteta)
 
int getGCTRegionPhi (int ttphi)
 
bool realignBaseline (linStruc &lin, float forceBase12)
 
int uncodeWeight (double weight, int complement2=7)
 
double uncodeWeight (int iweight, int complement2=7)
 

Private Attributes

int bst_conf_id_
 
int btt_conf_id_
 
int bxt_conf_id_
 
unsigned int complement2_
 
EcalTPGDBAppdb_
 
bool DBEE_
 
unsigned int DBrunNb_
 
int del_conf_id_
 
std::map< int, std::vector< int > > delays_EB_
 
std::map< int, std::vector< int > > delays_EE_
 
double Et_sat_EB_
 
double Et_sat_EE_
 
edm::ESHandle< EcalTrigTowerConstituentsMapeTTmap_
 
double FG_highRatio_EB_
 
double FG_highThreshold_EB_
 
double FG_lowRatio_EB_
 
double FG_lowThreshold_EB_
 
unsigned int FG_lut_EB_
 
unsigned int FG_lut_strip_EE_
 
unsigned int FG_lut_tower_EE_
 
double FG_Threshold_EE_
 
int fgr_conf_id_
 
int forcedPedestalValue_
 
bool forceEtaSlice_
 
std::ofstream * geomFile_
 
bool H2_
 
int lin_conf_id_
 
int lut_conf_id_
 
double LUT_constant_EB_
 
double LUT_constant_EE_
 
double LUT_noise_EB_
 
double LUT_noise_EE_
 
std::string LUT_option_
 
double LUT_stochastic_EB_
 
double LUT_stochastic_EE_
 
double LUT_threshold_EB_
 
double LUT_threshold_EE_
 
int m_write_bst
 
int m_write_btt
 
int m_write_bxt
 
int m_write_del
 
int m_write_fgr
 
int m_write_lin
 
int m_write_lut
 
int m_write_ped
 
int m_write_sli
 
int m_write_spi
 
int m_write_wei
 
unsigned int nSample_
 
Char_t ntupleCrate_ [10]
 
Char_t ntupleDet_ [10]
 
Int_t * ntupleInts_
 
std::ofstream * out_file_
 
int ped_conf_id_
 
unsigned int pedestal_offset_
 
std::map< int, std::vector< int > > phases_EB_
 
std::map< int, std::vector< int > > phases_EE_
 
unsigned int sampleMax_
 
unsigned int SFGVB_lut_
 
int SFGVB_SpikeKillingThreshold_
 
unsigned int SFGVB_Threshold_
 
int sli_conf_id_
 
unsigned int sliding_
 
int spi_conf_id_
 
std::string tag_
 
const CaloSubdetectorGeometrytheBarrelGeometry_
 
const CaloSubdetectorGeometrytheEndcapGeometry_
 
const EcalElectronicsMappingtheMapping_
 
std::string TimingDelays_EB_
 
std::string TimingDelays_EE_
 
std::string TimingPhases_EB_
 
std::string TimingPhases_EE_
 
std::string Transparency_Corr_
 
std::map< int, double > Transparency_Correction_
 
double TTF_highThreshold_EB_
 
double TTF_highThreshold_EE_
 
double TTF_lowThreshold_EB_
 
double TTF_lowThreshold_EE_
 
bool useDBShape_
 
bool useInterCalibration_
 
bool useTransparencyCorr_
 
bool useTransverseEnergy_
 
int version_
 
int wei_conf_id_
 
double weight_timeShift_
 
bool weight_unbias_recovery_
 
bool writeToDB_
 
bool writeToFiles_
 
double xtal_LSB_EB_
 
double xtal_LSB_EE_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 59 of file EcalTPGParamBuilder.h.

Constructor & Destructor Documentation

EcalTPGParamBuilder::EcalTPGParamBuilder ( edm::ParameterSet const &  pSet)
explicit

Definition at line 56 of file EcalTPGParamBuilder.cc.

References bst_conf_id_, btt_conf_id_, bxt_conf_id_, db_, DBEE_, del_conf_id_, delays_EB_, delays_EE_, Et_sat_EB_, Et_sat_EE_, FG_highRatio_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_lowThreshold_EB_, FG_lut_EB_, FG_lut_strip_EE_, FG_lut_tower_EE_, FG_Threshold_EE_, fgr_conf_id_, forcedPedestalValue_, forceEtaSlice_, geomFile_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), H2_, createfilelist::int, lin_conf_id_, lut_conf_id_, LUT_constant_EB_, LUT_constant_EE_, LUT_noise_EB_, LUT_noise_EE_, LUT_option_, LUT_stochastic_EB_, LUT_stochastic_EE_, LUT_threshold_EB_, LUT_threshold_EE_, m_write_bst, m_write_btt, m_write_bxt, m_write_del, m_write_fgr, m_write_lin, m_write_lut, m_write_ped, m_write_sli, m_write_spi, m_write_wei, MillePedeFileConverter_cfg::out, out_file_, GetRecoTauVFromDQM_MC_cff::outFile, ped_conf_id_, pedestal_offset_, phases_EB_, phases_EE_, sampleMax_, SFGVB_lut_, SFGVB_SpikeKillingThreshold_, SFGVB_Threshold_, funct::sin(), sli_conf_id_, sliding_, spi_conf_id_, AlCaHLTBitMon_QueryRunRegistry::string, tag_, TimingDelays_EB_, TimingDelays_EE_, TimingPhases_EB_, TimingPhases_EE_, Transparency_Corr_, Transparency_Correction_, TTF_highThreshold_EB_, TTF_highThreshold_EE_, TTF_lowThreshold_EB_, TTF_lowThreshold_EE_, useInterCalibration_, useTransparencyCorr_, useTransverseEnergy_, version_, wei_conf_id_, weight_timeShift_, weight_unbias_recovery_, writeToDB_, and writeToFiles_.

58 {
59  ped_conf_id_=0;
60  lin_conf_id_=0;
61  lut_conf_id_=0;
62  wei_conf_id_=0;
63  fgr_conf_id_=0;
64  sli_conf_id_=0;
65  spi_conf_id_=0; //modif-alex 21/01/11
66  del_conf_id_=0; //modif-alex 21/01/11
67  bxt_conf_id_=0;
68  btt_conf_id_=0;
69  bst_conf_id_=0;
70  tag_="";
71  version_=0;
72 
73  m_write_ped=1;
74  m_write_lin=1;
75  m_write_lut=1;
76  m_write_wei=1;
77  m_write_fgr=1;
78  m_write_sli=1;
79  m_write_spi=1; //modif-alex 21/01/11
80  m_write_del=1; //modif-alex 21/01/11
81  m_write_bxt=1;
82  m_write_btt=1;
83  m_write_bst=1;
84 
85  writeToDB_ = pSet.getParameter<bool>("writeToDB") ;
86  DBEE_ = pSet.getParameter<bool>("allowDBEE") ;
87  string DBsid = pSet.getParameter<std::string>("DBsid") ;
88  string DBuser = pSet.getParameter<std::string>("DBuser") ;
89  string DBpass = pSet.getParameter<std::string>("DBpass") ;
90  //uint32_t DBport = pSet.getParameter<unsigned int>("DBport") ;
91 
92  tag_ = pSet.getParameter<std::string>("TPGtag") ;
93  version_ = pSet.getParameter<unsigned int>("TPGversion") ;
94 
95  m_write_ped = pSet.getParameter<unsigned int>("TPGWritePed") ;
96  m_write_lin = pSet.getParameter<unsigned int>("TPGWriteLin") ;
97  m_write_lut = pSet.getParameter<unsigned int>("TPGWriteLut") ;
98  m_write_wei = pSet.getParameter<unsigned int>("TPGWriteWei") ;
99  m_write_fgr = pSet.getParameter<unsigned int>("TPGWriteFgr") ;
100  m_write_sli = pSet.getParameter<unsigned int>("TPGWriteSli") ;
101  m_write_spi = pSet.getParameter<unsigned int>("TPGWriteSpi") ; //modif-alex 21/01/11
102  m_write_del = pSet.getParameter<unsigned int>("TPGWriteDel") ; //modif-alex 21/01/11
103  m_write_bxt = pSet.getParameter<unsigned int>("TPGWriteBxt") ;
104  m_write_btt = pSet.getParameter<unsigned int>("TPGWriteBtt") ;
105  m_write_bst = pSet.getParameter<unsigned int>("TPGWriteBst") ;
106 
110 
111  if(m_write_ped != 0 && m_write_ped != 1 ) ped_conf_id_=m_write_ped;
112 
113  if (writeToDB_) edm::LogInfo("TopInfo") << "data will be saved with tag and version=" << tag_ << ".version" << version_<< "\n";
114  db_ = new EcalTPGDBApp(DBsid, DBuser, DBpass) ;
115 
116  writeToFiles_ = pSet.getParameter<bool>("writeToFiles") ;
117  if (writeToFiles_) {
118  std::string outFile = pSet.getParameter<std::string>("outFile") ;
119  out_file_ = new std::ofstream(outFile.c_str(), std::ios::out) ;
120  }
121  geomFile_ = new std::ofstream("geomFile.txt", std::ios::out) ;
122 
123 
124  useTransverseEnergy_ = pSet.getParameter<bool>("useTransverseEnergy") ;
125 
126  Et_sat_EB_ = pSet.getParameter<double>("Et_sat_EB") ;
127  Et_sat_EE_ = pSet.getParameter<double>("Et_sat_EE") ;
128  sliding_ = pSet.getParameter<unsigned int>("sliding") ;
129  weight_timeShift_ = pSet.getParameter<double>("weight_timeShift") ;
130  sampleMax_ = pSet.getParameter<unsigned int>("weight_sampleMax") ;
131  weight_unbias_recovery_ = pSet.getParameter<bool>("weight_unbias_recovery") ;
132 
133  forcedPedestalValue_ = pSet.getParameter<int>("forcedPedestalValue") ;
134  forceEtaSlice_ = pSet.getParameter<bool>("forceEtaSlice") ;
135 
136  LUT_option_ = pSet.getParameter<std::string>("LUT_option") ;
137  LUT_threshold_EB_ = pSet.getParameter<double>("LUT_threshold_EB") ;
138  LUT_threshold_EE_ = pSet.getParameter<double>("LUT_threshold_EE") ;
139  LUT_stochastic_EB_ = pSet.getParameter<double>("LUT_stochastic_EB") ;
140  LUT_noise_EB_ =pSet.getParameter<double>("LUT_noise_EB") ;
141  LUT_constant_EB_ =pSet.getParameter<double>("LUT_constant_EB") ;
142  LUT_stochastic_EE_ = pSet.getParameter<double>("LUT_stochastic_EE") ;
143  LUT_noise_EE_ =pSet.getParameter<double>("LUT_noise_EE") ;
144  LUT_constant_EE_ =pSet.getParameter<double>("LUT_constant_EE") ;
145 
146  TTF_lowThreshold_EB_ = pSet.getParameter<double>("TTF_lowThreshold_EB") ;
147  TTF_highThreshold_EB_ = pSet.getParameter<double>("TTF_highThreshold_EB") ;
148  TTF_lowThreshold_EE_ = pSet.getParameter<double>("TTF_lowThreshold_EE") ;
149  TTF_highThreshold_EE_ = pSet.getParameter<double>("TTF_highThreshold_EE") ;
150 
151  FG_lowThreshold_EB_ = pSet.getParameter<double>("FG_lowThreshold_EB") ;
152  FG_highThreshold_EB_ = pSet.getParameter<double>("FG_highThreshold_EB") ;
153  FG_lowRatio_EB_ = pSet.getParameter<double>("FG_lowRatio_EB") ;
154  FG_highRatio_EB_ = pSet.getParameter<double>("FG_highRatio_EB") ;
155  FG_lut_EB_ = pSet.getParameter<unsigned int>("FG_lut_EB") ;
156  FG_Threshold_EE_ = pSet.getParameter<double>("FG_Threshold_EE") ;
157  FG_lut_strip_EE_ = pSet.getParameter<unsigned int>("FG_lut_strip_EE") ;
158  FG_lut_tower_EE_ = pSet.getParameter<unsigned int>("FG_lut_tower_EE") ;
159  SFGVB_Threshold_ = pSet.getParameter<unsigned int>("SFGVB_Threshold") ;
160  SFGVB_lut_ = pSet.getParameter<unsigned int>("SFGVB_lut") ;
161  SFGVB_SpikeKillingThreshold_ = pSet.getParameter<int>("SFGVB_SpikeKillingThreshold") ; //modif-alex 21/01/11
162  pedestal_offset_ = pSet.getParameter<unsigned int>("pedestal_offset") ;
163 
164  useInterCalibration_ = pSet.getParameter<bool>("useInterCalibration") ;
165  H2_ = pSet.getUntrackedParameter<bool>("H2",false) ;
166 
167  useTransparencyCorr_ = false;
168  useTransparencyCorr_ = pSet.getParameter<bool>("useTransparencyCorr") ; //modif-alex-25/04/2012
169  Transparency_Corr_ = pSet.getParameter<std::string>("transparency_corrections");//modif-alex-30/01/2012
170 
171  //modif-alex-23/02/2011
172  //convert the spike killing first from GeV to ADC (10 bits)
173  //depending on the saturation scale: Et_sat_EB_
174  if(SFGVB_SpikeKillingThreshold_ == -1 || (SFGVB_SpikeKillingThreshold_ > Et_sat_EB_))
175  SFGVB_SpikeKillingThreshold_ = 1023; //nokilling
176  else
177  SFGVB_SpikeKillingThreshold_ = int(SFGVB_SpikeKillingThreshold_ * 1024/Et_sat_EB_);
178  edm::LogInfo("TopInfo") << "INFO:SPIKE KILLING THRESHOLD (ADC)=" << SFGVB_SpikeKillingThreshold_ << "\n";
179 
180  //modif-alex-02/02/11
181  //TIMING information
182  TimingDelays_EB_ = pSet.getParameter<std::string>("timing_delays_EB") ;
183  TimingDelays_EE_ = pSet.getParameter<std::string>("timing_delays_EE") ;
184  TimingPhases_EB_ = pSet.getParameter<std::string>("timing_phases_EB") ;
185  TimingPhases_EE_ = pSet.getParameter<std::string>("timing_phases_EE") ;
186 
187  std::ostringstream ss;
188  // edm::LogInfo("TopInfo") << "INFO: READING timing files" << "\n";
189  ss << "INFO: READING timing files\n";
190  std::ifstream delay_eb(TimingDelays_EB_.c_str());
191  if(!delay_eb) edm::LogError("TopInfo") << "ERROR: File " << TimingDelays_EB_.c_str() << " could not be opened" << "\n";
192  std::ifstream delay_ee(TimingDelays_EE_.c_str());
193  if(!delay_ee) edm::LogError("TopInfo") << "ERROR: File " << TimingDelays_EE_.c_str() << " could not be opened" << "\n";
194  std::ifstream phase_eb(TimingPhases_EB_.c_str());
195  if(!phase_eb) edm::LogError("TopInfo") << "ERROR: File " << TimingPhases_EB_.c_str() << " could not be opened" << "\n";
196  std::ifstream phase_ee(TimingPhases_EE_.c_str());
197  if(!phase_ee) edm::LogError("TopInfo") << "ERROR: File " << TimingPhases_EE_.c_str() << " could not be opened" << "\n";
198 
199  char buf[1024];
200  //READING DELAYS EB
201  delay_eb.getline(buf,sizeof(buf),'\n');
202  while( delay_eb ) {
203  std::stringstream sin(buf);
204 
205  int tcc;
206  sin >> tcc;
207 
208  vector<int> vec_delays_eb;
209  for(int ieb=0; ieb<68; ++ieb){
210  int time_delay = -1;
211  sin >> time_delay;
212  vec_delays_eb.push_back(time_delay);
213  if(time_delay==-1) edm::LogError("TopInfo") << "ERROR:Barrel timing delay -1, check file" << "\n";
214  }
215 
216  if(vec_delays_eb.size()!=68)
217  edm::LogError("TopInfo") << "ERROR:Barrel timing delay wrong, not enough towers, check file" << "\n";
218 
219  if (delays_EB_.find(tcc) == delays_EB_.end())
220  delays_EB_.insert(make_pair(tcc,vec_delays_eb));
221 
222  // edm::LogInfo("TopInfo") << tcc << "\n";
223  ss << tcc;
224  for(unsigned int ieb=0; ieb<vec_delays_eb.size(); ++ieb)
225  // edm::LogInfo("TopInfo") << vec_delays_eb[ieb] << "\n";
226  ss << " " << vec_delays_eb[ieb];
227  delay_eb.getline(buf,sizeof(buf),'\n');
228  ss << "\n";
229  }//loop delay file EB
230  delay_eb.close();
231 
232  //READING PHASES EB
233  phase_eb.getline(buf,sizeof(buf),'\n');
234  while( phase_eb ) {
235  std::stringstream sin(buf);
236  int tcc;
237  sin >> tcc;
238 
239  vector<int> vec_phases_eb;
240  for(unsigned int ieb=0; ieb<68; ++ieb){
241  int time_phase = -1;
242  sin >> time_phase;
243  vec_phases_eb.push_back(time_phase);
244  if(time_phase==-1) edm::LogError("TopInfo") << "ERROR:Barrel timing phase -1, check file" << "\n";
245  }
246 
247  if(vec_phases_eb.size()!=68)
248  edm::LogError("TopInfo") << "ERROR:Barrel timing phase wrong, not enough towers, check file" << "\n";
249 
250  if (phases_EB_.find(tcc) == phases_EB_.end())
251  phases_EB_.insert(make_pair(tcc,vec_phases_eb));
252 
253  // edm::LogInfo("TopInfo") << tcc << "\n";
254  ss << tcc;
255  for(unsigned int ieb=0; ieb<vec_phases_eb.size(); ++ieb)
256  // edm::LogInfo("TopInfo") << vec_phases_eb[ieb] << "\n";
257  ss << " " << vec_phases_eb[ieb];
258  phase_eb.getline(buf,sizeof(buf),'\n');
259  ss << "\n";
260  }//loop phase file EB
261  phase_eb.close();
262 
263  //READING DELAYS EE//------------------------------------------------
264  delay_ee.getline(buf,sizeof(buf),'\n');
265  while( delay_ee ) {
266  std::stringstream sin(buf);
267  int tcc;
268  sin >> tcc;
269 
270  vector<int> vec_delays_ee;
271  for(unsigned int iee=0; iee<48; ++iee){
272  int time_delay = -1;
273  sin >> time_delay;
274  vec_delays_ee.push_back(time_delay);
275  if(time_delay==-1) edm::LogError("TopInfo") << "ERROR:EE timing delay -1, check file" << "\n";
276  }
277 
278  if(vec_delays_ee.size()!=48)
279  edm::LogError("TopInfo") << "ERROR:EE timing delay wrong, not enough towers, check file" << "\n";
280 
281  if (delays_EE_.find(tcc) == delays_EE_.end())
282  delays_EE_.insert(make_pair(tcc,vec_delays_ee));
283 
284  // edm::LogInfo("TopInfo") << tcc << "\n";
285  ss << tcc;
286  for(unsigned int iee=0; iee<vec_delays_ee.size(); ++iee)
287  // edm::LogInfo("TopInfo") << vec_delays_ee[iee] << "\n";
288  ss << " " << vec_delays_ee[iee];
289  ss << "\n";
290  delay_ee.getline(buf,sizeof(buf),'\n');
291  }//loop delay file EE
292  delay_ee.close();
293 
294  //READING PHASES EE
295  phase_ee.getline(buf,sizeof(buf),'\n');
296  while( phase_ee ) {
297  std::stringstream sin(buf);
298  int tcc;
299  sin >> tcc;
300 
301  vector<int> vec_phases_ee;
302  for(unsigned int iee=0; iee<48; ++iee){
303  int time_phase = -1;
304  sin >> time_phase;
305  vec_phases_ee.push_back(time_phase);
306  if(time_phase==-1) edm::LogError("TopInfo") << "ERROR:EE timing phase -1, check file" << "\n";
307  }
308 
309  if(vec_phases_ee.size()!=48)
310  edm::LogError("TopInfo") << "ERROR:EE timing phase wrong, not enough towers, check file" << "\n";
311 
312  if (phases_EE_.find(tcc) == phases_EE_.end())
313  phases_EE_.insert(make_pair(tcc,vec_phases_ee));
314  // edm::LogInfo("TopInfo") << tcc << "\n";
315  ss << tcc;
316  for(unsigned int iee = 0; iee < vec_phases_ee.size(); ++iee)
317  // edm::LogInfo("TopInfo") << vec_phases_ee[iee] << "\n";
318  ss << " " << vec_phases_ee[iee];
319  ss << "\n";
320  phase_ee.getline(buf,sizeof(buf),'\n');
321  }//loop phase file EE
322  phase_ee.close();
323 
324  // edm::LogInfo("TopInfo") << "INFO: DONE reading timing files for EB and EE" << "\n";
325  ss << "INFO: DONE reading timing files for EB and EE\n";
326  edm::LogInfo("TopInfo") << ss.str();
327 
328  //modif-alex-30/01/2012
329  ss.str("");
330  if(useTransparencyCorr_){
331  // edm::LogInfo("TopInfo") << "INFO: READING transparency correction files" << "\n";
332  ss << "INFO: READING transparency correction files\n";
333  std::ifstream transparency(Transparency_Corr_.c_str());
334  if(!transparency) edm::LogError("TopInfo") << "ERROR: File " << Transparency_Corr_.c_str() << " could not be opened" << "\n";
335 
336  transparency.getline(buf,sizeof(buf),'\n');
337  int xtalcounter = 0;
338  while( transparency ) {
339  std::stringstream sin(buf);
340 
341  int raw_xtal_id;
342  sin >> raw_xtal_id;
343 
344  double xtal_trans_corr;
345  sin >> xtal_trans_corr;
346 
347  // edm::LogInfo("TopInfo") << raw_xtal_id << " " << xtal_trans_corr << "\n";
348  ss << raw_xtal_id << " " << xtal_trans_corr << "\n";
349 
350  Transparency_Correction_.insert(make_pair(raw_xtal_id,xtal_trans_corr));
351 
352  xtalcounter++;
353  transparency.getline(buf,sizeof(buf),'\n');
354  }//loop transparency
355  transparency.close();
356  ss << "INFO: DONE transparency correction files " << xtalcounter << "\n";
357  edm::LogInfo("TopInfo") << ss.str();
358  ss.str("");
359  }//if transparency
360 }
std::map< int, std::vector< int > > phases_EB_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< int, double > Transparency_Correction_
std::ofstream * out_file_
std::map< int, std::vector< int > > delays_EB_
std::map< int, std::vector< int > > delays_EE_
std::ofstream * geomFile_
std::map< int, std::vector< int > > phases_EE_
EcalTPGParamBuilder::~EcalTPGParamBuilder ( )
override

Definition at line 362 of file EcalTPGParamBuilder.cc.

References out_file_, and writeToFiles_.

363 {
364  if (writeToFiles_) {
365  (*out_file_ )<<"EOF"<<std::endl ;
366  out_file_->close() ;
367  delete out_file_ ;
368  }
369 }
std::ofstream * out_file_

Member Function Documentation

void EcalTPGParamBuilder::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
override

Definition at line 399 of file EcalTPGParamBuilder.cc.

References funct::abs(), EcalCondObjectContainer< T >::barrelItems(), runEdmFileComparison::base, EcalCondObjectContainer< T >::begin(), bst_conf_id_, btt_conf_id_, bxt_conf_id_, coeffStruc::calibCoeff_, EcalTriggerElectronicsId::channelId(), computeFineGrainEBParameters(), computeFineGrainEEParameters(), computeLinearizerParam(), computeLUT(), computeWeights(), createfilelist::dataset, db_, DBEE_, EcalElectronicsId::dccId(), EcalElectronicsMapping::DCCid(), TauDecayModes::dec, del_conf_id_, delays_EB_, delays_EE_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::endcapItems(), Et_sat_EB_, Et_sat_EE_, eTTmap_, EcalCondDBInterface::fetchDataSet(), FG_highRatio_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_lowThreshold_EB_, FG_Threshold_EE_, fgr_conf_id_, plotBeamSpotDB::first, objects.autophobj::float, forcedPedestalValue_, forceEtaSlice_, g, callgraph::G, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), coeffStruc::gainRatio_, edm::EventSetup::get(), FEConfigMainInfo::getBstId(), FEConfigMainInfo::getBttId(), FEConfigMainInfo::getBxtId(), getCoeff(), getCrate(), getDet(), EcalADCToGeVConstant::getEBValue(), EcalCondDBInterface::getEcalLogicID(), EcalCondDBInterface::getEcalLogicIDSetOrdered(), EcalADCToGeVConstant::getEEValue(), EcalElectronicsMapping::getElectronicsId(), FEConfigMainInfo::getFgrId(), getGCTRegionEta(), getGCTRegionPhi(), CaloSubdetectorGeometry::getGeometry(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), FEConfigMainInfo::getLinId(), EcalLogicID::getLogicID(), FEConfigMainInfo::getLUTId(), EcalCondObjectContainer< T >::getMap(), EcalLogicID::getName(), FEConfigMainInfo::getPedId(), FEConfigPedDat::getPedMeanG1(), FEConfigPedDat::getPedMeanG12(), FEConfigPedDat::getPedMeanG6(), FEConfigMainInfo::getSliId(), FEConfigMainInfo::getSpiId(), FEConfigMainInfo::getTimId(), EcalElectronicsMapping::getTriggerElectronicsId(), CaloSubdetectorGeometry::getValidDetIds(), FEConfigMainInfo::getWeiId(), H2_, cmsBatch::handle, ecalpyutils::hashedIndex(), mps_fire::i, triggerObjects_cff::id, EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::ietaAbs(), EcalCondObjectContainer< T >::insert(), createfilelist::int, EcalTrigTowerDetId::iphi(), EcalElectronicsMapping::iTT(), gen::k, lin_conf_id_, lumiPlot::lut, lut_conf_id_, LUT_option_, lumiCalc2::lute, m_write_del, m_write_fgr, m_write_lin, m_write_lut, m_write_ped, m_write_sli, m_write_spi, m_write_wei, EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, linStruc::mult_, ntupleCrate_, ntupleDet_, ntupleInts_, EcalLogicID::NULLID, convertSQLiteXML::ok, MillePedeFileConverter_cfg::out, out_file_, AlCaHLTBitMon_ParallelJobs::p, ped_conf_id_, linStruc::pedestal_, pedestal_offset_, coeffStruc::pedestals_, phases_EB_, phases_EE_, funct::pow(), edm::ESHandle< T >::product(), EcalTriggerElectronicsId::pseudoStripId(), EcalTriggerElectronicsId::rawId(), DetId::rawId(), realignBaseline(), EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, simplePhotonAnalyzer_cfi::sample, IODConfig::setConfigTag(), FEConfigLinParamDat::setETSat(), FEConfigLUTParamDat::setETSat(), EcalShapeBase::setEventSetup(), FEConfigFgrParamDat::setFGhighratio(), FEConfigFgrParamDat::setFGhighthresh(), FEConfigFgrParamDat::setFGlowratio(), FEConfigFgrParamDat::setFGlowthresh(), FEConfigFgrGroupDat::setFgrGroupId(), FEConfigFgrDat::setFgrGroupId(), FEConfigPedInfo::setId(), FEConfigFgrEEStripDat::setLutFgr(), FEConfigLUTDat::setLUTGroupId(), FEConfigLUTGroupDat::setLUTGroupId(), FEConfigFgrEETowerDat::setLutValue(), FEConfigLUTGroupDat::setLUTValue(), FEConfigFgrGroupDat::setLUTValue(), FEConfigLinDat::setMultX1(), FEConfigLinDat::setMultX12(), FEConfigLinDat::setMultX6(), FEConfigPedDat::setPedMeanG1(), FEConfigPedDat::setPedMeanG12(), FEConfigPedDat::setPedMeanG6(), FEConfigFgrGroupDat::setRatioHigh(), FEConfigFgrGroupDat::setRatioLow(), FEConfigLinDat::setShift1(), FEConfigLinDat::setShift12(), FEConfigLinDat::setShift6(), FEConfigSlidingDat::setSliding(), FEConfigSpikeDat::setSpikeThreshold(), FEConfigFgrGroupDat::setThreshHigh(), FEConfigFgrGroupDat::setThreshLow(), FEConfigFgrEEStripDat::setThreshold(), FEConfigTimingDat::setTimingPar1(), FEConfigTimingDat::setTimingPar2(), FEConfigLUTParamDat::setTTThreshhigh(), FEConfigLUTParamDat::setTTThreshlow(), FEConfigWeightGroupDat::setWeight0(), FEConfigWeightGroupDat::setWeight1(), FEConfigWeightGroupDat::setWeight2(), FEConfigWeightGroupDat::setWeight3(), FEConfigWeightGroupDat::setWeight4(), FEConfigWeightGroupDat::setWeightGroupId(), FEConfigWeightDat::setWeightGroupId(), SFGVB_lut_, SFGVB_SpikeKillingThreshold_, SFGVB_Threshold_, edm::shift, linStruc::shift_, funct::sin(), findQualityFiles::size, sli_conf_id_, sliding_, EBDetId::SMCRYSTALMODE, spi_conf_id_, str, AlCaHLTBitMon_QueryRunRegistry::string, EcalElectronicsId::stripId(), EcalTrigTowerDetId::subDet(), tag_, EcalElectronicsMapping::TCCid(), theBarrelGeometry_, theEndcapGeometry_, theMapping_, theta(), electronIdCutBased_cfi::threshold, EcalElectronicsId::towerId(), funct::true, TTF_highThreshold_EB_, TTF_highThreshold_EE_, TTF_lowThreshold_EB_, TTF_lowThreshold_EE_, EBDetId::unhashIndex(), EEDetId::unhashIndex(), useDBShape_, useTransverseEnergy_, heppy_batch::val, version_, wei_conf_id_, create_public_lumi_plots::weights, EcalTPGDBApp::writeToConfDB_Delay(), EcalTPGDBApp::writeToConfDB_Spike(), EcalTPGDBApp::writeToConfDB_TPGFgr(), EcalTPGDBApp::writeToConfDB_TPGLinearCoef(), EcalTPGDBApp::writeToConfDB_TPGLUT(), EcalTPGDBApp::writeToConfDB_TPGMain(), EcalTPGDBApp::writeToConfDB_TPGPedestals(), EcalTPGDBApp::writeToConfDB_TPGSliding(), EcalTPGDBApp::writeToConfDB_TPGWeight(), writeToDB_, writeToFiles_, x, xtal_LSB_EB_, xtal_LSB_EE_, EcalElectronicsId::xtalId(), EEDetId::XYMODE, y, z, EcalTrigTowerDetId::zside(), and ecaldqm::zside().

400 {
401  using namespace edm;
402  using namespace std;
403 
404  // geometry
405  ESHandle<CaloGeometry> theGeometry;
406  ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
407  evtSetup.get<CaloGeometryRecord>().get( theGeometry );
408  evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap",theEndcapGeometry_handle);
409  evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel",theBarrelGeometry_handle);
410  evtSetup.get<IdealGeometryRecord>().get(eTTmap_);
411  theEndcapGeometry_ = theEndcapGeometry_handle.product();
412  theBarrelGeometry_ = theBarrelGeometry_handle.product();
413 
414  // electronics mapping
416  evtSetup.get< EcalMappingRcd >().get(ecalmapping);
417  theMapping_ = ecalmapping.product();
418 
419  // get record for alpha
420  std::ostringstream ss;
421  ss << "EcalLaserDbAnalyzer::analyze\n";
423  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
424  ss << "EcalLaserDbAnalyzer::analyze-> got EcalLaserDbRecord: \n";
425  const EcalLaserAlphaMap& laserAlphaMap = handle.product()->getMap(); // map of apdpns
426 
427  //modif-alex-27-july-2015-+ Jean june 2016 beg
428  // use alpha to check
430  int cnt = 0;
431  // Barrel loop
432  for(italpha = laserAlphaMap.barrelItems().begin(); italpha != laserAlphaMap.barrelItems().end(); ++italpha) {
433  if (cnt %1000 == 0) {
434  EBDetId ebdetid = EBDetId::unhashIndex(cnt);
435  ss << " Barrel ALPHA = " << (*italpha) << " cmsswId " << ebdetid.rawId() << "\n";
436  }
437  cnt++;
438  }
439  ss << "Number of barrel Alpha parameters : " << cnt << "\n";
440  // Endcap loop
441  cnt = 0;
442  for(italpha = laserAlphaMap.endcapItems().begin(); italpha != laserAlphaMap.endcapItems().end(); ++italpha) {
443  if (cnt %1000 == 0) {
444  EEDetId eedetid = EEDetId::unhashIndex(cnt);
445  ss << "EndCap ALPHA = " << (*italpha) << " cmsswId " << eedetid.rawId() << "\n";
446  }
447  cnt++;
448  }
449  ss << "Number of Endcap Alpha parameters : " << cnt << "\n";
450  edm::LogInfo("TopInfo") << ss.str();
451  ss.str("");
452  //modif-alex-27-july-2015 +-Jean june 2016-end
453 
454  // histo
455  TFile saving ("EcalTPGParam.root","recreate") ;
456  saving.cd () ;
457  TH2F * ICEB = new TH2F("ICEB", "IC: Barrel", 360, 1, 361, 172, -86, 86) ;
458  ICEB->GetYaxis()->SetTitle("eta index") ;
459  ICEB->GetXaxis()->SetTitle("phi index") ;
460  TH2F * tpgFactorEB = new TH2F("tpgFactorEB", "tpgFactor: Barrel", 360, 1, 361, 172, -86, 86) ;
461  tpgFactorEB->GetYaxis()->SetTitle("eta index") ;
462  tpgFactorEB->GetXaxis()->SetTitle("phi index") ;
463 
464  TH2F * ICEEPlus = new TH2F("ICEEPlus", "IC: Plus Endcap", 120, -9, 111, 120, -9, 111) ;
465  ICEEPlus->GetYaxis()->SetTitle("y index") ;
466  ICEEPlus->GetXaxis()->SetTitle("x index") ;
467  TH2F * tpgFactorEEPlus = new TH2F("tpgFactorEEPlus", "tpgFactor: Plus Endcap", 120, -9, 111, 120, -9, 111) ;
468  tpgFactorEEPlus->GetYaxis()->SetTitle("y index") ;
469  tpgFactorEEPlus->GetXaxis()->SetTitle("x index") ;
470  TH2F * ICEEMinus = new TH2F("ICEEMinus", "IC: Minus Endcap", 120, -9, 111, 120, -9, 111) ;
471  ICEEMinus->GetYaxis()->SetTitle("y index") ;
472  ICEEMinus->GetXaxis()->SetTitle("x index") ;
473  TH2F * tpgFactorEEMinus = new TH2F("tpgFactorEEMinus", "tpgFactor: Minus Endcap", 120, -9, 111, 120, -9, 111) ;
474  tpgFactorEEMinus->GetYaxis()->SetTitle("y index") ;
475  tpgFactorEEMinus->GetXaxis()->SetTitle("x index") ;
476 
477  TH2F * IC = new TH2F("IC", "IC", 720, -acos(-1.), acos(-1.), 600, -3., 3.) ;
478  IC->GetYaxis()->SetTitle("eta") ;
479  IC->GetXaxis()->SetTitle("phi") ;
480  TH2F * tpgFactor = new TH2F("tpgFactor", "tpgFactor", 720, -acos(-1.), acos(-1.), 600, -3., 3.) ;
481  tpgFactor->GetYaxis()->SetTitle("eta") ;
482  tpgFactor->GetXaxis()->SetTitle("phi") ;
483 
484  TH1F * hshapeEB = new TH1F("shapeEB", "shapeEB", 250, 0., 10.) ;
485  TH1F * hshapeEE = new TH1F("shapeEE", "shapeEE", 250, 0., 10.) ;
486 
487  TTree * ntuple = new TTree("tpgmap","TPG geometry map") ;
488  const std::string branchFloat[26] = {"fed","tcc","tower","stripInTower","xtalInStrip",
489  "CCU","VFE","xtalInVFE","xtalInCCU","ieta","iphi",
490  "ix","iy","iz","hashedId","ic","cmsswId","dbId","ietaTT","iphiTT",
491  "TCCch","TCCslot","SLBch","SLBslot","ietaGCT","iphiGCT"} ;
492  ntupleInts_ = new Int_t[26] ;
493  for (int i=0 ; i<26 ; i++) ntuple->Branch(branchFloat[i].c_str(),&ntupleInts_[i],(branchFloat[i]+string("/I")).c_str()) ;
494  ntuple->Branch("det",ntupleDet_,"det/C") ;
495  ntuple->Branch("crate",ntupleCrate_,"crate/C") ;
496 
497 
498  TNtuple *ntupleSpike = new TNtuple("spikeParam","Spike parameters","gainId:theta:G:g:ped:pedLin") ;
499 
500 
501 
502 
504  // Initialization section //
506  list<uint32_t> towerListEB ;
507  list<uint32_t> stripListEB ;
508  list<uint32_t> towerListEE ;
509  list<uint32_t> stripListEE ;
510  list<uint32_t>::iterator itList ;
511 
512  map<int, uint32_t> stripMapEB ; // <EcalLogicId.hashed, strip elec id>
513  map<uint32_t, uint32_t> stripMapEBsintheta ; // <strip elec id, sintheta>
514 
515 
516  // Pedestals
517 
518  EcalPedestalsMap pedMap ;
519 
520  if(m_write_ped == 1) {
521  ss <<"Getting the pedestals from offline DB...\n";
522 
523  ESHandle<EcalPedestals> pedHandle;
524  evtSetup.get<EcalPedestalsRcd>().get( pedHandle );
525  pedMap = pedHandle.product()->getMap() ;
526 
527 
528  EcalPedestalsMapIterator pedIter ;
529  int nPed = 0 ;
530  for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
531  EcalPedestals::Item aped = (*pedIter);
532  ss <<aped.mean_x12<<", "<<aped.mean_x6<<", "<<aped.mean_x1<< "\n" ;
533  }
534  } else if(m_write_ped==0) {
535  ss <<"Getting the pedestals from previous configuration\n";
536 
537  EcalPedestals peds ;
538 
539  FEConfigMainInfo fe_main_info;
540  fe_main_info.setConfigTag(tag_);
541  ss << "trying to read previous tag if it exists tag="<< tag_<< ".version"<<version_<< "\n";
542  db_-> fetchConfigSet(&fe_main_info);
543  if(fe_main_info.getPedId()>0 ) ped_conf_id_=fe_main_info.getPedId();
544 
545  FEConfigPedInfo fe_ped_info;
546  fe_ped_info.setId(ped_conf_id_);
547  db_-> fetchConfigSet(&fe_ped_info);
548  std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
549  db_->fetchDataSet(&dataset_TpgPed, &fe_ped_info);
550 
551  typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
552  EcalLogicID ecid_xt;
553  FEConfigPedDat rd_ped;
554  int icells=0;
555  for (CIfeped p = dataset_TpgPed.begin(); p != dataset_TpgPed.end(); p++)
556  {
557  ecid_xt = p->first;
558  rd_ped = p->second;
559 
560  std::string ecid_name=ecid_xt.getName();
561 
562  // EB data
563  if (ecid_name=="EB_crystal_number") {
564 
565 
566  int sm_num=ecid_xt.getID1();
567  int xt_num=ecid_xt.getID2();
568 
569  EBDetId ebdetid(sm_num,xt_num,EBDetId::SMCRYSTALMODE);
570  EcalPedestals::Item item;
571  item.mean_x1 =rd_ped.getPedMeanG1() ;
572  item.mean_x6 =rd_ped.getPedMeanG6();
573  item.mean_x12 =rd_ped.getPedMeanG12();
574  item.rms_x1 =0.5 ;
575  item.rms_x6 =1. ;
576  item.rms_x12 =1.2 ;
577 
578  if(icells<10) ss << " copy the EB data " << " ped = " << item.mean_x12<< "\n";
579 
580  peds.insert(std::make_pair(ebdetid.rawId(),item));
581 
582  ++icells;
583  }else if (ecid_name=="EE_crystal_number"){
584 
585  // EE data
586  int z=ecid_xt.getID1();
587  int x=ecid_xt.getID2();
588  int y=ecid_xt.getID3();
589  EEDetId eedetid(x,y,z,EEDetId::XYMODE);
590  EcalPedestals::Item item;
591  item.mean_x1 =rd_ped.getPedMeanG1() ;
592  item.mean_x6 =rd_ped.getPedMeanG6();
593  item.mean_x12 =rd_ped.getPedMeanG12();
594  item.rms_x1 =0.5 ;
595  item.rms_x6 =1. ;
596  item.rms_x12 =1.2 ;
597 
598  peds.insert(std::make_pair(eedetid.rawId(),item));
599  ++icells;
600  }
601  }
602 
603  pedMap = peds.getMap() ;
604 
605  EcalPedestalsMapIterator pedIter ;
606  int nPed = 0 ;
607  for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
608  EcalPedestals::Item aped = (*pedIter);
609  ss << aped.mean_x12 <<", " << aped.mean_x6 << ", " << aped.mean_x1 << "\n" ;
610  }
611 
612 
613 
614 
615 
616  } else if(m_write_ped >1) {
617  ss <<"Getting the pedestals from configuration number"<< m_write_ped << "\n";
618 
619 
620 
621  EcalPedestals peds ;
622 
623 
624 
625  FEConfigPedInfo fe_ped_info;
626  fe_ped_info.setId(m_write_ped);
627  db_-> fetchConfigSet(&fe_ped_info);
628  std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
629  db_->fetchDataSet(&dataset_TpgPed, &fe_ped_info);
630 
631  typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
632  EcalLogicID ecid_xt;
633  FEConfigPedDat rd_ped;
634  int icells=0;
635  for (CIfeped p = dataset_TpgPed.begin(); p != dataset_TpgPed.end(); p++)
636  {
637  ecid_xt = p->first;
638  rd_ped = p->second;
639 
640  std::string ecid_name=ecid_xt.getName();
641 
642  // EB data
643  if (ecid_name=="EB_crystal_number") {
644  if(icells<10) edm::LogInfo("TopInfo") << " copy the EB data " << " icells = " << icells << "\n";
645  int sm_num=ecid_xt.getID1();
646  int xt_num=ecid_xt.getID2();
647 
648  EBDetId ebdetid(sm_num,xt_num,EBDetId::SMCRYSTALMODE);
649  EcalPedestals::Item item;
650  item.mean_x1 =(unsigned int)rd_ped.getPedMeanG1() ;
651  item.mean_x6 =(unsigned int)rd_ped.getPedMeanG6();
652  item.mean_x12 =(unsigned int)rd_ped.getPedMeanG12();
653  item.rms_x1 =0.5 ;
654  item.rms_x6 =1. ;
655  item.rms_x12 =1.2 ;
656 
657  peds.insert(std::make_pair(ebdetid.rawId(),item));
658  ++icells;
659  }else if (ecid_name=="EE_crystal_number"){
660 
661  // EE data
662  int z=ecid_xt.getID1();
663  int x=ecid_xt.getID2();
664  int y=ecid_xt.getID3();
665  EEDetId eedetid(x,y,z,EEDetId::XYMODE);
666  EcalPedestals::Item item;
667  item.mean_x1 =(unsigned int)rd_ped.getPedMeanG1();
668  item.mean_x6 =(unsigned int)rd_ped.getPedMeanG6();
669  item.mean_x12 =(unsigned int)rd_ped.getPedMeanG12();
670  item.rms_x1 =0.5 ;
671  item.rms_x6 =1. ;
672  item.rms_x12 =1.2 ;
673 
674  peds.insert(std::make_pair(eedetid.rawId(),item));
675  ++icells;
676  }
677  }
678 
679  pedMap = peds.getMap() ;
680 
681  EcalPedestalsMapIterator pedIter ;
682  int nPed = 0 ;
683  for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
684  EcalPedestals::Item aped = (*pedIter);
685  ss << aped.mean_x12 << ", " << aped.mean_x6 << ", " << aped.mean_x1 << "\n" ;
686  }
687  }
688 
689  edm::LogInfo("TopInfo") << ss.str();
690  ss.str("");
691 
692  // Intercalib constants
693  ss <<"Getting intercalib from offline DB...\n";
695  evtSetup.get<EcalIntercalibConstantsRcd>().get(pIntercalib) ;
696  const EcalIntercalibConstants * intercalib = pIntercalib.product() ;
697  const EcalIntercalibConstantMap & calibMap = intercalib->getMap() ;
699  int nCal = 0 ;
700  for (calIter = calibMap.begin() ; calIter != calibMap.end() && nCal<10 ; ++calIter, nCal++) {
701  ss << (*calIter)<< "\n" ;
702  }
703  edm::LogInfo("TopInfo") << ss.str();
704  ss.str("");
705  float calibvec[1700] ;
706  if (H2_) {
707  edm::LogInfo("TopInfo") <<"H2: overwriting IC coef with file"<< "\n" ;
708  std::ifstream calibfile("calib_sm36.txt", std::ios::out) ;
709  int idata, icry ;
710  float fdata, fcali ;
711  std::string strdata ;
712  if (calibfile.is_open()) {
713  calibfile >> strdata >> strdata >> strdata >> strdata >> strdata ;
714  while(!calibfile.eof()) {
715  calibfile >> idata >> icry >> fcali >> fdata >> fdata ;
716  calibvec[icry-1] = fcali ;
717  if(calibfile.eof()){
718  break ; // avoid last line duplication
719  }
720  }
721  }
722  }
723 
724  // Gain Ratios
725  ss << "Getting the gain ratios from offline DB...\n";
727  evtSetup.get<EcalGainRatiosRcd>().get(pRatio);
728  const EcalGainRatioMap & gainMap = pRatio.product()->getMap();
730  int nGain = 0 ;
731  for (gainIter = gainMap.begin() ; gainIter != gainMap.end() && nGain<10 ; ++gainIter, nGain++) {
732  const EcalMGPAGainRatio & aGain = (*gainIter) ;
733  ss << aGain.gain12Over6() << ", " << aGain.gain6Over1() * aGain.gain12Over6()<< "\n" ;
734  }
735  edm::LogInfo("TopInfo") << ss.str();
736  ss.str("");
737 
738  // ADCtoGeV
739  ss << "Getting the ADC to GeV from offline DB...\n";
741  evtSetup.get<EcalADCToGeVConstantRcd>().get(pADCToGeV) ;
742  const EcalADCToGeVConstant * ADCToGeV = pADCToGeV.product() ;
743  xtal_LSB_EB_ = ADCToGeV->getEBValue() ;
744  xtal_LSB_EE_ = ADCToGeV->getEEValue() ;
745  ss <<"xtal_LSB_EB_ = "<<xtal_LSB_EB_<< "\n" ;
746  ss <<"xtal_LSB_EE_ = "<<xtal_LSB_EE_<< "\n" ;
747 
748  vector<EcalLogicID> my_EcalLogicId;
749  vector<EcalLogicID> my_TTEcalLogicId;
750  vector<EcalLogicID> my_StripEcalLogicId;
751  EcalLogicID my_EcalLogicId_EB;
752  // Endcap identifiers
753  EcalLogicID my_EcalLogicId_EE;
754  vector<EcalLogicID> my_TTEcalLogicId_EE;
755  vector<EcalLogicID> my_RTEcalLogicId_EE;
756  vector<EcalLogicID> my_StripEcalLogicId1_EE;
757  vector<EcalLogicID> my_StripEcalLogicId2_EE;
758  vector<EcalLogicID> my_CrystalEcalLogicId_EE;
759  vector<EcalLogicID> my_TTEcalLogicId_EB_by_TCC;
760  vector<EcalLogicID> my_StripEcalLogicId_EE_strips_by_TCC;
761 
764  my_EcalLogicId = db_->getEcalLogicIDSetOrdered( "EB_crystal_number",
765  1, 36,
766  1, 1700,
768  "EB_crystal_number",12 );
769  my_TTEcalLogicId = db_->getEcalLogicIDSetOrdered( "EB_trigger_tower",
770  1, 36,
771  1, 68,
773  "EB_trigger_tower",12 );
774  my_StripEcalLogicId = db_->getEcalLogicIDSetOrdered( "EB_VFE", 1, 36, 1, 68, 1,5 , "EB_VFE",123 ); //last digi means ordered 1st by SM,then TT, then strip
775  ss <<"got the 3 ecal barrel logic id set\n";
776 
777  // EE crystals identifiers
778  my_CrystalEcalLogicId_EE = db_->getEcalLogicIDSetOrdered("EE_crystal_number",
779  -1, 1,
780  0, 200,
781  0, 200,
782  "EE_crystal_number",123 );
783 
784  // EE Strip identifiers
785  // DCC=601-609 TT = ~40 EEstrip = 5
786  my_StripEcalLogicId1_EE = db_->getEcalLogicIDSetOrdered( "ECAL_readout_strip",
787  601, 609,
788  1, 100,
789  0,5 ,
790  "ECAL_readout_strip",123 );
791  // EE Strip identifiers
792  // DCC=646-654 TT = ~40 EEstrip = 5
793  my_StripEcalLogicId2_EE = db_->getEcalLogicIDSetOrdered( "ECAL_readout_strip",
794  646, 654,
795  1, 100,
796  0,5 ,
797  "ECAL_readout_strip",123 );
798  // ----> modif here 31/1/2011
799  // EE Strip identifiers by TCC tower strip
800  // TCC=1-108 TT = ~40 EEstrip = 1-5
801  my_StripEcalLogicId_EE_strips_by_TCC = db_->getEcalLogicIDSetOrdered( "EE_trigger_strip",
802  1, 108,
803  1, 100,
804  1,5 ,
805  "EE_trigger_strip",123 );
806 
807 
808  // ----> modif here 31/1/2011
809  // ECAL Barrel trigger towers by TCC/tower identifiers
810  // TTC=38-72 TT = 1-68
811  my_TTEcalLogicId_EB_by_TCC = db_->getEcalLogicIDSetOrdered( "ECAL_trigger_tower",
812  1, 108,
813  1, 68,
815  "ECAL_trigger_tower",12 );
816 
817  // EE TT identifiers
818  // TTC=72 TT = 1440
819  my_TTEcalLogicId_EE = db_->getEcalLogicIDSetOrdered( "EE_trigger_tower",
820  1, 108,
821  1, 40,
823  "EE_trigger_tower",12 );
824 
825  // EE TT identifiers
826  // TTC=72 TT = 1440
827  my_RTEcalLogicId_EE = db_->getEcalLogicIDSetOrdered( "EE_readout_tower",
828  1, 1000,
829  1, 100,
831  "EE_readout_tower",12 );
832  edm::LogInfo("TopInfo") << ss.str();
833  ss.str("");
834 
835  if (writeToDB_) {
836  ss <<"Getting the latest ids for this tag (latest version) "<< "\n";
837 
838  FEConfigMainInfo fe_main_info;
839  fe_main_info.setConfigTag(tag_);
840 
841  ss << "trying to read previous tag if it exists tag="<< tag_<< ".version"<<version_<< "\n";
842 
843  db_-> fetchConfigSet(&fe_main_info);
844  if(fe_main_info.getPedId()>0 && ped_conf_id_ ==0 ) ped_conf_id_=fe_main_info.getPedId();
845  lin_conf_id_=fe_main_info.getLinId();
846  lut_conf_id_=fe_main_info.getLUTId();
847  wei_conf_id_=fe_main_info.getWeiId();
848  fgr_conf_id_=fe_main_info.getFgrId();
849  sli_conf_id_=fe_main_info.getSliId();
850  spi_conf_id_=fe_main_info.getSpiId(); //modif-alex 21/01/11
851  del_conf_id_=fe_main_info.getTimId(); //modif-alex 21/01/11
852  if(fe_main_info.getBxtId()>0 && bxt_conf_id_==0 ) bxt_conf_id_=fe_main_info.getBxtId();
853  if(fe_main_info.getBttId()>0 && btt_conf_id_==0 ) btt_conf_id_=fe_main_info.getBttId();
854  if(fe_main_info.getBstId()>0 && bst_conf_id_==0 ) bst_conf_id_=fe_main_info.getBstId();
855  // those that are not written specifically in this program are propagated
856  // from the previous record with the same tag and the highest version
857 
858  }
859 
861  // Compute linearization coeff section //
863 
864  map<EcalLogicID, FEConfigPedDat> pedset ;
865  map<EcalLogicID, FEConfigLinDat> linset ;
866  map<EcalLogicID, FEConfigLinParamDat> linparamset ;
867  map<EcalLogicID, FEConfigLUTParamDat> lutparamset ;
868  map<EcalLogicID, FEConfigFgrParamDat> fgrparamset ;
869 
870  map<int, linStruc> linEtaSlice ;
871  map< vector<int>, linStruc > linMap ;
872 
873  // count number of strip per tower
874  int NbOfStripPerTCC[108][68] ;
875  for (int i=0 ; i<108 ; i++)
876  for (int j=0 ; j<68 ; j++)
877  NbOfStripPerTCC[i][j] = 0 ;
878  const std::vector<DetId> & ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
879  const std::vector<DetId> & eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
880  for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
881  EBDetId id(*it) ;
882  const EcalTrigTowerDetId towid= id.tower();
884  int tccNb = theMapping_->TCCid(towid) ;
885  int towerInTCC = theMapping_->iTT(towid) ;
886  int stripInTower = elId.pseudoStripId() ;
887  if (stripInTower>NbOfStripPerTCC[tccNb-1][towerInTCC-1]) NbOfStripPerTCC[tccNb-1][towerInTCC-1] = stripInTower ;
888  }
889  for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
890  EEDetId id(*it) ;
891  const EcalTrigTowerDetId towid= (*eTTmap_).towerOf(id) ;
893  int tccNb = theMapping_->TCCid(towid) ;
894  int towerInTCC = theMapping_->iTT(towid) ;
895  int stripInTower = elId.pseudoStripId() ;
896  if (stripInTower>NbOfStripPerTCC[tccNb-1][towerInTCC-1]) NbOfStripPerTCC[tccNb-1][towerInTCC-1] = stripInTower ;
897  }
898 
899 
900 
901  // loop on EB xtals
902  if (writeToFiles_) (*out_file_)<<"COMMENT ====== barrel crystals ====== "<<std::endl ;
903 
904  // special case of eta slices
905  for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
906  EBDetId id(*it) ;
907  double theta = theBarrelGeometry_->getGeometry(id)->getPosition().theta() ;
908  if (!useTransverseEnergy_) theta = acos(0.) ;
909  const EcalTrigTowerDetId towid= id.tower();
911  int dccNb = theMapping_->DCCid(towid) ;
912  int tccNb = theMapping_->TCCid(towid) ;
913  int towerInTCC = theMapping_->iTT(towid) ; // from 1 to 68 (EB)
914  int stripInTower = elId.pseudoStripId() ; // from 1 to 5
915  int xtalInStrip = elId.channelId() ; // from 1 to 5
917  int CCUid = Id.towerId() ;
918  int VFEid = Id.stripId() ;
919  int xtalInVFE = Id.xtalId() ;
920  int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ; // Evgueni expects [0,24]
921 
922  (*geomFile_)<<"dccNb = "<<dccNb<<" tccNb = "<<tccNb<<" towerInTCC = "<<towerInTCC
923  <<" stripInTower = "<<stripInTower<<" xtalInStrip = "<<xtalInStrip
924  <<" CCUid = "<<CCUid<<" VFEid = "<<VFEid<<" xtalInVFE = "<<xtalInVFE
925  <<" xtalWithinCCUid = "<<xtalWithinCCUid<<" ieta = "<<id.ieta()<<" iphi = "<<id.iphi()
926  <<" xtalhashedId = "<<id.hashedIndex()<<" xtalNb = "<<id.ic()
927  <<" ietaTT = "<<towid.ieta()<<" iphiTT = "<<towid.iphi()<<endl ;
928 
929  int TCCch = towerInTCC ;
930  int SLBslot = int((towerInTCC-1)/8.) + 1 ;
931  int SLBch = (towerInTCC-1)%8 + 1 ;
932  int cmsswId = id.rawId() ;
933  int ixtal=(id.ism()-1)*1700+(id.ic()-1);
934  EcalLogicID logicId =my_EcalLogicId[ixtal];
935  int dbId = logicId.getLogicID() ;
936  int val[] = {dccNb+600,tccNb,towerInTCC,stripInTower,
937  xtalInStrip,CCUid,VFEid,xtalInVFE,xtalWithinCCUid,id.ieta(),id.iphi(),
938  -999,-999,towid.ieta()/abs(towid.ieta()),id.hashedIndex(),
939  id.ic(), cmsswId, dbId,
940  towid.ieta(),towid.iphi(), TCCch, getCrate(tccNb).second, SLBch, SLBslot,
941  getGCTRegionEta(towid.ieta()),getGCTRegionPhi(towid.iphi())} ;
942  for (int i=0 ; i<26 ; i++) ntupleInts_[i] = val[i] ;
943 
944  strcpy(ntupleDet_,getDet(tccNb).c_str()) ;
945  strcpy(ntupleCrate_,getCrate(tccNb).first.c_str()) ;
946  ntuple->Fill() ;
947 
948 
949  if (tccNb == 37 && stripInTower == 3 && xtalInStrip == 3 && (towerInTCC-1)%4==0) {
950  int etaSlice = towid.ietaAbs() ;
951  coeffStruc coeff ;
952  //getCoeff(coeff, calibMap, id.rawId()) ;
953  //modif-alex-27-july-2015
954  string str;
955  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str) ;
956  ss << str;
957  getCoeff(coeff, gainMap, id.rawId()) ;
958  getCoeff(coeff, pedMap, id.rawId()) ;
959  linStruc lin ;
960  for (int i=0 ; i<3 ; i++) {
961  int mult, shift ;
962  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EB", mult , shift) ;
963  if (!ok) edm::LogError("TopInfo") << "unable to compute the parameters for SM="<< id.ism()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
964  else {
965  lin.pedestal_[i] = coeff.pedestals_[i] ;
966  lin.mult_[i] = mult ;
967  lin.shift_[i] = shift ;
968  }
969  }
970 
971  bool ok(true) ;
972  if (forcedPedestalValue_ == -2) ok = realignBaseline(lin, 0) ;
973  if (!ok) ss << "SM="<< id.ism()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
974  linEtaSlice[etaSlice] = lin ;
975  }
976  }
977 
978  // general case
979  for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
980  EBDetId id(*it) ;
981  double theta = theBarrelGeometry_->getGeometry(id)->getPosition().theta() ;
982  if (!useTransverseEnergy_) theta = acos(0.) ;
983  const EcalTrigTowerDetId towid= id.tower();
984  towerListEB.push_back(towid.rawId()) ;
986  stripListEB.push_back(elId.rawId() & 0xfffffff8) ;
987  int dccNb = theMapping_->DCCid(towid) ;
988  //int tccNb = theMapping_->TCCid(towid) ;
989  int towerInTCC = theMapping_->iTT(towid) ; // from 1 to 68 (EB)
990  //int stripInTower = elId.pseudoStripId() ; // from 1 to 5
991  //int xtalInStrip = elId.channelId() ; // from 1 to 5
993  int CCUid = Id.towerId() ;
994  int VFEid = Id.stripId() ;
995  int xtalInVFE = Id.xtalId() ;
996  int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ; // Evgueni expects [0,24]
997  int etaSlice = towid.ietaAbs() ;
998 
999  // hashed index of strip EcalLogicID:
1000  int hashedStripLogicID = 68*5*(id.ism()-1) + 5*(towerInTCC-1) + (VFEid-1) ;
1001  stripMapEB[hashedStripLogicID] = elId.rawId() & 0xfffffff8 ;
1002  stripMapEBsintheta[elId.rawId() & 0xfffffff8] = SFGVB_Threshold_ + abs(int(sin(theta)*pedestal_offset_)) ;
1003 
1004  //modif-debug
1005  /*
1006  FEConfigFgrEEStripDat stripdebug;
1007  EcalLogicID thestrip_debug = my_StripEcalLogicId[hashedStripLogicID] ;
1008  if(towid.ieta() == 6 && towid.iphi() == 7){
1009  std::cout << "xtal info=" << id << " VFE=" << VFEid << std::endl;
1010  std::cout << "TOWER DEBUG ieta=" << towid.ieta() << " iphi=" << towid.iphi() << " SFGVB=" << SFGVB_Threshold_ + abs(int(sin(theta)*pedestal_offset_))
1011  << " dbId=" << (elId.rawId() & 0xfffffff8) << " " << hashedStripLogicID << " " << thestrip_debug.getLogicID() << std::endl; //modif-debug
1012  }//EB+3 TT24
1013  */
1014  //std::cout<<std::dec<<SFGVB_Threshold_ + abs(int(sin(theta)*pedestal_offset_))<<" "<<SFGVB_Threshold_<<" "<<abs(int(sin(theta)*pedestal_offset_))<<std::endl ;
1015 
1016  FEConfigPedDat pedDB ;
1017  FEConfigLinDat linDB ;
1018  if (writeToFiles_) (*out_file_)<<"CRYSTAL "<<dec<<id.rawId()<<std::endl ;
1019  // if (writeToDB_) logicId = db_->getEcalLogicID ("EB_crystal_number", id.ism(), id.ic()) ;
1020 
1021  coeffStruc coeff ;
1022  //getCoeff(coeff, calibMap, id.rawId()) ;
1023  //modif-alex-27-july-2015
1024  std::string str;
1025  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str) ;
1026  ss << str;
1027 
1028  if (H2_) coeff.calibCoeff_ = calibvec[id.ic()-1] ;
1029  getCoeff(coeff, gainMap, id.rawId()) ;
1030  getCoeff(coeff, pedMap, id.rawId()) ;
1031  ICEB->Fill(id.iphi(), id.ieta(), coeff.calibCoeff_) ;
1032  IC->Fill(theBarrelGeometry_->getGeometry(id)->getPosition().phi(), theBarrelGeometry_->getGeometry(id)->getPosition().eta(), coeff.calibCoeff_) ;
1033 
1034  vector<int> xtalCCU ;
1035  xtalCCU.push_back(dccNb+600) ;
1036  xtalCCU.push_back(CCUid) ;
1037  xtalCCU.push_back(xtalWithinCCUid) ;
1038  xtalCCU.push_back(id.rawId()) ;
1039 
1040  // compute and fill linearization parameters
1041  // case of eta slice
1042  if (forceEtaSlice_) {
1043  map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1044  if (itLin != linEtaSlice.end()) {
1045  linMap[xtalCCU] = itLin->second ;
1046  if (writeToFiles_) {
1047  for (int i=0 ; i<3 ; i++)
1048  (*out_file_) << hex <<" 0x"<<itLin->second.pedestal_[i]<<" 0x"<<itLin->second.mult_[i]<<" 0x"<<itLin->second.shift_[i]<<std::endl;
1049  }
1050  if (writeToDB_) {
1051  for (int i=0 ; i<3 ; i++) {
1052  if (i==0) {pedDB.setPedMeanG12(itLin->second.pedestal_[i]) ; linDB.setMultX12(itLin->second.mult_[i]) ; linDB.setShift12(itLin->second.shift_[i]) ; }
1053  if (i==1) {pedDB.setPedMeanG6(itLin->second.pedestal_[i]) ; linDB.setMultX6(itLin->second.mult_[i]) ; linDB.setShift6(itLin->second.shift_[i]) ; }
1054  if (i==2) {pedDB.setPedMeanG1(itLin->second.pedestal_[i]) ; linDB.setMultX1(itLin->second.mult_[i]) ; linDB.setShift1(itLin->second.shift_[i]) ; }
1055  }
1056  }
1057  float factor = float(itLin->second.mult_[0])*pow(2.,-itLin->second.shift_[0])/xtal_LSB_EB_ ;
1058  tpgFactorEB->Fill(id.iphi(), id.ieta(), factor) ;
1059  tpgFactor->Fill(theBarrelGeometry_->getGeometry(id)->getPosition().phi(),
1060  theBarrelGeometry_->getGeometry(id)->getPosition().eta(), factor) ;
1061  }
1062  else ss <<"current EtaSlice = "<<etaSlice<<" not found in the EtaSlice map"<< "\n" ;
1063  }
1064  else {
1065  // general case
1066  linStruc lin ;
1067  int forceBase12 = 0 ;
1068  for (int i=0 ; i<3 ; i++) {
1069  int mult, shift ;
1070  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EB", mult , shift) ;
1071  if (!ok) edm::LogError("TopInfo") << "unable to compute the parameters for SM="<< id.ism()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
1072  else {
1073  //PP begin
1074  // mult = 0 ; shift = 0 ;
1075  // if (CCUid==1 && xtalWithinCCUid==21) {
1076  // if (i==0) {mult = 0x80 ; shift = 0x3 ;}
1077  // if (i==1) {mult = 0x80 ; shift = 0x2 ;}
1078  // if (i==2) {mult = 0xc0 ; shift = 0x0 ;}
1079  // }
1080  //PP end
1081  double base = coeff.pedestals_[i] ;
1082  if (forcedPedestalValue_ == -3 && i==0) {
1083  double G = mult*pow(2.0,-(shift+2)) ;
1084  double g = G/sin(theta) ;
1085  // int pedestal = coeff.pedestals_[i] ;
1086  base = double(coeff.pedestals_[i]) - pedestal_offset_/g ;
1087  if (base<0.) base = 0 ;
1088  forceBase12 = int(base) ;
1089  }
1090  lin.pedestal_[i] = coeff.pedestals_[i] ;
1091  lin.mult_[i] = mult ;
1092  lin.shift_[i] = shift ;
1093 
1094 // if (xtalWithinCCUid != 14) {
1095 // forceBase12 = 0 ;
1096 // lin.pedestal_[i] = 0 ;
1097 // lin.mult_[i] = 0 ;
1098 // lin.shift_[i] = 0 ;
1099 // }
1100 
1101  }
1102  }
1103 
1104  bool ok(true) ;
1105  if (forcedPedestalValue_ == -2) ok = realignBaseline(lin, 0) ;
1106  if (forcedPedestalValue_ == -3) ok = realignBaseline(lin, forceBase12) ;
1107  if (!ok) ss << "SM="<< id.ism()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
1108 
1109  for (int i=0 ; i<3 ; i++) {
1110  if (writeToFiles_) (*out_file_) << hex <<" 0x"<<lin.pedestal_[i]<<" 0x"<<lin.mult_[i]<<" 0x"<<lin.shift_[i]<<std::endl;
1111  if (writeToDB_) {
1112  if (i==0) {pedDB.setPedMeanG12(lin.pedestal_[i]) ; linDB.setMultX12(lin.mult_[i]) ; linDB.setShift12(lin.shift_[i]) ; }
1113  if (i==1) {pedDB.setPedMeanG6(lin.pedestal_[i]) ; linDB.setMultX6(lin.mult_[i]) ; linDB.setShift6(lin.shift_[i]) ; }
1114  if (i==2) {pedDB.setPedMeanG1(lin.pedestal_[i]) ; linDB.setMultX1(lin.mult_[i]) ; linDB.setShift1(lin.shift_[i]) ; }
1115  }
1116  if (i==0) {
1117  float factor = float(lin.mult_[i])*pow(2.,-lin.shift_[i])/xtal_LSB_EB_ ;
1118  tpgFactorEB->Fill(id.iphi(), id.ieta(), factor) ;
1119  tpgFactor->Fill(theBarrelGeometry_->getGeometry(id)->getPosition().phi(),
1120  theBarrelGeometry_->getGeometry(id)->getPosition().eta(), factor) ;
1121  }
1122  double G = lin.mult_[i]*pow(2.0,-(lin.shift_[i]+2)) ;
1123  double g = G/sin(theta) ;
1124  float val[] = { float(i),
1125  float(theta),
1126  float(G),
1127  float(g),
1128  float(coeff.pedestals_[i]),
1129  float(lin.pedestal_[i])};// first arg = gainId (0 means gain12)
1130  ntupleSpike->Fill(val) ;
1131  }
1132  linMap[xtalCCU] = lin ;
1133  }
1134  if (writeToDB_) {
1135  // 1700 crystals/SM in the ECAL barrel
1136  int ixtal=(id.ism()-1)*1700+(id.ic()-1);
1137  EcalLogicID logicId =my_EcalLogicId[ixtal];
1138  pedset[logicId] = pedDB ;
1139  linset[logicId] = linDB ;
1140  }
1141  } //ebCells
1142 
1143  if (writeToDB_) {
1144  // EcalLogicID of the whole barrel is: my_EcalLogicId_EB
1145  FEConfigLinParamDat linparam ;
1146  linparam.setETSat(Et_sat_EB_);
1147  linparamset[my_EcalLogicId_EB] = linparam ;
1148 
1149  FEConfigFgrParamDat fgrparam ;
1152  fgrparam.setFGlowratio(FG_lowRatio_EB_);
1153  fgrparam.setFGhighratio(FG_highRatio_EB_);
1154  fgrparamset[my_EcalLogicId_EB] = fgrparam ;
1155 
1156 
1157  FEConfigLUTParamDat lutparam ;
1158  lutparam.setETSat(Et_sat_EB_);
1161  lutparamset[my_EcalLogicId_EB] = lutparam ;
1162 
1163  }
1164 
1165 
1166  // loop on EE xtals
1167  if (writeToFiles_) (*out_file_)<<"COMMENT ====== endcap crystals ====== "<<std::endl ;
1168 
1169  // special case of eta slices
1170  for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1171  EEDetId id(*it) ;
1172  double theta = theEndcapGeometry_->getGeometry(id)->getPosition().theta() ;
1173  if (!useTransverseEnergy_) theta = acos(0.) ;
1174  const EcalTrigTowerDetId towid= (*eTTmap_).towerOf(id) ;
1177  int dccNb = Id.dccId() ;
1178  int tccNb = theMapping_->TCCid(towid) ;
1179  int towerInTCC = theMapping_->iTT(towid) ;
1180  int stripInTower = elId.pseudoStripId() ;
1181  int xtalInStrip = elId.channelId() ;
1182  int CCUid = Id.towerId() ;
1183  int VFEid = Id.stripId() ;
1184  int xtalInVFE = Id.xtalId() ;
1185  int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ; // Evgueni expects [0,24]
1186 
1187  (*geomFile_)<<"dccNb = "<<dccNb<<" tccNb = "<<tccNb<<" towerInTCC = "<<towerInTCC
1188  <<" stripInTower = "<<stripInTower<<" xtalInStrip = "<<xtalInStrip
1189  <<" CCUid = "<<CCUid<<" VFEid = "<<VFEid<<" xtalInVFE = "<<xtalInVFE
1190  <<" xtalWithinCCUid = "<<xtalWithinCCUid<<" ix = "<<id.ix()<<" iy = "<<id.iy()
1191  <<" xtalhashedId = "<<id.hashedIndex()<<" xtalNb = "<<id.isc()
1192  <<" ietaTT = "<<towid.ieta()<<" iphiTT = "<<towid.iphi()<<endl ;
1193 
1194  int TCCch = stripInTower ;
1195  int SLBslot, SLBch ;
1196  if (towerInTCC<5) {
1197  SLBslot = 1 ;
1198  SLBch = 4 + towerInTCC ;
1199  }
1200  else {
1201  SLBslot = int((towerInTCC-5)/8.) + 2 ;
1202  SLBch = (towerInTCC-5)%8 + 1 ;
1203  }
1204  for (int j=0 ; j<towerInTCC-1 ; j++) TCCch += NbOfStripPerTCC[tccNb-1][j] ;
1205 
1206  int cmsswId = id.rawId() ;
1207  EcalLogicID logicId ;
1208  int iz = id.positiveZ() ;
1209  if (iz ==0) iz = -1 ;
1210  for (int k=0; k<(int)my_CrystalEcalLogicId_EE.size(); k++) {
1211  int z= my_CrystalEcalLogicId_EE[k].getID1() ;
1212  int x= my_CrystalEcalLogicId_EE[k].getID2() ;
1213  int y= my_CrystalEcalLogicId_EE[k].getID3() ;
1214  if (id.ix()==x && id.iy()==y && iz==z) logicId=my_CrystalEcalLogicId_EE[k];
1215  }
1216  int dbId = logicId.getLogicID() ;
1217 
1218  int val[] = {dccNb+600,tccNb,towerInTCC,stripInTower,
1219  xtalInStrip,CCUid,VFEid,xtalInVFE,xtalWithinCCUid,-999,-999,
1220  id.ix(),id.iy(),towid.ieta()/abs(towid.ieta()),id.hashedIndex(),
1221  id.ic(),cmsswId, dbId,
1222  towid.ieta(),towid.iphi(),TCCch, getCrate(tccNb).second, SLBch, SLBslot,
1223  getGCTRegionEta(towid.ieta()),getGCTRegionPhi(towid.iphi())} ;
1224  for (int i=0 ; i<26 ; i++) ntupleInts_[i] = val[i] ;
1225  strcpy(ntupleDet_,getDet(tccNb).c_str()) ;
1226  strcpy(ntupleCrate_,getCrate(tccNb).first.c_str()) ;
1227  ntuple->Fill() ;
1228 
1229  if ((tccNb == 76 || tccNb == 94) && stripInTower == 1 && xtalInStrip == 3 && (towerInTCC-1)%4==0) {
1230  int etaSlice = towid.ietaAbs() ;
1231  coeffStruc coeff ;
1232  //getCoeff(coeff, calibMap, id.rawId()) ;
1233  //modif-alex-27-july-2015
1234  std::string str;
1235  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str) ;
1236  ss << str;
1237  getCoeff(coeff, gainMap, id.rawId()) ;
1238  getCoeff(coeff, pedMap, id.rawId()) ;
1239  linStruc lin ;
1240  for (int i=0 ; i<3 ; i++) {
1241  int mult, shift ;
1242  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EE", mult , shift) ;
1243  if (!ok) edm::LogError("TopInfo") << "unable to compute the parameters for Quadrant="<< id.iquadrant()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
1244  else {
1245  lin.pedestal_[i] = coeff.pedestals_[i] ;
1246  lin.mult_[i] = mult ;
1247  lin.shift_[i] = shift ;
1248  }
1249  }
1250 
1251  bool ok(true) ;
1252  if (forcedPedestalValue_ == -2 || forcedPedestalValue_ == -3) ok = realignBaseline(lin, 0) ;
1253  if (!ok) ss <<"Quadrant="<< id.iquadrant()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
1254 
1255  linEtaSlice[etaSlice] = lin ;
1256  }
1257  }
1258 
1259  // general case
1260  for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1261  EEDetId id(*it);
1262  double theta = theEndcapGeometry_->getGeometry(id)->getPosition().theta() ;
1263  if (!useTransverseEnergy_) theta = acos(0.) ;
1264  const EcalTrigTowerDetId towid= (*eTTmap_).towerOf(id) ;
1267  towerListEE.push_back(towid.rawId()) ;
1268  // special case of towers in inner rings of EE
1269  if (towid.ietaAbs() == 27 || towid.ietaAbs() == 28) {
1270  EcalTrigTowerDetId additionalTower(towid.zside(), towid.subDet(), towid.ietaAbs(), towid.iphi()+1) ;
1271  towerListEE.push_back(additionalTower.rawId()) ;
1272  }
1273  stripListEE.push_back(elId.rawId() & 0xfffffff8) ;
1274  int dccNb = Id.dccId() ;
1275  //int tccNb = theMapping_->TCCid(towid) ;
1276  //int towerInTCC = theMapping_->iTT(towid) ;
1277  //int stripInTower = elId.pseudoStripId() ;
1278  //int xtalInStrip = elId.channelId() ;
1279  int CCUid = Id.towerId() ;
1280  int VFEid = Id.stripId() ;
1281  int xtalInVFE = Id.xtalId() ;
1282  int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ; // Evgueni expects [0,24]
1283  int etaSlice = towid.ietaAbs() ;
1284 
1285  EcalLogicID logicId ;
1286  FEConfigPedDat pedDB ;
1287  FEConfigLinDat linDB ;
1288  if (writeToFiles_) (*out_file_)<<"CRYSTAL "<<dec<<id.rawId()<<std::endl ;
1289  if (writeToDB_ && DBEE_) {
1290  int iz = id.positiveZ() ;
1291  if (iz ==0) iz = -1 ;
1292  for (int k=0; k<(int)my_CrystalEcalLogicId_EE.size(); k++) {
1293  int z= my_CrystalEcalLogicId_EE[k].getID1() ;
1294  int x= my_CrystalEcalLogicId_EE[k].getID2() ;
1295  int y= my_CrystalEcalLogicId_EE[k].getID3() ;
1296  if (id.ix()==x && id.iy()==y && iz==z) logicId=my_CrystalEcalLogicId_EE[k];
1297  }
1298  }
1299 
1300  coeffStruc coeff ;
1301  //getCoeff(coeff, calibMap, id.rawId()) ;
1302  //modif-alex-27-july-2015
1303  string str;
1304  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str) ;
1305  ss << str;
1306  getCoeff(coeff, gainMap, id.rawId()) ;
1307  getCoeff(coeff, pedMap, id.rawId()) ;
1308  if (id.zside()>0) ICEEPlus->Fill(id.ix(), id.iy(), coeff.calibCoeff_) ;
1309  else ICEEMinus->Fill(id.ix(), id.iy(), coeff.calibCoeff_) ;
1310  IC->Fill(theEndcapGeometry_->getGeometry(id)->getPosition().phi(), theEndcapGeometry_->getGeometry(id)->getPosition().eta(), coeff.calibCoeff_) ;
1311 
1312  vector<int> xtalCCU ;
1313  xtalCCU.push_back(dccNb+600) ;
1314  xtalCCU.push_back(CCUid) ;
1315  xtalCCU.push_back(xtalWithinCCUid) ;
1316  xtalCCU.push_back(id.rawId()) ;
1317 
1318  // compute and fill linearization parameters
1319  // case of eta slice
1320  if (forceEtaSlice_) {
1321  map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1322  if (itLin != linEtaSlice.end()) {
1323  linMap[xtalCCU] = itLin->second ;
1324  if (writeToFiles_) {
1325  for (int i=0 ; i<3 ; i++)
1326  (*out_file_) << hex <<" 0x"<<itLin->second.pedestal_[i]<<" 0x"<<itLin->second.mult_[i]<<" 0x"<<itLin->second.shift_[i]<<std::endl;
1327  }
1328  if (writeToDB_ && DBEE_) {
1329  for (int i=0 ; i<3 ; i++) {
1330  if (i==0) {pedDB.setPedMeanG12(itLin->second.pedestal_[i]) ; linDB.setMultX12(itLin->second.mult_[i]) ; linDB.setShift12(itLin->second.shift_[i]) ; }
1331  if (i==1) {pedDB.setPedMeanG6(itLin->second.pedestal_[i]) ; linDB.setMultX6(itLin->second.mult_[i]) ; linDB.setShift6(itLin->second.shift_[i]) ; }
1332  if (i==2) {pedDB.setPedMeanG1(itLin->second.pedestal_[i]) ; linDB.setMultX1(itLin->second.mult_[i]) ; linDB.setShift1(itLin->second.shift_[i]) ; }
1333  }
1334  }
1335  float factor = float(itLin->second.mult_[0])*pow(2.,-itLin->second.shift_[0])/xtal_LSB_EE_ ;
1336  if (id.zside()>0) tpgFactorEEPlus->Fill(id.ix(), id.iy(), factor) ;
1337  else tpgFactorEEMinus->Fill(id.ix(), id.iy(), factor) ;
1338  tpgFactor->Fill(theEndcapGeometry_->getGeometry(id)->getPosition().phi(),
1339  theEndcapGeometry_->getGeometry(id)->getPosition().eta(), factor) ;
1340  }
1341  else ss <<"current EtaSlice = "<<etaSlice<<" not found in the EtaSlice map"<< "\n";
1342  }
1343  else {
1344  // general case
1345  linStruc lin ;
1346  for (int i=0 ; i<3 ; i++) {
1347  int mult, shift ;
1348  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EE", mult , shift) ;
1349  if (!ok) edm::LogError("TopInfo") << "unable to compute the parameters for "<<dec<<id.rawId()<< "\n" ;
1350  else {
1351  lin.pedestal_[i] = coeff.pedestals_[i] ;
1352  lin.mult_[i] = mult ;
1353  lin.shift_[i] = shift ;
1354  }
1355  }
1356 
1357  bool ok(true) ;
1358  if (forcedPedestalValue_ == -2 || forcedPedestalValue_ == -3) ok = realignBaseline(lin, 0) ;
1359  if (!ok) ss <<"Quadrant="<< id.iquadrant()<<" xt="<< id.ic()<<" " <<dec<<id.rawId()<< "\n" ;
1360 
1361  for (int i=0 ; i<3 ; i++) {
1362  if (writeToFiles_) (*out_file_) << hex <<" 0x"<<lin.pedestal_[i]<<" 0x"<<lin.mult_[i]<<" 0x"<<lin.shift_[i]<<std::endl;
1363  if (writeToDB_ && DBEE_) {
1364  if (i==0) {pedDB.setPedMeanG12(lin.pedestal_[i]) ; linDB.setMultX12(lin.mult_[i]) ; linDB.setShift12(lin.shift_[i]) ; }
1365  if (i==1) {pedDB.setPedMeanG6(lin.pedestal_[i]) ; linDB.setMultX6(lin.mult_[i]) ; linDB.setShift6(lin.shift_[i]) ; }
1366  if (i==2) {pedDB.setPedMeanG1(lin.pedestal_[i]) ; linDB.setMultX1(lin.mult_[i]) ; linDB.setShift1(lin.shift_[i]) ; }
1367  }
1368  if (i==0) {
1369  float factor = float(lin.mult_[i])*pow(2.,-lin.shift_[i])/xtal_LSB_EE_ ;
1370  if (id.zside()>0) tpgFactorEEPlus->Fill(id.ix(), id.iy(), factor) ;
1371  else tpgFactorEEMinus->Fill(id.ix(), id.iy(), factor) ;
1372  tpgFactor->Fill(theEndcapGeometry_->getGeometry(id)->getPosition().phi(),
1373  theEndcapGeometry_->getGeometry(id)->getPosition().eta(), factor) ;
1374  }
1375  }
1376  linMap[xtalCCU] = lin ;
1377  }
1378  if (writeToDB_ && DBEE_) {
1379  pedset[logicId] = pedDB ;
1380  linset[logicId] = linDB ;
1381  }
1382  } //eeCells
1383  edm::LogInfo("TopInfo") << ss.str();
1384  ss.str("");
1385 
1386  if (writeToDB_ ) {
1387  // EcalLogicID of the whole barrel is: my_EcalLogicId_EB
1388  FEConfigLinParamDat linparam ;
1389  linparam.setETSat(Et_sat_EE_);
1390  linparamset[my_EcalLogicId_EE] = linparam ;
1391 
1392  FEConfigLUTParamDat lutparam ;
1393  lutparam.setETSat(Et_sat_EE_);
1396  lutparamset[my_EcalLogicId_EE] = lutparam ;
1397 
1398 
1399  FEConfigFgrParamDat fgrparam ;
1400  fgrparam.setFGlowthresh(FG_Threshold_EE_);
1401  fgrparam.setFGhighthresh(FG_Threshold_EE_);
1402  fgrparamset[my_EcalLogicId_EE] = fgrparam ;
1403 
1404  }
1405 
1406  if (writeToDB_) {
1407 
1408  ostringstream ltag;
1409  ltag.str("EB_"); ltag<<Et_sat_EB_<<"_EE_"<<Et_sat_EE_;
1410  std::string lin_tag=ltag.str();
1411  ss << " LIN tag "<<lin_tag<< "\n";
1412 
1413  if(m_write_ped==1) {
1414  ped_conf_id_=db_->writeToConfDB_TPGPedestals(pedset, 1, "from_OfflineDB") ;
1415  } else {
1416  ss << "the ped id ="<<ped_conf_id_<<" will be used for the pedestals "<< "\n";
1417  }
1418 
1419  if(m_write_lin==1) lin_conf_id_=db_->writeToConfDB_TPGLinearCoef(linset,linparamset, 1, lin_tag) ;
1420  }
1421 
1423  // Evgueni interface
1425  std::ofstream evgueni("TPG_hardcoded.hh", std::ios::out) ;
1426  evgueni<<"void getLinParamTPG_hardcoded(int fed, int ccu, int xtal,"<<endl ;
1427  evgueni<<" int & mult12, int & shift12, int & base12,"<<endl ;
1428  evgueni<<" int & mult6, int & shift6, int & base6,"<<endl ;
1429  evgueni<<" int & mult1, int & shift1, int & base1)"<<endl ;
1430  evgueni<<"{"<<endl;
1431  evgueni<<" mult12 = 0 ; shift12 = 0 ; base12 = 0 ; mult6 = 0 ; shift6 = 0 ; base6 = 0 ; mult1 = 0 ; shift1 = 0 ; base1 = 0 ;"<<endl ;
1432  map< vector<int>, linStruc>::const_iterator itLinMap ;
1433  for (itLinMap = linMap.begin() ; itLinMap != linMap.end() ; itLinMap++) {
1434  vector<int> xtalInCCU = itLinMap->first ;
1435  evgueni<<" if (fed=="<<xtalInCCU[0]<<" && ccu=="<<xtalInCCU[1]<<" && xtal=="<<xtalInCCU[2]<<") {" ;
1436  evgueni<<" mult12 = "<<itLinMap->second.mult_[0]<<" ; shift12 = "<<itLinMap->second.shift_[0]<<" ; base12 = "<<itLinMap->second.pedestal_[0]<<" ; " ;
1437  evgueni<<" mult6 = "<<itLinMap->second.mult_[1]<<" ; shift6 = "<<itLinMap->second.shift_[1]<<" ; base6 = "<<itLinMap->second.pedestal_[1]<<" ; " ;
1438  evgueni<<" mult1 = "<<itLinMap->second.mult_[2]<<" ; shift1 = "<<itLinMap->second.shift_[2]<<" ; base1 = "<<itLinMap->second.pedestal_[2]<<" ; " ;
1439  evgueni<<" return ;}" <<endl ;
1440  }
1441  evgueni<<"}" <<endl ;
1442  evgueni.close() ;
1443 
1444 
1445 
1447  // Compute weights section //
1449 
1450  const int NWEIGROUPS = 2 ;
1451  std::vector<unsigned int> weights[NWEIGROUPS] ;
1452 
1453  bool useDBShape = useDBShape_;
1454  EBShape shapeEB(useDBShape) ; shapeEB.setEventSetup(evtSetup); // EBShape, EEShape are fetched now from DB (2018.05.22 K. Theofilatos)
1455  EEShape shapeEE(useDBShape) ; shapeEE.setEventSetup(evtSetup); //
1456  weights[0] = computeWeights(shapeEB, hshapeEB) ;
1457  weights[1] = computeWeights(shapeEE, hshapeEE) ;
1458 
1459  map<EcalLogicID, FEConfigWeightGroupDat> dataset;
1460 
1461  for (int igrp=0 ; igrp<NWEIGROUPS ; igrp++) {
1462 
1463  if (weights[igrp].size() == 5) {
1464 
1465  if (writeToFiles_) {
1466  (*out_file_) <<std::endl ;
1467  (*out_file_) <<"WEIGHT "<<igrp<<endl ;
1468  for (unsigned int sample=0 ; sample<5 ; sample++) (*out_file_) << "0x" <<hex<<weights[igrp][sample]<<" " ;
1469  (*out_file_)<<std::endl ;
1470  (*out_file_) <<std::endl ;
1471  }
1472  if (writeToDB_) {
1473  ss <<"going to write the weights for groupe:"<<igrp<< "\n";
1475  gut.setWeightGroupId(igrp);
1476  //PP WARNING: weights order is reverted when stored in the DB
1477  gut.setWeight0(weights[igrp][4] );
1478  gut.setWeight1(weights[igrp][3]+ 0x80); //0x80 to identify the max of the pulse in the FENIX (doesn't exist in emulator)
1479  gut.setWeight2(weights[igrp][2] );
1480  gut.setWeight3(weights[igrp][1] );
1481  gut.setWeight4(weights[igrp][0] );
1482  EcalLogicID ecid = EcalLogicID( "DUMMY", igrp,igrp); //1 dummy ID per group
1483  // Fill the dataset
1484  dataset[ecid] = gut;
1485  }
1486  }
1487  }
1488 
1489  if (writeToDB_) {
1490 
1491  // now we store in the DB the correspondence btw channels and groups
1492  map<EcalLogicID, FEConfigWeightDat> dataset2;
1493 
1494  // EB loop
1495  for (int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1496  FEConfigWeightDat wut;
1497  int igroup = 0; // this group is for EB
1498  wut.setWeightGroupId(igroup);
1499  dataset2[my_StripEcalLogicId[ich]] = wut;
1500  }
1501 
1502  // EE loop
1503  for (int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1504  FEConfigWeightDat wut;
1505  int igroup = 1; // this group is for EE
1506  wut.setWeightGroupId(igroup);
1507  // Fill the dataset
1508  dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1509  }
1510  // EE loop 2 (we had to split the ids of EE in 2 vectors to avoid crash!)
1511  for (int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1512  FEConfigWeightDat wut;
1513  int igroup = 1; // this group is for EE
1514  wut.setWeightGroupId(igroup);
1515  // Fill the dataset
1516  dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1517  }
1518 
1519  // Insert the datasets
1520  ostringstream wtag;
1521  wtag.str(""); wtag<<"Shape_NGroups_"<<NWEIGROUPS;
1522  std::string weight_tag=wtag.str();
1523  ss << " weight tag "<<weight_tag<< "\n";
1524  if (m_write_wei==1) wei_conf_id_=db_->writeToConfDB_TPGWeight(dataset, dataset2, NWEIGROUPS, weight_tag) ;
1525  }
1526  edm::LogInfo("TopInfo") << ss.str();
1527  ss.str("");
1528 
1530  // Compute FG section //
1532 
1533  // barrel
1534  unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG ;
1535  computeFineGrainEBParameters(lowRatio, highRatio, lowThreshold, highThreshold, lutFG) ;
1536  if (writeToFiles_) {
1537  (*out_file_) <<std::endl ;
1538  (*out_file_) <<"FG 0"<<std::endl ;
1539  (*out_file_)<<hex<<"0x"<<lowThreshold<<" 0x"<<highThreshold
1540  <<" 0x"<<lowRatio<<" 0x"<<highRatio<<" 0x"<<lutFG
1541  <<std::endl ;
1542  }
1543 
1544  // endcap
1545  unsigned int threshold, lut_tower ;
1546  unsigned int lut_strip;
1547  computeFineGrainEEParameters(threshold, lut_strip, lut_tower) ;
1548 
1549  // and here we store the fgr part
1550 
1551 
1552  if (writeToDB_) {
1553  ss <<"going to write the fgr "<< "\n";
1554  map<EcalLogicID, FEConfigFgrGroupDat> dataset;
1555  // we create 1 group
1556  int NFGRGROUPS =1;
1557  for (int ich=0; ich<NFGRGROUPS; ich++){
1558  FEConfigFgrGroupDat gut;
1559  gut.setFgrGroupId(ich);
1560  gut.setThreshLow(lowRatio );
1561  gut.setThreshHigh(highRatio);
1562  gut.setRatioLow(lowThreshold);
1563  gut.setRatioHigh(highThreshold);
1564  gut.setLUTValue(lutFG);
1565  EcalLogicID ecid = EcalLogicID( "DUMMY", ich,ich);
1566  // Fill the dataset
1567  dataset[ecid] = gut; // we use any logic id but different, because it is in any case ignored...
1568  }
1569 
1570  // now we store in the DB the correspondence btw channels and groups
1571  map<EcalLogicID, FEConfigFgrDat> dataset2;
1572  // in this case I decide in a stupid way which channel belongs to which group
1573  for (int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1574  FEConfigFgrDat wut;
1575  int igroup=0;
1576  wut.setFgrGroupId(igroup);
1577  // Fill the dataset
1578  // the logic ids are ordered by SM (1,...36) and TT (1,...68)
1579  // you have to calculate the right index here
1580  dataset2[my_TTEcalLogicId[ich]] = wut;
1581  }
1582 
1583  // endcap loop
1584  for (int ich=0; ich<(int)my_RTEcalLogicId_EE.size() ; ich++){
1585  // std::cout << " endcap FGR " << std::endl;
1586  FEConfigFgrDat wut;
1587  int igroup=0;
1588  wut.setFgrGroupId(igroup);
1589  // Fill the dataset
1590  // the logic ids are ordered by .... ?
1591  // you have to calculate the right index here
1592  dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1593  }
1594 
1595  // endcap TT loop for the FEfgr EE Tower
1596  map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1597  for (int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1598  FEConfigFgrEETowerDat fgreett;
1599  fgreett.setLutValue(lut_tower);
1600  dataset3[my_TTEcalLogicId_EE[ich]]=fgreett;
1601  }
1602 
1603  // endcap strip loop for the FEfgr EE strip
1604  // and barrel strip loop for the spike parameters (same structure than EE FGr)
1605  map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1606  for (int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1608  zut.setThreshold(threshold);
1609  zut.setLutFgr(lut_strip);
1610  dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1611  }
1612  for (int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1614  zut.setThreshold(threshold);
1615  zut.setLutFgr(lut_strip);
1616  // Fill the dataset
1617  dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1618  }
1619  for (int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1620  // EB
1622  EcalLogicID thestrip = my_StripEcalLogicId[ich] ;
1623  uint32_t elStripId = stripMapEB[ich] ;
1624  map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId) ;
1625  if (it != stripMapEBsintheta.end()) zut.setThreshold(it->second);
1626  else {
1627  edm::LogError("TopInfo") <<"ERROR: strip SFGVB threshold parameter not found for that strip:"<<thestrip.getID1()<<" "<<thestrip.getID3()<<" "<<thestrip.getID3()<< "\n" ;
1628  edm::LogError("TopInfo") <<" using value = "<<SFGVB_Threshold_+pedestal_offset_<< "\n" ;
1629  zut.setThreshold(SFGVB_Threshold_+pedestal_offset_) ;
1630  }
1631  zut.setLutFgr(SFGVB_lut_);
1632  // Fill the dataset
1633  dataset4[thestrip] = zut;
1634  }
1635 
1636  // Insert the dataset
1637  ostringstream wtag;
1638  wtag.str(""); wtag<<"FGR_"<<lutFG<<"_N_"<<NFGRGROUPS<<"_eb_"<<FG_lowThreshold_EB_<<"_EB_"<<FG_highThreshold_EB_;
1639  std::string weight_tag=wtag.str();
1640  ss << " weight tag "<<weight_tag<< "\n";
1641  if(m_write_fgr==1) fgr_conf_id_=db_->writeToConfDB_TPGFgr(dataset, dataset2, fgrparamset,dataset3, dataset4, NFGRGROUPS, weight_tag) ;
1642 
1643  //modif-alex 21/01/11
1644  map<EcalLogicID, FEConfigSpikeDat> datasetspike; //loob EB TT
1645  for (int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1646  FEConfigSpikeDat spiketh;
1648  datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1649  }//loop EB TT towers
1650 
1651  //modif-alex 21/01/11
1652  ostringstream stag;
1653  stag.str(""); stag<<"SpikeTh"<<SFGVB_SpikeKillingThreshold_;
1654  std::string spike_tag=stag.str();
1655  ss << " spike tag "<<spike_tag<< "\n";
1656  if(m_write_spi==1) spi_conf_id_=db_->writeToConfDB_Spike(datasetspike, spike_tag) ; //modif-alex 21/01/11
1657 
1658  //modif-alex 31/01/11
1659  //DELAYS EB
1660  map<EcalLogicID, FEConfigTimingDat> datasetdelay; // the loop goes from TCC 38 to 72 and throught the towers from 1 to 68
1661  for (int ich=0; ich<(int)my_TTEcalLogicId_EB_by_TCC.size() ; ich++){
1662  FEConfigTimingDat delay;
1663 
1664  EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich] ;
1665  int id1_tcc=my_TTEcalLogicId_EB_by_TCC[ich].getID1(); // the TCC
1666  int id2_tt =my_TTEcalLogicId_EB_by_TCC[ich].getID2(); // the tower
1667  std::map<int, vector<int> >::const_iterator ittEB = delays_EB_.find(id1_tcc);
1668  std::vector<int> TimingDelaysEB = ittEB->second;
1669 
1670  if (ittEB != delays_EB_.end()){
1671  if(TimingDelaysEB[id2_tt-1] == -1){
1672  edm::LogError("TopInfo") << "ERROR: Barrel timing delay not specified, check file, putting default value 1" << "\n";
1673  delay.setTimingPar1(1);
1674  }
1675  else delay.setTimingPar1(TimingDelaysEB[id2_tt-1]);
1676  } else {
1677  edm::LogError("TopInfo") << "ERROR:Barrel Could not find delay parameter for that trigger tower " << "\n";
1678  edm::LogError("TopInfo") << "Using default value = 1" << "\n";
1679  delay.setTimingPar1(1);
1680  }
1681 
1682  std::map<int, vector<int> >::const_iterator ittpEB = phases_EB_.find(id1_tcc);
1683  std::vector<int> TimingPhasesEB = ittpEB->second;
1684 
1685  if (ittpEB != phases_EB_.end()){
1686  if(TimingPhasesEB[id2_tt-1] == -1){
1687  edm::LogError("TopInfo") << "ERROR: Barrel timing phase not specified, check file, putting default value 0" << "\n";
1688  delay.setTimingPar2(0);
1689  }
1690  else delay.setTimingPar2(TimingPhasesEB[id2_tt-1]);
1691  } else {
1692  edm::LogError("TopInfo") << "ERROR:Barrel Could not find phase parameter for that trigger tower " << "\n";
1693  edm::LogError("TopInfo") << "Using default value = 0" << "\n";
1694  delay.setTimingPar2(0);
1695  }
1696 
1697  ss << ich << " tcc=" << id1_tcc << " TT=" << id2_tt << " logicId=" << logiciddelay.getLogicID()
1698  << " delay=" << TimingDelaysEB[id2_tt-1] << " phase=" << TimingPhasesEB[id2_tt-1] << "\n";
1699 
1700  //delay.setTimingPar1(1);
1701  //delay.setTimingPar2(2);
1702  datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] = delay;
1703  }//loop EB TT towers
1704 
1705  //DELAYS EE
1706  int stripindex = 0;
1707  int tccin = 1;
1708  for (int ich=0; ich<(int)my_StripEcalLogicId_EE_strips_by_TCC.size() ; ich++){
1709  FEConfigTimingDat delay;
1710  //int id1_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID1(); // the TCC
1711  //int id2_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2(); // the Tower
1712  //int id3_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3(); // the strip
1713 
1714  EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich] ;
1715  int id1_tcc=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID1(); // the TCC
1716  int id2_tt =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2(); // the tower
1717  int id3_st =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3(); // the strip
1718 
1719  //reset strip counter
1720  if(id1_tcc != tccin) {tccin = id1_tcc; stripindex=0;}
1721 
1722  std::map<int, vector<int> >::const_iterator ittEE = delays_EE_.find(id1_tcc);
1723  std::vector<int> TimingDelaysEE = ittEE->second;
1724 
1725  if (ittEE != delays_EE_.end()){
1726  if(TimingDelaysEE[stripindex] == -1){
1727  edm::LogError("TopInfo") << "ERROR: Endcap timing delay not specified, check file, putting default value 1" << "\n";
1728  delay.setTimingPar1(1);
1729  }
1730  else delay.setTimingPar1(TimingDelaysEE[stripindex]);
1731  } else {
1732  edm::LogError("TopInfo") << "ERROR:Endcap Could not find delay parameter for that trigger tower " << "\n";
1733  edm::LogError("TopInfo") << "Using default value = 1" << "\n";
1734  delay.setTimingPar1(1);
1735  }
1736 
1737  std::map<int, vector<int> >::const_iterator ittpEE = phases_EE_.find(id1_tcc);
1738  std::vector<int> TimingPhasesEE = ittpEE->second;
1739 
1740  if (ittpEE != phases_EE_.end()){
1741  if(TimingPhasesEE[stripindex] == -1){
1742  edm::LogError("TopInfo") << "ERROR: Endcap timing phase not specified, check file, putting default value 0" << "\n";
1743  delay.setTimingPar2(0);
1744  }
1745  else delay.setTimingPar2(TimingPhasesEE[stripindex]);
1746  } else {
1747  edm::LogError("TopInfo") << "ERROR:Endcap Could not find phase parameter for that trigger tower " << "\n";
1748  edm::LogError("TopInfo") << "Using default value = 0" << "\n";
1749  delay.setTimingPar2(0);
1750  }
1751 
1752  ss << ich << " stripindex=" << stripindex << " tcc=" << id1_tcc << " TT=" << id2_tt << " id3_st=" << id3_st
1753  << " logicId=" << logiciddelay.getLogicID()
1754  << " delay=" << TimingDelaysEE[stripindex] << " phase=" << TimingPhasesEE[stripindex] << "\n";
1755 
1756 
1757  //delay.setTimingPar1(1);
1758  //delay.setTimingPar2(2);
1759  datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] = delay;
1760  stripindex++;
1761  }//loop EE strip towers
1762 
1763  ostringstream de_tag;
1764  de_tag.str(""); de_tag<<"DelaysFromFile";
1765  std::string delay_tag=de_tag.str();
1766  ss << " delay tag "<<delay_tag<< "\n";
1767  if(m_write_del==1) del_conf_id_=db_->writeToConfDB_Delay(datasetdelay, delay_tag) ; //modif-alex 31/01/11
1768 
1769 
1770  } //write to DB
1771 
1772  if (writeToDB_) {
1773  ss <<"going to write the sliding "<< "\n";
1774  map<EcalLogicID, FEConfigSlidingDat> dataset;
1775  // in this case I decide in a stupid way which channel belongs to which group
1776  for (int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1777  FEConfigSlidingDat wut;
1778  wut.setSliding(sliding_);
1779  // Fill the dataset
1780  // the logic ids are ordered by SM (1,...36) , TT (1,...68) and strip (1..5)
1781  // you have to calculate the right index here
1782  dataset[my_StripEcalLogicId[ich]] = wut;
1783  }
1784 
1785  // endcap loop
1786  for (int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1787  FEConfigSlidingDat wut;
1788  wut.setSliding(sliding_);
1789  // Fill the dataset
1790  // the logic ids are ordered by fed tower strip
1791  // you have to calculate the right index here
1792  dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1793  }
1794  for (int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1795  FEConfigSlidingDat wut;
1796  wut.setSliding(sliding_);
1797  // Fill the dataset
1798  // the logic ids are ordered by ... ?
1799  // you have to calculate the right index here
1800  dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1801  }
1802 
1803 
1804  // Insert the dataset
1805  ostringstream wtag;
1806  wtag.str(""); wtag<<"Sliding_"<<sliding_;
1807  std::string justatag=wtag.str();
1808  ss << " sliding tag "<<justatag<< "\n";
1809  int iov_id=0; // just a parameter ...
1810  if(m_write_sli==1) sli_conf_id_=db_->writeToConfDB_TPGSliding(dataset,iov_id, justatag) ;
1811  }
1812 
1813 
1814 
1815 
1816 
1818  // Compute LUT section //
1820 
1821  int lut_EB[1024], lut_EE[1024] ;
1822 
1823  // barrel
1824  computeLUT(lut_EB, "EB") ;
1825  if (writeToFiles_) {
1826  (*out_file_) <<std::endl ;
1827  (*out_file_) <<"LUT 0"<<std::endl ;
1828  for (int i=0 ; i<1024 ; i++) (*out_file_)<<"0x"<<hex<<lut_EB[i]<<endl ;
1829  (*out_file_)<<endl ;
1830  }
1831 
1832  // endcap
1833  computeLUT(lut_EE, "EE") ;
1834  // check first if lut_EB and lut_EE are the same
1835  bool newLUT(false) ;
1836  for (int i=0 ; i<1024 ; i++) if (lut_EE[i] != lut_EB[i]) newLUT = true ;
1837  if (newLUT && writeToFiles_) {
1838  (*out_file_) <<std::endl ;
1839  (*out_file_) <<"LUT 1"<<std::endl ;
1840  for (int i=0 ; i<1024 ; i++) (*out_file_)<<"0x"<<hex<<lut_EE[i]<<endl ;
1841  (*out_file_)<<endl ;
1842  }
1843 
1844 
1845 
1846  if (writeToDB_) {
1847 
1848 
1849 
1850  map<EcalLogicID, FEConfigLUTGroupDat> dataset;
1851  // we create 1 LUT group
1852  int NLUTGROUPS =0;
1853  int ich=0;
1855  lut.setLUTGroupId(ich);
1856  for (int i=0; i<1024; i++){
1857  lut.setLUTValue(i, lut_EB[i] );
1858  }
1859  EcalLogicID ecid = EcalLogicID( "DUMMY", ich,ich);
1860  // Fill the dataset
1861  dataset[ecid] = lut; // we use any logic id but different, because it is in any case ignored...
1862 
1863  ich++;
1864 
1866  lute.setLUTGroupId(ich);
1867  for (int i=0; i<1024; i++){
1868  lute.setLUTValue(i, lut_EE[i] );
1869  }
1870  EcalLogicID ecide = EcalLogicID( "DUMMY", ich,ich);
1871  // Fill the dataset
1872  dataset[ecide] = lute; // we use any logic id but different, because it is in any case ignored...
1873 
1874  ich++;
1875 
1876  NLUTGROUPS=ich;
1877 
1878  // now we store in the DB the correspondence btw channels and LUT groups
1879  map<EcalLogicID, FEConfigLUTDat> dataset2;
1880  // in this case I decide in a stupid way which channel belongs to which group
1881  for (int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1883  int igroup=0;
1884  lut.setLUTGroupId(igroup);
1885  // calculate the right TT - in the vector they are ordered by SM and by TT
1886  // Fill the dataset
1887  dataset2[my_TTEcalLogicId[ich]] = lut;
1888  }
1889 
1890  // endcap loop
1891  for (int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1893  int igroup=1;
1894  lut.setLUTGroupId(igroup);
1895  // calculate the right TT
1896  // Fill the dataset
1897  dataset2[my_TTEcalLogicId_EE[ich]] = lut;
1898  }
1899 
1900  // Insert the dataset
1901  ostringstream ltag;
1902  ltag.str(""); ltag<<LUT_option_<<"_NGroups_"<<NLUTGROUPS;
1903  std::string lut_tag=ltag.str();
1904  ss << " LUT tag "<<lut_tag<< "\n";
1905  if(m_write_lut==1) lut_conf_id_=db_->writeToConfDB_TPGLUT(dataset, dataset2,lutparamset, NLUTGROUPS, lut_tag) ;
1906 
1907  }
1908 
1909  // last we insert the FE_CONFIG_MAIN table
1910  if (writeToDB_) {
1911 
1912  //int conf_id_=db_->writeToConfDB_TPGMain(ped_conf_id_,lin_conf_id_, lut_conf_id_, fgr_conf_id_,
1913  // sli_conf_id_, wei_conf_id_, bxt_conf_id_, btt_conf_id_, tag_, version_) ;
1916 
1917  ss << "\n Conf ID = " << conf_id_ << "\n";
1918 
1919  }
1920 
1922  // loop on strips and associate them with values //
1924 
1925  // Barrel
1926  stripListEB.sort() ;
1927  stripListEB.unique() ;
1928  ss <<"Number of EB strips="<<dec<<stripListEB.size()<< "\n" ;
1929  if (writeToFiles_) {
1930  (*out_file_) <<std::endl ;
1931  for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++ ) {
1932  (*out_file_) <<"STRIP_EB "<<dec<<(*itList)<<endl ;
1933  (*out_file_) << hex << "0x" <<sliding_<<std::endl ;
1934  (*out_file_) <<"0" <<std::endl ;
1935  (*out_file_) <<"0x"<<stripMapEBsintheta[(*itList)] << " 0x" << SFGVB_lut_ <<std::endl ;
1936  }
1937  }
1938 
1939  // Endcap
1940  stripListEE.sort() ;
1941  stripListEE.unique() ;
1942  ss <<"Number of EE strips="<<dec<<stripListEE.size()<< "\n" ;
1943  if (writeToFiles_) {
1944  (*out_file_) <<std::endl ;
1945  for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++ ) {
1946  (*out_file_) <<"STRIP_EE "<<dec<<(*itList)<<endl ;
1947  (*out_file_) << hex << "0x" <<sliding_<<std::endl ;
1948  //(*out_file_) <<" 0" << std::endl ;
1949  (*out_file_) <<" 1" << std::endl ; //modif-debug to get the correct EE TPG
1950  (*out_file_)<<hex<<"0x"<<threshold<<" 0x"<<lut_strip<<std::endl ;
1951  }
1952  }
1953  edm::LogInfo("TopInfo") << ss.str();
1954  ss.str("");
1955 
1956 
1958  // loop on towers and associate them with default values //
1960 
1961  // Barrel
1962  towerListEB.sort() ;
1963  towerListEB.unique() ;
1964  ss <<"Number of EB towers="<<dec<<towerListEB.size()<< "\n" ;
1965  if (writeToFiles_) {
1966  (*out_file_) <<std::endl ;
1967  for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++ ) {
1968  (*out_file_) <<"TOWER_EB "<<dec<<(*itList)<<endl ;
1969  (*out_file_) <<" 0\n 0\n" ;
1970  (*out_file_) <<" " << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex
1971  }
1972  }
1973 
1974  // Endcap
1975  towerListEE.sort() ;
1976  towerListEE.unique() ;
1977  ss <<"Number of EE towers="<<dec<<towerListEE.size()<< "\n" ;
1978  if (writeToFiles_) {
1979  (*out_file_) <<std::endl ;
1980  for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++ ) {
1981  (*out_file_) <<"TOWER_EE "<<dec<<(*itList)<<endl ;
1982  if (newLUT) (*out_file_) <<" 1\n" ;
1983  else (*out_file_) <<" 0\n" ;
1984  (*out_file_)<<hex<<"0x"<<lut_tower<<std::endl ;
1985  }
1986  }
1987  edm::LogInfo("TopInfo") << ss.str();
1988  ss.str("");
1989 
1990 
1991 
1993  // store control histos //
1995  ICEB->Write() ;
1996  tpgFactorEB->Write() ;
1997  ICEEPlus->Write() ;
1998  tpgFactorEEPlus->Write() ;
1999  ICEEMinus->Write() ;
2000  tpgFactorEEMinus->Write() ;
2001  IC->Write() ;
2002  tpgFactor->Write() ;
2003  hshapeEB->Write() ;
2004  hshapeEE->Write() ;
2005  ntuple->Write() ;
2006  ntupleSpike->Write() ;
2007  saving.Close () ;
2008 }
size
Write out results.
int writeToConfDB_TPGLinearCoef(const std::map< EcalLogicID, FEConfigLinDat > &linset, const std::map< EcalLogicID, FEConfigLinParamDat > &linparamset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:42
std::map< int, std::vector< int > > phases_EB_
void setThreshLow(float x)
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
int xtalId() const
get the channel id
int stripId() const
get the tower id
void setFGhighratio(float x)
const self & getMap() const
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
void setShift12(int x)
float getPedMeanG1() const
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
void setTimingPar2(int x)
std::pair< std::string, int > getCrate(int tcc)
const Items & barrelItems() const
int getGCTRegionPhi(int ttphi)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double gainRatio_[3]
static const int XYMODE
Definition: EEDetId.h:339
void setMultX1(int x)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
std::string getDet(int tcc)
Geom::Theta< T > theta() const
void setFGlowthresh(float x)
int towerId() const
get the tower id
void setRatioHigh(float x)
int iTT(const EcalTrigTowerDetId &id) const
returns the index of a Trigger Tower within its TCC.
int zside(DetId const &)
int writeToConfDB_TPGSliding(const std::map< EcalLogicID, FEConfigSlidingDat > &sliset, int iovId, std::string tag)
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
int writeToConfDB_Delay(const std::map< EcalLogicID, FEConfigTimingDat > &delaygroupset, std::string tag)
const CaloSubdetectorGeometry * theEndcapGeometry_
void setShift6(int x)
int writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int spi, int tim, int bxt, int btt, int bst, std::string tag, int ver)
Definition: EcalTPGDBApp.cc:68
std::ofstream * out_file_
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
Definition: ntuple.py:1
std::map< int, std::vector< int > > delays_EB_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
int channelId() const
get the channel id
int ieta() const
get the tower ieta
void setPedMeanG6(float mean)
int zside() const
get the z-side of the tower (1/-1)
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
int getID2() const
Definition: EcalLogicID.cc:51
void setShift1(int x)
int TCCid(const EBDetId &id) const
returns the TCCid of an EBDetId
std::vector< unsigned int > computeWeights(EcalShapeBase &shape, TH1F *histo)
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
std::string getName() const
Definition: EcalLogicID.cc:36
void setThreshold(unsigned int mean)
void setPedMeanG1(float mean)
void setThreshHigh(float x)
std::map< int, std::vector< int > > delays_EE_
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:52
void setLutFgr(unsigned int mean)
int ietaAbs() const
get the absolute value of the tower ieta
const EcalElectronicsMapping * theMapping_
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) noexcept(false)
void computeLUT(int *lut, std::string det="EB")
int getTimId() const
void setLUTValue(int i, int x)
int getLinId() const
int getSpiId() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
int getWeiId() const
int getID1() const
Definition: EcalLogicID.cc:46
float gain6Over1() const
void setLUTGroupId(int x)
base
Make Sure CMSSW is Setup ##.
int getLogicID() const
Definition: EcalLogicID.cc:41
int pseudoStripId() const
get the tower id
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
void setSpikeThreshold(int x)
float getPedMeanG12() const
void setTimingPar1(int x)
const_iterator begin() const
void insert(std::pair< uint32_t, Item > const &a)
void setFgrGroupId(int x)
Definition: EBShape.h:6
int writeToConfDB_Spike(const std::map< EcalLogicID, FEConfigSpikeDat > &spikegroupset, std::string tag)
void computeFineGrainEEParameters(uint &threshold, uint &lut_strip, uint &lut_tower)
int k[5][pyjets_maxn]
bool realignBaseline(linStruc &lin, float forceBase12)
bool computeLinearizerParam(double theta, double gainRatio, double calibCoeff, std::string subdet, int &mult, int &shift)
int iphi() const
get the tower iphi
const CaloSubdetectorGeometry * theBarrelGeometry_
int getFgrId() const
int writeToConfDB_TPGPedestals(const std::map< EcalLogicID, FEConfigPedDat > &pedset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:17
void setPedMeanG12(float mean)
int getBttId() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void setMultX6(int x)
std::vector< Item >::const_iterator const_iterator
int DCCid(const EBDetId &id) const
returns the DCC of an EBDetId
float gain12Over6() const
float getPedMeanG6() const
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
int getPedId() const
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setFGlowratio(float x)
void setSliding(float mean)
HLT enums.
static const int NULLID
Definition: EcalLogicID.h:42
T get() const
Definition: EventSetup.h:62
int getBxtId() const
int getBstId() const
void setTTThreshhigh(float x)
int writeToConfDB_TPGLUT(const std::map< EcalLogicID, FEConfigLUTGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigLUTDat > &lutdat, const std::map< EcalLogicID, FEConfigLUTParamDat > &lutparamset, int iovId, std::string tag)
void setMultX12(int x)
void setId(int id)
static unsigned int const shift
int writeToConfDB_TPGFgr(const std::map< EcalLogicID, FEConfigFgrGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigFgrDat > &lutdat, const std::map< EcalLogicID, FEConfigFgrParamDat > &fgrparamset, const std::map< EcalLogicID, FEConfigFgrEETowerDat > &dataset3, const std::map< EcalLogicID, FEConfigFgrEEStripDat > &dataset4, int iovId, std::string tag)
int getLUTId() const
const_iterator end() const
int writeToConfDB_TPGWeight(const std::map< EcalLogicID, FEConfigWeightGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigWeightDat > &lutdat, int iovId, std::string tag)
int getGCTRegionEta(int tteta)
int getID3() const
Definition: EcalLogicID.cc:56
void setTTThreshlow(float x)
const Items & endcapItems() const
static const int SMCRYSTALMODE
Definition: EBDetId.h:167
#define str(s)
void setWeightGroupId(int x)
T const * product() const
Definition: ESHandle.h:86
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
void setFGhighthresh(float x)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::map< int, std::vector< int > > phases_EE_
int getSliId() const
Definition: EEShape.h:6
void computeFineGrainEBParameters(uint &lowRatio, uint &highRatio, uint &lowThreshold, uint &highThreshold, uint &lut)
void getCoeff(coeffStruc &coeff, const EcalGainRatioMap &gainMap, uint rawId)
void EcalTPGParamBuilder::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 2010 of file EcalTPGParamBuilder.cc.

References create_header(), TauDecayModes::dec, DetId::Ecal, EcalBarrel, EcalEndcap, Et_sat_EB_, Et_sat_EE_, FG_highRatio_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_lowThreshold_EB_, FG_Threshold_EE_, DetId::rawId(), TTF_highThreshold_EB_, TTF_highThreshold_EE_, TTF_lowThreshold_EB_, TTF_lowThreshold_EE_, and writeToFiles_.

2011 {
2012  using namespace edm;
2013  using namespace std;
2014 
2015  edm::LogInfo("TopInfo") <<"we are in beginJob\n";
2016 
2017  create_header() ;
2018 
2021 
2022  if (writeToFiles_) {
2023  (*out_file_)<<"PHYSICS_EB "<<dec<<eb.rawId()<<std::endl ;
2024  (*out_file_)<<Et_sat_EB_<<" "<<TTF_lowThreshold_EB_<<" "<<TTF_highThreshold_EB_<<std::endl ;
2025  (*out_file_)<<FG_lowThreshold_EB_<<" "<<FG_highThreshold_EB_<<" "
2026  <<FG_lowRatio_EB_<<" "<<FG_highRatio_EB_<<std::endl ;
2027  //(*out_file_) << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex02/02/2011
2028  (*out_file_) <<std::endl ;
2029 
2030  (*out_file_)<<"PHYSICS_EE "<<dec<<ee.rawId()<<std::endl ;
2031  (*out_file_)<<Et_sat_EE_<<" "<<TTF_lowThreshold_EE_<<" "<<TTF_highThreshold_EE_<<std::endl ;
2032  (*out_file_)<<FG_Threshold_EE_<<" "<<-1<<" "
2033  <<-1<<" "<<-1<<std::endl ;
2034  (*out_file_) <<std::endl ;
2035  }
2036 
2037 }
Definition: DetId.h:18
HLT enums.
bool EcalTPGParamBuilder::checkIfOK ( EcalPedestals::Item  item)

Definition at line 372 of file EcalTPGParamBuilder.cc.

References EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, mps_fire::result, EcalPedestal::rms_x1, EcalPedestal::rms_x12, and EcalPedestal::rms_x6.

373 {
374  bool result=true;
375  if( item.mean_x1 <150. || item.mean_x1 >250) result=false;
376  if( item.mean_x6 <150. || item.mean_x6 >250) result=false;
377  if( item.mean_x12 <150. || item.mean_x12 >250) result=false;
378  if( item.rms_x1 <0 || item.rms_x1 > 2) result=false;
379  if( item.rms_x6 <0 || item.rms_x6 > 3) result=false;
380  if( item.rms_x12 <0 || item.rms_x12 > 5) result=false;
381  return result;
382 }
void EcalTPGParamBuilder::computeFineGrainEBParameters ( uint &  lowRatio,
uint &  highRatio,
uint &  lowThreshold,
uint &  highThreshold,
uint &  lut 
)
private

Definition at line 2489 of file EcalTPGParamBuilder.cc.

References Et_sat_EB_, FG_highRatio_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_lowThreshold_EB_, FG_lut_EB_, and createfilelist::int.

Referenced by analyze().

2491 {
2492  lowRatio = int(0x80*FG_lowRatio_EB_ + 0.5) ;
2493  if (lowRatio>0x7f) lowRatio = 0x7f ;
2494  highRatio = int(0x80*FG_highRatio_EB_ + 0.5) ;
2495  if (highRatio>0x7f) highRatio = 0x7f ;
2496 
2497  // lsb at the stage of the FG calculation is:
2498  double lsb_FG = Et_sat_EB_/1024./4 ;
2499  lowThreshold = int(FG_lowThreshold_EB_/lsb_FG+0.5) ;
2500  if (lowThreshold>0xff) lowThreshold = 0xff ;
2501  highThreshold = int(FG_highThreshold_EB_/lsb_FG+0.5) ;
2502  if (highThreshold>0xff) highThreshold = 0xff ;
2503 
2504  // FG lut: FGVB response is LUT(adress) where adress is:
2505  // bit3: maxof2/ET >= lowRatio, bit2: maxof2/ET >= highRatio, bit1: ET >= lowThreshold, bit0: ET >= highThreshold
2506  // FGVB =1 if jet-like (veto active), =0 if E.M.-like
2507  // the condition for jet-like is: ET>Threshold and maxof2/ET < Ratio (only TT with enough energy are vetoed)
2508 
2509  // With the following lut, what matters is only max(TLow, Thigh) and max(Elow, Ehigh)
2510  // So, jet-like if maxof2/ettot<max(TLow, Thigh) && ettot >= max(Elow, Ehigh)
2511  if (FG_lut_EB_ == 0) lut = 0x0888 ;
2512  else lut = FG_lut_EB_ ; // let's use the users value (hope he/she knows what he/she does!)
2513 }
void EcalTPGParamBuilder::computeFineGrainEEParameters ( uint &  threshold,
uint &  lut_strip,
uint &  lut_tower 
)
private

Definition at line 2515 of file EcalTPGParamBuilder.cc.

References Et_sat_EE_, FG_lut_strip_EE_, FG_lut_tower_EE_, FG_Threshold_EE_, and createfilelist::int.

Referenced by analyze().

2516 {
2517  // lsb for EE:
2518  double lsb_FG = Et_sat_EE_/1024. ; // FIXME is it true????
2519  threshold = int(FG_Threshold_EE_/lsb_FG+0.5) ;
2520  lut_strip = FG_lut_strip_EE_ ;
2521  lut_tower = FG_lut_tower_EE_ ;
2522 }
bool EcalTPGParamBuilder::computeLinearizerParam ( double  theta,
double  gainRatio,
double  calibCoeff,
std::string  subdet,
int &  mult,
int &  shift 
)
private

Definition at line 2041 of file EcalTPGParamBuilder.cc.

References Et_sat_EB_, Et_sat_EE_, funct::false, createfilelist::int, particleFlowDisplacedVertex_cfi::ratio, funct::sin(), sliding_, funct::true, xtal_LSB_EB_, and xtal_LSB_EE_.

Referenced by analyze().

2042 {
2043  /*
2044  Linearization coefficient are determined in order to satisfy:
2045  tpg(ADC_sat) = 1024
2046  where:
2047  tpg() is a model of the linearized tpg response on 10b
2048  ADC_sat is the number of ADC count corresponding the Et_sat, the maximum scale of the transverse energy
2049 
2050  Since we have:
2051  Et_sat = xtal_LSB * ADC_sat * gainRatio * calibCoeff * sin(theta)
2052  and a simple model of tpg() being given by:
2053  tpg(X) = [ (X*mult) >> (shift+2) ] >> (sliding+shiftDet)
2054  we must satisfy:
2055  [ (Et_sat/(xtal_LSB * gainRatio * calibCoeff * sin(theta)) * mult) >> (shift+2) ] >> (sliding+shiftDet) = 1024
2056  that is:
2057  mult = 1024/Et_sat * xtal_LSB * gainRatio * calibCoeff * sin(theta) * 2^-(sliding+shiftDet+2) * 2^-shift
2058  mult = factor * 2^-shift
2059  */
2060 
2061  // case barrel:
2062  int shiftDet = 2 ; //fixed, due to FE FENIX TCP format
2063  double ratio = xtal_LSB_EB_/Et_sat_EB_ ;
2064  // case endcap:
2065  if (subdet=="EE") {
2066  shiftDet = 2 ; //applied in TCC-EE and not in FE FENIX TCP... This parameters is setable in the TCC-EE
2067  //shiftDet = 0 ; //was like this before with FE bug
2068  ratio = xtal_LSB_EE_/Et_sat_EE_ ;
2069  }
2070 
2071  //modif-alex-30/01/2012
2072  //std::cout << "calibCoeff="<<calibCoeff<<endl;
2073 
2074  double factor = 1024 * ratio * gainRatio * calibCoeff * sin(theta) * (1 << (sliding_ + shiftDet + 2)) ;
2075  // Let's try first with shift = 0 (trivial solution)
2076  mult = (int)(factor+0.5) ;
2077  for (shift = 0 ; shift<15 ; shift++) {
2078  if (mult>=128 && mult<256) return true ;
2079  factor *= 2 ;
2080  mult = (int)(factor+0.5) ;
2081  }
2082  edm::LogError("TopInfo") << "too bad we did not manage to calculate the factor for calib=" << calibCoeff << "\n";
2083  return false ;
2084 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
static unsigned int const shift
void EcalTPGParamBuilder::computeLUT ( int *  lut,
std::string  det = "EB" 
)
private

Definition at line 2311 of file EcalTPGParamBuilder.cc.

References Et_sat_EB_, Et_sat_EE_, patCandidates_cff::func, mps_fire::i, createfilelist::int, LUT_constant_EB_, LUT_constant_EE_, LUT_noise_EB_, LUT_noise_EE_, LUT_option_, LUT_stochastic_EB_, LUT_stochastic_EE_, LUT_threshold_EB_, LUT_threshold_EE_, oneOverEtResolEt(), TTF_highThreshold_EB_, TTF_highThreshold_EE_, TTF_lowThreshold_EB_, and TTF_lowThreshold_EE_.

Referenced by analyze().

2312 {
2313  double Et_sat = Et_sat_EB_ ;
2314  double LUT_threshold = LUT_threshold_EB_ ;
2315  double LUT_stochastic = LUT_stochastic_EB_ ;
2316  double LUT_noise = LUT_noise_EB_ ;
2317  double LUT_constant = LUT_constant_EB_ ;
2318  double TTF_lowThreshold = TTF_lowThreshold_EB_ ;
2319  double TTF_highThreshold = TTF_highThreshold_EB_ ;
2320  if (det == "EE") {
2321  Et_sat = Et_sat_EE_ ;
2322  LUT_threshold = LUT_threshold_EE_ ;
2323  LUT_stochastic = LUT_stochastic_EE_ ;
2324  LUT_noise = LUT_noise_EE_ ;
2325  LUT_constant = LUT_constant_EE_ ;
2326  TTF_lowThreshold = TTF_lowThreshold_EE_ ;
2327  TTF_highThreshold = TTF_highThreshold_EE_ ;
2328  }
2329 
2330  // initialisation with identity
2331  for (int i=0 ; i<1024 ; i++) {
2332  lut[i] = i ;
2333  if (lut[i]>0xff) lut[i] = 0xff ;
2334  }
2335 
2336  // case linear LUT
2337  if (LUT_option_ == "Linear") {
2338  int mylut = 0 ;
2339  for (int i=0 ; i<1024 ; i++) {
2340  lut[i] = mylut ;
2341  if ((i+1)%4 == 0 ) mylut++ ;
2342  //if ((i+1)%8 == 0 ) mylut++ ;//modif-alex 16/12/2010 LSB==500MeV ONLY USED FOR BEAMV4 key
2343  }
2344  }
2345 
2346  // case LUT following Ecal resolution
2347  if (LUT_option_ == "EcalResolution") {
2348  TF1 * func = new TF1("func",oneOverEtResolEt, 0., Et_sat,3) ;
2349  func->SetParameters(LUT_stochastic, LUT_noise, LUT_constant) ;
2350  double norm = func->Integral(0., Et_sat) ;
2351  for (int i=0 ; i<1024 ; i++) {
2352  double Et = i*Et_sat/1024. ;
2353  lut[i] = int(0xff*func->Integral(0., Et)/norm + 0.5) ;
2354  }
2355  }
2356 
2357  // Now, add TTF thresholds to LUT and apply LUT threshold if needed
2358  for (int j=0 ; j<1024 ; j++) {
2359  double Et_GeV = Et_sat/1024*(j+0.5) ;
2360  if (Et_GeV <= LUT_threshold) lut[j] = 0 ; // LUT threshold
2361  int ttf = 0x0 ;
2362  if (Et_GeV >= TTF_highThreshold) ttf = 3 ;
2363  if (Et_GeV >= TTF_lowThreshold && Et_GeV < TTF_highThreshold) ttf = 1 ;
2364  ttf = ttf << 8 ;
2365  lut[j] += ttf ;
2366  }
2367 
2368 }
double oneOverEtResolEt(double *x, double *par)
std::vector< unsigned int > EcalTPGParamBuilder::computeWeights ( EcalShapeBase shape,
TH1F *  histo 
)
private

Definition at line 2197 of file EcalTPGParamBuilder.cc.

References complement2_, KineDebug3::count(), CustomPhysics_cfi::gamma, createfilelist::int, SiStripPI::max, min(), nSample_, funct::pow(), simplePhotonAnalyzer_cfi::sample, sampleMax_, ntuplemaker::time, HBHEMethod2Parameters_cfi::timeMax, EcalShapeBase::timeOfMax(), EcalShapeBase::timeOfThr(), uncodeWeight(), mps_merge::weight, weight_timeShift_, and weight_unbias_recovery_.

Referenced by analyze().

2197  {
2198  std::ostringstream ss;
2199  ss <<"Computing Weights...\n" ;
2200  double timeMax = shape.timeOfMax() - shape.timeOfThr() ; // timeMax w.r.t begining of pulse
2201  double max = shape(timeMax) ;
2202 
2203  double sumf = 0. ;
2204  double sumf2 = 0. ;
2205  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2206  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2207  time -= weight_timeShift_ ;
2208  sumf += shape(time)/max ;
2209  sumf2 += shape(time)/max * shape(time)/max ;
2210  for (int subtime = 0 ; subtime<25 ; subtime++) histo->Fill(float(sample*25. + subtime)/25., shape(time+subtime)) ;
2211  }
2212  double lambda = 1./(sumf2-sumf*sumf/nSample_) ;
2213  double gamma = -lambda*sumf/nSample_ ;
2214  double * weight = new double[nSample_] ;
2215  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2216  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2217  time -= weight_timeShift_ ;
2218  weight[sample] = lambda*shape(time)/max + gamma ;
2219  }
2220 
2221 
2222  int * iweight = new int[nSample_] ;
2223  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) iweight[sample] = uncodeWeight(weight[sample], complement2_) ;
2224 
2225  // Let's check:
2226  int isumw = 0 ;
2227  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) isumw += iweight[sample] ;
2228  unsigned int imax = (unsigned int)(pow(2.,int(complement2_))-1) ;
2229  isumw = (isumw & imax ) ;
2230 
2231  double ampl = 0. ;
2232  double sumw = 0. ;
2233  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2234  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2235  time -= weight_timeShift_ ;
2236  ampl += weight[sample]*shape(time) ;
2237  sumw += weight[sample] ;
2238  ss <<"weight="<<weight[sample]<<" shape="<<shape(time)<< "\n" ;
2239  }
2240  ss <<"Weights: sum="<<isumw<<" in float ="<<uncodeWeight(isumw, complement2_)<<" sum of floats ="<<sumw<< "\n" ;
2241  ss <<"Weights: sum (weight*shape) = "<<ampl<< "\n" ;
2242 
2243 
2244 
2245  // Let's correct for bias if any
2247  int count = 0 ;
2248  while (isumw != 0 && count<10) {
2249  double min = 99. ;
2250  unsigned int index = 0 ;
2251  if ( (isumw & (1<<(complement2_-1))) != 0) {
2252  // add 1:
2253  ss << "Correcting for bias: adding 1\n" ;
2254  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2255  int new_iweight = iweight[sample]+1 ;
2256  double new_weight = uncodeWeight(new_iweight, complement2_) ;
2257  if (fabs(new_weight-weight[sample])<min) {
2258  min = fabs(new_weight-weight[sample]) ;
2259  index = sample ;
2260  }
2261  }
2262  iweight[index] ++ ;
2263  } else {
2264  // Sub 1:
2265  ss <<"Correcting for bias: subtracting 1\n" ;
2266  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2267  int new_iweight = iweight[sample]-1 ;
2268  double new_weight = uncodeWeight(new_iweight, complement2_) ;
2269  if (fabs(new_weight-weight[sample])<min) {
2270  min = fabs(new_weight-weight[sample]) ;
2271  index = sample ;
2272  }
2273  }
2274  iweight[index] -- ;
2275  }
2276  isumw = 0 ;
2277  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) isumw += iweight[sample] ;
2278  imax = (unsigned int)(pow(2.,int(complement2_))-1) ;
2279  isumw = (isumw & imax ) ;
2280  ss <<"Correcting weight number: "<< index << " sum weights = " << isumw<< "\n" ;
2281  count ++ ;
2282  }
2283  }
2284 
2285  // let's check again
2286  isumw = 0 ;
2287  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) isumw += iweight[sample] ;
2288  imax = (unsigned int)(pow(2.,int(complement2_))-1) ;
2289  isumw = (isumw & imax ) ;
2290  ampl = 0. ;
2291  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2292  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2293  time -= weight_timeShift_ ;
2294  double new_weight = uncodeWeight(iweight[sample], complement2_) ;
2295  sumw += uncodeWeight(iweight[sample], complement2_) ;
2296  ampl += new_weight*shape(time) ;
2297  ss <<"weight unbiased after integer conversion="<<new_weight<<" shape="<<shape(time)<< "\n" ;
2298  }
2299  ss <<"Weights: sum="<<isumw<<" in float ="<<uncodeWeight(isumw, complement2_)<<" sum of floats ="<<sumw<< "\n" ;
2300  ss <<"Weights: sum (weight*shape) = "<<ampl<< "\n" ;
2301  edm::LogInfo("TopInfo") << ss.str();
2302 
2303  std::vector<unsigned int> theWeights ;
2304  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) theWeights.push_back(iweight[sample]) ;
2305 
2306  delete[] weight ;
2307  delete[] iweight ;
2308  return theWeights ;
2309 }
Definition: weight.py:1
return((rh^lh)&mask)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T min(T a, T b)
Definition: MathUtil.h:58
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
double timeOfThr() const
HLT enums.
#define str(s)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int uncodeWeight(double weight, int complement2=7)
double timeOfMax() const
void EcalTPGParamBuilder::create_header ( )
private

Definition at line 2086 of file EcalTPGParamBuilder.cc.

References mathSSE::return(), and writeToFiles_.

Referenced by beginJob().

2087 {
2088  if (!writeToFiles_) return ;
2089  (*out_file_) <<"COMMENT put your comments here"<<std::endl ;
2090 
2091  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2092  (*out_file_) <<"COMMENT physics EB structure"<<std::endl ;
2093  (*out_file_) <<"COMMENT"<<std::endl ;
2094  (*out_file_) <<"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)"<<std::endl ;
2095  (*out_file_) <<"COMMENT FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio"<<std::endl ;
2096  //(*out_file_) <<"COMMENT SFGVB_SpikeKillingThreshold (GeV)"<<std::endl ; //modif-alex-02/02/2011
2097  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2098  (*out_file_) <<"COMMENT"<<std::endl ;
2099 
2100  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2101  (*out_file_) <<"COMMENT physics EE structure"<<std::endl ;
2102  (*out_file_) <<"COMMENT"<<std::endl ;
2103  (*out_file_) <<"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)"<<std::endl ;
2104  (*out_file_) <<"COMMENT FG_Threshold (GeV), dummy, dummy, dummy"<<std::endl ;
2105  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2106  (*out_file_) <<"COMMENT"<<std::endl ;
2107 
2108  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2109  (*out_file_) <<"COMMENT crystal structure (same for EB and EE)"<<std::endl ;
2110  (*out_file_) <<"COMMENT"<<std::endl ;
2111  (*out_file_) <<"COMMENT ped, mult, shift [gain12]"<<std::endl ;
2112  (*out_file_) <<"COMMENT ped, mult, shift [gain6]"<<std::endl ;
2113  (*out_file_) <<"COMMENT ped, mult, shift [gain1]"<<std::endl ;
2114  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2115  (*out_file_) <<"COMMENT"<<std::endl ;
2116 
2117  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2118  (*out_file_) <<"COMMENT strip EB structure"<<std::endl ;
2119  (*out_file_) <<"COMMENT"<<std::endl ;
2120  (*out_file_) <<"COMMENT sliding_window"<<std::endl ;
2121  (*out_file_) <<"COMMENT weightGroupId"<<std::endl ;
2122  (*out_file_) <<"COMMENT threshold_sfg lut_sfg"<<std::endl ;
2123  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2124  (*out_file_) <<"COMMENT"<<std::endl ;
2125 
2126  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2127  (*out_file_) <<"COMMENT strip EE structure"<<std::endl ;
2128  (*out_file_) <<"COMMENT"<<std::endl ;
2129  (*out_file_) <<"COMMENT sliding_window"<<std::endl ;
2130  (*out_file_) <<"COMMENT weightGroupId"<<std::endl ;
2131  (*out_file_) <<"COMMENT threshold_fg lut_fg"<<std::endl ;
2132  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2133  (*out_file_) <<"COMMENT"<<std::endl ;
2134 
2135  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2136  (*out_file_) <<"COMMENT tower EB structure"<<std::endl ;
2137  (*out_file_) <<"COMMENT"<<std::endl ;
2138  (*out_file_) <<"COMMENT LUTGroupId"<<std::endl ;
2139  (*out_file_) <<"COMMENT FgGroupId"<<std::endl ;
2140  (*out_file_) <<"COMMENT spike_killing_threshold"<<std::endl ;//modif alex
2141  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2142  (*out_file_) <<"COMMENT"<<std::endl ;
2143 
2144  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2145  (*out_file_) <<"COMMENT tower EE structure"<<std::endl ;
2146  (*out_file_) <<"COMMENT"<<std::endl ;
2147  (*out_file_) <<"COMMENT LUTGroupId"<<std::endl ;
2148  (*out_file_) <<"COMMENT tower_lut_fg"<<std::endl ;
2149  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2150  (*out_file_) <<"COMMENT"<<std::endl ;
2151 
2152  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2153  (*out_file_) <<"COMMENT Weight structure"<<std::endl ;
2154  (*out_file_) <<"COMMENT"<<std::endl ;
2155  (*out_file_) <<"COMMENT weightGroupId"<<std::endl ;
2156  (*out_file_) <<"COMMENT w0, w1, w2, w3, w4"<<std::endl ;
2157  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2158  (*out_file_) <<"COMMENT"<<std::endl ;
2159 
2160  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2161  (*out_file_) <<"COMMENT lut structure"<<std::endl ;
2162  (*out_file_) <<"COMMENT"<<std::endl ;
2163  (*out_file_) <<"COMMENT LUTGroupId"<<std::endl ;
2164  (*out_file_) <<"COMMENT LUT[1-1024]"<<std::endl ;
2165  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2166  (*out_file_) <<"COMMENT"<<std::endl ;
2167 
2168  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2169  (*out_file_) <<"COMMENT fg EB structure"<<std::endl ;
2170  (*out_file_) <<"COMMENT"<<std::endl ;
2171  (*out_file_) <<"COMMENT FgGroupId"<<std::endl ;
2172  (*out_file_) <<"COMMENT el, eh, tl, th, lut_fg"<<std::endl ;
2173  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2174  (*out_file_) <<"COMMENT"<<std::endl ;
2175 
2176  (*out_file_) <<std::endl ;
2177 }
return((rh^lh)&mask)
void EcalTPGParamBuilder::getCoeff ( coeffStruc coeff,
const EcalGainRatioMap gainMap,
uint  rawId 
)
private

Referenced by analyze(), and getCoeff().

void EcalTPGParamBuilder::getCoeff ( coeffStruc coeff,
const EcalPedestalsMap pedMap,
uint  rawId 
)
private
void EcalTPGParamBuilder::getCoeff ( coeffStruc coeff,
const std::map< EcalLogicID, MonPedestalsDat > &  pedMap,
const EcalLogicID logicId 
)
private

Definition at line 2471 of file EcalTPGParamBuilder.cc.

References EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), MonPedestalsDat::getPedMeanG1(), MonPedestalsDat::getPedMeanG12(), MonPedestalsDat::getPedMeanG6(), createfilelist::int, and coeffStruc::pedestals_.

2472 {
2473  // get current pedestal
2474  coeff.pedestals_[0] = 0 ;
2475  coeff.pedestals_[1] = 0 ;
2476  coeff.pedestals_[2] = 0 ;
2477 
2478  map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2479  if (it != pedMap.end()) {
2480  MonPedestalsDat ped = it->second ;
2481  coeff.pedestals_[0] = int(ped.getPedMeanG12() + 0.5) ;
2482  coeff.pedestals_[1] = int(ped.getPedMeanG6() + 0.5) ;
2483  coeff.pedestals_[2] = int(ped.getPedMeanG1() + 0.5) ;
2484  }
2485  else edm::LogError("TopInfo") <<"getCoeff: "<<logicId.getID1()<<", "<<logicId.getID2()<<", "<<logicId.getID3()
2486  <<" not found in map<EcalLogicID, MonPedestalsDat\n" ;
2487 }
int getID2() const
Definition: EcalLogicID.cc:51
float getPedMeanG12() const
int getID1() const
Definition: EcalLogicID.cc:46
float getPedMeanG1() const
float getPedMeanG6() const
int getID3() const
Definition: EcalLogicID.cc:56
void EcalTPGParamBuilder::getCoeff ( coeffStruc coeff,
const EcalIntercalibConstantMap calibMap,
const EcalLaserAlphaMap laserAlphaMap,
uint  rawId,
std::string &  ss 
)
private

Definition at line 2370 of file EcalTPGParamBuilder.cc.

References coeffStruc::calibCoeff_, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), forcedPedestalValue_, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), coeffStruc::gainRatio_, getCoeff(), createfilelist::int, EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, coeffStruc::pedestals_, funct::pow(), mathSSE::return(), DetId::subdetId(), Transparency_Correction_, useInterCalibration_, and useTransparencyCorr_.

2371 {
2372  // get current intercalibration coeff
2373  coeff.calibCoeff_ = 1. ;
2375  EcalIntercalibConstantMap::const_iterator icalit = calibMap.find(rawId);
2376 
2377  //modif-alex-30/01/2012
2378  std::map<int, double >::const_iterator itCorr = Transparency_Correction_.find(rawId);
2379  double icorr = 1.0;
2380  double alpha_factor = 1.0;
2381 
2383  icorr = itCorr->second;
2384  if( itCorr != Transparency_Correction_.end() ) {
2385  stringstream ss;
2386  ss << rawId;
2387  stringstream ss1;
2388  ss1 << icorr;
2389  stringstream ss2;
2390  ss2 << (*icalit);
2391  st = "Transparency correction found for xtal " + ss.str() + " corr=" + ss1.str() + " intercalib=" + ss2.str() + "\n";
2392  }
2393  else
2394  edm::LogError("TopInfo") << "ERROR = Transparency correction not found for xtal " << rawId << "\n";
2395 
2396  //modif-alex-27-july-2015
2397  DetId ECALdetid(rawId);
2398  // ss << "DETID=" << ECALdetid.subdetId() << "\n";
2399  stringstream ss;
2400  ss << ECALdetid.subdetId();
2401  st += "DETID=" + ss.str() + "\n";
2402  if(ECALdetid.subdetId() == 1){ //ECAL BARREL
2403  EBDetId barrel_detid(rawId);
2404  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(barrel_detid);
2405  if ( italpha != laserAlphaMap.end() ) alpha_factor = (*italpha);
2406  else edm::LogError("TopInfo") << "ERROR:LaserAlphe parameter note found!!" << "\n";
2407  }
2408  if(ECALdetid.subdetId() == 1){ //ECAL ENDCAP
2409  EEDetId endcap_detid(rawId);
2410  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(endcap_detid);
2411  if ( italpha != laserAlphaMap.end() ) alpha_factor = (*italpha);
2412  else edm::LogError("TopInfo") << "ERROR:LaserAlphe parameter note found!!" << "\n";
2413  }
2414 
2415  }//transparency corrections applied
2416 
2417  //if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit) ;
2418  //if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit)/icorr; //modif-alex-30/01/2010 tansparency corrections
2419  // ss << "rawId " << (*icalit) << " " << icorr << " " << alpha_factor << "\n";
2420  stringstream ss;
2421  ss << (*icalit);
2422  stringstream ss1;
2423  ss1 << icorr;
2424  stringstream ss2;
2425  ss2 << alpha_factor;
2426  st += "rawId " + ss.str() + " " + ss1.str() + " " + ss2.str() + "\n";
2427  if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit)/std::pow(icorr,alpha_factor); //modif-alex-27/07/2015 tansparency corrections with alpha parameters
2428 
2429  else edm::LogError("TopInfo") <<"getCoeff: "<<rawId<<" not found in EcalIntercalibConstantMap"<< "\n" ;
2430 }
std::map< int, double > Transparency_Correction_
return((rh^lh)&mask)
Definition: DetId.h:18
std::vector< Item >::const_iterator const_iterator
const_iterator find(uint32_t rawId) const
const_iterator end() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::pair< std::string, int > EcalTPGParamBuilder::getCrate ( int  tcc)
private

Definition at line 2587 of file EcalTPGParamBuilder.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

2587  {
2588  std::stringstream crate ;
2589  std::string pos ;
2590  int slot = 0 ;
2591 
2592  crate<<"S2D" ;
2593  if (tcc>=40 && tcc<=42) {crate<<"02d" ; slot = 5 + (tcc-40)*6 ;}
2594  if (tcc>=43 && tcc<=45) {crate<<"03d" ; slot = 5 + (tcc-43)*6 ;}
2595  if (tcc>=37 && tcc<=39) {crate<<"04d" ; slot = 5 + (tcc-37)*6 ;}
2596  if (tcc>=52 && tcc<=54) {crate<<"06d" ; slot = 5 + (tcc-52)*6 ;}
2597  if (tcc>=46 && tcc<=48) {crate<<"07d" ; slot = 5 + (tcc-46)*6 ;}
2598  if (tcc>=49 && tcc<=51) {crate<<"08d" ; slot = 5 + (tcc-49)*6 ;}
2599  if (tcc>=58 && tcc<=60) {crate<<"02h" ; slot = 5 + (tcc-58)*6 ;}
2600  if (tcc>=61 && tcc<=63) {crate<<"03h" ; slot = 5 + (tcc-61)*6 ;}
2601  if (tcc>=55 && tcc<=57) {crate<<"04h" ; slot = 5 + (tcc-55)*6 ;}
2602  if (tcc>=70 && tcc<=72) {crate<<"06h" ; slot = 5 + (tcc-70)*6 ;}
2603  if (tcc>=64 && tcc<=66) {crate<<"07h" ; slot = 5 + (tcc-64)*6 ;}
2604  if (tcc>=67 && tcc<=69) {crate<<"08h" ; slot = 5 + (tcc-67)*6 ;}
2605 
2606  if (tcc>=76 && tcc<=81) {
2607  crate<<"02l" ;
2608  if (tcc%2==0) slot = 2 + (tcc-76)*3 ;
2609  else slot = 4 + (tcc-77)*3 ;
2610  }
2611  if (tcc>=94 && tcc<=99) {
2612  crate<<"02l" ;
2613  if (tcc%2==0) slot = 3 + (tcc-94)*3 ;
2614  else slot = 5 + (tcc-95)*3 ;
2615  }
2616 
2617  if (tcc>=22 && tcc<=27) {
2618  crate<<"03l" ;
2619  if (tcc%2==0) slot = 2 + (tcc-22)*3 ;
2620  else slot = 4 + (tcc-23)*3 ;
2621  }
2622  if (tcc>=4 && tcc<=9) {
2623  crate<<"03l" ;
2624  if (tcc%2==0) slot = 3 + (tcc-4)*3 ;
2625  else slot = 5 + (tcc-5)*3 ;
2626  }
2627 
2628  if (tcc>=82 && tcc<=87) {
2629  crate<<"07l" ;
2630  if (tcc%2==0) slot = 2 + (tcc-82)*3 ;
2631  else slot = 4 + (tcc-83)*3 ;
2632  }
2633  if (tcc>=100 && tcc<=105) {
2634  crate<<"07l" ;
2635  if (tcc%2==0) slot = 3 + (tcc-100)*3 ;
2636  else slot = 5 + (tcc-101)*3 ;
2637  }
2638 
2639  if (tcc>=28 && tcc<=33) {
2640  crate<<"08l" ;
2641  if (tcc%2==0) slot = 2 + (tcc-28)*3 ;
2642  else slot = 4 + (tcc-29)*3 ;
2643  }
2644  if (tcc>=10 && tcc<=15) {
2645  crate<<"08l" ;
2646  if (tcc%2==0) slot = 3 + (tcc-10)*3 ;
2647  else slot = 5 + (tcc-11)*3 ;
2648  }
2649 
2650  if (tcc==34) {crate<<"04l" ; slot = 2 ;}
2651  if (tcc==16) {crate<<"04l" ; slot = 3 ;}
2652  if (tcc==35) {crate<<"04l" ; slot = 4 ;}
2653  if (tcc==17) {crate<<"04l" ; slot = 5 ;}
2654  if (tcc==36) {crate<<"04l" ; slot = 8 ;}
2655  if (tcc==18) {crate<<"04l" ; slot = 9 ;}
2656  if (tcc==19) {crate<<"04l" ; slot = 10 ;}
2657  if (tcc==1) {crate<<"04l" ; slot = 11 ;}
2658  if (tcc==20) {crate<<"04l" ; slot = 14 ;}
2659  if (tcc==2) {crate<<"04l" ; slot = 15 ;}
2660  if (tcc==21) {crate<<"04l" ; slot = 16 ;}
2661  if (tcc==3) {crate<<"04l" ; slot = 17 ;}
2662 
2663  if (tcc==88) {crate<<"06l" ; slot = 2 ;}
2664  if (tcc==106) {crate<<"06l" ; slot = 3 ;}
2665  if (tcc==89) {crate<<"06l" ; slot = 4 ;}
2666  if (tcc==107) {crate<<"06l" ; slot = 5 ;}
2667  if (tcc==90) {crate<<"06l" ; slot = 8 ;}
2668  if (tcc==108) {crate<<"06l" ; slot = 9 ;}
2669  if (tcc==73) {crate<<"06l" ; slot = 10 ;}
2670  if (tcc==91) {crate<<"06l" ; slot = 11 ;}
2671  if (tcc==74) {crate<<"06l" ; slot = 14 ;}
2672  if (tcc==92) {crate<<"06l" ; slot = 15 ;}
2673  if (tcc==75) {crate<<"06l" ; slot = 16 ;}
2674  if (tcc==93) {crate<<"06l" ; slot = 17 ;}
2675 
2676  return std::pair< std::string, int > (crate.str(),slot) ;
2677 }
std::string EcalTPGParamBuilder::getDet ( int  tcc)
private

Definition at line 2563 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

2563  {
2564  std::stringstream sdet ;
2565 
2566  if (tcc>36 && tcc<55) sdet<<"EB-"<<tcc-36 ;
2567  else if (tcc>=55 && tcc<73) sdet<<"EB+"<<tcc-54 ;
2568  else if (tcc<=36) sdet<<"EE-" ;
2569  else sdet<<"EE+" ;
2570 
2571  if (tcc<=36 || tcc>=73) {
2572  if (tcc>=73) tcc-=72 ;
2573  if (tcc==1 || tcc==18 || tcc==19 || tcc==36) sdet<<7 ;
2574  else if (tcc==2 || tcc==3 || tcc==20 || tcc==21) sdet<<8 ;
2575  else if (tcc==4 || tcc==5 || tcc==22 || tcc==23) sdet<<9 ;
2576  else if (tcc==6 || tcc==7 || tcc==24 || tcc==25) sdet<<1 ;
2577  else if (tcc==8 || tcc==9 || tcc==26 || tcc==27) sdet<<2 ;
2578  else if (tcc==10 || tcc==11 || tcc==28 || tcc==29) sdet<<3 ;
2579  else if (tcc==12 || tcc==13 || tcc==30 || tcc==31) sdet<<4 ;
2580  else if (tcc==14 || tcc==15 || tcc==32 || tcc==33) sdet<<5 ;
2581  else if (tcc==16 || tcc==17 || tcc==34 || tcc==35) sdet<<6 ;
2582  }
2583 
2584  return sdet.str() ;
2585 }
int EcalTPGParamBuilder::getEtaSlice ( int  tccId,
int  towerInTCC 
)
private

Definition at line 384 of file EcalTPGParamBuilder.cc.

385 {
386  int etaSlice = (towerInTCC-1)/4+1 ;
387  // barrel
388  if (tccId>36 || tccId<73) return etaSlice ;
389  //endcap
390  else {
391  if (tccId >=1 && tccId <= 18) etaSlice += 21 ; // inner -
392  if (tccId >=19 && tccId <= 36) etaSlice += 17 ; // outer -
393  if (tccId >=91 && tccId <= 108) etaSlice += 21 ; // inner +
394  if (tccId >=73 && tccId <= 90) etaSlice += 17 ; // outer +
395  }
396  return etaSlice ;
397 }
unsigned tccId(DetId const &)
int EcalTPGParamBuilder::getGCTRegionEta ( int  tteta)
private

Definition at line 2556 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

2556  {
2557  int gcteta = 0;
2558  if(tteta>0) gcteta = (tteta-1)/4 + 11;
2559  else if(tteta<0) gcteta = (tteta+1)/4 + 10;
2560  return gcteta;
2561 }
int EcalTPGParamBuilder::getGCTRegionPhi ( int  ttphi)
private

Definition at line 2548 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

2548  {
2549  int gctphi=0;
2550  gctphi = (ttphi+1)/4;
2551  if(ttphi<=2) gctphi=0;
2552  if(ttphi>=71) gctphi=0;
2553  return gctphi;
2554 }
bool EcalTPGParamBuilder::realignBaseline ( linStruc lin,
float  forceBase12 
)
private

Definition at line 2524 of file EcalTPGParamBuilder.cc.

References runEdmFileComparison::base, funct::false, objects.autophobj::float, mps_fire::i, linStruc::mult_, convertSQLiteXML::ok, linStruc::pedestal_, funct::pow(), and linStruc::shift_.

Referenced by analyze().

2525 {
2526  bool ok(true) ;
2527  float base[3] = {forceBase12, float(lin.pedestal_[1]), float(lin.pedestal_[2])} ;
2528  for (int i=1 ; i<3 ; i++) {
2529  if (lin.mult_[i]>0) {
2530  base[i] = float(lin.pedestal_[i]) -
2531  float(lin.mult_[0])/float(lin.mult_[i])*pow(2., -(lin.shift_[0]-lin.shift_[i]))*(lin.pedestal_[0]-base[0]) ;
2532  } else base[i] = 0 ;
2533  }
2534 
2535  for (int i=0 ; i<3 ; i++) {
2536  lin.pedestal_[i] = base[i] ;
2537  //cout<<lin.pedestal_[i]<<" "<<base[i]<<endl ;
2538  if (base[i]<0 || lin.pedestal_[i]>1000) {
2539  edm::LogError("TopInfo") <<"WARNING: base= "<<base[i]<<", "<<lin.pedestal_[i]<<" for gainId[0-2]="<<i<<" ==> forcing at 0"<< "\n" ;
2540  lin.pedestal_[i] = 0 ;
2541  ok = false ;
2542  }
2543  }
2544  return ok ;
2545 
2546 }
base
Make Sure CMSSW is Setup ##.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int EcalTPGParamBuilder::uncodeWeight ( double  weight,
int  complement2 = 7 
)
private

Definition at line 2180 of file EcalTPGParamBuilder.cc.

References createfilelist::int, SiStripPI::max, and funct::pow().

Referenced by computeWeights().

2181 {
2182  int iweight ;
2183  unsigned int max = (unsigned int)(pow(2.,complement2)-1) ;
2184  if (weight>0) iweight=int((1<<6)*weight+0.5) ; // +0.5 for rounding pb
2185  else iweight= max - int(-weight*(1<<6)+0.5) +1 ;
2186  iweight = iweight & max ;
2187  return iweight ;
2188 }
Definition: weight.py:1
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double EcalTPGParamBuilder::uncodeWeight ( int  iweight,
int  complement2 = 7 
)
private

Definition at line 2190 of file EcalTPGParamBuilder.cc.

References funct::pow(), and mps_merge::weight.

2190  {
2191  double weight = double(iweight)/pow(2., 6.) ;
2192  // test if negative weight:
2193  if ( (iweight & (1<<(complement2-1))) != 0) weight = (double(iweight)-pow(2., complement2))/pow(2., 6.) ;
2194  return weight ;
2195 }
Definition: weight.py:1
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

int EcalTPGParamBuilder::bst_conf_id_
private

Definition at line 158 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::btt_conf_id_
private

Definition at line 157 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::bxt_conf_id_
private

Definition at line 156 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::complement2_
private

Definition at line 106 of file EcalTPGParamBuilder.h.

Referenced by computeWeights().

EcalTPGDBApp* EcalTPGParamBuilder::db_
private

Definition at line 142 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

bool EcalTPGParamBuilder::DBEE_
private

Definition at line 146 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::DBrunNb_
private

Definition at line 145 of file EcalTPGParamBuilder.h.

int EcalTPGParamBuilder::del_conf_id_
private

Definition at line 155 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

std::map<int, std::vector<int> > EcalTPGParamBuilder::delays_EB_
private

Definition at line 132 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

std::map<int, std::vector<int> > EcalTPGParamBuilder::delays_EE_
private

Definition at line 134 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::Et_sat_EB_
private
double EcalTPGParamBuilder::Et_sat_EE_
private
edm::ESHandle<EcalTrigTowerConstituentsMap> EcalTPGParamBuilder::eTTmap_
private

Definition at line 95 of file EcalTPGParamBuilder.h.

Referenced by analyze().

double EcalTPGParamBuilder::FG_highRatio_EB_
private
double EcalTPGParamBuilder::FG_highThreshold_EB_
private
double EcalTPGParamBuilder::FG_lowRatio_EB_
private
double EcalTPGParamBuilder::FG_lowThreshold_EB_
private
unsigned int EcalTPGParamBuilder::FG_lut_EB_
private

Definition at line 114 of file EcalTPGParamBuilder.h.

Referenced by computeFineGrainEBParameters(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::FG_lut_strip_EE_
private

Definition at line 116 of file EcalTPGParamBuilder.h.

Referenced by computeFineGrainEEParameters(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::FG_lut_tower_EE_
private

Definition at line 116 of file EcalTPGParamBuilder.h.

Referenced by computeFineGrainEEParameters(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::FG_Threshold_EE_
private
int EcalTPGParamBuilder::fgr_conf_id_
private

Definition at line 151 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::forcedPedestalValue_
private

Definition at line 117 of file EcalTPGParamBuilder.h.

Referenced by analyze(), EcalTPGParamBuilder(), and getCoeff().

bool EcalTPGParamBuilder::forceEtaSlice_
private

Definition at line 118 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

std::ofstream* EcalTPGParamBuilder::geomFile_
private

Definition at line 141 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

bool EcalTPGParamBuilder::H2_
private

Definition at line 121 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::lin_conf_id_
private

Definition at line 149 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::lut_conf_id_
private

Definition at line 150 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_constant_EB_
private

Definition at line 109 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_constant_EE_
private

Definition at line 110 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_noise_EB_
private

Definition at line 109 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_noise_EE_
private

Definition at line 110 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

std::string EcalTPGParamBuilder::LUT_option_
private

Definition at line 107 of file EcalTPGParamBuilder.h.

Referenced by analyze(), computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_stochastic_EB_
private

Definition at line 109 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_stochastic_EE_
private

Definition at line 110 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_threshold_EB_
private

Definition at line 108 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::LUT_threshold_EE_
private

Definition at line 108 of file EcalTPGParamBuilder.h.

Referenced by computeLUT(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_bst
private

Definition at line 171 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_btt
private

Definition at line 170 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_bxt
private

Definition at line 169 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_del
private

Definition at line 168 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_fgr
private

Definition at line 165 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_lin
private

Definition at line 162 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_lut
private

Definition at line 163 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_ped
private

Definition at line 161 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_sli
private

Definition at line 166 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_spi
private

Definition at line 167 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::m_write_wei
private

Definition at line 164 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::nSample_
private

Definition at line 105 of file EcalTPGParamBuilder.h.

Referenced by computeWeights().

Char_t EcalTPGParamBuilder::ntupleCrate_[10]
private

Definition at line 175 of file EcalTPGParamBuilder.h.

Referenced by analyze().

Char_t EcalTPGParamBuilder::ntupleDet_[10]
private

Definition at line 174 of file EcalTPGParamBuilder.h.

Referenced by analyze().

Int_t* EcalTPGParamBuilder::ntupleInts_
private

Definition at line 173 of file EcalTPGParamBuilder.h.

Referenced by analyze().

std::ofstream* EcalTPGParamBuilder::out_file_
private

Definition at line 140 of file EcalTPGParamBuilder.h.

Referenced by analyze(), EcalTPGParamBuilder(), and ~EcalTPGParamBuilder().

int EcalTPGParamBuilder::ped_conf_id_
private

Definition at line 148 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::pedestal_offset_
private

Definition at line 119 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

std::map<int, std::vector<int> > EcalTPGParamBuilder::phases_EB_
private

Definition at line 133 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

std::map<int, std::vector<int> > EcalTPGParamBuilder::phases_EE_
private

Definition at line 135 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::sampleMax_
private

Definition at line 102 of file EcalTPGParamBuilder.h.

Referenced by computeWeights(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::SFGVB_lut_
private

Definition at line 119 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::SFGVB_SpikeKillingThreshold_
private

Definition at line 120 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::SFGVB_Threshold_
private

Definition at line 119 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::sli_conf_id_
private

Definition at line 152 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

unsigned int EcalTPGParamBuilder::sliding_
private

Definition at line 101 of file EcalTPGParamBuilder.h.

Referenced by analyze(), computeLinearizerParam(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::spi_conf_id_
private

Definition at line 154 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

std::string EcalTPGParamBuilder::tag_
private

Definition at line 159 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

const CaloSubdetectorGeometry* EcalTPGParamBuilder::theBarrelGeometry_
private

Definition at line 94 of file EcalTPGParamBuilder.h.

Referenced by analyze().

const CaloSubdetectorGeometry* EcalTPGParamBuilder::theEndcapGeometry_
private

Definition at line 93 of file EcalTPGParamBuilder.h.

Referenced by analyze().

const EcalElectronicsMapping* EcalTPGParamBuilder::theMapping_
private

Definition at line 96 of file EcalTPGParamBuilder.h.

Referenced by analyze().

std::string EcalTPGParamBuilder::TimingDelays_EB_
private

Definition at line 128 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

std::string EcalTPGParamBuilder::TimingDelays_EE_
private

Definition at line 129 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

std::string EcalTPGParamBuilder::TimingPhases_EB_
private

Definition at line 130 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

std::string EcalTPGParamBuilder::TimingPhases_EE_
private

Definition at line 131 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

std::string EcalTPGParamBuilder::Transparency_Corr_
private

Definition at line 124 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder().

std::map<int, double > EcalTPGParamBuilder::Transparency_Correction_
private

Definition at line 138 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder(), and getCoeff().

double EcalTPGParamBuilder::TTF_highThreshold_EB_
private

Definition at line 111 of file EcalTPGParamBuilder.h.

Referenced by analyze(), beginJob(), computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::TTF_highThreshold_EE_
private

Definition at line 112 of file EcalTPGParamBuilder.h.

Referenced by analyze(), beginJob(), computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::TTF_lowThreshold_EB_
private

Definition at line 111 of file EcalTPGParamBuilder.h.

Referenced by analyze(), beginJob(), computeLUT(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::TTF_lowThreshold_EE_
private

Definition at line 112 of file EcalTPGParamBuilder.h.

Referenced by analyze(), beginJob(), computeLUT(), and EcalTPGParamBuilder().

bool EcalTPGParamBuilder::useDBShape_
private

Definition at line 177 of file EcalTPGParamBuilder.h.

Referenced by analyze().

bool EcalTPGParamBuilder::useInterCalibration_
private

Definition at line 121 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder(), and getCoeff().

bool EcalTPGParamBuilder::useTransparencyCorr_
private

Definition at line 125 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder(), and getCoeff().

bool EcalTPGParamBuilder::useTransverseEnergy_
private

Definition at line 98 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::version_
private

Definition at line 160 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

int EcalTPGParamBuilder::wei_conf_id_
private

Definition at line 153 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

double EcalTPGParamBuilder::weight_timeShift_
private

Definition at line 103 of file EcalTPGParamBuilder.h.

Referenced by computeWeights(), and EcalTPGParamBuilder().

bool EcalTPGParamBuilder::weight_unbias_recovery_
private

Definition at line 104 of file EcalTPGParamBuilder.h.

Referenced by computeWeights(), and EcalTPGParamBuilder().

bool EcalTPGParamBuilder::writeToDB_
private

Definition at line 143 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and EcalTPGParamBuilder().

bool EcalTPGParamBuilder::writeToFiles_
private
double EcalTPGParamBuilder::xtal_LSB_EB_
private

Definition at line 99 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and computeLinearizerParam().

double EcalTPGParamBuilder::xtal_LSB_EE_
private

Definition at line 99 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and computeLinearizerParam().