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

virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup)
 
virtual void beginJob ()
 
bool checkIfOK (EcalPedestals::Item item)
 
 EcalTPGParamBuilder (edm::ParameterSet const &pSet)
 
 ~EcalTPGParamBuilder ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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
 
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 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 &)
 
- 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 ( )

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 
)
virtual

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_, PV3DBase< T, PVType, FrameType >::eta(), 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(), CaloCellGeometry::getPosition(), FEConfigMainInfo::getSliId(), FEConfigMainInfo::getSpiId(), FEConfigMainInfo::getTimId(), EcalElectronicsMapping::getTriggerElectronicsId(), CaloSubdetectorGeometry::getValidDetIds(), FEConfigMainInfo::getWeiId(), H2_, cmsBatch::handle, ecalpyutils::hashedIndex(), mps_fire::i, hcalTTPDigis_cfi::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_, PV3DBase< T, PVType, FrameType >::phi(), 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(), FEConfigFgrParamDat::setFGhighratio(), FEConfigFgrParamDat::setFGhighthresh(), FEConfigFgrParamDat::setFGlowratio(), FEConfigFgrParamDat::setFGlowthresh(), FEConfigFgrGroupDat::setFgrGroupId(), FEConfigFgrDat::setFgrGroupId(), FEConfigPedInfo::setId(), FEConfigFgrEEStripDat::setLutFgr(), FEConfigLUTGroupDat::setLUTGroupId(), FEConfigLUTDat::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_, harvestTrackValidationPlots::str, AlCaHLTBitMon_QueryRunRegistry::string, EcalElectronicsId::stripId(), EcalTrigTowerDetId::subDet(), tag_, EcalElectronicsMapping::TCCid(), theBarrelGeometry_, theEndcapGeometry_, theMapping_, PV3DBase< T, PVType, FrameType >::theta(), theta(), ctppsDiamondLocalTracks_cfi::threshold, EcalElectronicsId::towerId(), funct::true, TTF_highThreshold_EB_, TTF_highThreshold_EE_, TTF_lowThreshold_EB_, TTF_lowThreshold_EE_, EBDetId::unhashIndex(), EEDetId::unhashIndex(), 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, HcalDigiParam_cfi::zside, and EcalTrigTowerDetId::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);
412  theBarrelGeometry_ = &(*theBarrelGeometry_handle);
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) ;
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_) ;
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_) ;
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  EBShape shapeEB ;
1454  EEShape shapeEE ;
1455  weights[0] = computeWeights(shapeEB, hshapeEB) ;
1456  weights[1] = computeWeights(shapeEE, hshapeEE) ;
1457 
1458  map<EcalLogicID, FEConfigWeightGroupDat> dataset;
1459 
1460  for (int igrp=0 ; igrp<NWEIGROUPS ; igrp++) {
1461 
1462  if (weights[igrp].size() == 5) {
1463 
1464  if (writeToFiles_) {
1465  (*out_file_) <<std::endl ;
1466  (*out_file_) <<"WEIGHT "<<igrp<<endl ;
1467  for (unsigned int sample=0 ; sample<5 ; sample++) (*out_file_) << "0x" <<hex<<weights[igrp][sample]<<" " ;
1468  (*out_file_)<<std::endl ;
1469  (*out_file_) <<std::endl ;
1470  }
1471  if (writeToDB_) {
1472  ss <<"going to write the weights for groupe:"<<igrp<< "\n";
1474  gut.setWeightGroupId(igrp);
1475  //PP WARNING: weights order is reverted when stored in the DB
1476  gut.setWeight0(weights[igrp][4] );
1477  gut.setWeight1(weights[igrp][3]+ 0x80); //0x80 to identify the max of the pulse in the FENIX (doesn't exist in emulator)
1478  gut.setWeight2(weights[igrp][2] );
1479  gut.setWeight3(weights[igrp][1] );
1480  gut.setWeight4(weights[igrp][0] );
1481  EcalLogicID ecid = EcalLogicID( "DUMMY", igrp,igrp); //1 dummy ID per group
1482  // Fill the dataset
1483  dataset[ecid] = gut;
1484  }
1485  }
1486  }
1487 
1488  if (writeToDB_) {
1489 
1490  // now we store in the DB the correspondence btw channels and groups
1491  map<EcalLogicID, FEConfigWeightDat> dataset2;
1492 
1493  // EB loop
1494  for (int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1495  FEConfigWeightDat wut;
1496  int igroup = 0; // this group is for EB
1497  wut.setWeightGroupId(igroup);
1498  dataset2[my_StripEcalLogicId[ich]] = wut;
1499  }
1500 
1501  // EE loop
1502  for (int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1503  FEConfigWeightDat wut;
1504  int igroup = 1; // this group is for EE
1505  wut.setWeightGroupId(igroup);
1506  // Fill the dataset
1507  dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1508  }
1509  // EE loop 2 (we had to split the ids of EE in 2 vectors to avoid crash!)
1510  for (int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1511  FEConfigWeightDat wut;
1512  int igroup = 1; // this group is for EE
1513  wut.setWeightGroupId(igroup);
1514  // Fill the dataset
1515  dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1516  }
1517 
1518  // Insert the datasets
1519  ostringstream wtag;
1520  wtag.str(""); wtag<<"Shape_NGroups_"<<NWEIGROUPS;
1521  std::string weight_tag=wtag.str();
1522  ss << " weight tag "<<weight_tag<< "\n";
1523  if (m_write_wei==1) wei_conf_id_=db_->writeToConfDB_TPGWeight(dataset, dataset2, NWEIGROUPS, weight_tag) ;
1524  }
1525  edm::LogInfo("TopInfo") << ss.str();
1526  ss.str("");
1527 
1529  // Compute FG section //
1531 
1532  // barrel
1533  unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG ;
1534  computeFineGrainEBParameters(lowRatio, highRatio, lowThreshold, highThreshold, lutFG) ;
1535  if (writeToFiles_) {
1536  (*out_file_) <<std::endl ;
1537  (*out_file_) <<"FG 0"<<std::endl ;
1538  (*out_file_)<<hex<<"0x"<<lowThreshold<<" 0x"<<highThreshold
1539  <<" 0x"<<lowRatio<<" 0x"<<highRatio<<" 0x"<<lutFG
1540  <<std::endl ;
1541  }
1542 
1543  // endcap
1544  unsigned int threshold, lut_tower ;
1545  unsigned int lut_strip;
1546  computeFineGrainEEParameters(threshold, lut_strip, lut_tower) ;
1547 
1548  // and here we store the fgr part
1549 
1550 
1551  if (writeToDB_) {
1552  ss <<"going to write the fgr "<< "\n";
1553  map<EcalLogicID, FEConfigFgrGroupDat> dataset;
1554  // we create 1 group
1555  int NFGRGROUPS =1;
1556  for (int ich=0; ich<NFGRGROUPS; ich++){
1557  FEConfigFgrGroupDat gut;
1558  gut.setFgrGroupId(ich);
1559  gut.setThreshLow(lowRatio );
1560  gut.setThreshHigh(highRatio);
1561  gut.setRatioLow(lowThreshold);
1562  gut.setRatioHigh(highThreshold);
1563  gut.setLUTValue(lutFG);
1564  EcalLogicID ecid = EcalLogicID( "DUMMY", ich,ich);
1565  // Fill the dataset
1566  dataset[ecid] = gut; // we use any logic id but different, because it is in any case ignored...
1567  }
1568 
1569  // now we store in the DB the correspondence btw channels and groups
1570  map<EcalLogicID, FEConfigFgrDat> dataset2;
1571  // in this case I decide in a stupid way which channel belongs to which group
1572  for (int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1573  FEConfigFgrDat wut;
1574  int igroup=0;
1575  wut.setFgrGroupId(igroup);
1576  // Fill the dataset
1577  // the logic ids are ordered by SM (1,...36) and TT (1,...68)
1578  // you have to calculate the right index here
1579  dataset2[my_TTEcalLogicId[ich]] = wut;
1580  }
1581 
1582  // endcap loop
1583  for (int ich=0; ich<(int)my_RTEcalLogicId_EE.size() ; ich++){
1584  // std::cout << " endcap FGR " << std::endl;
1585  FEConfigFgrDat wut;
1586  int igroup=0;
1587  wut.setFgrGroupId(igroup);
1588  // Fill the dataset
1589  // the logic ids are ordered by .... ?
1590  // you have to calculate the right index here
1591  dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1592  }
1593 
1594  // endcap TT loop for the FEfgr EE Tower
1595  map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1596  for (int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1597  FEConfigFgrEETowerDat fgreett;
1598  fgreett.setLutValue(lut_tower);
1599  dataset3[my_TTEcalLogicId_EE[ich]]=fgreett;
1600  }
1601 
1602  // endcap strip loop for the FEfgr EE strip
1603  // and barrel strip loop for the spike parameters (same structure than EE FGr)
1604  map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1605  for (int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1607  zut.setThreshold(threshold);
1608  zut.setLutFgr(lut_strip);
1609  dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1610  }
1611  for (int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1613  zut.setThreshold(threshold);
1614  zut.setLutFgr(lut_strip);
1615  // Fill the dataset
1616  dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1617  }
1618  for (int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1619  // EB
1621  EcalLogicID thestrip = my_StripEcalLogicId[ich] ;
1622  uint32_t elStripId = stripMapEB[ich] ;
1623  map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId) ;
1624  if (it != stripMapEBsintheta.end()) zut.setThreshold(it->second);
1625  else {
1626  edm::LogError("TopInfo") <<"ERROR: strip SFGVB threshold parameter not found for that strip:"<<thestrip.getID1()<<" "<<thestrip.getID3()<<" "<<thestrip.getID3()<< "\n" ;
1627  edm::LogError("TopInfo") <<" using value = "<<SFGVB_Threshold_+pedestal_offset_<< "\n" ;
1628  zut.setThreshold(SFGVB_Threshold_+pedestal_offset_) ;
1629  }
1630  zut.setLutFgr(SFGVB_lut_);
1631  // Fill the dataset
1632  dataset4[thestrip] = zut;
1633  }
1634 
1635  // Insert the dataset
1636  ostringstream wtag;
1637  wtag.str(""); wtag<<"FGR_"<<lutFG<<"_N_"<<NFGRGROUPS<<"_eb_"<<FG_lowThreshold_EB_<<"_EB_"<<FG_highThreshold_EB_;
1638  std::string weight_tag=wtag.str();
1639  ss << " weight tag "<<weight_tag<< "\n";
1640  if(m_write_fgr==1) fgr_conf_id_=db_->writeToConfDB_TPGFgr(dataset, dataset2, fgrparamset,dataset3, dataset4, NFGRGROUPS, weight_tag) ;
1641 
1642  //modif-alex 21/01/11
1643  map<EcalLogicID, FEConfigSpikeDat> datasetspike; //loob EB TT
1644  for (int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1645  FEConfigSpikeDat spiketh;
1647  datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1648  }//loop EB TT towers
1649 
1650  //modif-alex 21/01/11
1651  ostringstream stag;
1652  stag.str(""); stag<<"SpikeTh"<<SFGVB_SpikeKillingThreshold_;
1653  std::string spike_tag=stag.str();
1654  ss << " spike tag "<<spike_tag<< "\n";
1655  if(m_write_spi==1) spi_conf_id_=db_->writeToConfDB_Spike(datasetspike, spike_tag) ; //modif-alex 21/01/11
1656 
1657  //modif-alex 31/01/11
1658  //DELAYS EB
1659  map<EcalLogicID, FEConfigTimingDat> datasetdelay; // the loop goes from TCC 38 to 72 and throught the towers from 1 to 68
1660  for (int ich=0; ich<(int)my_TTEcalLogicId_EB_by_TCC.size() ; ich++){
1661  FEConfigTimingDat delay;
1662 
1663  EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich] ;
1664  int id1_tcc=my_TTEcalLogicId_EB_by_TCC[ich].getID1(); // the TCC
1665  int id2_tt =my_TTEcalLogicId_EB_by_TCC[ich].getID2(); // the tower
1666  std::map<int, vector<int> >::const_iterator ittEB = delays_EB_.find(id1_tcc);
1667  std::vector<int> TimingDelaysEB = ittEB->second;
1668 
1669  if (ittEB != delays_EB_.end()){
1670  if(TimingDelaysEB[id2_tt-1] == -1){
1671  edm::LogError("TopInfo") << "ERROR: Barrel timing delay not specified, check file, putting default value 1" << "\n";
1672  delay.setTimingPar1(1);
1673  }
1674  else delay.setTimingPar1(TimingDelaysEB[id2_tt-1]);
1675  } else {
1676  edm::LogError("TopInfo") << "ERROR:Barrel Could not find delay parameter for that trigger tower " << "\n";
1677  edm::LogError("TopInfo") << "Using default value = 1" << "\n";
1678  delay.setTimingPar1(1);
1679  }
1680 
1681  std::map<int, vector<int> >::const_iterator ittpEB = phases_EB_.find(id1_tcc);
1682  std::vector<int> TimingPhasesEB = ittpEB->second;
1683 
1684  if (ittpEB != phases_EB_.end()){
1685  if(TimingPhasesEB[id2_tt-1] == -1){
1686  edm::LogError("TopInfo") << "ERROR: Barrel timing phase not specified, check file, putting default value 0" << "\n";
1687  delay.setTimingPar2(0);
1688  }
1689  else delay.setTimingPar2(TimingPhasesEB[id2_tt-1]);
1690  } else {
1691  edm::LogError("TopInfo") << "ERROR:Barrel Could not find phase parameter for that trigger tower " << "\n";
1692  edm::LogError("TopInfo") << "Using default value = 0" << "\n";
1693  delay.setTimingPar2(0);
1694  }
1695 
1696  ss << ich << " tcc=" << id1_tcc << " TT=" << id2_tt << " logicId=" << logiciddelay.getLogicID()
1697  << " delay=" << TimingDelaysEB[id2_tt-1] << " phase=" << TimingPhasesEB[id2_tt-1] << "\n";
1698 
1699  //delay.setTimingPar1(1);
1700  //delay.setTimingPar2(2);
1701  datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] = delay;
1702  }//loop EB TT towers
1703 
1704  //DELAYS EE
1705  int stripindex = 0;
1706  int tccin = 1;
1707  for (int ich=0; ich<(int)my_StripEcalLogicId_EE_strips_by_TCC.size() ; ich++){
1708  FEConfigTimingDat delay;
1709  //int id1_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID1(); // the TCC
1710  //int id2_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2(); // the Tower
1711  //int id3_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3(); // the strip
1712 
1713  EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich] ;
1714  int id1_tcc=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID1(); // the TCC
1715  int id2_tt =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2(); // the tower
1716  int id3_st =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3(); // the strip
1717 
1718  //reset strip counter
1719  if(id1_tcc != tccin) {tccin = id1_tcc; stripindex=0;}
1720 
1721  std::map<int, vector<int> >::const_iterator ittEE = delays_EE_.find(id1_tcc);
1722  std::vector<int> TimingDelaysEE = ittEE->second;
1723 
1724  if (ittEE != delays_EE_.end()){
1725  if(TimingDelaysEE[stripindex] == -1){
1726  edm::LogError("TopInfo") << "ERROR: Endcap timing delay not specified, check file, putting default value 1" << "\n";
1727  delay.setTimingPar1(1);
1728  }
1729  else delay.setTimingPar1(TimingDelaysEE[stripindex]);
1730  } else {
1731  edm::LogError("TopInfo") << "ERROR:Endcap Could not find delay parameter for that trigger tower " << "\n";
1732  edm::LogError("TopInfo") << "Using default value = 1" << "\n";
1733  delay.setTimingPar1(1);
1734  }
1735 
1736  std::map<int, vector<int> >::const_iterator ittpEE = phases_EE_.find(id1_tcc);
1737  std::vector<int> TimingPhasesEE = ittpEE->second;
1738 
1739  if (ittpEE != phases_EE_.end()){
1740  if(TimingPhasesEE[stripindex] == -1){
1741  edm::LogError("TopInfo") << "ERROR: Endcap timing phase not specified, check file, putting default value 0" << "\n";
1742  delay.setTimingPar2(0);
1743  }
1744  else delay.setTimingPar2(TimingPhasesEE[stripindex]);
1745  } else {
1746  edm::LogError("TopInfo") << "ERROR:Endcap Could not find phase parameter for that trigger tower " << "\n";
1747  edm::LogError("TopInfo") << "Using default value = 0" << "\n";
1748  delay.setTimingPar2(0);
1749  }
1750 
1751  ss << ich << " stripindex=" << stripindex << " tcc=" << id1_tcc << " TT=" << id2_tt << " id3_st=" << id3_st
1752  << " logicId=" << logiciddelay.getLogicID()
1753  << " delay=" << TimingDelaysEE[stripindex] << " phase=" << TimingPhasesEE[stripindex] << "\n";
1754 
1755 
1756  //delay.setTimingPar1(1);
1757  //delay.setTimingPar2(2);
1758  datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] = delay;
1759  stripindex++;
1760  }//loop EE strip towers
1761 
1762  ostringstream de_tag;
1763  de_tag.str(""); de_tag<<"DelaysFromFile";
1764  std::string delay_tag=de_tag.str();
1765  ss << " delay tag "<<delay_tag<< "\n";
1766  if(m_write_del==1) del_conf_id_=db_->writeToConfDB_Delay(datasetdelay, delay_tag) ; //modif-alex 31/01/11
1767 
1768 
1769  } //write to DB
1770 
1771  if (writeToDB_) {
1772  ss <<"going to write the sliding "<< "\n";
1773  map<EcalLogicID, FEConfigSlidingDat> dataset;
1774  // in this case I decide in a stupid way which channel belongs to which group
1775  for (int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1776  FEConfigSlidingDat wut;
1777  wut.setSliding(sliding_);
1778  // Fill the dataset
1779  // the logic ids are ordered by SM (1,...36) , TT (1,...68) and strip (1..5)
1780  // you have to calculate the right index here
1781  dataset[my_StripEcalLogicId[ich]] = wut;
1782  }
1783 
1784  // endcap loop
1785  for (int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1786  FEConfigSlidingDat wut;
1787  wut.setSliding(sliding_);
1788  // Fill the dataset
1789  // the logic ids are ordered by fed tower strip
1790  // you have to calculate the right index here
1791  dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1792  }
1793  for (int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1794  FEConfigSlidingDat wut;
1795  wut.setSliding(sliding_);
1796  // Fill the dataset
1797  // the logic ids are ordered by ... ?
1798  // you have to calculate the right index here
1799  dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1800  }
1801 
1802 
1803  // Insert the dataset
1804  ostringstream wtag;
1805  wtag.str(""); wtag<<"Sliding_"<<sliding_;
1806  std::string justatag=wtag.str();
1807  ss << " sliding tag "<<justatag<< "\n";
1808  int iov_id=0; // just a parameter ...
1809  if(m_write_sli==1) sli_conf_id_=db_->writeToConfDB_TPGSliding(dataset,iov_id, justatag) ;
1810  }
1811 
1812 
1813 
1814 
1815 
1817  // Compute LUT section //
1819 
1820  int lut_EB[1024], lut_EE[1024] ;
1821 
1822  // barrel
1823  computeLUT(lut_EB, "EB") ;
1824  if (writeToFiles_) {
1825  (*out_file_) <<std::endl ;
1826  (*out_file_) <<"LUT 0"<<std::endl ;
1827  for (int i=0 ; i<1024 ; i++) (*out_file_)<<"0x"<<hex<<lut_EB[i]<<endl ;
1828  (*out_file_)<<endl ;
1829  }
1830 
1831  // endcap
1832  computeLUT(lut_EE, "EE") ;
1833  // check first if lut_EB and lut_EE are the same
1834  bool newLUT(false) ;
1835  for (int i=0 ; i<1024 ; i++) if (lut_EE[i] != lut_EB[i]) newLUT = true ;
1836  if (newLUT && writeToFiles_) {
1837  (*out_file_) <<std::endl ;
1838  (*out_file_) <<"LUT 1"<<std::endl ;
1839  for (int i=0 ; i<1024 ; i++) (*out_file_)<<"0x"<<hex<<lut_EE[i]<<endl ;
1840  (*out_file_)<<endl ;
1841  }
1842 
1843 
1844 
1845  if (writeToDB_) {
1846 
1847 
1848 
1849  map<EcalLogicID, FEConfigLUTGroupDat> dataset;
1850  // we create 1 LUT group
1851  int NLUTGROUPS =0;
1852  int ich=0;
1854  lut.setLUTGroupId(ich);
1855  for (int i=0; i<1024; i++){
1856  lut.setLUTValue(i, lut_EB[i] );
1857  }
1858  EcalLogicID ecid = EcalLogicID( "DUMMY", ich,ich);
1859  // Fill the dataset
1860  dataset[ecid] = lut; // we use any logic id but different, because it is in any case ignored...
1861 
1862  ich++;
1863 
1865  lute.setLUTGroupId(ich);
1866  for (int i=0; i<1024; i++){
1867  lute.setLUTValue(i, lut_EE[i] );
1868  }
1869  EcalLogicID ecide = EcalLogicID( "DUMMY", ich,ich);
1870  // Fill the dataset
1871  dataset[ecide] = lute; // we use any logic id but different, because it is in any case ignored...
1872 
1873  ich++;
1874 
1875  NLUTGROUPS=ich;
1876 
1877  // now we store in the DB the correspondence btw channels and LUT groups
1878  map<EcalLogicID, FEConfigLUTDat> dataset2;
1879  // in this case I decide in a stupid way which channel belongs to which group
1880  for (int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1882  int igroup=0;
1883  lut.setLUTGroupId(igroup);
1884  // calculate the right TT - in the vector they are ordered by SM and by TT
1885  // Fill the dataset
1886  dataset2[my_TTEcalLogicId[ich]] = lut;
1887  }
1888 
1889  // endcap loop
1890  for (int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1892  int igroup=1;
1893  lut.setLUTGroupId(igroup);
1894  // calculate the right TT
1895  // Fill the dataset
1896  dataset2[my_TTEcalLogicId_EE[ich]] = lut;
1897  }
1898 
1899  // Insert the dataset
1900  ostringstream ltag;
1901  ltag.str(""); ltag<<LUT_option_<<"_NGroups_"<<NLUTGROUPS;
1902  std::string lut_tag=ltag.str();
1903  ss << " LUT tag "<<lut_tag<< "\n";
1904  if(m_write_lut==1) lut_conf_id_=db_->writeToConfDB_TPGLUT(dataset, dataset2,lutparamset, NLUTGROUPS, lut_tag) ;
1905 
1906  }
1907 
1908  // last we insert the FE_CONFIG_MAIN table
1909  if (writeToDB_) {
1910 
1911  //int conf_id_=db_->writeToConfDB_TPGMain(ped_conf_id_,lin_conf_id_, lut_conf_id_, fgr_conf_id_,
1912  // sli_conf_id_, wei_conf_id_, bxt_conf_id_, btt_conf_id_, tag_, version_) ;
1915 
1916  ss << "\n Conf ID = " << conf_id_ << "\n";
1917 
1918  }
1919 
1921  // loop on strips and associate them with values //
1923 
1924  // Barrel
1925  stripListEB.sort() ;
1926  stripListEB.unique() ;
1927  ss <<"Number of EB strips="<<dec<<stripListEB.size()<< "\n" ;
1928  if (writeToFiles_) {
1929  (*out_file_) <<std::endl ;
1930  for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++ ) {
1931  (*out_file_) <<"STRIP_EB "<<dec<<(*itList)<<endl ;
1932  (*out_file_) << hex << "0x" <<sliding_<<std::endl ;
1933  (*out_file_) <<"0" <<std::endl ;
1934  (*out_file_) <<"0x"<<stripMapEBsintheta[(*itList)] << " 0x" << SFGVB_lut_ <<std::endl ;
1935  }
1936  }
1937 
1938  // Endcap
1939  stripListEE.sort() ;
1940  stripListEE.unique() ;
1941  ss <<"Number of EE strips="<<dec<<stripListEE.size()<< "\n" ;
1942  if (writeToFiles_) {
1943  (*out_file_) <<std::endl ;
1944  for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++ ) {
1945  (*out_file_) <<"STRIP_EE "<<dec<<(*itList)<<endl ;
1946  (*out_file_) << hex << "0x" <<sliding_<<std::endl ;
1947  //(*out_file_) <<" 0" << std::endl ;
1948  (*out_file_) <<" 1" << std::endl ; //modif-debug to get the correct EE TPG
1949  (*out_file_)<<hex<<"0x"<<threshold<<" 0x"<<lut_strip<<std::endl ;
1950  }
1951  }
1952  edm::LogInfo("TopInfo") << ss.str();
1953  ss.str("");
1954 
1955 
1957  // loop on towers and associate them with default values //
1959 
1960  // Barrel
1961  towerListEB.sort() ;
1962  towerListEB.unique() ;
1963  ss <<"Number of EB towers="<<dec<<towerListEB.size()<< "\n" ;
1964  if (writeToFiles_) {
1965  (*out_file_) <<std::endl ;
1966  for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++ ) {
1967  (*out_file_) <<"TOWER_EB "<<dec<<(*itList)<<endl ;
1968  (*out_file_) <<" 0\n 0\n" ;
1969  (*out_file_) <<" " << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex
1970  }
1971  }
1972 
1973  // Endcap
1974  towerListEE.sort() ;
1975  towerListEE.unique() ;
1976  ss <<"Number of EE towers="<<dec<<towerListEE.size()<< "\n" ;
1977  if (writeToFiles_) {
1978  (*out_file_) <<std::endl ;
1979  for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++ ) {
1980  (*out_file_) <<"TOWER_EE "<<dec<<(*itList)<<endl ;
1981  if (newLUT) (*out_file_) <<" 1\n" ;
1982  else (*out_file_) <<" 0\n" ;
1983  (*out_file_)<<hex<<"0x"<<lut_tower<<std::endl ;
1984  }
1985  }
1986  edm::LogInfo("TopInfo") << ss.str();
1987  ss.str("");
1988 
1989 
1990 
1992  // store control histos //
1994  ICEB->Write() ;
1995  tpgFactorEB->Write() ;
1996  ICEEPlus->Write() ;
1997  tpgFactorEEPlus->Write() ;
1998  ICEEMinus->Write() ;
1999  tpgFactorEEMinus->Write() ;
2000  IC->Write() ;
2001  tpgFactor->Write() ;
2002  hshapeEB->Write() ;
2003  hshapeEE->Write() ;
2004  ntuple->Write() ;
2005  ntupleSpike->Write() ;
2006  saving.Close () ;
2007 }
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
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void setMultX1(int x)
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 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)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
int getID2() const
Definition: EcalLogicID.cc:51
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
void setShift1(int x)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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
void setMultX6(int x)
const T & get() const
Definition: EventSetup.h:56
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
T eta() const
Definition: PV3DBase.h:76
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
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
void setWeightGroupId(int x)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
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  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 2009 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_.

