CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CondTools/Ecal/plugins/StoreEcalCondition.cc

Go to the documentation of this file.
00001 #include "CondTools/Ecal/plugins/StoreEcalCondition.h"
00002 
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "CondCore/DBCommon/interface/Time.h"
00007 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 
00010 #include <fstream>
00011 #include <iostream>
00012 #include <string>
00013 #include <cstring>
00014 #include <time.h>
00015 #include <unistd.h> 
00016 
00017 using std::string;
00018 using std::cout;
00019 using std::endl;
00020 
00021 StoreEcalCondition::StoreEcalCondition(const edm::ParameterSet& iConfig) {
00022 
00023   prog_name_ = "StoreEcalCondition";
00024 
00025   logfile_ = iConfig.getParameter< std::string >("logfile");
00026   sm_slot_ = iConfig.getUntrackedParameter< unsigned int >("smSlot", 1);
00027 
00028   typedef std::vector< edm::ParameterSet > Parameters;
00029   Parameters toPut=iConfig.getParameter<Parameters>("toPut");
00030   for(Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut) 
00031     {
00032       inpFileName_.push_back(itToPut->getUntrackedParameter<std::string>("inputFile"));
00033       inpFileNameEE_.push_back(itToPut->getUntrackedParameter<std::string>("inputFileEE"));
00034       objectName_.push_back(itToPut->getUntrackedParameter<std::string>("conditionType"));
00035       since_.push_back(itToPut->getUntrackedParameter<unsigned int>("since"));
00036     }
00037 
00038   sm_constr_ = -1;
00039 }
00040 
00041 void StoreEcalCondition::endJob() {
00042   
00043   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00044   if( !mydbservice.isAvailable() ){
00045     edm::LogError("StoreEcalCondition")<<"PoolDBOutputService is unavailable"<<std::endl;
00046     return;
00047   }
00048 
00049   bool toAppend=false;
00050   // copy a string to the char *
00051   std::string message = "finished OK\n";
00052   size_t messageSize = message.size() + 1;
00053   char * messChar = new char [messageSize];
00054   strncpy(messChar, message.c_str(), messageSize);
00055       
00056   for (unsigned int i=0;i<objectName_.size();i++) {
00057       cond::Time_t newTime;
00058       
00059       if ( mydbservice->isNewTagRequest( objectName_[i]+std::string("Rcd") ) ) {
00060         // This is the first object for this tag.
00061         // Append mode should be off.
00062         // newTime is the end of this new objects IOV.
00063         newTime = mydbservice->beginOfTime();
00064       } else {
00065         // There should already be an object in the DB for this tag.
00066         // Append IOV mode should be on.
00067         // newTime is the beginning of this new objects IOV.
00068         toAppend=true;
00069         newTime = (cond::Time_t)since_[i];
00070       }
00071       edm::LogInfo("StoreEcalCondition") << "Reading " << objectName_[i] 
00072                                          << " from file and writing to DB with newTime " << newTime << endl;
00073       std::cout << "Reading " << objectName_[i] 
00074                                          << " from file and writing to DB with newTime " << newTime << endl;
00075       
00076       if (objectName_[i] == "EcalWeightXtalGroups") {
00077         EcalWeightXtalGroups* mycali = readEcalWeightXtalGroupsFromFile(inpFileName_[i].c_str());
00078         if(!toAppend){
00079           mydbservice->createNewIOV<EcalWeightXtalGroups>(mycali,newTime,mydbservice->endOfTime(),"EcalWeightXtalGroupsRcd");
00080         }else{
00081           mydbservice->appendSinceTime<EcalWeightXtalGroups>(mycali,newTime,"EcalWeightXtalGroupsRcd");
00082         }
00083       }else if (objectName_[i]  =="EcalTBWeights") {
00084         EcalTBWeights* mycali=readEcalTBWeightsFromFile(inpFileName_[i].c_str());
00085         if(!toAppend){
00086           mydbservice->createNewIOV<EcalTBWeights>(mycali,newTime,mydbservice->endOfTime(),"EcalTBWeightsRcd");
00087         }else{
00088           mydbservice->appendSinceTime<EcalTBWeights>(mycali,newTime,"EcalTBWeightsRcd");
00089         }
00090       } else if (objectName_[i]  == "EcalADCToGeVConstant") {
00091         EcalADCToGeVConstant* mycali=readEcalADCToGeVConstantFromFile(inpFileName_[i].c_str());
00092         if(!toAppend){
00093           mydbservice->createNewIOV<EcalADCToGeVConstant>(mycali,newTime,mydbservice->endOfTime(),"EcalADCToGeVConstantRcd");
00094         }else{
00095           mydbservice->appendSinceTime<EcalADCToGeVConstant>(mycali,newTime,"EcalADCToGeVConstantRcd");
00096         }
00097       } else if (objectName_[i]  ==  "EcalIntercalibConstants") {
00098         EcalIntercalibConstants* mycali=readEcalIntercalibConstantsFromFile(inpFileName_[i].c_str(),inpFileNameEE_[i].c_str());
00099         if(!toAppend){
00100           mydbservice->createNewIOV<EcalIntercalibConstants>(mycali,newTime,mydbservice->endOfTime(),"EcalIntercalibConstantsRcd");
00101         }else{
00102           mydbservice->appendSinceTime<EcalIntercalibConstants>(mycali,newTime,"EcalIntercalibConstantsRcd");
00103         }
00104       } else if (objectName_[i]  ==  "EcalIntercalibConstantsMC") {
00105         EcalIntercalibConstantsMC* mycali=readEcalIntercalibConstantsMCFromFile(inpFileName_[i].c_str(),inpFileNameEE_[i].c_str());
00106         if(!toAppend){
00107           mydbservice->createNewIOV<EcalIntercalibConstantsMC>(mycali,newTime,mydbservice->endOfTime(),"EcalIntercalibConstantsMCRcd");
00108         }else{
00109           mydbservice->appendSinceTime<EcalIntercalibConstantsMC>(mycali,newTime,"EcalIntercalibConstantsMCRcd");
00110         }
00111       } else if (objectName_[i]  ==  "EcalGainRatios") {
00112         EcalGainRatios* mycali=readEcalGainRatiosFromFile(inpFileName_[i].c_str());
00113         if(!toAppend){
00114           mydbservice->createNewIOV<EcalGainRatios>(mycali,newTime,mydbservice->endOfTime(),"EcalGainRatiosRcd");
00115         }else{
00116           mydbservice->appendSinceTime<EcalGainRatios>(mycali,newTime,"EcalGainRatiosRcd");
00117         }
00118       } else if (objectName_[i]  ==  "EcalChannelStatus") 
00119         {
00120           EcalChannelStatus* mycali=readEcalChannelStatusFromFile(inpFileName_[i].c_str());
00121           if(!toAppend){
00122             mydbservice->createNewIOV<EcalChannelStatus>(mycali,newTime,mydbservice->endOfTime(),"EcalChannelStatusRcd");
00123           }else{
00124             mydbservice->appendSinceTime<EcalChannelStatus>(mycali,newTime,"EcalChannelStatusRcd");
00125           } 
00126         } else {
00127         edm::LogError("StoreEcalCondition")<< "Object " << objectName_[i]  << " is not supported by this program." << endl;
00128       }
00129       
00130 
00131       //      writeToLogFile(objectName_[i], inpFileName_[i], since_[i]);
00132       //writeToLogFileResults("finished OK\n");
00133       writeToLogFileResults(messChar);
00134    
00135       edm::LogInfo("StoreEcalCondition") << "Finished endJob" << endl;
00136   }
00137   
00138   delete [] messChar;
00139 }
00140 
00141 
00142 StoreEcalCondition::~StoreEcalCondition() {
00143 
00144 }
00145 
00146 //-------------------------------------------------------------
00147 void StoreEcalCondition::analyze( const edm::Event& evt, const edm::EventSetup& evtSetup) {
00148 //-------------------------------------------------------------
00149 
00150 }
00151 
00152 
00153 //------------------------------------------------------------
00154 void StoreEcalCondition::writeToLogFile(string a, string b, unsigned long long since) {
00155 //-------------------------------------------------------------
00156   
00157     FILE *outFile; // output log file for appending 
00158     outFile = fopen(logfile_.c_str(),"a");  
00159     if(!outFile) {
00160       edm::LogError("StoreEcalCondition") <<"*** Can not open file: " << logfile_;
00161       return;
00162     }
00163     char header[256];
00164     fillHeader(header);
00165     char appendMode[10];
00166     if (since != 0)
00167       sprintf(appendMode,"append");
00168     else
00169       sprintf(appendMode,"create");
00170 
00171     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", 
00172             header, a.c_str(),b .c_str(), sm_constr_, sm_slot_, appendMode, (unsigned int)since);
00173 
00174     fclose(outFile);           // close out file
00175 
00176 }
00177 //------------------------------------------------------------
00178 void StoreEcalCondition::writeToLogFileResults(char* arg) {
00179 //-------------------------------------------------------------
00180   
00181     FILE *outFile; // output log file for appending 
00182     outFile = fopen(logfile_.c_str(),"a");  
00183     if(!outFile) {
00184       edm::LogError("StoreEcalCondition")<<"*** Can not open file: " << logfile_;
00185       return;
00186     }
00187     char header[256];
00188     fillHeader(header);
00189     fprintf(outFile, "%s %s\n", header,arg);
00190     fclose(outFile);           // close out file
00191 }
00192 
00193 //------------------------------------------------------------
00194 void StoreEcalCondition::fillHeader(char* header)
00195 //------------------------------------------------------------
00196 {
00197   time_t rawtime;
00198   struct tm * timeinfo;
00199   time ( &rawtime );
00200   timeinfo = localtime ( &rawtime );
00201   char user[50];
00202   sprintf(user,"%s",getlogin());
00203   sprintf(header,"%s %s:",asctime(timeinfo),user);
00204 }
00205 
00206 /*
00207  * Format for ASCII groups & weights file
00208  * Updated by Alex Zabi Imperial College
00209  * 03/07/06: implementing final weights format
00210  * Accepted format:
00211  * groupId nSamples nTDCbins (introductory line)
00212  *  and then nTDCbins x (3 + nSamples) lines of nSamples numbers containing
00213  *  For TDCbin1
00214  *  gain 12 weights (before gain switch)
00215  *  ===========================================
00216  *  ampWeight[0] ampWeight[1] .............                           |
00217  *  pedWeight[0] pedWeight[1] .............                           |
00218  *  jitWeight[0] jitWeight[1] .............                           |
00219  *  chi2Matri[0][0] chi2Matrix[0][1] ..........                       |
00220  *  chi2Matrix[1][0] chi2Matrix[1][1] ..........                      |
00221  *   .....                                                            |
00222  *  chi2Matrix[nsamples-1][0] chi2Matrix[nsamples-1][1] ..........    |
00223  *  gain 6 and 1 weights (after gain switch)
00224  *  ===========================================
00225  *  ampWeight[0] ampWeight[1] .............                           |
00226  *  pedWeight[0] pedWeight[1] .............                           |
00227  *  jitWeight[0] jitWeight[1] .............                           |
00228  *  chi2Matri[0][0] chi2Matrix[0][1] ..........                       |
00229  *  chi2Matrix[1][0] chi2Matrix[1][1] ..........                      |
00230  *   .....                                                            |
00231  *  chi2Matrix[nsamples-1][0] chi2Matrix[nsamples-1][1] ..........    |
00232  *  ===========================================
00233  *  For TDCbin nTDCBins
00234  *  ............
00235  */
00236 
00237 //-------------------------------------------------------------
00238 EcalWeightXtalGroups*
00239 StoreEcalCondition::readEcalWeightXtalGroupsFromFile(const char* inputFile) {
00240 //-------------------------------------------------------------
00241 
00242 // Code taken from EcalWeightTools/test/MakeOfflineDbFromAscii.cpp
00243 
00244   EcalWeightXtalGroups* xtalGroups = new EcalWeightXtalGroups();
00245   std::ifstream groupid_in(inputFile);
00246 
00247   if(!groupid_in.is_open()) {
00248     edm::LogError("StoreEcalCondition")<< "*** Can not open file: "<< inputFile ;
00249     return 0;
00250   }  
00251 
00252   int smnumber=-99999;
00253 
00254   std::ostringstream str;
00255   groupid_in >> smnumber;
00256   if (smnumber == -99999) {
00257     edm::LogError("StoreEcalCondition") << "ERROR: SM number not found in file" << endl;
00258     return 0;
00259   }
00260   str << "sm= " << smnumber << endl;
00261   sm_constr_ = smnumber;
00262 
00263   char temp[256];
00264   //Reading the other 5 header lines containing various informations
00265   for (int i=0;i<=5;i++) {
00266     groupid_in.getline(temp,255);
00267     str << temp << endl;
00268   }
00269 
00270   // Skip the nGroup/Mean line
00271   groupid_in.getline(temp, 255);
00272   str << temp << endl;
00273 
00274   edm::LogInfo("StoreEcalCondition") << "GROUPID file " << str.str() ;
00275 
00276   int xtals = 0;
00277   int xtal, ietaf, iphif, groupID;
00278   while (groupid_in.good()) {
00279     groupid_in >> xtal >> ietaf >> iphif >> groupID;
00280     if (groupid_in.eof()) { break; }
00281     
00282     LogDebug("StoreEcalCondition") << "XTAL=" << xtal << " ETA=" << ietaf << " PHI=" << iphif 
00283                                        << " GROUP=" << groupID ;
00284 
00285     //EBDetId ebid(ieta,iphi);  
00286     EBDetId ebid(sm_slot_,xtal,EBDetId::SMCRYSTALMODE); 
00287     // xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( ebid.hashedIndex()) );
00288     xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( groupID ) );
00289     xtals++;
00290   }//loop iphi
00291 
00292   if (xtals != 1700) {
00293     edm::LogError("StoreEcalCondition") << "ERROR:  GROUPID file did not contain data for 1700 crystals" << endl;
00294     return 0;
00295   }
00296   
00297   edm::LogInfo("StoreEcalCondition") << "Groups for " << xtals << " xtals written into DB" ;
00298   sm_constr_ = smnumber;
00299   
00300   return xtalGroups;
00301 }
00302 
00303 //-------------------------------------------------------------
00304 EcalTBWeights*
00305 StoreEcalCondition::readEcalTBWeightsFromFile(const char* inputFile) {
00306   //-------------------------------------------------------------
00307   
00308   // Zabi code to be written here 
00309   
00310   EcalTBWeights* tbwgt = new EcalTBWeights();
00311   
00312   std::ifstream WeightsFileTB(inputFile);
00313   if(!WeightsFileTB.is_open()) {
00314     edm::LogError("StoreEcalCondition")<< "*** Can not open file: "<< inputFile ;
00315     return 0;
00316   }
00317 
00318   int smnumber=-99999;
00319 
00320   std::ostringstream str;
00321   WeightsFileTB >> smnumber;
00322   if (smnumber == -99999)
00323     return 0;
00324 
00325   str << "sm= " << smnumber << endl;
00326 
00327   char temp[256];
00328   //Reading the other 5 header lines containing various informations
00329   for (int i=0;i<=5;i++)
00330     {
00331       WeightsFileTB.getline(temp,255);
00332       str << temp << endl;
00333     }
00334 
00335   edm::LogInfo("StoreEcalCondition") << "Weights file " << str.str() ;
00336 
00337   int ngroups=0;
00338   while (WeightsFileTB.good())
00339     {
00340       int igroup_ID = -99999;
00341       int nSamples  = -99999;
00342       int nTdcBins  = -99999;
00343       
00344       WeightsFileTB >> igroup_ID >> nSamples >> nTdcBins;
00345       if (igroup_ID == -99999 || nSamples == -99999 || nTdcBins == -99999)
00346         break;
00347       
00348       std::ostringstream str;
00349       str << "Igroup=" << igroup_ID << " Nsamples=" << nSamples << " NTdcBins=" << nTdcBins <<"\n" ;
00350       
00351       for (int iTdcBin = 0; iTdcBin < nTdcBins; iTdcBin++) {
00352         
00353         EcalWeightSet wgt; // one set of weights
00354         EcalWeightSet::EcalWeightMatrix& wgt1   = wgt.getWeightsBeforeGainSwitch();
00355         EcalWeightSet::EcalWeightMatrix& wgt2   = wgt.getWeightsAfterGainSwitch();      
00356         EcalWeightSet::EcalChi2WeightMatrix& chisq1 = wgt.getChi2WeightsBeforeGainSwitch();
00357         EcalWeightSet::EcalChi2WeightMatrix& chisq2 = wgt.getChi2WeightsAfterGainSwitch();
00358         
00359 //      std::vector<EcalWeight> wamp, wped, wtime; //weights before gain switch
00360 //      std::vector<EcalWeight> wamp2, wped2, wtime2; //weights after gain switch
00361         
00362         //WEIGHTS BEFORE GAIN SWITCH
00363         //Amplitude weights 
00364         for(int j = 0; j < nSamples; ++j) {
00365           double ww = 0.0; WeightsFileTB >> ww;
00366           wgt1(0,j)=ww;
00367           str << ww << " ";
00368         }// loop Samples
00369         str << std::endl;
00370         
00371         //Pedestal weights
00372         for(int j = 0; j < nSamples; ++j) {
00373           double ww = 0.0; WeightsFileTB >> ww;
00374           wgt1(1,j)=ww;
00375           str << ww << " ";
00376         }//loop Samples
00377         str << std::endl;
00378         
00379         //Timing weights
00380         for(int j = 0; j < nSamples; ++j) {
00381           double ww = 0.0; WeightsFileTB >> ww;
00382           wgt1(2,j)=ww;
00383           str << ww << " ";
00384         }//loop Samples
00385         str << std::endl;
00386         
00387         for(int j = 0; j < nSamples; ++j) {
00388           // fill chi2 matrix
00389           //std::vector<EcalWeight> vChi2; // row of chi2 matrix
00390           for(int k = 0; k < nSamples; ++k) {
00391             double ww = 0.0; WeightsFileTB >> ww;
00392             chisq1(j,k)=ww;
00393             str << ww << " ";
00394           } //loop samples
00395           str << std::endl;
00396         }//loop lines
00397         
00398         //WEIGHTS AFTER GAIN SWITCH
00399         for(int j = 0; j < nSamples; ++j) {
00400           double ww = 0.0; WeightsFileTB >> ww;
00401           wgt2(0,j)=ww;
00402           str << ww << " ";
00403         }// loop Samples
00404         str << std::endl;
00405         
00406         //Pedestal weights
00407         for(int j = 0; j < nSamples; ++j) {
00408           double ww = 0.0; WeightsFileTB >> ww;
00409           wgt2(1,j)=ww;
00410           str << ww << " ";
00411         }//loop Samples
00412         str << std::endl;
00413         
00414         //Timing weights
00415         for(int j = 0; j < nSamples; ++j) {
00416           double ww = 0.0; WeightsFileTB >> ww;
00417           wgt2(2,j)=ww;
00418           str << ww << " ";
00419         }//loop Samples
00420         str << std::endl;
00421         
00422         for(int j = 0; j < nSamples; ++j) {
00423           // fill chi2 matrix
00424           //std::vector<EcalWeight> vChi2; // row of chi2 matrix
00425           for(int k = 0; k < nSamples; ++k) {
00426             double ww = 0.0; WeightsFileTB >> ww;
00427             chisq2(j,k)=ww;
00428             str << ww << " ";
00429           } //loop samples
00430           str << std::endl;
00431         }//loop lines
00432 
00433         LogDebug("StoreEcalCondition") << str.str();
00434       
00435         //modif-27-07-06 tdcid should start from 1
00436         tbwgt->setValue(std::make_pair( igroup_ID , iTdcBin+1 ), wgt);
00437       }//loop Tdc bins
00438       ngroups++;
00439     }//loop groupID
00440 
00441   sm_constr_ = smnumber;
00442 
00443 
00444   edm::LogInfo("StoreEcalCondition") << "Weights for " << ngroups << " groups written into DB" ;
00445   return tbwgt;
00446 }
00447 
00448 
00449 //-------------------------------------------------------------
00450 EcalADCToGeVConstant*
00451 StoreEcalCondition::readEcalADCToGeVConstantFromFile(const char* inputFile) {
00452 //-------------------------------------------------------------
00453   
00454     
00455     FILE *inpFile; // input file
00456     inpFile = fopen(inputFile,"r");
00457     if(!inpFile) {
00458       edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
00459       return 0;
00460     }
00461 
00462     char line[256];
00463     
00464     std::ostringstream str;
00465 
00466     fgets(line,255,inpFile);
00467     int sm_number=atoi(line);
00468     str << "sm= " << sm_number << endl ;  
00469 
00470     fgets(line,255,inpFile);
00471     //int nevents=atoi(line); // not necessary here just for online conddb
00472     
00473     fgets(line,255,inpFile);
00474     string gen_tag=to_string(line);
00475     str << "gen tag " << gen_tag << endl ;  // should I use this? 
00476 
00477     fgets(line,255,inpFile);
00478     string cali_method=to_string(line);
00479     str << "cali method " << cali_method << endl ; // not important 
00480 
00481     fgets(line,255,inpFile);
00482     string cali_version=to_string(line);
00483     str << "cali version " << cali_version << endl ; // not important 
00484 
00485     fgets(line,255,inpFile);
00486     string cali_type=to_string(line);
00487     str << "cali type " << cali_type << endl ; // not important
00488 
00489     edm::LogInfo("StoreEcalCondition") << "ADCToGeV file " << str.str() ;
00490 
00491     fgets(line,255,inpFile);
00492     float adc_to_gev=0;
00493     sscanf(line, "%f", &adc_to_gev );
00494     LogDebug("StoreEcalCondition") <<" calib="<< adc_to_gev ;
00495     fgets(line,255,inpFile);
00496     float adc_to_gev_ee=0;
00497     sscanf(line, "%f", &adc_to_gev_ee );
00498     LogDebug("StoreEcalCondition") <<" calib="<< adc_to_gev_ee ;
00499     
00500     fclose(inpFile);           // close inp. file
00501 
00502     sm_constr_ = sm_number;
00503 
00504     // barrel and endcaps the same 
00505     EcalADCToGeVConstant* agc = new EcalADCToGeVConstant(adc_to_gev,adc_to_gev_ee );
00506     edm::LogInfo("StoreEcalCondition") << "ADCtoGeV scale written into the DB";
00507     return agc;
00508 }
00509 
00510 
00511 //-------------------------------------------------------------
00512 EcalIntercalibConstants*
00513 StoreEcalCondition::readEcalIntercalibConstantsFromFile(const char* inputFile,const char* inputFileEE) {
00514 //-------------------------------------------------------------
00515 
00516   EcalIntercalibConstants* ical = new EcalIntercalibConstants();
00517 
00518     
00519     FILE *inpFile; // input file
00520     inpFile = fopen(inputFile,"r");
00521     if(!inpFile) {
00522       edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
00523       return 0;
00524     }
00525 
00526     char line[256];
00527  
00528     std::ostringstream str;
00529 
00530     fgets(line,255,inpFile);
00531     string sm_or_all=to_string(line);
00532     int sm_number=0;
00533     int nchan=1700;
00534     sm_number=atoi(line);
00535     str << "sm= " << sm_number << endl ;  
00536     if(sm_number!=-1){
00537       nchan=1700;
00538     } else {
00539       nchan=61200;
00540     }
00541     
00542 
00543     fgets(line,255,inpFile);
00544     //int nevents=atoi(line); // not necessary here just for online conddb
00545     
00546     fgets(line,255,inpFile);
00547     string gen_tag=to_string(line);
00548     str << "gen tag " << gen_tag << endl ;  // should I use this? 
00549 
00550     fgets(line,255,inpFile);
00551     string cali_method=to_string(line);
00552     str << "cali method " << cali_method << endl ; // not important 
00553 
00554     fgets(line,255,inpFile);
00555     string cali_version=to_string(line);
00556     str << "cali version " << cali_version << endl ; // not important 
00557 
00558     fgets(line,255,inpFile);
00559     string cali_type=to_string(line);
00560     str << "cali type " << cali_type << endl ; // not important
00561 
00562     edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str() ;
00563 
00564     int sm_num[61200]={0};
00565     int cry_num[61200]={0};
00566     float calib[61200]={0};
00567     float calib_rms[61200]={0};
00568     int calib_nevents[61200]={0};
00569     int calib_status[61200]={0};
00570 
00571     int ii = 0;
00572     if(sm_number!=-1){
00573       while(fgets(line,255,inpFile)) {
00574         sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii] );
00575 //       if(ii<10) { // print out only the first ten channels 
00576 //      cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
00577 //       }
00578         sm_num[ii]=sm_number;
00579         ii++ ;
00580       }
00581     } else {
00582       // this is for the whole Barrel 
00583       cout<<"mode ALL BARREL" <<endl; 
00584       while(fgets(line,255,inpFile)) {
00585         sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii] );
00586         if(ii==0) cout<<"crystal "<<cry_num[ii]<<" of sm "<<sm_num[ii]<<" cali= "<< calib[ii]<<endl;
00587         ii++ ;
00588       }
00589     }
00590 
00591     //    inf.close();           // close inp. file
00592     fclose(inpFile);           // close inp. file
00593 
00594     edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals " ; 
00595 
00596     cout << " I read the calibrations for "<< ii<< " crystals " << endl;
00597     if(ii!=nchan) edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0" << endl;
00598 
00599     // Get channel ID 
00600     
00601     sm_constr_ = sm_number;
00602 
00603 
00604     // Set the data
00605     for(int i=0; i<nchan; i++){
00606     
00607     // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
00608     // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
00609     
00610       int slot_num=convertFromConstructionSMToSlot(sm_num[i],-1);
00611       EBDetId ebid(slot_num,cry_num[i],EBDetId::SMCRYSTALMODE);
00612 
00613       ical->setValue( ebid.rawId(), calib[i]  );
00614 
00615       if(i==0) cout<<"crystal "<<cry_num[i]<<" of sm "<<sm_num[i]<< " in slot " <<slot_num<<" calib= "<< calib[i]<<endl;
00616 
00617     } // loop over channels 
00618 
00619     cout<<"loop on channels done" << endl;
00620 
00621     FILE *inpFileEE; // input file
00622     inpFileEE = fopen(inputFileEE,"r");
00623     if(!inpFileEE) {
00624       edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
00625 
00626     // dummy endcap data
00627 
00628     for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) 
00629       {
00630         for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) 
00631           {
00632             // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
00633             if (EEDetId::validDetId(iX,iY,1)) 
00634               {
00635                 EEDetId eedetidpos(iX,iY,1);
00636                 ical->setValue( eedetidpos, 1.0 );
00637               }
00638             if (EEDetId::validDetId(iX,iY,-1)) 
00639               {
00640                 EEDetId eedetidneg(iX,iY,-1);
00641                 ical->setValue( eedetidneg, 1.0 );
00642               }
00643           }
00644       }
00645 
00646     } else {
00647       cout<<"... now reading EE file ..." <<endl; 
00648 
00649       int ii=0;
00650       while(fgets(line,255,inpFileEE)) {
00651         int iz,ix,iy;
00652         float calibee;
00653         sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee );
00654         if(ii<=0) cout<<"crystal "<<iz<<"/"<<ix<<"/"<<iy<<" cali="<< calibee<<endl;
00655 
00656         if (EEDetId::validDetId(ix,iy,iz)) 
00657           {
00658             EEDetId eedetid(ix,iy,iz);
00659             ical->setValue( eedetid, calibee );
00660           }
00661         
00662         ii++ ;
00663       }
00664 
00665 
00666       fclose(inpFileEE);           // close inp. file
00667 
00668     }
00669 
00670     cout<<"loop on EE channels done" << endl;
00671 
00672 
00673 
00674   return ical;
00675 }
00676 
00677 //-------------------------------------------------------------
00678 EcalIntercalibConstantsMC*
00679 StoreEcalCondition::readEcalIntercalibConstantsMCFromFile(const char* inputFile,const char* inputFileEE) {
00680 //-------------------------------------------------------------
00681 
00682   EcalIntercalibConstantsMC* ical = new EcalIntercalibConstantsMC();
00683 
00684     
00685     FILE *inpFile; // input file
00686     inpFile = fopen(inputFile,"r");
00687     if(!inpFile) {
00688       edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
00689       return 0;
00690     }
00691 
00692     char line[256];
00693  
00694     std::ostringstream str;
00695 
00696     fgets(line,255,inpFile);
00697     string sm_or_all=to_string(line);
00698     int sm_number=0;
00699     int nchan=1700;
00700     sm_number=atoi(line);
00701     str << "sm= " << sm_number << endl ;  
00702     if(sm_number!=-1){
00703       nchan=1700;
00704     } else {
00705       nchan=61200;
00706     }
00707     
00708 
00709     fgets(line,255,inpFile);
00710     //int nevents=atoi(line); // not necessary here just for online conddb
00711     
00712     fgets(line,255,inpFile);
00713     string gen_tag=to_string(line);
00714     str << "gen tag " << gen_tag << endl ;  // should I use this? 
00715 
00716     fgets(line,255,inpFile);
00717     string cali_method=to_string(line);
00718     str << "cali method " << cali_method << endl ; // not important 
00719 
00720     fgets(line,255,inpFile);
00721     string cali_version=to_string(line);
00722     str << "cali version " << cali_version << endl ; // not important 
00723 
00724     fgets(line,255,inpFile);
00725     string cali_type=to_string(line);
00726     str << "cali type " << cali_type << endl ; // not important
00727 
00728     edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str() ;
00729 
00730     int sm_num[61200]={0};
00731     int cry_num[61200]={0};
00732     float calib[61200]={0};
00733     float calib_rms[61200]={0};
00734     int calib_nevents[61200]={0};
00735     int calib_status[61200]={0};
00736 
00737     int ii = 0;
00738     if(sm_number!=-1){
00739       while(fgets(line,255,inpFile)) {
00740         sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii] );
00741 //       if(ii<10) { // print out only the first ten channels 
00742 //      cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
00743 //       }
00744         sm_num[ii]=sm_number;
00745         ii++ ;
00746       }
00747     } else {
00748       // this is for the whole Barrel 
00749       cout<<"mode ALL BARREL" <<endl; 
00750       while(fgets(line,255,inpFile)) {
00751         sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii] );
00752         if(ii==0) cout<<"crystal "<<cry_num[ii]<<" of sm "<<sm_num[ii]<<" cali= "<< calib[ii]<<endl;
00753         ii++ ;
00754       }
00755     }
00756 
00757     //    inf.close();           // close inp. file
00758     fclose(inpFile);           // close inp. file
00759 
00760     edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals " ; 
00761 
00762     cout << " I read the calibrations for "<< ii<< " crystals " << endl;
00763     if(ii!=nchan) edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0" << endl;
00764 
00765     // Get channel ID 
00766     
00767     sm_constr_ = sm_number;
00768 
00769 
00770     // Set the data
00771     for(int i=0; i<nchan; i++){
00772     
00773     // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
00774     // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
00775     
00776       int slot_num=convertFromConstructionSMToSlot(sm_num[i],-1);
00777       EBDetId ebid(slot_num,cry_num[i],EBDetId::SMCRYSTALMODE);
00778 
00779       ical->setValue( ebid.rawId(), calib[i]  );
00780 
00781       if(i==0) cout<<"crystal "<<cry_num[i]<<" of sm "<<sm_num[i]<< " in slot " <<slot_num<<" calib= "<< calib[i]<<endl;
00782 
00783     } // loop over channels 
00784 
00785     cout<<"loop on channels done" << endl;
00786 
00787     FILE *inpFileEE; // input file
00788     inpFileEE = fopen(inputFileEE,"r");
00789     if(!inpFileEE) {
00790       edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
00791 
00792     // dummy endcap data
00793 
00794     for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) 
00795       {
00796         for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) 
00797           {
00798             // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
00799             if (EEDetId::validDetId(iX,iY,1)) 
00800               {
00801                 EEDetId eedetidpos(iX,iY,1);
00802                 ical->setValue( eedetidpos, 1.0 );
00803               }
00804             if (EEDetId::validDetId(iX,iY,-1)) 
00805               {
00806                 EEDetId eedetidneg(iX,iY,-1);
00807                 ical->setValue( eedetidneg, 1.0 );
00808               }
00809           }
00810       }
00811 
00812     } else {
00813       cout<<"... now reading EE file ..." <<endl; 
00814 
00815       int ii=0;
00816       while(fgets(line,255,inpFileEE)) {
00817         int iz,ix,iy;
00818         float calibee;
00819         sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee );
00820         if(ii<=0) cout<<"crystal "<<iz<<"/"<<ix<<"/"<<iy<<" cali="<< calibee<<endl;
00821 
00822         if (EEDetId::validDetId(ix,iy,iz)) 
00823           {
00824             EEDetId eedetid(ix,iy,iz);
00825             ical->setValue( eedetid, calibee );
00826           }
00827         
00828         ii++ ;
00829       }
00830 
00831 
00832       fclose(inpFileEE);           // close inp. file
00833 
00834     }
00835 
00836     cout<<"loop on EE channels done" << endl;
00837 
00838 
00839 
00840   return ical;
00841 }
00842 
00843 //-------------------------------------------------------------
00844 int StoreEcalCondition::convertFromConstructionSMToSlot(int sm_constr,int sm_slot){
00845   // input either cosntruction number or slot number and returns the other
00846   // the slots are numbered first EB+ slot 1 ...18 then EB- 1... 18 
00847   // the slots start at 1 and the SM start at 0
00848 //-------------------------------------------------------------
00849   int slot_to_constr[37]={-1,12,17,10,1,8,4,27,20,23,25,6,34,35,15,18,30,21,9 
00850                           ,24,22,13,31,26,16,2,11,5,0,29,28,14,33,32,3,7,19};
00851   int constr_to_slot[36]={28,4,25,34,6,27,11,35,5,18,3,26,1,21,31,14,24,2,15,
00852                           36,8,17,20,9,19,10,23,7,30,29,16,22,33,32,12,13  };
00853   
00854   int result=0;
00855   if(sm_constr!=-1) {
00856     result=constr_to_slot[sm_constr];
00857   } else if(sm_slot!=-1) {
00858     result=slot_to_constr[sm_slot];
00859   }
00860   return result;
00861 }
00862 
00863 //-------------------------------------------------------------
00864 EcalGainRatios*
00865 StoreEcalCondition::readEcalGainRatiosFromFile(const char* inputFile) {
00866 //-------------------------------------------------------------
00867 
00868   // create gain ratios
00869   EcalGainRatios* gratio = new EcalGainRatios;
00870     
00871 
00872     FILE *inpFile; // input file
00873     inpFile = fopen(inputFile,"r");
00874     if(!inpFile) {
00875       edm::LogError("StoreEcalCondition")<<"*** Can not open file: "<<inputFile;
00876       return 0;
00877     }
00878 
00879     char line[256];
00880     std::ostringstream str;
00881               
00882     fgets(line,255,inpFile);
00883     string sm_or_all=to_string(line);
00884     int sm_number=0;
00885     sm_number=atoi(line);
00886     str << "sm= " << sm_number << endl ;  
00887 
00888     fgets(line,255,inpFile);
00889     //int nevents=atoi(line);
00890     
00891     fgets(line,255,inpFile);
00892     string gen_tag=to_string(line);
00893     str << "gen tag " << gen_tag << endl ;    
00894 
00895     fgets(line,255,inpFile);
00896     string cali_method=to_string(line);
00897     str << "cali method " << cali_method << endl ;
00898 
00899     fgets(line,255,inpFile);
00900     string cali_version=to_string(line);
00901     str << "cali version " << cali_version << endl ;
00902 
00903 
00904     fgets(line,255,inpFile);
00905     string cali_type=to_string(line);
00906 
00907     str << "cali type " << cali_type << endl ;
00908 
00909     edm::LogInfo("StoreEcalCondition") << "GainRatio file " << str.str() ;
00910 
00911 
00912 
00913     int cry_num[61200]={0};
00914     float g1_g12[61200]={0};
00915     float g6_g12[61200]={0};
00916     int calib_status[61200]={0};
00917     int dummy1=0;
00918     int dummy2=0;
00919     int hash1=0;
00920 
00921     int ii = 0;
00922 
00923     if(sm_number!=-1){
00924       while(fgets(line,255,inpFile)) {
00925         sscanf(line, "%d %d %d %f %f %d", &dummy1, &dummy2, &cry_num[ii], &g1_g12[ii], &g6_g12[ii], &calib_status[ii] );
00926         ii++ ;
00927       } 
00928 
00929     
00930       fclose(inpFile);           // close inp. file
00931 
00932 
00933 
00934       edm::LogInfo("StoreEcalCondition") << "Read gainRatios for " << ii << " xtals " ;
00935       if(ii!=1700) edm::LogWarning("StoreEcalCondition") << " Missing crystals:: missing channels will be set to 0" << endl;
00936       
00937       // Get channel ID 
00938       sm_constr_ = sm_number;
00939       
00940       for(int i=0; i<1700; i++){
00941         // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
00942         // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
00943         EBDetId ebid(sm_slot_,cry_num[i],EBDetId::SMCRYSTALMODE);
00944         // cout << "ebid.rawId()"<< ebid.rawId()<< endl;
00945         EcalMGPAGainRatio gr;
00946         gr.setGain12Over6( g6_g12[i] );
00947         gr.setGain6Over1(g1_g12[i]/g6_g12[i]);
00948         gratio->setValue( ebid.rawId(), gr );
00949       } // loop over channels 
00950       
00951       
00952 
00953       
00954 
00955 
00956     } else {
00957       // this is for the whole Barrel 
00958       cout<<"mode ALL BARREL" <<endl; 
00959       while(fgets(line,255,inpFile)) {
00960         int eta=0; 
00961         int phi=0;
00962         sscanf(line, "%d %d %d %f %f",&hash1, &eta, &phi, &g1_g12[ii], &g6_g12[ii]);
00963         if(ii<20) cout<<"crystal eta/phi="<<eta<<"/"<<phi<<" g1_12/g6_12= "<< g1_g12[ii]<<"/"<<g6_g12[ii]<<endl;
00964 
00965         if(g1_g12[ii]<9 || g1_g12[ii]>15 ) g1_g12[ii]=12.0;
00966         if(g6_g12[ii]<1 || g6_g12[ii]>3 ) g6_g12[ii]=2.0;
00967 
00968         if(eta<-85|| eta>85 || eta==0) std::cout<<"error!!!"<<endl;
00969         if(phi<1 || phi>360) std::cout<<"error!!!"<<endl;
00970 
00971         EBDetId ebid(eta, phi,EBDetId::ETAPHIMODE);
00972         EcalMGPAGainRatio gr;
00973         gr.setGain12Over6( g6_g12[ii] );
00974         gr.setGain6Over1(g1_g12[ii]/g6_g12[ii]);
00975         gratio->setValue( ebid.rawId(), gr );
00976         
00977         ii++ ;
00978       }
00979     
00980       fclose(inpFile);           // close inp. file
00981       if(ii!=61200) edm::LogWarning("StoreEcalCondition") << " Missing crystals !!!!!!!" << endl;
00982       
00983       std::cout<< "number of crystals read:"<<ii<<endl;
00984 
00985     }
00986 
00987 
00988 
00989     for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00990       for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00991         // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
00992         EcalMGPAGainRatio gr;
00993         gr.setGain12Over6( 2. );
00994         gr.setGain6Over1( 6. );
00995 
00996 
00997         if (EEDetId::validDetId(iX,iY,1))
00998           {
00999             EEDetId eedetidpos(iX,iY,1);
01000             gratio->setValue( eedetidpos.rawId(), gr );
01001           }
01002         if (EEDetId::validDetId(iX,iY,-1))
01003           {
01004             EEDetId eedetidneg(iX,iY,-1);
01005             gratio->setValue( eedetidneg.rawId(), gr );
01006           }
01007       }
01008     }
01009   
01010 
01011     std::cout <<" gratio pointer="<<gratio<<endl;
01012 
01013 
01014 
01015     std::cout<< "now leaving"<<endl;
01016 
01017 
01018 
01019     return gratio;
01020 
01021 }
01022 
01023 EcalChannelStatus* 
01024 StoreEcalCondition::readEcalChannelStatusFromFile(const char* inputFile)
01025 {
01026         EcalChannelStatus* status = new EcalChannelStatus();
01027         // barrel
01028         for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) 
01029           {
01030             if(ieta==0) continue;
01031             for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01032               if (EBDetId::validDetId(ieta,iphi)) {
01033                 EBDetId ebid(ieta,iphi);
01034                 status->setValue( ebid, 0 );
01035               }
01036             }
01037           }
01038         // endcap
01039         for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) 
01040           {
01041             for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) 
01042               {
01043                 // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
01044                 if (EEDetId::validDetId(iX,iY,1)) 
01045                   {
01046                   EEDetId eedetidpos(iX,iY,1);
01047                   status->setValue( eedetidpos, 0 );
01048                   }
01049                 if (EEDetId::validDetId(iX,iY,-1)) 
01050                   {
01051                     EEDetId eedetidneg(iX,iY,-1);
01052                     status->setValue( eedetidneg, 0 );
01053                   }
01054               }
01055           }
01056 
01057         
01058         //        edm::LogInfo("EcalTrivialConditionRetriever") << "Reading channel status from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ;
01059         std::cout << "Reading channel status from file " << inputFile << std::endl;
01060         FILE *ifile = fopen( inputFile ,"r" );
01061         if ( !ifile ) 
01062           throw cms::Exception ("Cannot open ECAL channel status file") ;
01063 
01064         char line[256];
01065 
01066         fgets(line,255,ifile);
01067         std::string gen_tag= line;
01068         std::cout << "Gen tag " << gen_tag << std::endl ;  
01069 
01070         fgets(line,255,ifile);
01071         std::string comment = line ;
01072         std::cout << "Gen comment " << comment << std::endl ; 
01073 
01074         int iovRunStart(0);
01075         fgets(line,255,ifile);
01076         sscanf (line, "%d", &iovRunStart);
01077         std::cout << "IOV START " << iovRunStart << std::endl;
01078         //if -1 start of time
01079 
01080         int iovRunEnd(0);
01081         fgets(line,255,ifile);
01082         sscanf (line, "%d", &iovRunEnd);
01083         std::cout << "IOV END " << iovRunEnd << std::endl;
01084         //if -1 end of time
01085 
01086         int ii = 0;
01087         while(fgets(line,255,ifile)) 
01088           {
01089             std::string EBorEE;
01090             int hashedIndex(0);
01091             int chStatus(0);
01092             std::stringstream aStrStream;
01093             aStrStream << line;
01094             aStrStream >> EBorEE >> hashedIndex >> chStatus;
01095             //      if(ii==0) 
01096             std::cout << EBorEE << " hashedIndex " << hashedIndex << " status " <<  chStatus << std::endl;
01097             
01098             if (EBorEE == "EB") 
01099               {
01100                 EBDetId aEBDetId=EBDetId::unhashIndex(hashedIndex);
01101                 status->setValue( aEBDetId, chStatus );
01102               }
01103             else if (EBorEE == "EE")
01104               {
01105                 //              chStatus=1;
01106                 EEDetId aEEDetId=EEDetId::unhashIndex(hashedIndex);
01107                 status->setValue( aEEDetId, chStatus );
01108               }
01109             else if (EBorEE == "EBTT")
01110               {
01111                 int ism=hashedIndex;
01112                 int itt=chStatus;
01113 
01114                 int ixtt=(itt-1)%4;
01115                 int iytt=(itt-1)/4;
01116                 int ixmin=ixtt*5;
01117                 int iymin=iytt*5;
01118                 int ixmax=(ixtt+1)*5-1;
01119                 int iymax=(iytt+1)*5-1;
01120                 for(int ieta=iymin; ieta<=iymax; ieta++) {
01121                   for(int iphi=ixmin; iphi<=ixmax; iphi++) {
01122                     int ixt=ieta*20+iphi+1;
01123                     std::cout<< "killing crystal "<< ism << "/" << ixt << endl;
01124                     EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
01125                     status->setValue( ebid, 1 );
01126                   }
01127                 }
01128               }
01129             
01130             ii++ ;
01131             
01132           }
01133         
01134         fclose(ifile);
01135 
01136         
01137         /*
01138         std::cout <<"KILLING CHANNELS FOR CRAFT EB+16 AND EB+7"<<endl; 
01139 
01140         int ism=7;
01141         for(int ixt=1; ixt<=500; ixt++) {
01142           EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
01143           status->setValue( ebid, 1 );
01144         }
01145         for(int ixt=501; ixt<=900; ixt++) {
01146           EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
01147           if( ((ixt)%20==0) || ((ixt)%20>10) ){  
01148             status->setValue( ebid, 1 );
01149           }
01150         }
01151         ism=16;
01152         for(int ixt=501; ixt<=900; ixt++) {
01153           EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
01154           if( ((ixt)%20==0) || ((ixt)%20>10) ){  
01155             status->setValue( ebid, 1 );
01156           }
01157         }
01158 
01159         */
01160 
01161 
01162         return status;
01163 
01164 
01165 }