CMS 3D CMS Logo

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

#include <EcalTPGParamBuilder.h>

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

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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_, 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 }
std::map< int, std::vector< int > > phases_EB_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::ofstream * out_file_
std::map< int, std::vector< int > > delays_EB_
std::map< int, std::vector< int > > delays_EE_
std::ofstream * geomFile_
std::map< int, std::vector< int > > phases_EE_
EcalTPGParamBuilder::~EcalTPGParamBuilder ( )
override

Definition at line 329 of file EcalTPGParamBuilder.cc.

References out_file_, and writeToFiles_.

330 {
331  if (writeToFiles_) {
332  (*out_file_ )<<"EOF"<<std::endl ;
333  out_file_->close() ;
334  delete out_file_ ;
335  }
336 }
std::ofstream * out_file_

Member Function Documentation

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

Definition at line 366 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(), writedatasetfile::dataset, db_, DBEE_, EcalElectronicsId::dccId(), EcalElectronicsMapping::DCCid(), TauDecayModes::dec, del_conf_id_, delays_EB_, delays_EE_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::endcapItems(), Et_sat_EB_, Et_sat_EE_, eTTmap_, EcalCondDBInterface::fetchDataSet(), FG_highRatio_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_lowThreshold_EB_, FG_Threshold_EE_, fgr_conf_id_, EcalCondObjectContainer< T >::find(), 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(), EcalLaserAPDPNRatios::getLaserMap(), FEConfigMainInfo::getLinId(), EcalLogicID::getLogicID(), FEConfigMainInfo::getLUTId(), EcalCondObjectContainer< T >::getMap(), EcalLogicID::getName(), FEConfigMainInfo::getPedId(), FEConfigPedDat::getPedMeanG1(), FEConfigPedDat::getPedMeanG12(), FEConfigPedDat::getPedMeanG6(), FEConfigMainInfo::getSliId(), FEConfigMainInfo::getSpiId(), FEConfigMainInfo::getTimId(), EcalElectronicsMapping::getTriggerElectronicsId(), CaloSubdetectorGeometry::getValidDetIds(), FEConfigMainInfo::getWeiId(), H2_, cmsBatch::handle, ecalpyutils::hashedIndex(), mps_fire::i, cuy::ib, triggerObjects_cff::id, EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::ietaAbs(), EcalCondObjectContainer< T >::insert(), createfilelist::int, EcalTrigTowerDetId::iphi(), EcalElectronicsMapping::iTT(), gen::k, lin_conf_id_, lumiPlot::lut, lut_conf_id_, LUT_option_, lumiCalc2::lute, m_write_del, m_write_fgr, m_write_lin, m_write_lut, m_write_ped, m_write_sli, m_write_spi, m_write_wei, EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, linStruc::mult_, ntupleCrate_, ntupleDet_, ntupleInts_, EcalLogicID::NULLID, convertSQLiteXML::ok, MillePedeFileConverter_cfg::out, out_file_, AlCaHLTBitMon_ParallelJobs::p, ped_conf_id_, linStruc::pedestal_, pedestal_offset_, coeffStruc::pedestals_, phases_EB_, phases_EE_, funct::pow(), edm::ESHandle< T >::product(), EcalTriggerElectronicsId::pseudoStripId(), EcalTriggerElectronicsId::rawId(), DetId::rawId(), realignBaseline(), EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, simplePhotonAnalyzer_cfi::sample, IODConfig::setConfigTag(), FEConfigLinParamDat::setETSat(), FEConfigLUTParamDat::setETSat(), EcalShapeBase::setEventSetup(), FEConfigFgrParamDat::setFGhighratio(), FEConfigFgrParamDat::setFGhighthresh(), FEConfigFgrParamDat::setFGlowratio(), FEConfigFgrParamDat::setFGlowthresh(), FEConfigFgrDat::setFgrGroupId(), FEConfigFgrGroupDat::setFgrGroupId(), FEConfigPedInfo::setId(), FEConfigFgrEEStripDat::setLutFgr(), FEConfigLUTDat::setLUTGroupId(), FEConfigLUTGroupDat::setLUTGroupId(), FEConfigFgrEETowerDat::setLutValue(), FEConfigLUTGroupDat::setLUTValue(), FEConfigFgrGroupDat::setLUTValue(), FEConfigLinDat::setMultX1(), FEConfigLinDat::setMultX12(), FEConfigLinDat::setMultX6(), FEConfigPedDat::setPedMeanG1(), FEConfigPedDat::setPedMeanG12(), FEConfigPedDat::setPedMeanG6(), FEConfigFgrGroupDat::setRatioHigh(), FEConfigFgrGroupDat::setRatioLow(), FEConfigLinDat::setShift1(), FEConfigLinDat::setShift12(), FEConfigLinDat::setShift6(), FEConfigSlidingDat::setSliding(), FEConfigSpikeDat::setSpikeThreshold(), FEConfigFgrGroupDat::setThreshHigh(), FEConfigFgrGroupDat::setThreshLow(), FEConfigFgrEEStripDat::setThreshold(), FEConfigTimingDat::setTimingPar1(), FEConfigTimingDat::setTimingPar2(), FEConfigLUTParamDat::setTTThreshhigh(), FEConfigLUTParamDat::setTTThreshlow(), FEConfigWeightGroupDat::setWeight0(), FEConfigWeightGroupDat::setWeight1(), FEConfigWeightGroupDat::setWeight2(), FEConfigWeightGroupDat::setWeight3(), FEConfigWeightGroupDat::setWeight4(), FEConfigWeightGroupDat::setWeightGroupId(), FEConfigWeightDat::setWeightGroupId(), SFGVB_lut_, SFGVB_SpikeKillingThreshold_, SFGVB_Threshold_, edm::shift, linStruc::shift_, funct::sin(), findQualityFiles::size, sli_conf_id_, sliding_, EBDetId::SMCRYSTALMODE, spi_conf_id_, str, AlCaHLTBitMon_QueryRunRegistry::string, EcalElectronicsId::stripId(), EcalTrigTowerDetId::subDet(), tag_, EcalElectronicsMapping::TCCid(), theBarrelGeometry_, theEndcapGeometry_, theMapping_, theta(), electronIdCutBased_cfi::threshold, EcalElectronicsId::towerId(), Transparency_Corr_, Transparency_Correction_, funct::true, TTF_highThreshold_EB_, TTF_highThreshold_EE_, TTF_lowThreshold_EB_, TTF_lowThreshold_EE_, EBDetId::unhashIndex(), EEDetId::unhashIndex(), useDBShape_, useTransparencyCorr_, useTransverseEnergy_, heppy_batch::val, version_, wei_conf_id_, HGCalRecHit_cfi::weights, EcalTPGDBApp::writeToConfDB_Delay(), EcalTPGDBApp::writeToConfDB_Spike(), EcalTPGDBApp::writeToConfDB_TPGFgr(), EcalTPGDBApp::writeToConfDB_TPGLinearCoef(), EcalTPGDBApp::writeToConfDB_TPGLUT(), EcalTPGDBApp::writeToConfDB_TPGMain(), EcalTPGDBApp::writeToConfDB_TPGPedestals(), EcalTPGDBApp::writeToConfDB_TPGSliding(), EcalTPGDBApp::writeToConfDB_TPGWeight(), writeToDB_, writeToFiles_, x, xtal_LSB_EB_, xtal_LSB_EE_, EcalElectronicsId::xtalId(), EEDetId::XYMODE, y, z, EcalTrigTowerDetId::zside(), and ecaldqm::zside().

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