2010 {
2011  using namespace edm;
2012  using namespace std;
2013 
2014  edm::LogInfo("TopInfo") <<"we are in beginJob\n";
2015 
2016  create_header() ;
2017 
2020 
2021  if (writeToFiles_) {
2022  (*out_file_)<<"PHYSICS_EB "<<dec<<eb.rawId()<<std::endl ;
2023  (*out_file_)<<Et_sat_EB_<<" "<<TTF_lowThreshold_EB_<<" "<<TTF_highThreshold_EB_<<std::endl ;
2024  (*out_file_)<<FG_lowThreshold_EB_<<" "<<FG_highThreshold_EB_<<" "
2025  <<FG_lowRatio_EB_<<" "<<FG_highRatio_EB_<<std::endl ;
2026  //(*out_file_) << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex02/02/2011
2027  (*out_file_) <<std::endl ;
2028 
2029  (*out_file_)<<"PHYSICS_EE "<<dec<<ee.rawId()<<std::endl ;
2030  (*out_file_)<<Et_sat_EE_<<" "<<TTF_lowThreshold_EE_<<" "<<TTF_highThreshold_EE_<<std::endl ;
2031  (*out_file_)<<FG_Threshold_EE_<<" "<<-1<<" "
2032  <<-1<<" "<<-1<<std::endl ;
2033  (*out_file_) <<std::endl ;
2034  }
2035 
2036 }
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 2488 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().

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

