CMS 3D CMS Logo

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

#include <StoreEcalCondition.h>

Inheritance diagram for StoreEcalCondition:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
int convertFromConstructionSMToSlot (int, int)
 
void endJob () override
 
EcalADCToGeVConstantreadEcalADCToGeVConstantFromFile (const char *)
 
EcalChannelStatusreadEcalChannelStatusFromFile (const char *)
 
EcalGainRatiosreadEcalGainRatiosFromFile (const char *)
 
EcalIntercalibConstantsreadEcalIntercalibConstantsFromFile (const char *, const char *)
 
EcalIntercalibConstantsMCreadEcalIntercalibConstantsMCFromFile (const char *, const char *)
 
EcalPFRecHitThresholdsreadEcalPFRecHitThresholdsFromFile (const char *, const char *)
 
EcalTBWeightsreadEcalTBWeightsFromFile (const char *)
 
EcalWeightXtalGroupsreadEcalWeightXtalGroupsFromFile (const char *)
 
 StoreEcalCondition (const edm::ParameterSet &iConfig)
 
void writeToLogFile (std::string, std::string, unsigned long long)
 
void writeToLogFileResults (char *)
 
 ~StoreEcalCondition () 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 fillHeader (char *)
 
std::string to_string (char value[])
 

Private Attributes

std::vector< std::string > inpFileName_
 
std::vector< std::string > inpFileNameEE_
 
std::string logfile_
 
std::vector< std::string > objectName_
 
std::string prog_name_
 
std::vector< unsigned long long > since_
 
int sm_constr_
 
int sm_slot_
 

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 39 of file StoreEcalCondition.h.

Constructor & Destructor Documentation

StoreEcalCondition::StoreEcalCondition ( const edm::ParameterSet iConfig)
explicit

Definition at line 21 of file StoreEcalCondition.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), inpFileName_, inpFileNameEE_, logfile_, objectName_, prog_name_, since_, sm_constr_, sm_slot_, AlCaHLTBitMon_QueryRunRegistry::string, and DBConfiguration_cff::toPut.

21  {
22 
23  prog_name_ = "StoreEcalCondition";
24 
25  logfile_ = iConfig.getParameter< std::string >("logfile");
26  sm_slot_ = iConfig.getUntrackedParameter< unsigned int >("smSlot", 1);
27 
28  typedef std::vector< edm::ParameterSet > Parameters;
29  Parameters toPut=iConfig.getParameter<Parameters>("toPut");
30  for(Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut)
31  {
32  inpFileName_.push_back(itToPut->getUntrackedParameter<std::string>("inputFile"));
33  inpFileNameEE_.push_back(itToPut->getUntrackedParameter<std::string>("inputFileEE"));
34  objectName_.push_back(itToPut->getUntrackedParameter<std::string>("conditionType"));
35  since_.push_back(itToPut->getUntrackedParameter<unsigned int>("since"));
36  }
37 
38  sm_constr_ = -1;
39 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > inpFileNameEE_
std::vector< unsigned long long > since_
vector< ParameterSet > Parameters
std::vector< std::string > objectName_
std::vector< std::string > inpFileName_
StoreEcalCondition::~StoreEcalCondition ( )
override

Definition at line 149 of file StoreEcalCondition.cc.

149  {
150 
151 }

Member Function Documentation

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

Definition at line 154 of file StoreEcalCondition.cc.

154  {
155 //-------------------------------------------------------------
156 
157 }
int StoreEcalCondition::convertFromConstructionSMToSlot ( int  sm_constr,
int  sm_slot 
)

Definition at line 929 of file StoreEcalCondition.cc.

References mps_fire::result.

Referenced by readEcalIntercalibConstantsFromFile(), and readEcalIntercalibConstantsMCFromFile().

929  {
930  // input either cosntruction number or slot number and returns the other
931  // the slots are numbered first EB+ slot 1 ...18 then EB- 1... 18
932  // the slots start at 1 and the SM start at 0
933 //-------------------------------------------------------------
934  int slot_to_constr[37]={-1,12,17,10,1,8,4,27,20,23,25,6,34,35,15,18,30,21,9
935  ,24,22,13,31,26,16,2,11,5,0,29,28,14,33,32,3,7,19};
936  int constr_to_slot[36]={28,4,25,34,6,27,11,35,5,18,3,26,1,21,31,14,24,2,15,
937  36,8,17,20,9,19,10,23,7,30,29,16,22,33,32,12,13 };
938 
939  int result=0;
940  if(sm_constr!=-1) {
941  result=constr_to_slot[sm_constr];
942  } else if(sm_slot!=-1) {
943  result=slot_to_constr[sm_slot];
944  }
945  return result;
946 }
void StoreEcalCondition::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 41 of file StoreEcalCondition.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::endOfTime(), mps_fire::i, inpFileName_, inpFileNameEE_, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), objectName_, readEcalADCToGeVConstantFromFile(), readEcalChannelStatusFromFile(), readEcalGainRatiosFromFile(), readEcalIntercalibConstantsFromFile(), readEcalIntercalibConstantsMCFromFile(), readEcalPFRecHitThresholdsFromFile(), readEcalTBWeightsFromFile(), readEcalWeightXtalGroupsFromFile(), since_, AlCaHLTBitMon_QueryRunRegistry::string, and writeToLogFileResults().