Reimplemented from edm::EDAnalyzer.

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

2041 {
2042  using namespace edm;
2043  using namespace std;
2044 
2045  edm::LogInfo("TopInfo") <<"we are in beginJob\n";
2046 
2047  create_header() ;
2048 
2051 
2052  if (writeToFiles_) {
2053  (*out_file_)<<"PHYSICS_EB "<<dec<<eb.rawId()<<std::endl ;
2054  (*out_file_)<<Et_sat_EB_<<" "<<TTF_lowThreshold_EB_<<" "<<TTF_highThreshold_EB_<<std::endl ;
2055  (*out_file_)<<FG_lowThreshold_EB_<<" "<<FG_highThreshold_EB_<<" "
2056  <<FG_lowRatio_EB_<<" "<<FG_highRatio_EB_<<std::endl ;
2057  //(*out_file_) << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex02/02/2011
2058  (*out_file_) <<std::endl ;
2059 
2060  (*out_file_)<<"PHYSICS_EE "<<dec<<ee.rawId()<<std::endl ;
2061  (*out_file_)<<Et_sat_EE_<<" "<<TTF_lowThreshold_EE_<<" "<<TTF_highThreshold_EE_<<std::endl ;
2062  (*out_file_)<<FG_Threshold_EE_<<" "<<-1<<" "
2063  <<-1<<" "<<-1<<std::endl ;
2064  (*out_file_) <<std::endl ;
2065  }
2066 
2067 }
Definition: DetId.h:18
HLT enums.
bool EcalTPGParamBuilder::checkIfOK ( EcalPedestals::Item  item)

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

340 {
341  bool result=true;
342  if( item.mean_x1 <150. || item.mean_x1 >250) result=false;
343  if( item.mean_x6 <150. || item.mean_x6 >250) result=false;
344  if( item.mean_x12 <150. || item.mean_x12 >250) result=false;
345  if( item.rms_x1 <0 || item.rms_x1 > 2) result=false;
346  if( item.rms_x6 <0 || item.rms_x6 > 3) result=false;
347  if( item.rms_x12 <0 || item.rms_x12 > 5) result=false;
348  return result;
349 }
void EcalTPGParamBuilder::computeFineGrainEBParameters ( uint &  lowRatio,
uint &  highRatio,
uint &  lowThreshold,
uint &  highThreshold,
uint &  lut 
)
private

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

2521 {
2522  lowRatio = int(0x80*FG_lowRatio_EB_ + 0.5) ;
2523  if (lowRatio>0x7f) lowRatio = 0x7f ;
2524  highRatio = int(0x80*FG_highRatio_EB_ + 0.5) ;
2525  if (highRatio>0x7f) highRatio = 0x7f ;
2526 
2527  // lsb at the stage of the FG calculation is:
2528  double lsb_FG = Et_sat_EB_/1024./4 ;
2529  lowThreshold = int(FG_lowThreshold_EB_/lsb_FG+0.5) ;
2530  if (lowThreshold>0xff) lowThreshold = 0xff ;
2531  highThreshold = int(FG_highThreshold_EB_/lsb_FG+0.5) ;
2532  if (highThreshold>0xff) highThreshold = 0xff ;
2533 
2534  // FG lut: FGVB response is LUT(adress) where adress is:
2535  // bit3: maxof2/ET >= lowRatio, bit2: maxof2/ET >= highRatio, bit1: ET >= lowThreshold, bit0: ET >= highThreshold
2536  // FGVB =1 if jet-like (veto active), =0 if E.M.-like
2537  // the condition for jet-like is: ET>Threshold and maxof2/ET < Ratio (only TT with enough energy are vetoed)
2538 
2539  // With the following lut, what matters is only max(TLow, Thigh) and max(Elow, Ehigh)
2540  // So, jet-like if maxof2/ettot<max(TLow, Thigh) && ettot >= max(Elow, Ehigh)
2541  if (FG_lut_EB_ == 0) lut = 0x0888 ;
2542  else lut = FG_lut_EB_ ; // let's use the users value (hope he/she knows what he/she does!)
2543 }
void EcalTPGParamBuilder::computeFineGrainEEParameters ( uint &  threshold,
uint &  lut_strip,
uint &  lut_tower 
)
private

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