Definition at line 2514 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().

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

Definition at line 2040 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().

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

References Et_sat_EB_, Et_sat_EE_, RecoEcal_EventContent_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().

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

Definition at line 2196 of file EcalTPGParamBuilder.cc.

References complement2_, KineDebug3::count(), CustomPhysics_cfi::gamma, diffTreeTool::index, createfilelist::int, hpstanc_transforms::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().

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

References reco::return(), and writeToFiles_.

Referenced by beginJob().

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

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

2471 {
2472  // get current pedestal
2473  coeff.pedestals_[0] = 0 ;
2474  coeff.pedestals_[1] = 0 ;
2475  coeff.pedestals_[2] = 0 ;
2476 
2477  map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2478  if (it != pedMap.end()) {
2479  MonPedestalsDat ped = it->second ;
2480  coeff.pedestals_[0] = int(ped.getPedMeanG12() + 0.5) ;
2481  coeff.pedestals_[1] = int(ped.getPedMeanG6() + 0.5) ;
2482  coeff.pedestals_[2] = int(ped.getPedMeanG1() + 0.5) ;
2483  }
2484  else edm::LogError("TopInfo") <<"getCoeff: "<<logicId.getID1()<<", "<<logicId.getID2()<<", "<<logicId.getID3()
2485  <<" not found in map<EcalLogicID, MonPedestalsDat\n" ;
2486 }
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 2369 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(), reco::return(), DetId::subdetId(), Transparency_Correction_, useInterCalibration_, and useTransparencyCorr_.

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

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

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

