CMS 3D CMS Logo

SiStripBadStripFromASCIIFile Class Reference

#include <CalibTracker/SiStripQuality/plugins/SiStripBadStripFromASCIIFile.h>

Inheritance diagram for SiStripBadStripFromASCIIFile:

ConditionDBWriter< SiStripBadStrip > edm::EDAnalyzer

List of all members.

Public Member Functions

 SiStripBadStripFromASCIIFile (const edm::ParameterSet &iConfig)
 ~SiStripBadStripFromASCIIFile ()

Private Member Functions

virtual SiStripBadStripgetNewObject ()

Private Attributes

edm::FileInPath fp_
bool printdebug_


Detailed Description

Definition at line 13 of file SiStripBadStripFromASCIIFile.h.


Constructor & Destructor Documentation

SiStripBadStripFromASCIIFile::SiStripBadStripFromASCIIFile ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 33 of file SiStripBadStripFromASCIIFile.cc.

References fp_, and edm::ParameterSet::getUntrackedParameter().

00033                                                                                           :
00034   ConditionDBWriter<SiStripBadStrip>( iConfig),
00035   printdebug_(iConfig.getUntrackedParameter<bool>("printDebug",false))
00036 {
00037   fp_ = iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripQuality/data/DefectsFromConstructionDB.dat"));
00038  }

SiStripBadStripFromASCIIFile::~SiStripBadStripFromASCIIFile (  )  [inline]

Definition at line 19 of file SiStripBadStripFromASCIIFile.h.

00019 {};


Member Function Documentation

SiStripBadStrip * SiStripBadStripFromASCIIFile::getNewObject (  )  [private, virtual]

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 41 of file SiStripBadStripFromASCIIFile.cc.

References count, GenMuonPlsPt100GeV_cfg::cout, SiStripBadStrip::encode(), lat::endl(), fp_, edm::FileInPath::fullPath(), TreeToEdges::infile, SiStripBadStrip::put(), and range.

00041                                                             {
00042 
00043   SiStripBadStrip* SiStripBadStrip_ = new SiStripBadStrip();
00044 
00045    // open file and fill DB
00046   ifstream infile((fp_.fullPath()).c_str());
00047   if(!infile){std::cout << "Problem while trying to open File: " << (fp_.fullPath()).c_str() << std::endl;}
00048   
00049 
00050   //variables needed for reading file and filling of SiStripBadStripObject
00051   uint32_t detid;
00052   short flag;
00053   short channel;
00054  
00055   bool firstrun=true;
00056   short tempchannel=0;
00057   int count =0;
00058   std::vector<unsigned int> theSiStripVector;
00059   uint32_t tempflag=0;
00060   uint32_t tempdetid=0;
00061 
00062 
00063    while(!infile.eof()){
00064 
00065     // get data from file: 
00066     infile >> detid >> channel >> flag;
00067 
00068     unsigned int theBadStripRange=0;
00069 
00070     // first loop ?
00071     if(firstrun) {
00072       tempdetid=detid;
00073       tempchannel=channel;
00074       tempflag=flag;
00075       count =0;
00076       firstrun=false;
00077     }
00078 
00079 
00080     if(detid==tempdetid){
00081       if (channel!=tempchannel+count || flag != tempflag){
00082                                           // 1.badstrip, nconsectrips, flag
00083           theBadStripRange = SiStripBadStrip_->encode(tempchannel, count, tempflag); 
00084                 
00085           edm::LogInfo("SiStripBadStripFromASCIIFile")<< "detid " << tempdetid << " \t"
00086                                                            << " firstBadStrip " << tempchannel << "\t "
00087                                                            << " NconsecutiveBadStrips " << count  << "\t "
00088                                                            <<"flag " << tempflag << "\t"
00089                                                            << " packed integer " << std::hex << theBadStripRange  << std::dec
00090                                                            << std::endl;            
00091 
00092           theSiStripVector.push_back(theBadStripRange);
00093           count=1;
00094           tempchannel=channel;
00095           tempflag=flag;
00096                 
00097       }else{count++;}
00098     }
00099     
00100     if(detid!=tempdetid){
00101                                                     // 1.badstrip, nconsectrips, flag
00102           theBadStripRange = SiStripBadStrip_->encode(tempchannel, count, tempflag); 
00103           edm::LogInfo("SiStripBadStripFromASCIIFile")<< "detid " << tempdetid << " \t"
00104                                                            << " firstBadStrip " << tempchannel << "\t "
00105                                                            << " NconsecutiveBadStrips " << count  << "\t "
00106                                                            <<"flag " << tempflag << "\t"
00107                                                            << " packed integer " << std::hex << theBadStripRange  << std::dec
00108                                                            << std::endl;            
00109           
00110           theSiStripVector.push_back(theBadStripRange);
00111           
00112           // populate db  object
00113           SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
00114     if ( ! SiStripBadStrip_->put(tempdetid,range) )
00115       edm::LogError("SiStripBadStripFromASCIIFile")<<"[SiStripBadStripFromASCIIFile::GetNewObject] detid already exists"<<std::endl;
00116     theSiStripVector.clear();
00117     
00118     count=1;
00119     tempdetid=detid;
00120     tempchannel=channel;
00121     tempflag=flag;
00122     }
00123    }
00124  
00125   return SiStripBadStrip_;
00126 }


Member Data Documentation

edm::FileInPath SiStripBadStripFromASCIIFile::fp_ [private]

Definition at line 25 of file SiStripBadStripFromASCIIFile.h.

Referenced by getNewObject(), and SiStripBadStripFromASCIIFile().

bool SiStripBadStripFromASCIIFile::printdebug_ [private]

Definition at line 26 of file SiStripBadStripFromASCIIFile.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:12 2009 for CMSSW by  doxygen 1.5.4