2546 {
2547  // lsb for EE:
2548  double lsb_FG = Et_sat_EE_/1024. ; // FIXME is it true????
2549  threshold = int(FG_Threshold_EE_/lsb_FG+0.5) ;
2550  lut_strip = FG_lut_strip_EE_ ;
2551  lut_tower = FG_lut_tower_EE_ ;
2552 }
bool EcalTPGParamBuilder::computeLinearizerParam ( double  theta,
double  gainRatio,
double  calibCoeff,
std::string  subdet,
int &  mult,
int &  shift 
)
private

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

2072 {
2073  /*
2074  Linearization coefficient are determined in order to satisfy:
2075  tpg(ADC_sat) = 1024
2076  where:
2077  tpg() is a model of the linearized tpg response on 10b
2078  ADC_sat is the number of ADC count corresponding the Et_sat, the maximum scale of the transverse energy
2079 
2080  Since we have:
2081  Et_sat = xtal_LSB * ADC_sat * gainRatio * calibCoeff * sin(theta)
2082  and a simple model of tpg() being given by:
2083  tpg(X) = [ (X*mult) >> (shift+2) ] >> (sliding+shiftDet)
2084  we must satisfy:
2085  [ (Et_sat/(xtal_LSB * gainRatio * calibCoeff * sin(theta)) * mult) >> (shift+2) ] >> (sliding+shiftDet) = 1024
2086  that is:
2087  mult = 1024/Et_sat * xtal_LSB * gainRatio * calibCoeff * sin(theta) * 2^-(sliding+shiftDet+2) * 2^-shift
2088  mult = factor * 2^-shift
2089  */
2090 
2091  // case barrel:
2092  int shiftDet = 2 ; //fixed, due to FE FENIX TCP format
2093  double ratio = xtal_LSB_EB_/Et_sat_EB_ ;
2094  // case endcap:
2095  if (subdet=="EE") {
2096  shiftDet = 2 ; //applied in TCC-EE and not in FE FENIX TCP... This parameters is setable in the TCC-EE
2097  //shiftDet = 0 ; //was like this before with FE bug
2098  ratio = xtal_LSB_EE_/Et_sat_EE_ ;
2099  }
2100 
2101  //modif-alex-30/01/2012
2102  //std::cout << "calibCoeff="<<calibCoeff<<endl;
2103 
2104  double factor = 1024 * ratio * gainRatio * calibCoeff * sin(theta) * (1 << (sliding_ + shiftDet + 2)) ;
2105  // Let's try first with shift = 0 (trivial solution)
2106  mult = (int)(factor+0.5) ;
2107  for (shift = 0 ; shift<15 ; shift++) {
2108  if (mult>=128 && mult<256) return true ;
2109  factor *= 2 ;
2110  mult = (int)(factor+0.5) ;
2111  }
2112  edm::LogError("TopInfo") << "too bad we did not manage to calculate the factor for calib=" << calibCoeff << "\n";
2113  return false ;
2114 }
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 2341 of file EcalTPGParamBuilder.cc.

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

Referenced by analyze().

2342 {
2343  double Et_sat = Et_sat_EB_ ;
2344  double LUT_threshold = LUT_threshold_EB_ ;
2345  double LUT_stochastic = LUT_stochastic_EB_ ;
2346  double LUT_noise = LUT_noise_EB_ ;
2347  double LUT_constant = LUT_constant_EB_ ;
2348  double TTF_lowThreshold = TTF_lowThreshold_EB_ ;
2349  double TTF_highThreshold = TTF_highThreshold_EB_ ;
2350  if (det == "EE") {
2351  Et_sat = Et_sat_EE_ ;
2352  LUT_threshold = LUT_threshold_EE_ ;
2353  LUT_stochastic = LUT_stochastic_EE_ ;
2354  LUT_noise = LUT_noise_EE_ ;
2355  LUT_constant = LUT_constant_EE_ ;
2356  TTF_lowThreshold = TTF_lowThreshold_EE_ ;
2357  TTF_highThreshold = TTF_highThreshold_EE_ ;
2358  }
2359 
2360  // initialisation with identity
2361  for (int i=0 ; i<1024 ; i++) {
2362  lut[i] = i ;
2363  if (lut[i]>0xff) lut[i] = 0xff ;
2364  }
2365 
2366  // case linear LUT
2367  if (LUT_option_ == "Linear") {
2368  int mylut = 0 ;
2369  for (int i=0 ; i<1024 ; i++) {
2370  lut[i] = mylut ;
2371  if ((i+1)%4 == 0 ) mylut++ ;
2372  //if ((i+1)%8 == 0 ) mylut++ ;//modif-alex 16/12/2010 LSB==500MeV ONLY USED FOR BEAMV4 key
2373  }
2374  }
2375 
2376  // case LUT following Ecal resolution
2377  if (LUT_option_ == "EcalResolution") {
2378  TF1 * func = new TF1("func",oneOverEtResolEt, 0., Et_sat,3) ;
2379  func->SetParameters(LUT_stochastic, LUT_noise, LUT_constant) ;
2380  double norm = func->Integral(0., Et_sat) ;
2381  for (int i=0 ; i<1024 ; i++) {
2382  double Et = i*Et_sat/1024. ;
2383  lut[i] = int(0xff*func->Integral(0., Et)/norm + 0.5) ;
2384  }
2385  }
2386 
2387  // Now, add TTF thresholds to LUT and apply LUT threshold if needed
2388  for (int j=0 ; j<1024 ; j++) {
2389  double Et_GeV = Et_sat/1024*(j+0.5) ;
2390  if (Et_GeV <= LUT_threshold) lut[j] = 0 ; // LUT threshold
2391  int ttf = 0x0 ;
2392  if (Et_GeV >= TTF_highThreshold) ttf = 3 ;
2393  if (Et_GeV >= TTF_lowThreshold && Et_GeV < TTF_highThreshold) ttf = 1 ;
2394  ttf = ttf << 8 ;
2395  lut[j] += ttf ;
2396  }
2397 
2398 }
double oneOverEtResolEt(double *x, double *par)
std::vector< unsigned int > EcalTPGParamBuilder::computeWeights ( EcalShapeBase shape,
TH1F *  histo 
)
private

