#include <OnlineDB/CSCCondDB/interface/CSCCompThreshAnalyzer.h>
Public Member Functions | |
virtual void | analyze (edm::Event const &e, edm::EventSetup const &iSetup) |
CSCCompThreshAnalyzer (edm::ParameterSet const &conf) | |
Analyzer for reading CSC comapartor thresholds. | |
~CSCCompThreshAnalyzer () | |
Private Attributes | |
TH2F | adc_vs_charge |
float | arrayMeanThresh [CHAMBERS_ct][LAYERS_ct][STRIPS_ct] |
std::string | chamber_id |
int | chamber_index |
int | chamber_num |
int | compadc |
int | comparator |
int | compstrip |
int | crateID [CHAMBERS_ct] |
bool | debug |
int | dmbID [CHAMBERS_ct] |
int | event |
int | eventNumber |
int | evt |
int | fff |
std::ifstream | filein |
int | first_strip_index |
int | i_chamber |
int | i_layer |
int | length |
int | lines |
float | mean [CHAMBERS_ct][LAYERS_ct][STRIPS_ct] |
float | meanmod [NUMMOD_ct][CHAMBERS_ct][LAYERS_ct][STRIPS_ct] |
float | meanThresh |
float | meanTot [CHAMBERS_ct][LAYERS_ct][STRIPS_ct] |
int | misMatch |
float | myCharge [35] |
float | myCompProb [35] |
int | mycompstrip |
std::string | name |
int | NChambers |
int | Nddu |
int | pedSum |
std::string | PSet |
int | reportedChambers |
int | ret_code |
int | sector |
int | size [CHAMBERS_ct] |
int | strip |
int | strips_per_layer |
float | theMeanThresh [CHAMBERS_ct][LAYERS_ct][STRIPS_ct] |
int | timebin |
Definition at line 27 of file CSCCompThreshAnalyzer.h.
CSCCompThreshAnalyzer::CSCCompThreshAnalyzer | ( | edm::ParameterSet const & | conf | ) | [explicit] |
Analyzer for reading CSC comapartor thresholds.
author O.Boeriu 17/11/06
Definition at line 33 of file CSCCompThreshAnalyzer.cc.
References adc_vs_charge, arrayMeanThresh, CHAMBERS_ct, compadc, comparator, compstrip, debug, eventNumber, evt, edm::ParameterSet::getUntrackedParameter(), i, i_chamber, i_layer, j, k, edm::es::l(), LAYERS_ct, length, mean, meanmod, meanThresh, meanTot, misMatch, mycompstrip, NChambers, Nddu, NUMBERPLOTTED_ct, reportedChambers, size, STRIPS_ct, theMeanThresh, and timebin.
00033 { 00034 debug = conf.getUntrackedParameter<bool>("debug",false); 00035 eventNumber = 0,compadc=0; 00036 evt = 0,Nddu=0,misMatch=0,event=0; 00037 i_chamber=0,i_layer=0,reportedChambers =0; 00038 length = 1, NChambers=0; 00039 meanThresh=0.0; 00040 timebin=-999,mycompstrip=-999,comparator=0,compstrip=0; 00041 00042 adc_vs_charge = TH2F("CFEB Comparator" ,"ADC_vs_charge", 100,0,300,100,0,2); 00043 00044 for (int i=0; i<NUMBERPLOTTED_ct; i++){ 00045 for (int j=0; j<CHAMBERS_ct; j++){ 00046 for (int k=0; k<LAYERS_ct; k++){ 00047 for (int l=0; l<STRIPS_ct; l++){ 00048 meanmod[i][j][k][l] = 0.0; 00049 } 00050 } 00051 } 00052 } 00053 00054 for(int i=0;i<CHAMBERS_ct;i++){ 00055 for(int j=0; j<LAYERS_ct; j++){ 00056 for(int k=0; k<STRIPS_ct; k++){ 00057 theMeanThresh[i][j][k] = 0.; 00058 arrayMeanThresh[i][j][k] = 0.; 00059 mean[i][j][k]=0.; 00060 meanTot[i][j][k]=0.; 00061 } 00062 } 00063 } 00064 00065 00066 for (int i=0; i<CHAMBERS_ct; i++){ 00067 size[i] = 0; 00068 } 00069 00070 }
CSCCompThreshAnalyzer::~CSCCompThreshAnalyzer | ( | ) |
Definition at line 210 of file CSCCompThreshAnalyzer.cc.
References adc_vs_charge, TCalibComparatorEvt::cham, chamber_id, chamber_index, chamber_num, GenMuonPlsPt100GeV_cfg::cout, cscmap::crate_chamber(), crateID, dmbID, lat::endl(), filein, first_strip_index, TCalibComparatorEvt::id, j, k, TCalibComparatorEvt::layer, LAYERS_ct, lines, python::multivaluedict::map(), meanmod, meanThresh, myCharge, myCompProb, name, NChambers, Nddu, NULL, NUMBERPLOTTED_ct, CSCobject::obj, sector, size, st, TCalibComparatorEvt::strip, STRIPS_ct, and strips_per_layer.
00210 { 00211 //get time of Run file for DB transfer 00212 filein.open("../test/CSCcomp.cfg"); 00213 filein.ignore(1000,'\n'); 00214 00215 while(filein != NULL){ 00216 lines++; 00217 getline(filein,PSet); 00218 00219 if (lines==3){ 00220 name=PSet; 00221 std::cout<<name<<std::endl; 00222 } 00223 } 00224 std::string::size_type runNameStart = name.find("\"",0); 00225 std::string::size_type runNameEnd = name.find("raw",0); 00226 std::string::size_type rootStart = name.find("CFEBComparator",0); 00227 int nameSize = runNameEnd+2-runNameStart; 00228 int myRootSize = rootStart-runNameStart+13; 00229 std::string myname= name.substr(runNameStart+1,nameSize); 00230 std::string myRootName= name.substr(runNameStart+1,myRootSize); 00231 std::string myRootEnd = ".root"; 00232 std::string runFile= myRootName; 00233 std::string myRootFileName = runFile+myRootEnd; 00234 const char *myNewName=myRootFileName.c_str(); 00235 00236 struct tm* clock; 00237 struct stat attrib; 00238 stat(myname.c_str(), &attrib); 00239 clock = localtime(&(attrib.st_mtime)); 00240 std::string myTime=asctime(clock); 00241 00242 //DB object and map 00243 CSCobject *cn = new CSCobject(); 00244 cscmap *map = new cscmap(); 00245 //condbon *dbon = new condbon(); 00246 00247 //root ntuple information 00248 TCalibComparatorEvt calib_evt; 00249 TFile calibfile(myNewName, "RECREATE"); 00250 TTree calibtree("Calibration","CFEB Comparator"); 00251 calibtree.Branch("EVENT", &calib_evt, "strip/I:layer/I:cham/I:id/I"); 00252 00253 00254 for (int dduiter=0;dduiter<Nddu;dduiter++){ 00255 for(int chamberiter=0; chamberiter<NChambers; chamberiter++){ 00256 for (int cham=0;cham<NChambers;cham++){ 00257 if (cham !=chamberiter) continue; 00258 00259 //get chamber ID from DB mapping 00260 int new_crateID = crateID[cham]; 00261 int new_dmbID = dmbID[cham]; 00262 std::cout<<" Crate: "<<new_crateID<<" and DMB: "<<new_dmbID<<std::endl; 00263 map->crate_chamber(new_crateID,new_dmbID,&chamber_id,&chamber_num,§or,&first_strip_index,&strips_per_layer,&chamber_index); 00264 std::cout<<"Data is for chamber:: "<< chamber_id<<" in sector: "<<sector<<std::endl; 00265 00266 calib_evt.id=chamber_num; 00267 00268 for (int layeriter=0; layeriter<LAYERS_ct; layeriter++){ 00269 for (int stripiter=0; stripiter<STRIPS_ct; stripiter++){ 00270 00271 for (int j=0; j<LAYERS_ct; j++){//layer 00272 if (j != layeriter) continue; 00273 00274 int layer_id=chamber_num+j+1; 00275 if(sector==-100)continue; 00276 cn->obj[layer_id].resize(size[cham]); 00277 00278 for (int k=0; k<size[cham]; k++){//strip 00279 if (k != stripiter) continue; 00280 00281 for (int st=0;st<NUMBERPLOTTED_ct;st++){ 00282 myCharge[st] =0.0; 00283 myCompProb[st]=0.0; 00284 } 00285 00286 for(int ii=0; ii<NUMBERPLOTTED_ct; ii++){//numbers 00287 //start at 13mV,35 steps of 3mV; 00288 myCharge[ii] = 13 +(3*ii); 00289 myCompProb[ii] = meanmod[ii][cham][j][k]; 00290 adc_vs_charge.Fill(myCharge[ii],meanmod[ii][cham][j][k]); 00291 meanThresh= meanmod[ii][cham][j][k]; 00292 std::cout<<"Ch "<<cham<<" Layer "<<j<<" strip "<<k<<" comparator threshold "<<meanThresh<<std::endl; 00293 }//numberplotted 00294 00295 calib_evt.strip = k; 00296 calib_evt.layer = j; 00297 calib_evt.cham = cham; 00298 00299 calibtree.Fill(); 00300 }//strip 00301 }//j loop 00302 }//stripiter 00303 }//layeriter 00304 }//cham 00305 }//chamberiter 00306 }//dduiter 00307 00308 //send data to DB 00309 //dbon->cdbon_last_record("comparator",&record); 00310 //std::cout<<"Last comparator record "<<record<<" for run file "<<myname<<" saved "<<myTime<<std::endl; 00311 //if(debug) dbon->cdbon_write(cn,"comparator",11,myTime); 00312 00313 //write histograms 00314 adc_vs_charge.Write(); 00315 calibfile.Write(); 00316 calibfile.Close(); 00317 }
void CSCCompThreshAnalyzer::analyze | ( | edm::Event const & | e, | |
edm::EventSetup const & | iSetup | |||
) | [virtual] |
Take a reference to this FED's data
unpack data
get a pointer to data and pass it to constructor for unpacking
loop over DDUs
get a reference to chamber data
Implements edm::EDAnalyzer.
Definition at line 72 of file CSCCompThreshAnalyzer.cc.
References CSCDMBHeader::cfebAvailable(), CHAMBERS_ct, comparator, CSCCLCTData::comparatorDigis(), compstrip, GenMuonPlsPt100GeV_cfg::cout, crateID, FEDRawData::data(), dmbID, lat::endl(), eventNumber, evt, first, edm::Event::getByLabel(), edm::Event::getByType(), FEDNumbering::getCSCFEDIds(), i, i_chamber, i_layer, id, edm::Event::id(), int, j, kk, prof2calltree::last, LAYERS_ct, mean, meanmod, meanTot, misMatch, mycompstrip, NChambers, Nddu, NUMBERPLOTTED_ct, NUMMOD_ct, reportedChambers, FEDRawData::size(), size, STRIPS_ct, timebin, and tmp.
00072 { 00073 00074 // These declarations create handles to the types of records that you want 00075 // to retrieve from event "e". 00076 // 00077 edm::Handle<CSCStripDigiCollection> strips; 00078 edm::Handle<CSCComparatorDigiCollection> comparators; 00079 00080 // Pass the handle to the method "getByType", which is used to retrieve 00081 // one and only one instance of the type in question out of event "e". If 00082 // zero or more than one instance exists in the event an exception is thrown. 00083 // 00084 00085 e.getByLabel("cscunpacker","MuonCSCStripDigi",strips); 00086 e.getByLabel("cscunpacker","MuonCSCComparatorDigi",comparators); 00087 00088 for (CSCComparatorDigiCollection::DigiRangeIterator j=comparators->begin(); j!=comparators->end(); j++) { 00089 std::vector<CSCComparatorDigi>::const_iterator digiItr = (*j).second.first; 00090 std::vector<CSCComparatorDigi>::const_iterator last = (*j).second.second; 00091 for( ; digiItr != last; ++digiItr) { 00092 //digiItr->print(); 00093 std::cout<<"This is comp "<<digiItr->getStrip()<<std::endl; 00094 } 00095 } 00096 00097 00098 edm::Handle<FEDRawDataCollection> rawdata; 00099 e.getByType(rawdata); 00100 event =e.id().event(); 00101 for (int id=FEDNumbering::getCSCFEDIds().first; 00102 id<=FEDNumbering::getCSCFEDIds().second; ++id){ //for each of our DCCs 00103 00105 const FEDRawData& fedData = rawdata->FEDData(id); 00106 00107 if (fedData.size()){ 00108 00110 CSCDCCEventData dccData((short unsigned int *) fedData.data()); 00111 00112 const std::vector<CSCDDUEventData> & dduData = dccData.dduData(); 00113 evt++; 00114 00115 for (unsigned int iDDU=0; iDDU<dduData.size(); ++iDDU) { 00116 00117 const std::vector<CSCEventData> & cscData = dduData[iDDU].cscData(); 00118 Nddu=dduData.size(); 00119 reportedChambers += dduData[iDDU].header().ncsc(); 00120 NChambers = cscData.size(); 00121 int repChambers = dduData[iDDU].header().ncsc(); 00122 std::cout << " Reported Chambers = " << repChambers <<" "<<NChambers<< std::endl; 00123 if (NChambers!=repChambers) {std::cout<< "misMatched size!!!" << std::endl; misMatch++;continue;} 00124 00125 for (i_chamber=0; i_chamber<NChambers; i_chamber++) {//loop over all DMBs 00126 if (cscData[i_chamber].nclct()) { 00127 CSCCLCTData * clctData = cscData[i_chamber].clctData(); 00128 }else { 00129 std::cout<<" No CLCT!" <<std::endl; 00130 continue; 00131 } 00132 CSCCLCTData * clctData = cscData[i_chamber].clctData(); 00133 for(i_layer = 1; i_layer <= 6; ++i_layer) {//loop over all layers in chambers 00134 std::vector<CSCComparatorDigi> comp = clctData->comparatorDigis(i_layer); 00135 00136 const CSCDMBHeader * thisDMBheader = cscData[i_chamber].dmbHeader(); 00137 00138 if (cscData[i_chamber].dmbHeader() && thisDMBheader->cfebAvailable()){//check that CFEB data exists 00139 00140 dmbID[i_chamber] = cscData[i_chamber].dmbHeader()->dmbID(); //get DMB ID 00141 crateID[i_chamber] = cscData[i_chamber].dmbHeader()->crateID(); //get crate ID 00142 if(crateID[i_chamber] == 255) continue; //255 is reserved for old crate 00143 00144 for (unsigned int i=0; i<comp.size(); i++){//loop over CFEB comparator digis 00145 size[i_chamber] = comp.size(); 00146 comparator = comp[i].getComparator(); 00147 timebin = comp[i].getTimeBin() ; 00148 compstrip = comp[i].getStrip(); 00149 00150 //was for di-strip logic 00151 //int this_comparator[4] = {4, 5, 6, 7}; 00152 // for (int iii=0; iii<40; iii++){ 00153 // if ((compstrip == iii) && (comparator == this_comparator[0] || comparator == this_comparator[1])) { 00154 // mycompstrip = 0 + iii*2; 00155 // } else if ((compstrip == iii) && (comparator == this_comparator[2] || comparator == this_comparator[3])) { 00156 // mycompstrip = 1 + iii*2; 00157 // } 00158 // } 00159 00160 //is now for left=0,for right=1 halfstrip 00161 for (int iii=0; iii<40; iii++){ 00162 if ((compstrip == iii) && (comparator == 0)) { 00163 mycompstrip = 0 + iii*2; 00164 } else if ((compstrip == iii) && (comparator == 1)) { 00165 mycompstrip = 1 + iii*2; 00166 } 00167 } 00168 00169 mean[i_chamber][i_layer-1][mycompstrip] = comparator/5.; 00170 std::cout<<" mean "<<mean[i_chamber][i_layer-1][mycompstrip]<<" compstrip "<<mycompstrip<<std::endl; 00171 00172 }//end comp loop 00173 00174 meanTot[i_chamber][i_layer-1][mycompstrip] +=mean[i_chamber][i_layer-1][mycompstrip]/25.; 00175 00176 // On the 25th event and per CFEB 00177 if (evt%25 == 0 && (mycompstrip)%16 == (evt-1)/NUMMOD_ct){ 00178 int tmp = int((evt-1)/25)% NUMBERPLOTTED_ct ; 00179 std::cout<<" THIS IS tmp "<<tmp<<std::endl; 00180 meanmod[tmp][i_chamber][i_layer-1][mycompstrip] = meanTot[i_chamber][i_layer-1][mycompstrip]; 00181 00182 std::cout<<" meanval 25th event "<<meanmod[tmp][i_chamber][i_layer-1][mycompstrip]<<std::endl; 00183 } 00184 }//end if cfeb.available loop 00185 }//end layer loop 00186 }//end chamber loop 00187 00188 if((evt-1)%25==0){ 00189 //for(int iii=0;iii<DDU_sat;iii++){ 00190 for(int ii=0;ii<CHAMBERS_ct;ii++){ 00191 for(int jj=0;jj<LAYERS_ct;jj++){ 00192 for(int kk=0;kk<STRIPS_ct;kk++){ 00193 mean[ii][jj][kk]=0.0; 00194 meanTot[ii][jj][kk]=0.0; 00195 } 00196 } 00197 } 00198 } 00199 //} 00200 00201 eventNumber++; 00202 edm::LogInfo ("CSCCompThreshAnalyzer") << "end of event number " << eventNumber; 00203 00204 }//end DDU loop 00205 } 00206 } 00207 }
TH2F CSCCompThreshAnalyzer::adc_vs_charge [private] |
Definition at line 60 of file CSCCompThreshAnalyzer.h.
Referenced by CSCCompThreshAnalyzer(), and ~CSCCompThreshAnalyzer().
float CSCCompThreshAnalyzer::arrayMeanThresh[CHAMBERS_ct][LAYERS_ct][STRIPS_ct] [private] |
std::string CSCCompThreshAnalyzer::chamber_id [private] |
int CSCCompThreshAnalyzer::chamber_index [private] |
int CSCCompThreshAnalyzer::chamber_num [private] |
int CSCCompThreshAnalyzer::compadc [private] |
int CSCCompThreshAnalyzer::comparator [private] |
Definition at line 47 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::compstrip [private] |
Definition at line 47 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::crateID[CHAMBERS_ct] [private] |
Definition at line 48 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and ~CSCCompThreshAnalyzer().
bool CSCCompThreshAnalyzer::debug [private] |
int CSCCompThreshAnalyzer::dmbID[CHAMBERS_ct] [private] |
Definition at line 48 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and ~CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::event [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
int CSCCompThreshAnalyzer::eventNumber [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::evt [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::fff [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
std::ifstream CSCCompThreshAnalyzer::filein [private] |
int CSCCompThreshAnalyzer::first_strip_index [private] |
int CSCCompThreshAnalyzer::i_chamber [private] |
Definition at line 46 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::i_layer [private] |
Definition at line 46 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::length [private] |
int CSCCompThreshAnalyzer::lines [private] |
float CSCCompThreshAnalyzer::mean[CHAMBERS_ct][LAYERS_ct][STRIPS_ct] [private] |
Definition at line 52 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
float CSCCompThreshAnalyzer::meanmod[NUMMOD_ct][CHAMBERS_ct][LAYERS_ct][STRIPS_ct] [private] |
Definition at line 54 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), CSCCompThreshAnalyzer(), and ~CSCCompThreshAnalyzer().
float CSCCompThreshAnalyzer::meanThresh [private] |
Definition at line 49 of file CSCCompThreshAnalyzer.h.
Referenced by CSCCompThreshAnalyzer(), and ~CSCCompThreshAnalyzer().
float CSCCompThreshAnalyzer::meanTot[CHAMBERS_ct][LAYERS_ct][STRIPS_ct] [private] |
Definition at line 53 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::misMatch [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
float CSCCompThreshAnalyzer::myCharge[35] [private] |
float CSCCompThreshAnalyzer::myCompProb[35] [private] |
int CSCCompThreshAnalyzer::mycompstrip [private] |
Definition at line 47 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
std::string CSCCompThreshAnalyzer::name [private] |
int CSCCompThreshAnalyzer::NChambers [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), CSCCompThreshAnalyzer(), and ~CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::Nddu [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), CSCCompThreshAnalyzer(), and ~CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::pedSum [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
std::string CSCCompThreshAnalyzer::PSet [private] |
Definition at line 57 of file CSCCompThreshAnalyzer.h.
int CSCCompThreshAnalyzer::reportedChambers [private] |
Definition at line 46 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::ret_code [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
int CSCCompThreshAnalyzer::sector [private] |
int CSCCompThreshAnalyzer::size[CHAMBERS_ct] [private] |
Definition at line 48 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), CSCCompThreshAnalyzer(), and ~CSCCompThreshAnalyzer().
int CSCCompThreshAnalyzer::strip [private] |
Definition at line 45 of file CSCCompThreshAnalyzer.h.
int CSCCompThreshAnalyzer::strips_per_layer [private] |
float CSCCompThreshAnalyzer::theMeanThresh[CHAMBERS_ct][LAYERS_ct][STRIPS_ct] [private] |
int CSCCompThreshAnalyzer::timebin [private] |
Definition at line 47 of file CSCCompThreshAnalyzer.h.
Referenced by analyze(), and CSCCompThreshAnalyzer().