41  {
42 
44  if( !mydbservice.isAvailable() ){
45  edm::LogError("StoreEcalCondition")<<"PoolDBOutputService is unavailable"<<std::endl;
46  return;
47  }
48 
49  bool toAppend=false;
50  // copy a string to the char *
51  std::string message = "finished OK\n";
52  size_t messageSize = message.size() + 1;
53  char * messChar = new char [messageSize];
54  strncpy(messChar, message.c_str(), messageSize);
55 
56  for (unsigned int i=0;i<objectName_.size();i++) {
57  cond::Time_t newTime;
58 
59  if ( mydbservice->isNewTagRequest( objectName_[i]+std::string("Rcd") ) ) {
60  // This is the first object for this tag.
61  // Append mode should be off.
62  // newTime is the end of this new objects IOV.
63  newTime = mydbservice->beginOfTime();
64  } else {
65  // There should already be an object in the DB for this tag.
66  // Append IOV mode should be on.
67  // newTime is the beginning of this new objects IOV.
68  toAppend=true;
69  newTime = (cond::Time_t)since_[i];
70  }
71  edm::LogInfo("StoreEcalCondition") << "Reading " << objectName_[i]
72  << " from file and writing to DB with newTime " << newTime << endl;
73  std::cout << "Reading " << objectName_[i]
74  << " from file and writing to DB with newTime " << newTime << endl;
75 
76  if (objectName_[i] == "EcalWeightXtalGroups") {
78  if(!toAppend){
79  mydbservice->createNewIOV<EcalWeightXtalGroups>(mycali,newTime,mydbservice->endOfTime(),"EcalWeightXtalGroupsRcd");
80  }else{
81  mydbservice->appendSinceTime<EcalWeightXtalGroups>(mycali,newTime,"EcalWeightXtalGroupsRcd");
82  }
83  }else if (objectName_[i] =="EcalTBWeights") {
85  if(!toAppend){
86  mydbservice->createNewIOV<EcalTBWeights>(mycali,newTime,mydbservice->endOfTime(),"EcalTBWeightsRcd");
87  }else{
88  mydbservice->appendSinceTime<EcalTBWeights>(mycali,newTime,"EcalTBWeightsRcd");
89  }
90  } else if (objectName_[i] == "EcalADCToGeVConstant") {
92  if(!toAppend){
93  mydbservice->createNewIOV<EcalADCToGeVConstant>(mycali,newTime,mydbservice->endOfTime(),"EcalADCToGeVConstantRcd");
94  }else{
95  mydbservice->appendSinceTime<EcalADCToGeVConstant>(mycali,newTime,"EcalADCToGeVConstantRcd");
96  }
97  } else if (objectName_[i] == "EcalIntercalibConstants") {
99  if(!toAppend){
100  mydbservice->createNewIOV<EcalIntercalibConstants>(mycali,newTime,mydbservice->endOfTime(),"EcalIntercalibConstantsRcd");
101  }else{
102  mydbservice->appendSinceTime<EcalIntercalibConstants>(mycali,newTime,"EcalIntercalibConstantsRcd");
103  }
104  } else if (objectName_[i] == "EcalPFRecHitThresholds") {
106  if(!toAppend){
107  mydbservice->createNewIOV<EcalPFRecHitThresholds>(mycali,newTime,mydbservice->endOfTime(),"EcalPFRecHitThresholdsRcd");
108  }else{
109  mydbservice->appendSinceTime<EcalPFRecHitThresholds>(mycali,newTime,"EcalPFRecHitThresholdsRcd");
110  }
111  } else if (objectName_[i] == "EcalIntercalibConstantsMC") {
113  if(!toAppend){
114  mydbservice->createNewIOV<EcalIntercalibConstantsMC>(mycali,newTime,mydbservice->endOfTime(),"EcalIntercalibConstantsMCRcd");
115  }else{
116  mydbservice->appendSinceTime<EcalIntercalibConstantsMC>(mycali,newTime,"EcalIntercalibConstantsMCRcd");
117  }
118  } else if (objectName_[i] == "EcalGainRatios") {
120  if(!toAppend){
121  mydbservice->createNewIOV<EcalGainRatios>(mycali,newTime,mydbservice->endOfTime(),"EcalGainRatiosRcd");
122  }else{
123  mydbservice->appendSinceTime<EcalGainRatios>(mycali,newTime,"EcalGainRatiosRcd");
124  }
125  } else if (objectName_[i] == "EcalChannelStatus")
126  {
128  if(!toAppend){
129  mydbservice->createNewIOV<EcalChannelStatus>(mycali,newTime,mydbservice->endOfTime(),"EcalChannelStatusRcd");
130  }else{
131  mydbservice->appendSinceTime<EcalChannelStatus>(mycali,newTime,"EcalChannelStatusRcd");
132  }
133  } else {
134  edm::LogError("StoreEcalCondition")<< "Object " << objectName_[i] << " is not supported by this program." << endl;
135  }
136 
137 
138  // writeToLogFile(objectName_[i], inpFileName_[i], since_[i]);
139  //writeToLogFileResults("finished OK\n");
140  writeToLogFileResults(messChar);
141 
142  edm::LogInfo("StoreEcalCondition") << "Finished endJob" << endl;
143  }
144 
145  delete [] messChar;
146 }
EcalIntercalibConstantsMC * readEcalIntercalibConstantsMCFromFile(const char *, const char *)
std::vector< std::string > inpFileNameEE_
std::vector< unsigned long long > since_
EcalChannelStatus * readEcalChannelStatusFromFile(const char *)
void writeToLogFileResults(char *)
EcalIntercalibConstants * readEcalIntercalibConstantsFromFile(const char *, const char *)
EcalPFRecHitThresholds * readEcalPFRecHitThresholdsFromFile(const char *, const char *)
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
unsigned long long Time_t
Definition: Time.h:16
bool isNewTagRequest(const std::string &recordName)
std::vector< std::string > objectName_
EcalWeightXtalGroups * readEcalWeightXtalGroupsFromFile(const char *)
EcalGainRatios * readEcalGainRatiosFromFile(const char *)
bool isAvailable() const
Definition: Service.h:40
std::vector< std::string > inpFileName_
EcalADCToGeVConstant * readEcalADCToGeVConstantFromFile(const char *)
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
EcalTBWeights * readEcalTBWeightsFromFile(const char *)
void StoreEcalCondition::fillHeader ( char *  header)
private

Definition at line 201 of file StoreEcalCondition.cc.

References protons_cff::time, and dataset::user.

Referenced by writeToLogFile(), and writeToLogFileResults().

203 {
204  time_t rawtime;
205  struct tm * timeinfo;
206  time ( &rawtime );
207  timeinfo = localtime ( &rawtime );
208  char user[50];
209  sprintf(user,"%s",getlogin());
210  sprintf(header,"%s %s:",asctime(timeinfo),user);
211 }
EcalADCToGeVConstant * StoreEcalCondition::readEcalADCToGeVConstantFromFile ( const char *  inputFile)

Definition at line 458 of file StoreEcalCondition.cc.

References analyzePatCleaning_cfg::inputFile, mps_splice::line, LogDebug, sm_constr_, str, and to_string().

Referenced by endJob().