Definition at line 2227 of file EcalTPGParamBuilder.cc.

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

Referenced by analyze().

2227  {
2228  std::ostringstream ss;
2229  ss <<"Computing Weights...\n" ;
2230  double timeMax = shape.timeOfMax() - shape.timeOfThr() ; // timeMax w.r.t begining of pulse
2231  double max = shape(timeMax) ;
2232 
2233  double sumf = 0. ;
2234  double sumf2 = 0. ;
2235  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2236  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2237  time -= weight_timeShift_ ;
2238  sumf += shape(time)/max ;
2239  sumf2 += shape(time)/max * shape(time)/max ;
2240  for (int subtime = 0 ; subtime<25 ; subtime++) histo->Fill(float(sample*25. + subtime)/25., shape(time+subtime)) ;
2241  }
2242  double lambda = 1./(sumf2-sumf*sumf/nSample_) ;
2243  double gamma = -lambda*sumf/nSample_ ;
2244  double * weight = new double[nSample_] ;
2245  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2246  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2247  time -= weight_timeShift_ ;
2248  weight[sample] = lambda*shape(time)/max + gamma ;
2249  }
2250 
2251 
2252  int * iweight = new int[nSample_] ;
2253  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) iweight[sample] = uncodeWeight(weight[sample], complement2_) ;
2254 
2255  // Let's check:
2256  int isumw = 0 ;
2257  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) isumw += iweight[sample] ;
2258  unsigned int imax = (unsigned int)(pow(2.,int(complement2_))-1) ;
2259  isumw = (isumw & imax ) ;
2260 
2261  double ampl = 0. ;
2262  double sumw = 0. ;
2263  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2264  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2265  time -= weight_timeShift_ ;
2266  ampl += weight[sample]*shape(time) ;
2267  sumw += weight[sample] ;
2268  ss <<"weight="<<weight[sample]<<" shape="<<shape(time)<< "\n" ;
2269  }
2270  ss <<"Weights: sum="<<isumw<<" in float ="<<uncodeWeight(isumw, complement2_)<<" sum of floats ="<<sumw<< "\n" ;
2271  ss <<"Weights: sum (weight*shape) = "<<ampl<< "\n" ;
2272 
2273 
2274 
2275  // Let's correct for bias if any
2277  int count = 0 ;
2278  while (isumw != 0 && count<10) {
2279  double min = 99. ;
2280  unsigned int index = 0 ;
2281  if ( (isumw & (1<<(complement2_-1))) != 0) {
2282  // add 1:
2283  ss << "Correcting for bias: adding 1\n" ;
2284  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2285  int new_iweight = iweight[sample]+1 ;
2286  double new_weight = uncodeWeight(new_iweight, complement2_) ;
2287  if (fabs(new_weight-weight[sample])<min) {
2288  min = fabs(new_weight-weight[sample]) ;
2289  index = sample ;
2290  }
2291  }
2292  iweight[index] ++ ;
2293  } else {
2294  // Sub 1:
2295  ss <<"Correcting for bias: subtracting 1\n" ;
2296  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2297  int new_iweight = iweight[sample]-1 ;
2298  double new_weight = uncodeWeight(new_iweight, complement2_) ;
2299  if (fabs(new_weight-weight[sample])<min) {
2300  min = fabs(new_weight-weight[sample]) ;
2301  index = sample ;
2302  }
2303  }
2304  iweight[index] -- ;
2305  }
2306  isumw = 0 ;
2307  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) isumw += iweight[sample] ;
2308  imax = (unsigned int)(pow(2.,int(complement2_))-1) ;
2309  isumw = (isumw & imax ) ;
2310  ss <<"Correcting weight number: "<< index << " sum weights = " << isumw<< "\n" ;
2311  count ++ ;
2312  }
2313  }
2314 
2315  // let's check again
2316  isumw = 0 ;
2317  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) isumw += iweight[sample] ;
2318  imax = (unsigned int)(pow(2.,int(complement2_))-1) ;
2319  isumw = (isumw & imax ) ;
2320  ampl = 0. ;
2321  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) {
2322  double time = timeMax - ((double)sampleMax_-(double)sample)*25. ;
2323  time -= weight_timeShift_ ;
2324  double new_weight = uncodeWeight(iweight[sample], complement2_) ;
2325  sumw += uncodeWeight(iweight[sample], complement2_) ;
2326  ampl += new_weight*shape(time) ;
2327  ss <<"weight unbiased after integer conversion="<<new_weight<<" shape="<<shape(time)<< "\n" ;
2328  }
2329  ss <<"Weights: sum="<<isumw<<" in float ="<<uncodeWeight(isumw, complement2_)<<" sum of floats ="<<sumw<< "\n" ;
2330  ss <<"Weights: sum (weight*shape) = "<<ampl<< "\n" ;
2331  edm::LogInfo("TopInfo") << ss.str();
2332 
2333  std::vector<unsigned int> theWeights ;
2334  for (unsigned int sample = 0 ; sample<nSample_ ; sample++) theWeights.push_back(iweight[sample]) ;
2335 
2336  delete[] weight ;
2337  delete[] iweight ;
2338  return theWeights ;
2339 }
Definition: weight.py:1
return((rh^lh)&mask)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T min(T a, T b)
Definition: MathUtil.h:58
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
double timeOfThr() const
HLT enums.
#define str(s)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int uncodeWeight(double weight, int complement2=7)
double timeOfMax() const
void EcalTPGParamBuilder::create_header ( )
private

