#include <CondTools/Ecal/plugins/StoreEcalCondition.h>
Definition at line 38 of file StoreEcalCondition.h.
StoreEcalCondition::StoreEcalCondition | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 17 of file StoreEcalCondition.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), inpFileName_, logfile_, objectName_, prog_name_, sm_constr_, sm_slot_, and trackerGeometricDetLoaderSQLITE_cfg::toPut.
00017 { 00018 00019 prog_name_ = "StoreEcalCondition"; 00020 00021 logfile_ = iConfig.getParameter< std::string >("logfile"); 00022 sm_slot_ = iConfig.getUntrackedParameter< unsigned int >("smSlot", 1); 00023 00024 typedef std::vector< edm::ParameterSet > Parameters; 00025 Parameters toPut=iConfig.getParameter<Parameters>("toPut"); 00026 for(Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut) 00027 { 00028 inpFileName_.push_back(itToPut->getUntrackedParameter<std::string>("inputFile")); 00029 objectName_.push_back(itToPut->getUntrackedParameter<std::string>("conditionType")); 00030 // since_.push_back(itToPut->getUntrackedParameter<unsigned int>("since")); 00031 } 00032 00033 sm_constr_ = -1; 00034 }
StoreEcalCondition::~StoreEcalCondition | ( | ) |
void StoreEcalCondition::analyze | ( | const edm::Event & | evt, | |
const edm::EventSetup & | evtSetup | |||
) | [virtual] |
Definition at line 595 of file StoreEcalCondition.cc.
References HLT_VtxMuL3::result.
Referenced by readEcalIntercalibConstantsFromFile().
00595 { 00596 // input either cosntruction number or slot number and returns the other 00597 // the slots are numbered first EB+ slot 1 ...18 then EB- 1... 18 00598 // the slots start at 1 and the SM start at 0 00599 //------------------------------------------------------------- 00600 int slot_to_constr[37]={-1,12,17,10,1,8,4,27,20,23,25,6,34,35,15,18,30,21,9 00601 ,24,22,13,31,26,16,2,11,5,0,29,28,14,33,32,3,7,19}; 00602 int constr_to_slot[36]={28,4,25,34,6,27,11,35,5,18,3,26,1,21,31,14,24,2,15, 00603 36,8,17,20,9,19,10,23,7,30,29,16,22,33,32,12,13 }; 00604 00605 int result=0; 00606 if(sm_constr!=-1) { 00607 result=constr_to_slot[sm_constr]; 00608 } else if(sm_slot!=-1) { 00609 result=slot_to_constr[sm_slot]; 00610 } 00611 return result; 00612 }
Reimplemented from edm::EDAnalyzer.
Definition at line 36 of file StoreEcalCondition.cc.
References lat::endl(), i, inpFileName_, edm::Service< T >::isAvailable(), objectName_, readEcalADCToGeVConstantFromFile(), readEcalChannelStatusFromFile(), readEcalGainRatiosFromFile(), readEcalIntercalibConstantsFromFile(), readEcalTBWeightsFromFile(), readEcalWeightXtalGroupsFromFile(), since_, and writeToLogFileResults().
00036 { 00037 edm::Service<cond::service::PoolDBOutputService> mydbservice; 00038 if( !mydbservice.isAvailable() ){ 00039 edm::LogError("StoreEcalCondition")<<"PoolDBOutputService is unavailable"<<std::endl; 00040 return; 00041 } 00042 00043 bool toAppend=false; 00044 for (unsigned int i=0;i<objectName_.size();i++) { 00045 cond::Time_t newTime; 00046 00047 if ( mydbservice->isNewTagRequest( objectName_[i]+std::string("Rcd") ) ) { 00048 // This is the first object for this tag. 00049 // Append mode should be off. 00050 // newTime is the end of this new objects IOV. 00051 newTime = mydbservice->beginOfTime(); 00052 } else { 00053 // There should already be an object in the DB for this tag. 00054 // Append IOV mode should be on. 00055 // newTime is the beginning of this new objects IOV. 00056 toAppend=true; 00057 newTime = (cond::Time_t)since_[i]; 00058 } 00059 edm::LogInfo("StoreEcalCondition") << "Reading " << objectName_[i] 00060 << " from file and writing to DB with newTime " << newTime << endl; 00061 00062 if (objectName_[i] == "EcalWeightXtalGroups") { 00063 EcalWeightXtalGroups* mycali = readEcalWeightXtalGroupsFromFile(inpFileName_[i].c_str()); 00064 if(!toAppend){ 00065 mydbservice->createNewIOV<EcalWeightXtalGroups>(mycali,newTime,mydbservice->endOfTime(),"EcalWeightXtalGroupsRcd"); 00066 }else{ 00067 mydbservice->appendSinceTime<EcalWeightXtalGroups>(mycali,newTime,"EcalWeightXtalGroupsRcd"); 00068 } 00069 }else if (objectName_[i] =="EcalTBWeights") { 00070 EcalTBWeights* mycali=readEcalTBWeightsFromFile(inpFileName_[i].c_str()); 00071 if(!toAppend){ 00072 mydbservice->createNewIOV<EcalTBWeights>(mycali,newTime,mydbservice->endOfTime(),"EcalTBWeightsRcd"); 00073 }else{ 00074 mydbservice->appendSinceTime<EcalTBWeights>(mycali,newTime,"EcalTBWeightsRcd"); 00075 } 00076 } else if (objectName_[i] == "EcalADCToGeVConstant") { 00077 EcalADCToGeVConstant* mycali=readEcalADCToGeVConstantFromFile(inpFileName_[i].c_str()); 00078 if(!toAppend){ 00079 mydbservice->createNewIOV<EcalADCToGeVConstant>(mycali,newTime,mydbservice->endOfTime(),"EcalADCToGeVConstantRcd"); 00080 }else{ 00081 mydbservice->appendSinceTime<EcalADCToGeVConstant>(mycali,newTime,"EcalADCToGeVConstantRcd"); 00082 } 00083 } else if (objectName_[i] == "EcalIntercalibConstants") { 00084 EcalIntercalibConstants* mycali=readEcalIntercalibConstantsFromFile(inpFileName_[i].c_str()); 00085 if(!toAppend){ 00086 mydbservice->createNewIOV<EcalIntercalibConstants>(mycali,newTime,mydbservice->endOfTime(),"EcalIntercalibConstantsRcd"); 00087 }else{ 00088 mydbservice->appendSinceTime<EcalIntercalibConstants>(mycali,newTime,"EcalIntercalibConstantsRcd"); 00089 } 00090 } else if (objectName_[i] == "EcalGainRatios") { 00091 EcalGainRatios* mycali=readEcalGainRatiosFromFile(inpFileName_[i].c_str()); 00092 if(!toAppend){ 00093 mydbservice->createNewIOV<EcalGainRatios>(mycali,newTime,mydbservice->endOfTime(),"EcalGainRatiosRcd"); 00094 }else{ 00095 mydbservice->appendSinceTime<EcalGainRatios>(mycali,newTime,"EcalGainRatiosRcd"); 00096 } 00097 } else if (objectName_[i] == "EcalChannelStatus") 00098 { 00099 EcalChannelStatus* mycali=readEcalChannelStatusFromFile(inpFileName_[i].c_str()); 00100 if(!toAppend){ 00101 mydbservice->createNewIOV<EcalChannelStatus>(mycali,newTime,mydbservice->endOfTime(),"EcalChannelStatusRcd"); 00102 }else{ 00103 mydbservice->appendSinceTime<EcalChannelStatus>(mycali,newTime,"EcalChannelStatusRcd"); 00104 } 00105 } else { 00106 edm::LogError("StoreEcalCondition")<< "Object " << objectName_[i] << " is not supported by this program." << endl; 00107 } 00108 00109 00110 // writeToLogFile(objectName_[i], inpFileName_[i], since_[i]); 00111 writeToLogFileResults("finished OK\n"); 00112 edm::LogInfo("StoreEcalCondition") << "Finished endJob" << endl; 00113 } 00114 }
void StoreEcalCondition::fillHeader | ( | char * | header | ) | [private] |
Definition at line 169 of file StoreEcalCondition.cc.
References cmsBenchmark::user.
Referenced by writeToLogFile(), and writeToLogFileResults().
00171 { 00172 time_t rawtime; 00173 struct tm * timeinfo; 00174 time ( &rawtime ); 00175 timeinfo = localtime ( &rawtime ); 00176 char user[50]; 00177 sprintf(user,"%s",getlogin()); 00178 sprintf(header,"%s %s:",asctime(timeinfo),user); 00179 }
EcalADCToGeVConstant * StoreEcalCondition::readEcalADCToGeVConstantFromFile | ( | const char * | inputFile | ) |
Definition at line 426 of file StoreEcalCondition.cc.
References lat::endl(), parsecf::pyparsing::line(), LogDebug, sm_constr_, and to_string().
Referenced by endJob().
00426 { 00427 //------------------------------------------------------------- 00428 00429 00430 FILE *inpFile; // input file 00431 inpFile = fopen(inputFile,"r"); 00432 if(!inpFile) { 00433 edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile; 00434 return 0; 00435 } 00436 00437 char line[256]; 00438 00439 std::ostringstream str; 00440 00441 fgets(line,255,inpFile); 00442 int sm_number=atoi(line); 00443 str << "sm= " << sm_number << endl ; 00444 00445 fgets(line,255,inpFile); 00446 //int nevents=atoi(line); // not necessary here just for online conddb 00447 00448 fgets(line,255,inpFile); 00449 string gen_tag=to_string(line); 00450 str << "gen tag " << gen_tag << endl ; // should I use this? 00451 00452 fgets(line,255,inpFile); 00453 string cali_method=to_string(line); 00454 str << "cali method " << cali_method << endl ; // not important 00455 00456 fgets(line,255,inpFile); 00457 string cali_version=to_string(line); 00458 str << "cali version " << cali_version << endl ; // not important 00459 00460 fgets(line,255,inpFile); 00461 string cali_type=to_string(line); 00462 str << "cali type " << cali_type << endl ; // not important 00463 00464 edm::LogInfo("StoreEcalCondition") << "ADCToGeV file " << str.str() ; 00465 00466 fgets(line,255,inpFile); 00467 float adc_to_gev=0; 00468 sscanf(line, "%f", &adc_to_gev ); 00469 LogDebug("StoreEcalCondition") <<" calib="<< adc_to_gev ; 00470 00471 fclose(inpFile); // close inp. file 00472 00473 sm_constr_ = sm_number; 00474 00475 // barrel and endcaps the same 00476 EcalADCToGeVConstant* agc = new EcalADCToGeVConstant(adc_to_gev,adc_to_gev ); 00477 edm::LogInfo("StoreEcalCondition") << "ADCtoGeV scale written into the DB"; 00478 return agc; 00479 }
EcalChannelStatus * StoreEcalCondition::readEcalChannelStatusFromFile | ( | const char * | inputFile | ) |
Definition at line 781 of file StoreEcalCondition.cc.
References comment, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), Exception, indexGen::ifile, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, parsecf::pyparsing::line(), EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalCondObjectContainer< T >::setValue(), StDecayID::status, EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validDetId(), and EBDetId::validDetId().
Referenced by endJob().
00782 { 00783 EcalChannelStatus* status = new EcalChannelStatus(); 00784 // barrel 00785 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) 00786 { 00787 if(ieta==0) continue; 00788 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) { 00789 if (EBDetId::validDetId(ieta,iphi)) { 00790 EBDetId ebid(ieta,iphi); 00791 status->setValue( ebid, 0 ); 00792 } 00793 } 00794 } 00795 // endcap 00796 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) 00797 { 00798 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) 00799 { 00800 // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals 00801 if (EEDetId::validDetId(iX,iY,1)) 00802 { 00803 EEDetId eedetidpos(iX,iY,1); 00804 status->setValue( eedetidpos, 0 ); 00805 } 00806 if (EEDetId::validDetId(iX,iY,-1)) 00807 { 00808 EEDetId eedetidneg(iX,iY,-1); 00809 status->setValue( eedetidneg, 0 ); 00810 } 00811 } 00812 } 00813 00814 00815 // edm::LogInfo("EcalTrivialConditionRetriever") << "Reading channel status from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ; 00816 std::cout << "Reading channel status from file " << inputFile << std::endl; 00817 FILE *ifile = fopen( inputFile ,"r" ); 00818 if ( !ifile ) 00819 throw cms::Exception ("Cannot open ECAL channel status file") ; 00820 00821 char line[256]; 00822 00823 fgets(line,255,ifile); 00824 std::string gen_tag= line; 00825 std::cout << "Gen tag " << gen_tag << std::endl ; 00826 00827 fgets(line,255,ifile); 00828 std::string comment = line ; 00829 std::cout << "Gen comment " << comment << std::endl ; 00830 00831 int iovRunStart(0); 00832 fgets(line,255,ifile); 00833 sscanf (line, "%d", &iovRunStart); 00834 std::cout << "IOV START " << iovRunStart << std::endl; 00835 //if -1 start of time 00836 00837 int iovRunEnd(0); 00838 fgets(line,255,ifile); 00839 sscanf (line, "%d", &iovRunEnd); 00840 std::cout << "IOV END " << iovRunEnd << std::endl; 00841 //if -1 end of time 00842 00843 int ii = 0; 00844 while(fgets(line,255,ifile)) 00845 { 00846 std::string EBorEE; 00847 int hashedIndex(0); 00848 int chStatus(0); 00849 std::stringstream aStrStream; 00850 aStrStream << line; 00851 aStrStream >> EBorEE >> hashedIndex >> chStatus; 00852 // if(ii==0) 00853 std::cout << EBorEE << " hashedIndex " << hashedIndex << " status " << chStatus << std::endl; 00854 00855 if (EBorEE == "EB") 00856 { 00857 EBDetId aEBDetId=EBDetId::unhashIndex(hashedIndex); 00858 status->setValue( aEBDetId, chStatus ); 00859 } 00860 else if (EBorEE == "EE") 00861 { 00862 EEDetId aEEDetId=EEDetId::unhashIndex(hashedIndex); 00863 status->setValue( aEEDetId, chStatus ); 00864 } 00865 00866 ii++ ; 00867 00868 } 00869 00870 fclose(ifile); 00871 return status; 00872 }
EcalGainRatios * StoreEcalCondition::readEcalGainRatiosFromFile | ( | const char * | inputFile | ) |
Definition at line 616 of file StoreEcalCondition.cc.
References GenMuonPlsPt100GeV_cfg::cout, dummy1, dummy2, lat::endl(), eta, EBDetId::ETAPHIMODE, i, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, parsecf::pyparsing::line(), phi, DetId::rawId(), EcalMGPAGainRatio::setGain12Over6(), EcalMGPAGainRatio::setGain6Over1(), EcalCondObjectContainer< T >::setValue(), sm_constr_, sm_slot_, EBDetId::SMCRYSTALMODE, to_string(), and EEDetId::validDetId().
Referenced by endJob().
00616 { 00617 //------------------------------------------------------------- 00618 00619 // create gain ratios 00620 EcalGainRatios* gratio = new EcalGainRatios; 00621 00622 00623 FILE *inpFile; // input file 00624 inpFile = fopen(inputFile,"r"); 00625 if(!inpFile) { 00626 edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile; 00627 return 0; 00628 } 00629 00630 char line[256]; 00631 std::ostringstream str; 00632 00633 fgets(line,255,inpFile); 00634 string sm_or_all=to_string(line); 00635 int sm_number=0; 00636 int nchan=1700; 00637 sm_number=atoi(line); 00638 str << "sm= " << sm_number << endl ; 00639 if(sm_number!=-1){ 00640 nchan=1700; 00641 } else { 00642 nchan=61200; 00643 } 00644 00645 fgets(line,255,inpFile); 00646 //int nevents=atoi(line); 00647 00648 fgets(line,255,inpFile); 00649 string gen_tag=to_string(line); 00650 str << "gen tag " << gen_tag << endl ; 00651 00652 fgets(line,255,inpFile); 00653 string cali_method=to_string(line); 00654 str << "cali method " << cali_method << endl ; 00655 00656 fgets(line,255,inpFile); 00657 string cali_version=to_string(line); 00658 str << "cali version " << cali_version << endl ; 00659 00660 00661 fgets(line,255,inpFile); 00662 string cali_type=to_string(line); 00663 00664 str << "cali type " << cali_type << endl ; 00665 00666 edm::LogInfo("StoreEcalCondition") << "GainRatio file " << str.str() ; 00667 00668 00669 00670 int cry_num[61200]={0}; 00671 float g1_g12[61200]={0}; 00672 float g6_g12[61200]={0}; 00673 int calib_status[61200]={0}; 00674 int dummy1=0; 00675 int dummy2=0; 00676 int hash1=0; 00677 00678 int ii = 0; 00679 00680 if(sm_number!=-1){ 00681 while(fgets(line,255,inpFile)) { 00682 sscanf(line, "%d %d %d %f %f %d", &dummy1, &dummy2, &cry_num[ii], &g1_g12[ii], &g6_g12[ii], &calib_status[ii] ); 00683 ii++ ; 00684 } 00685 00686 00687 fclose(inpFile); // close inp. file 00688 00689 00690 00691 edm::LogInfo("StoreEcalCondition") << "Read gainRatios for " << ii << " xtals " ; 00692 if(ii!=1700) edm::LogWarning("StoreEcalCondition") << " Missing crystals:: missing channels will be set to 0" << endl; 00693 00694 // Get channel ID 00695 sm_constr_ = sm_number; 00696 00697 for(int i=0; i<1700; i++){ 00698 // EBDetId(int index1, int index2, int mode = ETAPHIMODE) 00699 // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4 00700 EBDetId ebid(sm_slot_,cry_num[i],EBDetId::SMCRYSTALMODE); 00701 // cout << "ebid.rawId()"<< ebid.rawId()<< endl; 00702 EcalMGPAGainRatio gr; 00703 gr.setGain12Over6( g6_g12[i] ); 00704 gr.setGain6Over1(g1_g12[i]/g6_g12[i]); 00705 gratio->setValue( ebid.rawId(), gr ); 00706 } // loop over channels 00707 00708 00709 00710 00711 00712 00713 } else { 00714 // this is for the whole Barrel 00715 cout<<"mode ALL BARREL" <<endl; 00716 while(fgets(line,255,inpFile)) { 00717 int eta=0; 00718 int phi=0; 00719 sscanf(line, "%d %d %d %f %f",&hash1, &eta, &phi, &g1_g12[ii], &g6_g12[ii]); 00720 if(ii<20) cout<<"crystal eta/phi="<<eta<<"/"<<phi<<" g1_12/g6_12= "<< g1_g12[ii]<<"/"<<g6_g12[ii]<<endl; 00721 00722 if(g1_g12[ii]<9 || g1_g12[ii]>15 ) g1_g12[ii]=12.0; 00723 if(g6_g12[ii]<1 || g6_g12[ii]>3 ) g6_g12[ii]=2.0; 00724 00725 if(eta<-85|| eta>85 || eta==0) std::cout<<"error!!!"<<endl; 00726 if(phi<1 || phi>360) std::cout<<"error!!!"<<endl; 00727 00728 EBDetId ebid(eta, phi,EBDetId::ETAPHIMODE); 00729 EcalMGPAGainRatio gr; 00730 gr.setGain12Over6( g6_g12[ii] ); 00731 gr.setGain6Over1(g1_g12[ii]/g6_g12[ii]); 00732 gratio->setValue( ebid.rawId(), gr ); 00733 00734 ii++ ; 00735 } 00736 00737 fclose(inpFile); // close inp. file 00738 if(ii!=61200) edm::LogWarning("StoreEcalCondition") << " Missing crystals !!!!!!!" << endl; 00739 00740 std::cout<< "number of crystals read:"<<ii<<endl; 00741 00742 } 00743 00744 00745 00746 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) { 00747 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) { 00748 // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals 00749 EcalMGPAGainRatio gr; 00750 gr.setGain12Over6( 2. ); 00751 gr.setGain6Over1( 6. ); 00752 00753 00754 if (EEDetId::validDetId(iX,iY,1)) 00755 { 00756 EEDetId eedetidpos(iX,iY,1); 00757 gratio->setValue( eedetidpos.rawId(), gr ); 00758 } 00759 if (EEDetId::validDetId(iX,iY,-1)) 00760 { 00761 EEDetId eedetidneg(iX,iY,-1); 00762 gratio->setValue( eedetidneg.rawId(), gr ); 00763 } 00764 } 00765 } 00766 00767 00768 std::cout <<" gratio pointer="<<gratio<<endl; 00769 00770 00771 00772 std::cout<< "now leaving"<<endl; 00773 00774 00775 00776 return gratio; 00777 00778 }
EcalIntercalibConstants * StoreEcalCondition::readEcalIntercalibConstantsFromFile | ( | const char * | inputFile | ) |
Definition at line 484 of file StoreEcalCondition.cc.
References calib, convertFromConstructionSMToSlot(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), i, parsecf::pyparsing::line(), DetId::rawId(), EcalCondObjectContainer< T >::setValue(), sm_constr_, EBDetId::SMCRYSTALMODE, and to_string().
Referenced by endJob().
00484 { 00485 //------------------------------------------------------------- 00486 00487 EcalIntercalibConstants* ical = new EcalIntercalibConstants(); 00488 00489 00490 FILE *inpFile; // input file 00491 inpFile = fopen(inputFile,"r"); 00492 if(!inpFile) { 00493 edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile; 00494 return 0; 00495 } 00496 00497 char line[256]; 00498 00499 std::ostringstream str; 00500 00501 fgets(line,255,inpFile); 00502 string sm_or_all=to_string(line); 00503 int sm_number=0; 00504 int nchan=1700; 00505 sm_number=atoi(line); 00506 str << "sm= " << sm_number << endl ; 00507 if(sm_number!=-1){ 00508 nchan=1700; 00509 } else { 00510 nchan=61200; 00511 } 00512 00513 00514 fgets(line,255,inpFile); 00515 //int nevents=atoi(line); // not necessary here just for online conddb 00516 00517 fgets(line,255,inpFile); 00518 string gen_tag=to_string(line); 00519 str << "gen tag " << gen_tag << endl ; // should I use this? 00520 00521 fgets(line,255,inpFile); 00522 string cali_method=to_string(line); 00523 str << "cali method " << cali_method << endl ; // not important 00524 00525 fgets(line,255,inpFile); 00526 string cali_version=to_string(line); 00527 str << "cali version " << cali_version << endl ; // not important 00528 00529 fgets(line,255,inpFile); 00530 string cali_type=to_string(line); 00531 str << "cali type " << cali_type << endl ; // not important 00532 00533 edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str() ; 00534 00535 int sm_num[61200]={0}; 00536 int cry_num[61200]={0}; 00537 float calib[61200]={0}; 00538 float calib_rms[61200]={0}; 00539 int calib_nevents[61200]={0}; 00540 int calib_status[61200]={0}; 00541 00542 int ii = 0; 00543 if(sm_number!=-1){ 00544 while(fgets(line,255,inpFile)) { 00545 sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii] ); 00546 // if(ii<10) { // print out only the first ten channels 00547 // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl; 00548 // } 00549 sm_num[ii]=sm_number; 00550 ii++ ; 00551 } 00552 } else { 00553 // this is for the whole Barrel 00554 cout<<"mode ALL BARREL" <<endl; 00555 while(fgets(line,255,inpFile)) { 00556 sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii] ); 00557 if(ii==0) cout<<"crystal "<<cry_num[ii]<<" of sm "<<sm_num[ii]<<" cali= "<< calib[ii]<<endl; 00558 ii++ ; 00559 } 00560 } 00561 00562 // inf.close(); // close inp. file 00563 fclose(inpFile); // close inp. file 00564 00565 edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals " ; 00566 00567 cout << " I read the calibrations for "<< ii<< " crystals " << endl; 00568 if(ii!=nchan) edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0" << endl; 00569 00570 // Get channel ID 00571 00572 sm_constr_ = sm_number; 00573 00574 00575 // Set the data 00576 for(int i=0; i<nchan; i++){ 00577 00578 // EBDetId(int index1, int index2, int mode = ETAPHIMODE) 00579 // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4 00580 00581 int slot_num=convertFromConstructionSMToSlot(sm_num[i],-1); 00582 EBDetId ebid(slot_num,cry_num[i],EBDetId::SMCRYSTALMODE); 00583 00584 ical->setValue( ebid.rawId(), calib[i] ); 00585 00586 if(i==0) cout<<"crystal "<<cry_num[i]<<" of sm "<<sm_num[i]<< " in slot " <<slot_num<<" calib= "<< calib[i]<<endl; 00587 00588 } // loop over channels 00589 00590 cout<<"loop on channels done" << endl; 00591 return ical; 00592 }
EcalTBWeights * StoreEcalCondition::readEcalTBWeightsFromFile | ( | const char * | inputFile | ) |
Definition at line 280 of file StoreEcalCondition.cc.
References lat::endl(), EcalWeightSet::getChi2WeightsAfterGainSwitch(), EcalWeightSet::getChi2WeightsBeforeGainSwitch(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), i, j, k, LogDebug, EcalTBWeights::setValue(), sm_constr_, tbwgt, pyDBSRunClass::temp, and ww.
Referenced by endJob().
00280 { 00281 //------------------------------------------------------------- 00282 00283 // Zabi code to be written here 00284 00285 EcalTBWeights* tbwgt = new EcalTBWeights(); 00286 00287 std::ifstream WeightsFileTB(inputFile); 00288 if(!WeightsFileTB.is_open()) { 00289 edm::LogError("StoreEcalCondition")<< "*** Can not open file: "<< inputFile ; 00290 return 0; 00291 } 00292 00293 int smnumber=-99999; 00294 00295 std::ostringstream str; 00296 WeightsFileTB >> smnumber; 00297 if (smnumber == -99999) 00298 return 0; 00299 00300 str << "sm= " << smnumber << endl; 00301 00302 char temp[256]; 00303 //Reading the other 5 header lines containing various informations 00304 for (int i=0;i<=5;i++) 00305 { 00306 WeightsFileTB.getline(temp,255); 00307 str << temp << endl; 00308 } 00309 00310 edm::LogInfo("StoreEcalCondition") << "Weights file " << str.str() ; 00311 00312 int ngroups=0; 00313 while (WeightsFileTB.good()) 00314 { 00315 int igroup_ID = -99999; 00316 int nSamples = -99999; 00317 int nTdcBins = -99999; 00318 00319 WeightsFileTB >> igroup_ID >> nSamples >> nTdcBins; 00320 if (igroup_ID == -99999 || nSamples == -99999 || nTdcBins == -99999) 00321 break; 00322 00323 std::ostringstream str; 00324 str << "Igroup=" << igroup_ID << " Nsamples=" << nSamples << " NTdcBins=" << nTdcBins <<"\n" ; 00325 00326 for (int iTdcBin = 0; iTdcBin < nTdcBins; iTdcBin++) { 00327 00328 EcalWeightSet wgt; // one set of weights 00329 EcalWeightSet::EcalWeightMatrix& wgt1 = wgt.getWeightsBeforeGainSwitch(); 00330 EcalWeightSet::EcalWeightMatrix& wgt2 = wgt.getWeightsAfterGainSwitch(); 00331 EcalWeightSet::EcalChi2WeightMatrix& chisq1 = wgt.getChi2WeightsBeforeGainSwitch(); 00332 EcalWeightSet::EcalChi2WeightMatrix& chisq2 = wgt.getChi2WeightsAfterGainSwitch(); 00333 00334 // std::vector<EcalWeight> wamp, wped, wtime; //weights before gain switch 00335 // std::vector<EcalWeight> wamp2, wped2, wtime2; //weights after gain switch 00336 00337 //WEIGHTS BEFORE GAIN SWITCH 00338 //Amplitude weights 00339 for(int j = 0; j < nSamples; ++j) { 00340 double ww = 0.0; WeightsFileTB >> ww; 00341 wgt1(0,j)=ww; 00342 str << ww << " "; 00343 }// loop Samples 00344 str << std::endl; 00345 00346 //Pedestal weights 00347 for(int j = 0; j < nSamples; ++j) { 00348 double ww = 0.0; WeightsFileTB >> ww; 00349 wgt1(1,j)=ww; 00350 str << ww << " "; 00351 }//loop Samples 00352 str << std::endl; 00353 00354 //Timing weights 00355 for(int j = 0; j < nSamples; ++j) { 00356 double ww = 0.0; WeightsFileTB >> ww; 00357 wgt1(2,j)=ww; 00358 str << ww << " "; 00359 }//loop Samples 00360 str << std::endl; 00361 00362 for(int j = 0; j < nSamples; ++j) { 00363 // fill chi2 matrix 00364 //std::vector<EcalWeight> vChi2; // row of chi2 matrix 00365 for(int k = 0; k < nSamples; ++k) { 00366 double ww = 0.0; WeightsFileTB >> ww; 00367 chisq1(j,k)=ww; 00368 str << ww << " "; 00369 } //loop samples 00370 str << std::endl; 00371 }//loop lines 00372 00373 //WEIGHTS AFTER GAIN SWITCH 00374 for(int j = 0; j < nSamples; ++j) { 00375 double ww = 0.0; WeightsFileTB >> ww; 00376 wgt2(0,j)=ww; 00377 str << ww << " "; 00378 }// loop Samples 00379 str << std::endl; 00380 00381 //Pedestal weights 00382 for(int j = 0; j < nSamples; ++j) { 00383 double ww = 0.0; WeightsFileTB >> ww; 00384 wgt2(1,j)=ww; 00385 str << ww << " "; 00386 }//loop Samples 00387 str << std::endl; 00388 00389 //Timing weights 00390 for(int j = 0; j < nSamples; ++j) { 00391 double ww = 0.0; WeightsFileTB >> ww; 00392 wgt2(2,j)=ww; 00393 str << ww << " "; 00394 }//loop Samples 00395 str << std::endl; 00396 00397 for(int j = 0; j < nSamples; ++j) { 00398 // fill chi2 matrix 00399 //std::vector<EcalWeight> vChi2; // row of chi2 matrix 00400 for(int k = 0; k < nSamples; ++k) { 00401 double ww = 0.0; WeightsFileTB >> ww; 00402 chisq2(j,k)=ww; 00403 str << ww << " "; 00404 } //loop samples 00405 str << std::endl; 00406 }//loop lines 00407 00408 LogDebug("StoreEcalCondition") << str.str(); 00409 00410 //modif-27-07-06 tdcid should start from 1 00411 tbwgt->setValue(std::make_pair( igroup_ID , iTdcBin+1 ), wgt); 00412 }//loop Tdc bins 00413 ngroups++; 00414 }//loop groupID 00415 00416 sm_constr_ = smnumber; 00417 00418 00419 edm::LogInfo("StoreEcalCondition") << "Weights for " << ngroups << " groups written into DB" ; 00420 return tbwgt; 00421 }
EcalWeightXtalGroups * StoreEcalCondition::readEcalWeightXtalGroupsFromFile | ( | const char * | inputFile | ) |
Definition at line 214 of file StoreEcalCondition.cc.
References lat::endl(), i, LogDebug, DetId::rawId(), EcalCondObjectContainer< T >::setValue(), sm_constr_, sm_slot_, EBDetId::SMCRYSTALMODE, and pyDBSRunClass::temp.
Referenced by endJob().
00214 { 00215 //------------------------------------------------------------- 00216 00217 // Code taken from EcalWeightTools/test/MakeOfflineDbFromAscii.cpp 00218 00219 EcalWeightXtalGroups* xtalGroups = new EcalWeightXtalGroups(); 00220 std::ifstream groupid_in(inputFile); 00221 00222 if(!groupid_in.is_open()) { 00223 edm::LogError("StoreEcalCondition")<< "*** Can not open file: "<< inputFile ; 00224 return 0; 00225 } 00226 00227 int smnumber=-99999; 00228 00229 std::ostringstream str; 00230 groupid_in >> smnumber; 00231 if (smnumber == -99999) { 00232 edm::LogError("StoreEcalCondition") << "ERROR: SM number not found in file" << endl; 00233 return 0; 00234 } 00235 str << "sm= " << smnumber << endl; 00236 sm_constr_ = smnumber; 00237 00238 char temp[256]; 00239 //Reading the other 5 header lines containing various informations 00240 for (int i=0;i<=5;i++) { 00241 groupid_in.getline(temp,255); 00242 str << temp << endl; 00243 } 00244 00245 // Skip the nGroup/Mean line 00246 groupid_in.getline(temp, 255); 00247 str << temp << endl; 00248 00249 edm::LogInfo("StoreEcalCondition") << "GROUPID file " << str.str() ; 00250 00251 int xtals = 0; 00252 int xtal, ietaf, iphif, groupID; 00253 while (groupid_in.good()) { 00254 groupid_in >> xtal >> ietaf >> iphif >> groupID; 00255 if (groupid_in.eof()) { break; } 00256 00257 LogDebug("StoreEcalCondition") << "XTAL=" << xtal << " ETA=" << ietaf << " PHI=" << iphif 00258 << " GROUP=" << groupID ; 00259 00260 //EBDetId ebid(ieta,iphi); 00261 EBDetId ebid(sm_slot_,xtal,EBDetId::SMCRYSTALMODE); 00262 // xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( ebid.hashedIndex()) ); 00263 xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( groupID ) ); 00264 xtals++; 00265 }//loop iphi 00266 00267 if (xtals != 1700) { 00268 edm::LogError("StoreEcalCondition") << "ERROR: GROUPID file did not contain data for 1700 crystals" << endl; 00269 return 0; 00270 } 00271 00272 edm::LogInfo("StoreEcalCondition") << "Groups for " << xtals << " xtals written into DB" ; 00273 sm_constr_ = smnumber; 00274 00275 return xtalGroups; 00276 }
std::string StoreEcalCondition::to_string | ( | char | value[] | ) | [inline, private] |
Definition at line 70 of file StoreEcalCondition.h.
Referenced by readEcalADCToGeVConstantFromFile(), readEcalGainRatiosFromFile(), and readEcalIntercalibConstantsFromFile().
00070 { 00071 std::ostringstream streamOut; 00072 streamOut << value; 00073 return streamOut.str(); 00074 }
void StoreEcalCondition::writeToLogFile | ( | string | a, | |
string | b, | |||
unsigned long long | since | |||
) |
Definition at line 129 of file StoreEcalCondition.cc.
References fillHeader(), header, int, logfile_, sm_constr_, and sm_slot_.
00129 { 00130 //------------------------------------------------------------- 00131 00132 FILE *outFile; // output log file for appending 00133 outFile = fopen(logfile_.c_str(),"a"); 00134 if(!outFile) { 00135 edm::LogError("StoreEcalCondition") <<"*** Can not open file: " << logfile_; 00136 return; 00137 } 00138 char header[256]; 00139 fillHeader(header); 00140 char appendMode[10]; 00141 if (since != 0) 00142 sprintf(appendMode,"append"); 00143 else 00144 sprintf(appendMode,"create"); 00145 00146 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", 00147 header, a.c_str(),b .c_str(), sm_constr_, sm_slot_, appendMode, (unsigned int)since); 00148 00149 fclose(outFile); // close out file 00150 00151 }
void StoreEcalCondition::writeToLogFileResults | ( | char * | arg | ) |
Definition at line 153 of file StoreEcalCondition.cc.
References fillHeader(), header, and logfile_.
Referenced by endJob().
00153 { 00154 //------------------------------------------------------------- 00155 00156 FILE *outFile; // output log file for appending 00157 outFile = fopen(logfile_.c_str(),"a"); 00158 if(!outFile) { 00159 edm::LogError("StoreEcalCondition")<<"*** Can not open file: " << logfile_; 00160 return; 00161 } 00162 char header[256]; 00163 fillHeader(header); 00164 fprintf(outFile, "%s %s\n", header,arg); 00165 fclose(outFile); // close out file 00166 }
std::vector< std::string > StoreEcalCondition::inpFileName_ [private] |
Definition at line 63 of file StoreEcalCondition.h.
Referenced by endJob(), and StoreEcalCondition().
std::string StoreEcalCondition::logfile_ [private] |
Definition at line 68 of file StoreEcalCondition.h.
Referenced by StoreEcalCondition(), writeToLogFile(), and writeToLogFileResults().
std::vector< std::string > StoreEcalCondition::objectName_ [private] |
Definition at line 61 of file StoreEcalCondition.h.
Referenced by endJob(), and StoreEcalCondition().
std::string StoreEcalCondition::prog_name_ [private] |
std::vector< unsigned long long > StoreEcalCondition::since_ [private] |
int StoreEcalCondition::sm_constr_ [private] |
Definition at line 65 of file StoreEcalCondition.h.
Referenced by readEcalADCToGeVConstantFromFile(), readEcalGainRatiosFromFile(), readEcalIntercalibConstantsFromFile(), readEcalTBWeightsFromFile(), readEcalWeightXtalGroupsFromFile(), StoreEcalCondition(), and writeToLogFile().
int StoreEcalCondition::sm_slot_ [private] |
Definition at line 66 of file StoreEcalCondition.h.
Referenced by readEcalGainRatiosFromFile(), readEcalWeightXtalGroupsFromFile(), StoreEcalCondition(), and writeToLogFile().