458  {
459 //-------------------------------------------------------------
460 
461 
462  FILE *inpFile; // input file
463  inpFile = fopen(inputFile,"r");
464  if(!inpFile) {
465  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
466  return nullptr;
467  }
468 
469  char line[256];
470 
471  std::ostringstream str;
472 
473  fgets(line,255,inpFile);
474  int sm_number=atoi(line);
475  str << "sm= " << sm_number << endl ;
476 
477  fgets(line,255,inpFile);
478  //int nevents=atoi(line); // not necessary here just for online conddb
479 
480  fgets(line,255,inpFile);
481  string gen_tag=to_string(line);
482  str << "gen tag " << gen_tag << endl ; // should I use this?
483 
484  fgets(line,255,inpFile);
485  string cali_method=to_string(line);
486  str << "cali method " << cali_method << endl ; // not important
487 
488  fgets(line,255,inpFile);
489  string cali_version=to_string(line);
490  str << "cali version " << cali_version << endl ; // not important
491 
492  fgets(line,255,inpFile);
493  string cali_type=to_string(line);
494  str << "cali type " << cali_type << endl ; // not important
495 
496  edm::LogInfo("StoreEcalCondition") << "ADCToGeV file " << str.str() ;
497 
498  fgets(line,255,inpFile);
499  float adc_to_gev=0;
500  sscanf(line, "%f", &adc_to_gev );
501  LogDebug("StoreEcalCondition") <<" calib="<< adc_to_gev ;
502  fgets(line,255,inpFile);
503  float adc_to_gev_ee=0;
504  sscanf(line, "%f", &adc_to_gev_ee );
505  LogDebug("StoreEcalCondition") <<" calib="<< adc_to_gev_ee ;
506 
507  fclose(inpFile); // close inp. file
508 
509  sm_constr_ = sm_number;
510 
511  // barrel and endcaps the same
512  EcalADCToGeVConstant* agc = new EcalADCToGeVConstant(adc_to_gev,adc_to_gev_ee );
513  edm::LogInfo("StoreEcalCondition") << "ADCtoGeV scale written into the DB";
514  return agc;
515 }
#define LogDebug(id)
std::string to_string(char value[])
#define str(s)
EcalChannelStatus * StoreEcalCondition::readEcalChannelStatusFromFile ( const char *  inputFile)

Definition at line 1109 of file StoreEcalCondition.cc.

References comment, gather_cfg::cout, Exception, ecalpyutils::hashedIndex(), compare_using_db::ifile, cuy::ii, ecalpyutils::ism(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, mps_splice::line, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalCondObjectContainer< T >::setValue(), EBDetId::SMCRYSTALMODE, mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, EBDetId::unhashIndex(), EEDetId::unhashIndex(), EBDetId::validDetId(), and EEDetId::validDetId().

Referenced by endJob().

1110 {
1112  // barrel
1113  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta)
1114  {
1115  if(ieta==0) continue;
1116  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
1117  if (EBDetId::validDetId(ieta,iphi)) {
1118  EBDetId ebid(ieta,iphi);
1119  status->setValue( ebid, 0 );
1120  }
1121  }
1122  }
1123  // endcap
1124  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX)
1125  {
1126  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY)
1127  {
1128  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1129  if (EEDetId::validDetId(iX,iY,1))
1130  {
1131  EEDetId eedetidpos(iX,iY,1);
1132  status->setValue( eedetidpos, 0 );
1133  }
1134  if (EEDetId::validDetId(iX,iY,-1))
1135  {
1136  EEDetId eedetidneg(iX,iY,-1);
1137  status->setValue( eedetidneg, 0 );
1138  }
1139  }
1140  }
1141 
1142 
1143  // edm::LogInfo("EcalTrivialConditionRetriever") << "Reading channel status from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ;
1144  std::cout << "Reading channel status from file " << inputFile << std::endl;
1145  FILE *ifile = fopen( inputFile ,"r" );
1146  if ( !ifile )
1147  throw cms::Exception ("Cannot open ECAL channel status file") ;
1148 
1149  char line[256];
1150 
1151  fgets(line,255,ifile);
1152  std::string gen_tag= line;
1153  std::cout << "Gen tag " << gen_tag << std::endl ;
1154 
1155  fgets(line,255,ifile);
1157  std::cout << "Gen comment " << comment << std::endl ;
1158 
1159  int iovRunStart(0);
1160  fgets(line,255,ifile);
1161  sscanf (line, "%d", &iovRunStart);
1162  std::cout << "IOV START " << iovRunStart << std::endl;
1163  //if -1 start of time
1164 
1165  int iovRunEnd(0);
1166  fgets(line,255,ifile);
1167  sscanf (line, "%d", &iovRunEnd);
1168  std::cout << "IOV END " << iovRunEnd << std::endl;
1169  //if -1 end of time
1170 
1171  int ii = 0;
1172  while(fgets(line,255,ifile))
1173  {
1174  std::string EBorEE;
1175  int hashedIndex(0);
1176  int chStatus(0);
1177  std::stringstream aStrStream;
1178  aStrStream << line;
1179  aStrStream >> EBorEE >> hashedIndex >> chStatus;
1180  // if(ii==0)
1181  std::cout << EBorEE << " hashedIndex " << hashedIndex << " status " << chStatus << std::endl;
1182 
1183  if (EBorEE == "EB")
1184  {
1186  status->setValue( aEBDetId, chStatus );
1187  }
1188  else if (EBorEE == "EE")
1189  {
1190  // chStatus=1;
1192  status->setValue( aEEDetId, chStatus );
1193  }
1194  else if (EBorEE == "EBTT")
1195  {
1196  int ism=hashedIndex;
1197  int itt=chStatus;
1198 
1199  int ixtt=(itt-1)%4;
1200  int iytt=(itt-1)/4;
1201  int ixmin=ixtt*5;
1202  int iymin=iytt*5;
1203  int ixmax=(ixtt+1)*5-1;
1204  int iymax=(iytt+1)*5-1;
1205  for(int ieta=iymin; ieta<=iymax; ieta++) {
1206  for(int iphi=ixmin; iphi<=ixmax; iphi++) {
1207  int ixt=ieta*20+iphi+1;
1208  std::cout<< "killing crystal "<< ism << "/" << ixt << endl;
1209  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1210  status->setValue( ebid, 1 );
1211  }
1212  }
1213  }
1214 
1215  ii++ ;
1216 
1217  }
1218 
1219  fclose(ifile);
1220 
1221 
1222  /*
1223  std::cout <<"KILLING CHANNELS FOR CRAFT EB+16 AND EB+7"<<endl;
1224 
1225  int ism=7;
1226  for(int ixt=1; ixt<=500; ixt++) {
1227  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1228  status->setValue( ebid, 1 );
1229  }
1230  for(int ixt=501; ixt<=900; ixt++) {
1231  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1232  if( ((ixt)%20==0) || ((ixt)%20>10) ){
1233  status->setValue( ebid, 1 );
1234  }
1235  }
1236  ism=16;
1237  for(int ixt=501; ixt<=900; ixt++) {
1238  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1239  if( ((ixt)%20==0) || ((ixt)%20>10) ){
1240  status->setValue( ebid, 1 );
1241  }
1242  }
1243 
1244  */
1245 
1246 
1247  return status;
1248 
1249 
1250 }
static const int MIN_IPHI
Definition: EBDetId.h:135
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
void setValue(const uint32_t id, const Item &item)
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
EcalChannelStatusMap EcalChannelStatus
ii
Definition: cuy.py:590
static const int IX_MAX
Definition: EEDetId.h:298
static const int MAX_IPHI
Definition: EBDetId.h:137
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:136
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
static const int IY_MAX
Definition: EEDetId.h:302
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
#define comment(par)
Definition: vmac.h:163
EcalGainRatios * StoreEcalCondition::readEcalGainRatiosFromFile ( const char *  inputFile)