Definition at line 2116 of file EcalTPGParamBuilder.cc.

References mathSSE::return(), and writeToFiles_.

Referenced by beginJob().

2117 {
2118  if (!writeToFiles_) return ;
2119  (*out_file_) <<"COMMENT put your comments here"<<std::endl ;
2120 
2121  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2122  (*out_file_) <<"COMMENT physics EB structure"<<std::endl ;
2123  (*out_file_) <<"COMMENT"<<std::endl ;
2124  (*out_file_) <<"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)"<<std::endl ;
2125  (*out_file_) <<"COMMENT FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio"<<std::endl ;
2126  //(*out_file_) <<"COMMENT SFGVB_SpikeKillingThreshold (GeV)"<<std::endl ; //modif-alex-02/02/2011
2127  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2128  (*out_file_) <<"COMMENT"<<std::endl ;
2129 
2130  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2131  (*out_file_) <<"COMMENT physics EE structure"<<std::endl ;
2132  (*out_file_) <<"COMMENT"<<std::endl ;
2133  (*out_file_) <<"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)"<<std::endl ;
2134  (*out_file_) <<"COMMENT FG_Threshold (GeV), dummy, dummy, dummy"<<std::endl ;
2135  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2136  (*out_file_) <<"COMMENT"<<std::endl ;
2137 
2138  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2139  (*out_file_) <<"COMMENT crystal structure (same for EB and EE)"<<std::endl ;
2140  (*out_file_) <<"COMMENT"<<std::endl ;
2141  (*out_file_) <<"COMMENT ped, mult, shift [gain12]"<<std::endl ;
2142  (*out_file_) <<"COMMENT ped, mult, shift [gain6]"<<std::endl ;
2143  (*out_file_) <<"COMMENT ped, mult, shift [gain1]"<<std::endl ;
2144  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2145  (*out_file_) <<"COMMENT"<<std::endl ;
2146 
2147  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2148  (*out_file_) <<"COMMENT strip EB structure"<<std::endl ;
2149  (*out_file_) <<"COMMENT"<<std::endl ;
2150  (*out_file_) <<"COMMENT sliding_window"<<std::endl ;
2151  (*out_file_) <<"COMMENT weightGroupId"<<std::endl ;
2152  (*out_file_) <<"COMMENT threshold_sfg lut_sfg"<<std::endl ;
2153  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2154  (*out_file_) <<"COMMENT"<<std::endl ;
2155 
2156  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2157  (*out_file_) <<"COMMENT strip EE structure"<<std::endl ;
2158  (*out_file_) <<"COMMENT"<<std::endl ;
2159  (*out_file_) <<"COMMENT sliding_window"<<std::endl ;
2160  (*out_file_) <<"COMMENT weightGroupId"<<std::endl ;
2161  (*out_file_) <<"COMMENT threshold_fg lut_fg"<<std::endl ;
2162  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2163  (*out_file_) <<"COMMENT"<<std::endl ;
2164 
2165  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2166  (*out_file_) <<"COMMENT tower EB structure"<<std::endl ;
2167  (*out_file_) <<"COMMENT"<<std::endl ;
2168  (*out_file_) <<"COMMENT LUTGroupId"<<std::endl ;
2169  (*out_file_) <<"COMMENT FgGroupId"<<std::endl ;
2170  (*out_file_) <<"COMMENT spike_killing_threshold"<<std::endl ;//modif alex
2171  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2172  (*out_file_) <<"COMMENT"<<std::endl ;
2173 
2174  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2175  (*out_file_) <<"COMMENT tower EE structure"<<std::endl ;
2176  (*out_file_) <<"COMMENT"<<std::endl ;
2177  (*out_file_) <<"COMMENT LUTGroupId"<<std::endl ;
2178  (*out_file_) <<"COMMENT tower_lut_fg"<<std::endl ;
2179  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2180  (*out_file_) <<"COMMENT"<<std::endl ;
2181 
2182  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2183  (*out_file_) <<"COMMENT Weight structure"<<std::endl ;
2184  (*out_file_) <<"COMMENT"<<std::endl ;
2185  (*out_file_) <<"COMMENT weightGroupId"<<std::endl ;
2186  (*out_file_) <<"COMMENT w0, w1, w2, w3, w4"<<std::endl ;
2187  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2188  (*out_file_) <<"COMMENT"<<std::endl ;
2189 
2190  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2191  (*out_file_) <<"COMMENT lut structure"<<std::endl ;
2192  (*out_file_) <<"COMMENT"<<std::endl ;
2193  (*out_file_) <<"COMMENT LUTGroupId"<<std::endl ;
2194  (*out_file_) <<"COMMENT LUT[1-1024]"<<std::endl ;
2195  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2196  (*out_file_) <<"COMMENT"<<std::endl ;
2197 
2198  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2199  (*out_file_) <<"COMMENT fg EB structure"<<std::endl ;
2200  (*out_file_) <<"COMMENT"<<std::endl ;
2201  (*out_file_) <<"COMMENT FgGroupId"<<std::endl ;
2202  (*out_file_) <<"COMMENT el, eh, tl, th, lut_fg"<<std::endl ;
2203  (*out_file_) <<"COMMENT ================================="<<std::endl ;
2204  (*out_file_) <<"COMMENT"<<std::endl ;
2205 
2206  (*out_file_) <<std::endl ;
2207 }
return((rh^lh)&mask)
void EcalTPGParamBuilder::getCoeff ( coeffStruc coeff,
const EcalGainRatioMap gainMap,
uint  rawId 
)
private