Definition at line 2562 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

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

Referenced by analyze().

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

Definition at line 2547 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

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

Definition at line 2523 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().

2524 {
2525  bool ok(true) ;
2526  float base[3] = {forceBase12, float(lin.pedestal_[1]), float(lin.pedestal_[2])} ;
2527  for (int i=1 ; i<3 ; i++) {
2528  if (lin.mult_[i]>0) {
2529  base[i] = float(lin.pedestal_[i]) -
2530  float(lin.mult_[0])/float(lin.mult_[i])*pow(2., -(lin.shift_[0]-lin.shift_[i]))*(lin.pedestal_[0]-base[0]) ;
2531  } else base[i] = 0 ;
2532  }
2533 
2534  for (int i=0 ; i<3 ; i++) {
2535  lin.pedestal_[i] = base[i] ;
2536  //cout<<lin.pedestal_[i]<<" "<<base[i]<<endl ;
2537  if (base[i]<0 || lin.pedestal_[i]>1000) {
2538  edm::LogError("TopInfo") <<"WARNING: base= "<<base[i]<<", "<<lin.pedestal_[i]<<" for gainId[0-2]="<<i<<" ==> forcing at 0"<< "\n" ;
2539  lin.pedestal_[i] = 0 ;
2540  ok = false ;
2541  }
2542  }
2543  return ok ;
2544 
2545 }
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 2179 of file EcalTPGParamBuilder.cc.

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

Referenced by computeWeights().

2180 {
2181  int iweight ;
2182  unsigned int max = (unsigned int)(pow(2.,complement2)-1) ;
2183  if (weight>0) iweight=int((1<<6)*weight+0.5) ; // +0.5 for rounding pb
2184  else iweight= max - int(-weight*(1<<6)+0.5) +1 ;
2185  iweight = iweight & max ;
2186  return iweight ;
2187 }
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 2189 of file EcalTPGParamBuilder.cc.

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

2189  {
2190  double weight = double(iweight)/pow(2., 6.) ;
2191  // test if negative weight:
2192  if ( (iweight & (1<<(complement2-1))) != 0) weight = (double(iweight)-pow(2., complement2))/pow(2., 6.) ;
2193  return weight ;
2194 }
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::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().