Definition at line 950 of file StoreEcalCondition.cc.

References gather_cfg::cout, PVValHelper::eta, EBDetId::ETAPHIMODE, mps_fire::i, cuy::ii, analyzePatCleaning_cfg::inputFile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, mps_splice::line, phi, DetId::rawId(), EcalMGPAGainRatio::setGain12Over6(), EcalMGPAGainRatio::setGain6Over1(), EcalCondObjectContainer< T >::setValue(), sm_constr_, sm_slot_, EBDetId::SMCRYSTALMODE, str, to_string(), and EEDetId::validDetId().

Referenced by endJob().

950  {
951 //-------------------------------------------------------------
952 
953  // create gain ratios
954  EcalGainRatios* gratio = new EcalGainRatios;
955 
956 
957  FILE *inpFile; // input file
958  inpFile = fopen(inputFile,"r");
959  if(!inpFile) {
960  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
961  return nullptr;
962  }
963 
964  char line[256];
965  std::ostringstream str;
966 
967  fgets(line,255,inpFile);
968  string sm_or_all=to_string(line);
969  int sm_number=0;
970  sm_number=atoi(line);
971  str << "sm= " << sm_number << endl ;
972 
973  fgets(line,255,inpFile);
974  //int nevents=atoi(line);
975 
976  fgets(line,255,inpFile);
977  string gen_tag=to_string(line);
978  str << "gen tag " << gen_tag << endl ;
979 
980  fgets(line,255,inpFile);
981  string cali_method=to_string(line);
982  str << "cali method " << cali_method << endl ;
983 
984  fgets(line,255,inpFile);
985  string cali_version=to_string(line);
986  str << "cali version " << cali_version << endl ;
987 
988 
989  fgets(line,255,inpFile);
990  string cali_type=to_string(line);
991 
992  str << "cali type " << cali_type << endl ;
993 
994  edm::LogInfo("StoreEcalCondition") << "GainRatio file " << str.str() ;
995 
996 
997 
998  int cry_num[61200]={0};
999  float g1_g12[61200]={0};
1000  float g6_g12[61200]={0};
1001  int calib_status[61200]={0};
1002  int dummy1=0;
1003  int dummy2=0;
1004  int hash1=0;
1005 
1006  int ii = 0;
1007 
1008  if(sm_number!=-1){
1009  while(fgets(line,255,inpFile)) {
1010  sscanf(line, "%d %d %d %f %f %d", &dummy1, &dummy2, &cry_num[ii], &g1_g12[ii], &g6_g12[ii], &calib_status[ii] );
1011  ii++ ;
1012  }
1013 
1014 
1015  fclose(inpFile); // close inp. file
1016 
1017 
1018 
1019  edm::LogInfo("StoreEcalCondition") << "Read gainRatios for " << ii << " xtals " ;
1020  if(ii!=1700) edm::LogWarning("StoreEcalCondition") << " Missing crystals:: missing channels will be set to 0" << endl;
1021 
1022  // Get channel ID
1023  sm_constr_ = sm_number;
1024 
1025  for(int i=0; i<1700; i++){
1026  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
1027  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
1028  EBDetId ebid(sm_slot_,cry_num[i],EBDetId::SMCRYSTALMODE);
1029  // cout << "ebid.rawId()"<< ebid.rawId()<< endl;
1030  EcalMGPAGainRatio gr;
1031  gr.setGain12Over6( g6_g12[i] );
1032  gr.setGain6Over1(g1_g12[i]/g6_g12[i]);
1033  gratio->setValue( ebid.rawId(), gr );
1034  } // loop over channels
1035 
1036 
1037 
1038 
1039 
1040 
1041  } else {
1042  // this is for the whole Barrel
1043  cout<<"mode ALL BARREL" <<endl;
1044  while(fgets(line,255,inpFile)) {
1045  int eta=0;
1046  int phi=0;
1047  sscanf(line, "%d %d %d %f %f",&hash1, &eta, &phi, &g1_g12[ii], &g6_g12[ii]);
1048  if(ii<20) cout<<"crystal eta/phi="<<eta<<"/"<<phi<<" g1_12/g6_12= "<< g1_g12[ii]<<"/"<<g6_g12[ii]<<endl;
1049 
1050  if(g1_g12[ii]<9 || g1_g12[ii]>15 ) g1_g12[ii]=12.0;
1051  if(g6_g12[ii]<1 || g6_g12[ii]>3 ) g6_g12[ii]=2.0;
1052 
1053  if(eta<-85|| eta>85 || eta==0) std::cout<<"error!!!"<<endl;
1054  if(phi<1 || phi>360) std::cout<<"error!!!"<<endl;
1055 
1056  EBDetId ebid(eta, phi,EBDetId::ETAPHIMODE);
1057  EcalMGPAGainRatio gr;
1058  gr.setGain12Over6( g6_g12[ii] );
1059  gr.setGain6Over1(g1_g12[ii]/g6_g12[ii]);
1060  gratio->setValue( ebid.rawId(), gr );
1061 
1062  ii++ ;
1063  }
1064 
1065  fclose(inpFile); // close inp. file
1066  if(ii!=61200) edm::LogWarning("StoreEcalCondition") << " Missing crystals !!!!!!!" << endl;
1067 
1068  std::cout<< "number of crystals read:"<<ii<<endl;
1069 
1070  }
1071 
1072 
1073 
1074  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
1075  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
1076  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1077  EcalMGPAGainRatio gr;
1078  gr.setGain12Over6( 2. );
1079  gr.setGain6Over1( 6. );
1080 
1081 
1082  if (EEDetId::validDetId(iX,iY,1))
1083  {
1084  EEDetId eedetidpos(iX,iY,1);
1085  gratio->setValue( eedetidpos.rawId(), gr );
1086  }
1087  if (EEDetId::validDetId(iX,iY,-1))
1088  {
1089  EEDetId eedetidneg(iX,iY,-1);
1090  gratio->setValue( eedetidneg.rawId(), gr );
1091  }
1092  }
1093  }
1094 
1095 
1096  std::cout <<" gratio pointer="<<gratio<<endl;
1097 
1098 
1099 
1100  std::cout<< "now leaving"<<endl;
1101 
1102 
1103 
1104  return gratio;
1105 
1106 }
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
void setGain12Over6(const float &g)
void setValue(const uint32_t id, const Item &item)
EcalGainRatioMap EcalGainRatios
static const int ETAPHIMODE
Definition: EBDetId.h:158
ii
Definition: cuy.py:590
static const int IX_MAX
Definition: EEDetId.h:298
std::string to_string(char value[])
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int IY_MAX
Definition: EEDetId.h:302
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
void setGain6Over1(const float &g)
EcalIntercalibConstants * StoreEcalCondition::readEcalIntercalibConstantsFromFile ( const char *  inputFile,
const char *  inputFileEE 
)