Referenced by analyze(), and getCoeff().

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

Definition at line 2501 of file EcalTPGParamBuilder.cc.

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

2502 {
2503  // get current pedestal
2504  coeff.pedestals_[0] = 0 ;
2505  coeff.pedestals_[1] = 0 ;
2506  coeff.pedestals_[2] = 0 ;
2507 
2508  map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2509  if (it != pedMap.end()) {
2510  MonPedestalsDat ped = it->second ;
2511  coeff.pedestals_[0] = int(ped.getPedMeanG12() + 0.5) ;
2512  coeff.pedestals_[1] = int(ped.getPedMeanG6() + 0.5) ;
2513  coeff.pedestals_[2] = int(ped.getPedMeanG1() + 0.5) ;
2514  }
2515  else edm::LogError("TopInfo") <<"getCoeff: "<<logicId.getID1()<<", "<<logicId.getID2()<<", "<<logicId.getID3()
2516  <<" not found in map<EcalLogicID, MonPedestalsDat\n" ;
2517 }
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 2400 of file EcalTPGParamBuilder.cc.

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

2401 {
2402  // get current intercalibration coeff
2403  coeff.calibCoeff_ = 1. ;
2405  EcalIntercalibConstantMap::const_iterator icalit = calibMap.find(rawId);
2406 
2407  //modif-alex-30/01/2012
2408  std::map<int, double >::const_iterator itCorr = Transparency_Correction_.find(rawId);
2409  double icorr = 1.0;
2410  double alpha_factor = 1.0;
2411 
2413  icorr = itCorr->second;
2414  if( itCorr != Transparency_Correction_.end() ) {
2415  stringstream ss;
2416  ss << rawId;
2417  stringstream ss1;
2418  ss1 << icorr;
2419  stringstream ss2;
2420  ss2 << (*icalit);
2421  st = "Transparency correction found for xtal " + ss.str() + " corr=" + ss1.str() + " intercalib=" + ss2.str() + "\n";
2422  }
2423  else
2424  edm::LogError("TopInfo") << "ERROR = Transparency correction not found for xtal " << rawId << "\n";
2425 
2426  //modif-alex-27-july-2015
2427  DetId ECALdetid(rawId);
2428  // ss << "DETID=" << ECALdetid.subdetId() << "\n";
2429  stringstream ss;
2430  ss << ECALdetid.subdetId();
2431  st += "DETID=" + ss.str() + "\n";
2432  if(ECALdetid.subdetId() == 1){ //ECAL BARREL
2433  EBDetId barrel_detid(rawId);
2434  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(barrel_detid);
2435  if ( italpha != laserAlphaMap.end() ) alpha_factor = (*italpha);
2436  else edm::LogError("TopInfo") << "ERROR:LaserAlphe parameter note found!!" << "\n";
2437  }
2438  if(ECALdetid.subdetId() == 1){ //ECAL ENDCAP
2439  EEDetId endcap_detid(rawId);
2440  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(endcap_detid);
2441  if ( italpha != laserAlphaMap.end() ) alpha_factor = (*italpha);
2442  else edm::LogError("TopInfo") << "ERROR:LaserAlphe parameter note found!!" << "\n";
2443  }
2444 
2445  }//transparency corrections applied
2446 
2447  //if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit) ;
2448  //if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit)/icorr; //modif-alex-30/01/2010 tansparency corrections
2449  // ss << "rawId " << (*icalit) << " " << icorr << " " << alpha_factor << "\n";
2450  stringstream ss;
2451  ss << (*icalit);
2452  stringstream ss1;
2453  ss1 << icorr;
2454  stringstream ss2;
2455  ss2 << alpha_factor;
2456  st += "rawId " + ss.str() + " " + ss1.str() + " " + ss2.str() + "\n";
2457  if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit)/std::pow(icorr,alpha_factor); //modif-alex-27/07/2015 tansparency corrections with alpha parameters
2458 
2459  else edm::LogError("TopInfo") <<"getCoeff: "<<rawId<<" not found in EcalIntercalibConstantMap"<< "\n" ;
2460 }
std::map< int, double > Transparency_Correction_
return((rh^lh)&mask)
Definition: DetId.h:18
std::vector< Item >::const_iterator const_iterator
const_iterator find(uint32_t rawId) const
const_iterator end() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::pair< std::string, int > EcalTPGParamBuilder::getCrate ( int  tcc)
private

Definition at line 2617 of file EcalTPGParamBuilder.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