Definition at line 598 of file StoreEcalCondition.cc.

References convertFromConstructionSMToSlot(), gather_cfg::cout, mps_fire::i, cuy::ii, analyzePatCleaning_cfg::inputFile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, mps_splice::line, nchan, DetId::rawId(), EcalCondObjectContainer< T >::setValue(), sm_constr_, EBDetId::SMCRYSTALMODE, str, to_string(), and EEDetId::validDetId().

Referenced by endJob().

598  {
599 //-------------------------------------------------------------
600 
602 
603 
604  FILE *inpFile; // input file
605  inpFile = fopen(inputFile,"r");
606  if(!inpFile) {
607  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
608  return nullptr;
609  }
610 
611  char line[256];
612 
613  std::ostringstream str;
614 
615  fgets(line,255,inpFile);
616  string sm_or_all=to_string(line);
617  int sm_number=0;
618  int nchan=1700;
619  sm_number=atoi(line);
620  str << "sm= " << sm_number << endl ;
621  if(sm_number!=-1){
622  nchan=1700;
623  } else {
624  nchan=61200;
625  }
626 
627 
628  fgets(line,255,inpFile);
629  //int nevents=atoi(line); // not necessary here just for online conddb
630 
631  fgets(line,255,inpFile);
632  string gen_tag=to_string(line);
633  str << "gen tag " << gen_tag << endl ; // should I use this?
634 
635  fgets(line,255,inpFile);
636  string cali_method=to_string(line);
637  str << "cali method " << cali_method << endl ; // not important
638 
639  fgets(line,255,inpFile);
640  string cali_version=to_string(line);
641  str << "cali version " << cali_version << endl ; // not important
642 
643  fgets(line,255,inpFile);
644  string cali_type=to_string(line);
645  str << "cali type " << cali_type << endl ; // not important
646 
647  edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str() ;
648 
649  int sm_num[61200]={0};
650  int cry_num[61200]={0};
651  float calib[61200]={0};
652  float calib_rms[61200]={0};
653  int calib_nevents[61200]={0};
654  int calib_status[61200]={0};
655 
656  int ii = 0;
657  if(sm_number!=-1){
658  while(fgets(line,255,inpFile)) {
659  sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii] );
660 // if(ii<10) { // print out only the first ten channels
661 // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
662 // }
663  sm_num[ii]=sm_number;
664  ii++ ;
665  }
666  } else {
667  // this is for the whole Barrel
668  cout<<"mode ALL BARREL" <<endl;
669  while(fgets(line,255,inpFile)) {
670  sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii] );
671  if(ii==0) cout<<"crystal "<<cry_num[ii]<<" of sm "<<sm_num[ii]<<" cali= "<< calib[ii]<<endl;
672  ii++ ;
673  }
674  }
675 
676  // inf.close(); // close inp. file
677  fclose(inpFile); // close inp. file
678 
679  edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals " ;
680 
681  cout << " I read the calibrations for "<< ii<< " crystals " << endl;
682  if(ii!=nchan) edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0" << endl;
683 
684  // Get channel ID
685 
686  sm_constr_ = sm_number;
687 
688 
689  // Set the data
690  for(int i=0; i<nchan; i++){
691 
692  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
693  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
694 
695  int slot_num=convertFromConstructionSMToSlot(sm_num[i],-1);
696  EBDetId ebid(slot_num,cry_num[i],EBDetId::SMCRYSTALMODE);
697 
698  ical->setValue( ebid.rawId(), calib[i] );
699 
700  if(i==0) cout<<"crystal "<<cry_num[i]<<" of sm "<<sm_num[i]<< " in slot " <<slot_num<<" calib= "<< calib[i]<<endl;
701 
702  } // loop over channels
703 
704  cout<<"loop on channels done" << endl;
705 
706  FILE *inpFileEE; // input file
707  inpFileEE = fopen(inputFileEE,"r");
708  if(!inpFileEE) {
709  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
710 
711  // dummy endcap data
712 
713  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX)
714  {
715  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY)
716  {
717  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
718  if (EEDetId::validDetId(iX,iY,1))
719  {
720  EEDetId eedetidpos(iX,iY,1);
721  ical->setValue( eedetidpos, 1.0 );
722  }
723  if (EEDetId::validDetId(iX,iY,-1))
724  {
725  EEDetId eedetidneg(iX,iY,-1);
726  ical->setValue( eedetidneg, 1.0 );
727  }
728  }
729  }
730 
731  } else {
732  cout<<"... now reading EE file ..." <<endl;
733 
734  int ii=0;
735  while(fgets(line,255,inpFileEE)) {
736  int iz,ix,iy;
737  float calibee;
738  sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee );
739  if(ii<=0) cout<<"crystal "<<iz<<"/"<<ix<<"/"<<iy<<" cali="<< calibee<<endl;
740 
741  if (EEDetId::validDetId(ix,iy,iz))
742  {
743  EEDetId eedetid(ix,iy,iz);
744  ical->setValue( eedetid, calibee );
745  }
746 
747  ii++ ;
748  }
749 
750 
751  fclose(inpFileEE); // close inp. file
752 
753  }
754 
755  cout<<"loop on EE channels done" << endl;
756 
757 
758 
759  return ical;
760 }
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
void setValue(const uint32_t id, const Item &item)
int nchan
Definition: TauolaWrapper.h:80
ii
Definition: cuy.py:590
static const int IX_MAX
Definition: EEDetId.h:298
std::string to_string(char value[])
int convertFromConstructionSMToSlot(int, int)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EcalIntercalibConstantMap EcalIntercalibConstants
static const int IY_MAX
Definition: EEDetId.h:302
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
EcalIntercalibConstantsMC * StoreEcalCondition::readEcalIntercalibConstantsMCFromFile ( const char *  inputFile,
const char *  inputFileEE 
)

Definition at line 764 of file StoreEcalCondition.cc.

References convertFromConstructionSMToSlot(), gather_cfg::cout, mps_fire::i, cuy::ii, analyzePatCleaning_cfg::inputFile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, mps_splice::line, nchan, DetId::rawId(), EcalCondObjectContainer< T >::setValue(), sm_constr_, EBDetId::SMCRYSTALMODE, str, to_string(), and EEDetId::validDetId().

Referenced by endJob().

764  {
765 //-------------------------------------------------------------
766 
768 
769 
770  FILE *inpFile; // input file
771  inpFile = fopen(inputFile,"r");
772  if(!inpFile) {
773  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
774  return nullptr;
775  }
776 
777  char line[256];
778 
779  std::ostringstream str;
780 
781  fgets(line,255,inpFile);
782  string sm_or_all=to_string(line);
783  int sm_number=0;
784  int nchan=1700;
785  sm_number=atoi(line);
786  str << "sm= " << sm_number << endl ;
787  if(sm_number!=-1){
788  nchan=1700;
789  } else {
790  nchan=61200;
791  }
792 
793 
794  fgets(line,255,inpFile);
795  //int nevents=atoi(line); // not necessary here just for online conddb
796 
797  fgets(line,255,inpFile);
798  string gen_tag=to_string(line);
799  str << "gen tag " << gen_tag << endl ; // should I use this?
800 
801  fgets(line,255,inpFile);
802  string cali_method=to_string(line);
803  str << "cali method " << cali_method << endl ; // not important
804 
805  fgets(line,255,inpFile);
806  string cali_version=to_string(line);
807  str << "cali version " << cali_version << endl ; // not important
808 
809  fgets(line,255,inpFile);
810  string cali_type=to_string(line);
811  str << "cali type " << cali_type << endl ; // not important
812 
813  edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str() ;
814 
815  int sm_num[61200]={0};
816  int cry_num[61200]={0};
817  float calib[61200]={0};
818  float calib_rms[61200]={0};
819  int calib_nevents[61200]={0};
820  int calib_status[61200]={0};
821 
822  int ii = 0;
823  if(sm_number!=-1){
824  while(fgets(line,255,inpFile)) {
825  sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii] );
826 // if(ii<10) { // print out only the first ten channels
827 // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
828 // }
829  sm_num[ii]=sm_number;
830  ii++ ;
831  }
832  } else {
833  // this is for the whole Barrel
834  cout<<"mode ALL BARREL" <<endl;
835  while(fgets(line,255,inpFile)) {
836  sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii] );
837  if(ii==0) cout<<"crystal "<<cry_num[ii]<<" of sm "<<sm_num[ii]<<" cali= "<< calib[ii]<<endl;
838  ii++ ;
839  }
840  }
841 
842  // inf.close(); // close inp. file
843  fclose(inpFile); // close inp. file
844 
845  edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals " ;
846 
847  cout << " I read the calibrations for "<< ii<< " crystals " << endl;
848  if(ii!=nchan) edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0" << endl;
849 
850  // Get channel ID
851 
852  sm_constr_ = sm_number;
853 
854 
855  // Set the data
856  for(int i=0; i<nchan; i++){
857 
858  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
859  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
860 
861  int slot_num=convertFromConstructionSMToSlot(sm_num[i],-1);
862  EBDetId ebid(slot_num,cry_num[i],EBDetId::SMCRYSTALMODE);
863 
864  ical->setValue( ebid.rawId(), calib[i] );
865 
866  if(i==0) cout<<"crystal "<<cry_num[i]<<" of sm "<<sm_num[i]<< " in slot " <<slot_num<<" calib= "<< calib[i]<<endl;
867 
868  } // loop over channels
869 
870  cout<<"loop on channels done" << endl;
871 
872  FILE *inpFileEE; // input file
873  inpFileEE = fopen(inputFileEE,"r");
874  if(!inpFileEE) {
875  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
876 
877  // dummy endcap data
878 
879  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX)
880  {
881  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY)
882  {
883  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
884  if (EEDetId::validDetId(iX,iY,1))
885  {
886  EEDetId eedetidpos(iX,iY,1);
887  ical->setValue( eedetidpos, 1.0 );
888  }
889  if (EEDetId::validDetId(iX,iY,-1))
890  {
891  EEDetId eedetidneg(iX,iY,-1);
892  ical->setValue( eedetidneg, 1.0 );
893  }
894  }
895  }
896 
897  } else {
898  cout<<"... now reading EE file ..." <<endl;
899 
900  int ii=0;
901  while(fgets(line,255,inpFileEE)) {
902  int iz,ix,iy;
903  float calibee;
904  sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee );
905  if(ii<=0) cout<<"crystal "<<iz<<"/"<<ix<<"/"<<iy<<" cali="<< calibee<<endl;
906 
907  if (EEDetId::validDetId(ix,iy,iz))
908  {
909  EEDetId eedetid(ix,iy,iz);
910  ical->setValue( eedetid, calibee );
911  }
912 
913  ii++ ;
914  }
915 
916 
917  fclose(inpFileEE); // close inp. file
918 
919  }
920 
921  cout<<"loop on EE channels done" << endl;
922 
923 
924 
925  return ical;
926 }
EcalIntercalibConstantMCMap EcalIntercalibConstantsMC
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
void setValue(const uint32_t id, const Item &item)
int nchan
Definition: TauolaWrapper.h:80
ii
Definition: cuy.py:590
static const int IX_MAX
Definition: EEDetId.h:298
std::string to_string(char value[])
int convertFromConstructionSMToSlot(int, int)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int IY_MAX
Definition: EEDetId.h:302
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
EcalPFRecHitThresholds * StoreEcalCondition::readEcalPFRecHitThresholdsFromFile ( const char *  inputFile,
const char *  inputFileEE 
)

Definition at line 520 of file StoreEcalCondition.cc.

References gather_cfg::cout, cuy::ii, analyzePatCleaning_cfg::inputFile, mps_splice::line, DetId::rawId(), EcalCondObjectContainer< T >::setValue(), scrapingFilter_cfi::thresh, EBDetId::validDetId(), and EEDetId::validDetId().

Referenced by endJob().