2617  {
2618  std::stringstream crate ;
2619  std::string pos ;
2620  int slot = 0 ;
2621 
2622  crate<<"S2D" ;
2623  if (tcc>=40 && tcc<=42) {crate<<"02d" ; slot = 5 + (tcc-40)*6 ;}
2624  if (tcc>=43 && tcc<=45) {crate<<"03d" ; slot = 5 + (tcc-43)*6 ;}
2625  if (tcc>=37 && tcc<=39) {crate<<"04d" ; slot = 5 + (tcc-37)*6 ;}
2626  if (tcc>=52 && tcc<=54) {crate<<"06d" ; slot = 5 + (tcc-52)*6 ;}
2627  if (tcc>=46 && tcc<=48) {crate<<"07d" ; slot = 5 + (tcc-46)*6 ;}
2628  if (tcc>=49 && tcc<=51) {crate<<"08d" ; slot = 5 + (tcc-49)*6 ;}
2629  if (tcc>=58 && tcc<=60) {crate<<"02h" ; slot = 5 + (tcc-58)*6 ;}
2630  if (tcc>=61 && tcc<=63) {crate<<"03h" ; slot = 5 + (tcc-61)*6 ;}
2631  if (tcc>=55 && tcc<=57) {crate<<"04h" ; slot = 5 + (tcc-55)*6 ;}
2632  if (tcc>=70 && tcc<=72) {crate<<"06h" ; slot = 5 + (tcc-70)*6 ;}
2633  if (tcc>=64 && tcc<=66) {crate<<"07h" ; slot = 5 + (tcc-64)*6 ;}
2634  if (tcc>=67 && tcc<=69) {crate<<"08h" ; slot = 5 + (tcc-67)*6 ;}
2635 
2636  if (tcc>=76 && tcc<=81) {
2637  crate<<"02l" ;
2638  if (tcc%2==0) slot = 2 + (tcc-76)*3 ;
2639  else slot = 4 + (tcc-77)*3 ;
2640  }
2641  if (tcc>=94 && tcc<=99) {
2642  crate<<"02l" ;
2643  if (tcc%2==0) slot = 3 + (tcc-94)*3 ;
2644  else slot = 5 + (tcc-95)*3 ;
2645  }
2646 
2647  if (tcc>=22 && tcc<=27) {
2648  crate<<"03l" ;
2649  if (tcc%2==0) slot = 2 + (tcc-22)*3 ;
2650  else slot = 4 + (tcc-23)*3 ;
2651  }
2652  if (tcc>=4 && tcc<=9) {
2653  crate<<"03l" ;
2654  if (tcc%2==0) slot = 3 + (tcc-4)*3 ;
2655  else slot = 5 + (tcc-5)*3 ;
2656  }
2657 
2658  if (tcc>=82 && tcc<=87) {
2659  crate<<"07l" ;
2660  if (tcc%2==0) slot = 2 + (tcc-82)*3 ;
2661  else slot = 4 + (tcc-83)*3 ;
2662  }
2663  if (tcc>=100 && tcc<=105) {
2664  crate<<"07l" ;
2665  if (tcc%2==0) slot = 3 + (tcc-100)*3 ;
2666  else slot = 5 + (tcc-101)*3 ;
2667  }
2668 
2669  if (tcc>=28 && tcc<=33) {
2670  crate<<"08l" ;
2671  if (tcc%2==0) slot = 2 + (tcc-28)*3 ;
2672  else slot = 4 + (tcc-29)*3 ;
2673  }
2674  if (tcc>=10 && tcc<=15) {
2675  crate<<"08l" ;
2676  if (tcc%2==0) slot = 3 + (tcc-10)*3 ;
2677  else slot = 5 + (tcc-11)*3 ;
2678  }
2679 
2680  if (tcc==34) {crate<<"04l" ; slot = 2 ;}
2681  if (tcc==16) {crate<<"04l" ; slot = 3 ;}
2682  if (tcc==35) {crate<<"04l" ; slot = 4 ;}
2683  if (tcc==17) {crate<<"04l" ; slot = 5 ;}
2684  if (tcc==36) {crate<<"04l" ; slot = 8 ;}
2685  if (tcc==18) {crate<<"04l" ; slot = 9 ;}
2686  if (tcc==19) {crate<<"04l" ; slot = 10 ;}
2687  if (tcc==1) {crate<<"04l" ; slot = 11 ;}
2688  if (tcc==20) {crate<<"04l" ; slot = 14 ;}
2689  if (tcc==2) {crate<<"04l" ; slot = 15 ;}
2690  if (tcc==21) {crate<<"04l" ; slot = 16 ;}
2691  if (tcc==3) {crate<<"04l" ; slot = 17 ;}
2692 
2693  if (tcc==88) {crate<<"06l" ; slot = 2 ;}
2694  if (tcc==106) {crate<<"06l" ; slot = 3 ;}
2695  if (tcc==89) {crate<<"06l" ; slot = 4 ;}
2696  if (tcc==107) {crate<<"06l" ; slot = 5 ;}
2697  if (tcc==90) {crate<<"06l" ; slot = 8 ;}
2698  if (tcc==108) {crate<<"06l" ; slot = 9 ;}
2699  if (tcc==73) {crate<<"06l" ; slot = 10 ;}
2700  if (tcc==91) {crate<<"06l" ; slot = 11 ;}
2701  if (tcc==74) {crate<<"06l" ; slot = 14 ;}
2702  if (tcc==92) {crate<<"06l" ; slot = 15 ;}
2703  if (tcc==75) {crate<<"06l" ; slot = 16 ;}
2704  if (tcc==93) {crate<<"06l" ; slot = 17 ;}
2705 
2706  return std::pair< std::string, int > (crate.str(),slot) ;
2707 }
std::string EcalTPGParamBuilder::getDet ( int  tcc)
private

Definition at line 2593 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

2593  {
2594  std::stringstream sdet ;
2595 
2596  if (tcc>36 && tcc<55) sdet<<"EB-"<<tcc-36 ;
2597  else if (tcc>=55 && tcc<73) sdet<<"EB+"<<tcc-54 ;
2598  else if (tcc<=36) sdet<<"EE-" ;
2599  else sdet<<"EE+" ;
2600 
2601  if (tcc<=36 || tcc>=73) {
2602  if (tcc>=73) tcc-=72 ;
2603  if (tcc==1 || tcc==18 || tcc==19 || tcc==36) sdet<<7 ;
2604  else if (tcc==2 || tcc==3 || tcc==20 || tcc==21) sdet<<8 ;
2605  else if (tcc==4 || tcc==5 || tcc==22 || tcc==23) sdet<<9 ;
2606  else if (tcc==6 || tcc==7 || tcc==24 || tcc==25) sdet<<1 ;
2607  else if (tcc==8 || tcc==9 || tcc==26 || tcc==27) sdet<<2 ;
2608  else if (tcc==10 || tcc==11 || tcc==28 || tcc==29) sdet<<3 ;
2609  else if (tcc==12 || tcc==13 || tcc==30 || tcc==31) sdet<<4 ;
2610  else if (tcc==14 || tcc==15 || tcc==32 || tcc==33) sdet<<5 ;
2611  else if (tcc==16 || tcc==17 || tcc==34 || tcc==35) sdet<<6 ;
2612  }
2613 
2614  return sdet.str() ;
2615 }
int EcalTPGParamBuilder::getEtaSlice ( int  tccId,
int  towerInTCC 
)
private