520  {
521 //-------------------------------------------------------------
522 
524 
525 
526  FILE *inpFile; // input file
527  inpFile = fopen(inputFile,"r");
528  if(!inpFile) {
529  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
530  return nullptr;
531  }
532 
533  char line[256];
534 
535 
536  int ieta=0;
537  int iphi=0;
538  int ix=0;
539  int iy=0;
540  int iz=0;
541 
542  float thresh=0;
543 
544 
545  int ii = 0;
546  while(fgets(line,255,inpFile)) {
547  sscanf(line, "%d %d %f ", &ieta, &iphi, &thresh);
548  if(ii==0) cout<<"crystal "<<ieta<<"/"<<iphi<<" Thresh= "<< thresh<<endl;
549 
550  if (EBDetId::validDetId(ieta,iphi)) {
551  EBDetId ebid(ieta,iphi);
552  ical->setValue( ebid.rawId(), thresh );
553  ii++ ;
554  }
555  }
556 
557 
558  // inf.close(); // close inp. file
559  fclose(inpFile); // close inp. file
560 
561  edm::LogInfo("StoreEcalCondition") << "Read PF RecHits for " << ii << " xtals " ;
562 
563  cout << " I read the thresholds for "<< ii<< " crystals " << endl;
564 
565 
566 
567  FILE *inpFileEE; // input file
568  inpFileEE = fopen(inputFileEE,"r");
569  if(!inpFileEE) {
570  edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFileEE;
571  return nullptr;
572  }
573  ii=0;
574  while(fgets(line,255,inpFileEE)) {
575  sscanf(line, "%d %d %d %f ", &ix,&iy,&iz, &thresh);
576  if(ii==0) cout<<"crystal "<<ix<<"/"<<iy<<"/"<<iz<<" Thresh= "<< thresh<<endl;
577  if (EEDetId::validDetId(ix,iy,iz)) {
578  EEDetId eeid(ix,iy,iz);
579  ical->setValue( eeid.rawId(), thresh );
580  ii++ ;
581  }
582  }
583 
584 
585  // inf.close(); // close inp. file
586  fclose(inpFileEE); // close inp. file
587 
588 
589  cout<<"loop on EE channels done - number of crystals =" <<ii<< std::endl;
590 
591 
592 
593  return ical;
594 
595 }
EcalPFRecHitThresholdsMap EcalPFRecHitThresholds
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
void setValue(const uint32_t id, const Item &item)
ii
Definition: cuy.py:590
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EcalTBWeights * StoreEcalCondition::readEcalTBWeightsFromFile ( const char *  inputFile)

Definition at line 312 of file StoreEcalCondition.cc.

References EcalWeightSet::getChi2WeightsAfterGainSwitch(), EcalWeightSet::getChi2WeightsBeforeGainSwitch(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), mps_fire::i, analyzePatCleaning_cfg::inputFile, gen::k, LogDebug, hgc_digi::nSamples, EcalTBWeights::setValue(), sm_constr_, str, and groupFilesInBlocks::temp.

Referenced by endJob().

312  {
313  //-------------------------------------------------------------
314 
315  // Zabi code to be written here
316 
317  EcalTBWeights* tbwgt = new EcalTBWeights();
318 
319  std::ifstream WeightsFileTB(inputFile);
320  if(!WeightsFileTB.is_open()) {
321  edm::LogError("StoreEcalCondition")<< "*** Can not open file: "<< inputFile ;
322  return nullptr;
323  }
324 
325  int smnumber=-99999;
326 
327  std::ostringstream str;
328  WeightsFileTB >> smnumber;
329  if (smnumber == -99999)
330  return nullptr;
331 
332  str << "sm= " << smnumber << endl;
333 
334  char temp[256];
335  //Reading the other 5 header lines containing various informations
336  for (int i=0;i<=5;i++)
337  {
338  WeightsFileTB.getline(temp,255);
339  str << temp << endl;
340  }
341 
342  edm::LogInfo("StoreEcalCondition") << "Weights file " << str.str() ;
343 
344  int ngroups=0;
345  while (WeightsFileTB.good())
346  {
347  int igroup_ID = -99999;
348  int nSamples = -99999;
349  int nTdcBins = -99999;
350 
351  WeightsFileTB >> igroup_ID >> nSamples >> nTdcBins;
352  if (igroup_ID == -99999 || nSamples == -99999 || nTdcBins == -99999)
353  break;
354 
355  std::ostringstream str;
356  str << "Igroup=" << igroup_ID << " Nsamples=" << nSamples << " NTdcBins=" << nTdcBins <<"\n" ;
357 
358  for (int iTdcBin = 0; iTdcBin < nTdcBins; iTdcBin++) {
359 
360  EcalWeightSet wgt; // one set of weights
365 
366 // std::vector<EcalWeight> wamp, wped, wtime; //weights before gain switch
367 // std::vector<EcalWeight> wamp2, wped2, wtime2; //weights after gain switch
368 
369  //WEIGHTS BEFORE GAIN SWITCH
370  //Amplitude weights
371  for(int j = 0; j < nSamples; ++j) {
372  double ww = 0.0; WeightsFileTB >> ww;
373  wgt1(0,j)=ww;
374  str << ww << " ";
375  }// loop Samples
376  str << std::endl;
377 
378  //Pedestal weights
379  for(int j = 0; j < nSamples; ++j) {
380  double ww = 0.0; WeightsFileTB >> ww;
381  wgt1(1,j)=ww;
382  str << ww << " ";
383  }//loop Samples
384  str << std::endl;
385 
386  //Timing weights
387  for(int j = 0; j < nSamples; ++j) {
388  double ww = 0.0; WeightsFileTB >> ww;
389  wgt1(2,j)=ww;
390  str << ww << " ";
391  }//loop Samples
392  str << std::endl;
393 
394  for(int j = 0; j < nSamples; ++j) {
395  // fill chi2 matrix
396  //std::vector<EcalWeight> vChi2; // row of chi2 matrix
397  for(int k = 0; k < nSamples; ++k) {
398  double ww = 0.0; WeightsFileTB >> ww;
399  chisq1(j,k)=ww;
400  str << ww << " ";
401  } //loop samples
402  str << std::endl;
403  }//loop lines
404 
405  //WEIGHTS AFTER GAIN SWITCH
406  for(int j = 0; j < nSamples; ++j) {
407  double ww = 0.0; WeightsFileTB >> ww;
408  wgt2(0,j)=ww;
409  str << ww << " ";
410  }// loop Samples
411  str << std::endl;
412 
413  //Pedestal weights
414  for(int j = 0; j < nSamples; ++j) {
415  double ww = 0.0; WeightsFileTB >> ww;
416  wgt2(1,j)=ww;
417  str << ww << " ";
418  }//loop Samples
419  str << std::endl;
420 
421  //Timing weights
422  for(int j = 0; j < nSamples; ++j) {
423  double ww = 0.0; WeightsFileTB >> ww;
424  wgt2(2,j)=ww;
425  str << ww << " ";
426  }//loop Samples
427  str << std::endl;
428 
429  for(int j = 0; j < nSamples; ++j) {
430  // fill chi2 matrix
431  //std::vector<EcalWeight> vChi2; // row of chi2 matrix
432  for(int k = 0; k < nSamples; ++k) {
433  double ww = 0.0; WeightsFileTB >> ww;
434  chisq2(j,k)=ww;
435  str << ww << " ";
436  } //loop samples
437  str << std::endl;
438  }//loop lines
439 
440  LogDebug("StoreEcalCondition") << str.str();
441 
442  //modif-27-07-06 tdcid should start from 1
443  tbwgt->setValue(std::make_pair( igroup_ID , iTdcBin+1 ), wgt);
444  }//loop Tdc bins
445  ngroups++;
446  }//loop groupID
447 
448  sm_constr_ = smnumber;
449 
450 
451  edm::LogInfo("StoreEcalCondition") << "Weights for " << ngroups << " groups written into DB" ;
452  return tbwgt;
453 }
#define LogDebug(id)
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:31
void setValue(const EcalXtalGroupId &groupId, const EcalTDCId &tdcId, const EcalWeightSet &weight)
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
Definition: EcalWeightSet.h:32
constexpr size_t nSamples
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:30
int k[5][pyjets_maxn]
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:23
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:29
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:22
#define str(s)
EcalWeightXtalGroups * StoreEcalCondition::readEcalWeightXtalGroupsFromFile ( const char *  inputFile)

Definition at line 246 of file StoreEcalCondition.cc.

References mps_fire::i, analyzePatCleaning_cfg::inputFile, LogDebug, DetId::rawId(), EcalCondObjectContainer< T >::setValue(), sm_constr_, sm_slot_, EBDetId::SMCRYSTALMODE, str, and groupFilesInBlocks::temp.

Referenced by endJob().

246  {
247 //-------------------------------------------------------------
248 
249 // Code taken from EcalWeightTools/test/MakeOfflineDbFromAscii.cpp
250 
251  EcalWeightXtalGroups* xtalGroups = new EcalWeightXtalGroups();
252  std::ifstream groupid_in(inputFile);
253 
254  if(!groupid_in.is_open()) {
255  edm::LogError("StoreEcalCondition")<< "*** Can not open file: "<< inputFile ;
256  return nullptr;
257  }
258 
259  int smnumber=-99999;
260 
261  std::ostringstream str;
262  groupid_in >> smnumber;
263  if (smnumber == -99999) {
264  edm::LogError("StoreEcalCondition") << "ERROR: SM number not found in file" << endl;
265  return nullptr;
266  }
267  str << "sm= " << smnumber << endl;
268  sm_constr_ = smnumber;
269 
270  char temp[256];
271  //Reading the other 5 header lines containing various informations
272  for (int i=0;i<=5;i++) {
273  groupid_in.getline(temp,255);
274  str << temp << endl;
275  }
276 
277  // Skip the nGroup/Mean line
278  groupid_in.getline(temp, 255);
279  str << temp << endl;
280 
281  edm::LogInfo("StoreEcalCondition") << "GROUPID file " << str.str() ;
282 
283  int xtals = 0;
284  int xtal, ietaf, iphif, groupID;
285  while (groupid_in.good()) {
286  groupid_in >> xtal >> ietaf >> iphif >> groupID;
287  if (groupid_in.eof()) { break; }
288 
289  LogDebug("StoreEcalCondition") << "XTAL=" << xtal << " ETA=" << ietaf << " PHI=" << iphif
290  << " GROUP=" << groupID ;
291 
292  //EBDetId ebid(ieta,iphi);
294  // xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( ebid.hashedIndex()) );
295  xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( groupID ) );
296  xtals++;
297  }//loop iphi
298 
299  if (xtals != 1700) {
300  edm::LogError("StoreEcalCondition") << "ERROR: GROUPID file did not contain data for 1700 crystals" << endl;
301  return nullptr;
302  }
303 
304  edm::LogInfo("StoreEcalCondition") << "Groups for " << xtals << " xtals written into DB" ;
305  sm_constr_ = smnumber;
306 
307  return xtalGroups;
308 }
#define LogDebug(id)
EcalCondObjectContainer< EcalXtalGroupId > EcalWeightXtalGroups
void setValue(const uint32_t id, const Item &item)
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
std::string StoreEcalCondition::to_string ( char  value[])
inlineprivate

Definition at line 74 of file StoreEcalCondition.h.

References relativeConstraints::value.

Referenced by readEcalADCToGeVConstantFromFile(), readEcalGainRatiosFromFile(), readEcalIntercalibConstantsFromFile(), and readEcalIntercalibConstantsMCFromFile().

74  {
75  std::ostringstream streamOut;
76  streamOut << value;
77  return streamOut.str();
78  }
void StoreEcalCondition::writeToLogFile ( std::string  ,
std::string  ,
unsigned long  long 
)

Definition at line 161 of file StoreEcalCondition.cc.

References fillHeader(), RecoTauValidation_cfi::header, createfilelist::int, logfile_, GetRecoTauVFromDQM_MC_cff::outFile, sm_constr_, and sm_slot_.

161  {
162 //-------------------------------------------------------------
163 
164  FILE *outFile; // output log file for appending
165  outFile = fopen(logfile_.c_str(),"a");
166  if(!outFile) {
167  edm::LogError("StoreEcalCondition") <<"*** Can not open file: " << logfile_;
168  return;
169  }
170  char header[256];
171  fillHeader(header);
172  char appendMode[10];
173  if (since != 0)
174  sprintf(appendMode,"append");
175  else
176  sprintf(appendMode,"create");
177 
178  fprintf(outFile, "%s %s condition from file %s written into DB for SM %d (mapped to SM %d) in %s mode (since run %u)\n",
179  header, a.c_str(),b .c_str(), sm_constr_, sm_slot_, appendMode, (unsigned int)since);
180 
181  fclose(outFile); // close out file
182 
183 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void StoreEcalCondition::writeToLogFileResults ( char *  arg)

Definition at line 185 of file StoreEcalCondition.cc.

References fillHeader(), RecoTauValidation_cfi::header, logfile_, and GetRecoTauVFromDQM_MC_cff::outFile.

Referenced by endJob().

185  {
186 //-------------------------------------------------------------
187 
188  FILE *outFile; // output log file for appending
189  outFile = fopen(logfile_.c_str(),"a");
190  if(!outFile) {
191  edm::LogError("StoreEcalCondition")<<"*** Can not open file: " << logfile_;
192  return;
193  }
194  char header[256];
195  fillHeader(header);
196  fprintf(outFile, "%s %s\n", header,arg);
197  fclose(outFile); // close out file
198 }
A arg
Definition: Factorize.h:38

Member Data Documentation

std::vector< std::string > StoreEcalCondition::inpFileName_
private

Definition at line 66 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

std::vector< std::string > StoreEcalCondition::inpFileNameEE_
private

Definition at line 67 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

std::string StoreEcalCondition::logfile_
private

Definition at line 72 of file StoreEcalCondition.h.

Referenced by StoreEcalCondition(), writeToLogFile(), and writeToLogFileResults().

std::vector< std::string > StoreEcalCondition::objectName_
private

Definition at line 64 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

std::string StoreEcalCondition::prog_name_
private

Definition at line 68 of file StoreEcalCondition.h.

Referenced by StoreEcalCondition().

std::vector< unsigned long long > StoreEcalCondition::since_
private

Definition at line 71 of file StoreEcalCondition.h.

Referenced by endJob(), and StoreEcalCondition().

int StoreEcalCondition::sm_constr_
private
int StoreEcalCondition::sm_slot_
private