Definition at line 351 of file EcalTPGParamBuilder.cc.

352 {
353  int etaSlice = (towerInTCC-1)/4+1 ;
354  // barrel
355  if (tccId>36 || tccId<73) return etaSlice ;
356  //endcap
357  else {
358  if (tccId >=1 && tccId <= 18) etaSlice += 21 ; // inner -
359  if (tccId >=19 && tccId <= 36) etaSlice += 17 ; // outer -
360  if (tccId >=91 && tccId <= 108) etaSlice += 21 ; // inner +
361  if (tccId >=73 && tccId <= 90) etaSlice += 17 ; // outer +
362  }
363  return etaSlice ;
364 }
unsigned tccId(DetId const &)
int EcalTPGParamBuilder::getGCTRegionEta ( int  tteta)
private

Definition at line 2586 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

2586  {
2587  int gcteta = 0;
2588  if(tteta>0) gcteta = (tteta-1)/4 + 11;
2589  else if(tteta<0) gcteta = (tteta+1)/4 + 10;
2590  return gcteta;
2591 }
int EcalTPGParamBuilder::getGCTRegionPhi ( int  ttphi)
private

Definition at line 2578 of file EcalTPGParamBuilder.cc.

Referenced by analyze().

2578  {
2579  int gctphi=0;
2580  gctphi = (ttphi+1)/4;
2581  if(ttphi<=2) gctphi=0;
2582  if(ttphi>=71) gctphi=0;
2583  return gctphi;
2584 }
bool EcalTPGParamBuilder::realignBaseline ( linStruc lin,
float  forceBase12 
)
private

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

2555 {
2556  bool ok(true) ;
2557  float base[3] = {forceBase12, float(lin.pedestal_[1]), float(lin.pedestal_[2])} ;
2558  for (int i=1 ; i<3 ; i++) {
2559  if (lin.mult_[i]>0) {
2560  base[i] = float(lin.pedestal_[i]) -
2561  float(lin.mult_[0])/float(lin.mult_[i])*pow(2., -(lin.shift_[0]-lin.shift_[i]))*(lin.pedestal_[0]-base[0]) ;
2562  } else base[i] = 0 ;
2563  }
2564 
2565  for (int i=0 ; i<3 ; i++) {
2566  lin.pedestal_[i] = base[i] ;
2567  //cout<<lin.pedestal_[i]<<" "<<base[i]<<endl ;
2568  if (base[i]<0 || lin.pedestal_[i]>1000) {
2569  edm::LogError("TopInfo") <<"WARNING: base= "<<base[i]<<", "<<lin.pedestal_[i]<<" for gainId[0-2]="<<i<<" ==> forcing at 0"<< "\n" ;
2570  lin.pedestal_[i] = 0 ;
2571  ok = false ;
2572  }
2573  }
2574  return ok ;
2575 
2576 }
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 2210 of file EcalTPGParamBuilder.cc.

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

Referenced by computeWeights().

2211 {
2212  int iweight ;
2213  unsigned int max = (unsigned int)(pow(2.,complement2)-1) ;
2214  if (weight>0) iweight=int((1<<6)*weight+0.5) ; // +0.5 for rounding pb
2215  else iweight= max - int(-weight*(1<<6)+0.5) +1 ;
2216  iweight = iweight & max ;
2217  return iweight ;
2218 }
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 2220 of file EcalTPGParamBuilder.cc.

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

2220  {
2221  double weight = double(iweight)/pow(2., 6.) ;
2222  // test if negative weight:
2223  if ( (iweight & (1<<(complement2-1))) != 0) weight = (double(iweight)-pow(2., complement2))/pow(2., 6.) ;
2224  return weight ;
2225 }
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 analyze(), and EcalTPGParamBuilder().

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

Definition at line 138 of file EcalTPGParamBuilder.h.

Referenced by analyze(), and getCoeff().

double EcalTPGParamBuilder::TTF_highThreshold_EB_
private

Definition at line 111 of file EcalTPGParamBuilder.h.

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

double EcalTPGParamBuilder::TTF_highThreshold_EE_
private

Definition at line 112 of file EcalTPGParamBuilder.h.

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

double EcalTPGParamBuilder::TTF_lowThreshold_EB_
private

Definition at line 111 of file EcalTPGParamBuilder.h.

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

double EcalTPGParamBuilder::TTF_lowThreshold_EE_
private

Definition at line 112 of file EcalTPGParamBuilder.h.

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

bool EcalTPGParamBuilder::useDBShape_
private

Definition at line 177 of file EcalTPGParamBuilder.h.

Referenced by analyze().

bool EcalTPGParamBuilder::useInterCalibration_
private

Definition at line 121 of file EcalTPGParamBuilder.h.

Referenced by EcalTPGParamBuilder(), and getCoeff().

bool EcalTPGParamBuilder::useTransparencyCorr_
private

Definition at line 125 of file EcalTPGParamBuilder.h.

Referenced by analyze(), 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().