#include <OnlineDB/CSCCondDB/interface/CSCscaAnalyzer.h>
Public Member Functions | |
virtual void | analyze (edm::Event const &e, edm::EventSetup const &iSetup) |
CSCscaAnalyzer (edm::ParameterSet const &conf) | |
~CSCscaAnalyzer () | |
Private Attributes | |
std::vector< int > | adc |
TCalibSCAEvt | calib_evt |
TBranch * | calibevt |
TFile * | calibfile |
TTree * | calibtree |
int | cap |
int | chamber |
std::string | chamber_id |
int | chamber_index |
int | chamber_num |
std::string | chamber_type |
int | count_adc [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] |
int | count_adc_mean [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] |
int | counter |
int | counterzero |
int | crateID [CHAMBERS_sca] |
bool | debug |
float | div [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] |
int | dmbID [CHAMBERS_sca] |
int | eventNumber |
int | evt |
int | fff |
std::ifstream | filein |
int | first_strip_index |
int | flag |
int | layer |
int | lctPhase |
int | length |
int | lines |
unsigned int | maxDDU |
int | maxStrip |
int | misMatch |
float | my_scaValue |
float | my_scaValueMean |
int | myevt |
int | myIndex |
int | myNcham |
std::string | name |
int | NChambers |
int | Nddu |
float | pedMean |
int | power |
std::string | PSet |
int | reportedChambers |
int | ret_code |
int | run |
int | scaBlock |
int | scaNr [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca] |
int | scaNumber |
int | sector |
int | size [CHAMBERS_sca] |
int | strip |
int | strips_per_layer |
float | sum_weightSCAnr [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] |
int | trigTime |
int | value_adc [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] |
float | value_adc_mean [DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] |
Definition at line 35 of file CSCscaAnalyzer.h.
CSCscaAnalyzer::CSCscaAnalyzer | ( | edm::ParameterSet const & | conf | ) | [explicit] |
Definition at line 29 of file CSCscaAnalyzer.cc.
References chamber, CHAMBERS_sca, count_adc, count_adc_mean, counter, DDU_sca, debug, div, eventNumber, evt, flag, edm::ParameterSet::getUntrackedParameter(), i, j, k, edm::es::l(), layer, LAYERS_sca, length, m, maxDDU, maxStrip, misMatch, myevt, myIndex, myNcham, NChambers, Nddu, Number_sca, pedMean, reportedChambers, scaNr, strip, STRIPS_sca, sum_weightSCAnr, value_adc, and value_adc_mean.
00029 { 00030 debug = conf.getUntrackedParameter<bool>("debug",false); 00031 eventNumber=0,evt=0, Nddu=0; 00032 strip=0,misMatch=0,maxDDU=0,maxStrip=-999; 00033 chamber=0,layer=0,reportedChambers=0; 00034 length=1,myevt=0,flag=-9,myIndex=0; 00035 pedMean=0.0,NChambers=0,myNcham=0,counter=0; 00036 00037 for (int i=0;i<DDU_sca;i++){ 00038 for (int j=0;j<CHAMBERS_sca;j++){ 00039 for (int k=0;k<LAYERS_sca;k++){ 00040 for (int l=0;l<STRIPS_sca;l++){ 00041 scaNr[i][j][k][l]=0; 00042 } 00043 } 00044 } 00045 } 00046 00047 for (int i=0;i<DDU_sca;i++){ 00048 for (int j=0;j<CHAMBERS_sca;j++){ 00049 for (int k=0;k<LAYERS_sca;k++){ 00050 for (int l=0;l<STRIPS_sca;l++){ 00051 for (int m=0;m<Number_sca;m++){ 00052 value_adc[i][j][k][l][m]=0; 00053 value_adc_mean[i][j][k][l][m]=0.0; 00054 count_adc_mean[i][j][k][l][m]=0; 00055 count_adc[i][j][k][l][m]=0; 00056 div[i][j][k][l][m]=0.0; 00057 sum_weightSCAnr[i][j][k][l][m]=0.0; 00058 } 00059 } 00060 } 00061 } 00062 } 00063 }
CSCscaAnalyzer::~CSCscaAnalyzer | ( | ) |
Definition at line 174 of file CSCscaAnalyzer.cc.
References calib_evt, calibfile, calibtree, TCalibSCAEvt::cham, chamber_id, chamber_index, chamber_num, chamber_type, CSCMapItem::MapItem::chamberId, CSCMapItem::MapItem::chamberLabel, count_adc_mean, counter, GenMuonPlsPt100GeV_cfg::cout, cscmap1::cratedmb(), crateID, TCalibSCAEvt::ddu, dmbID, lat::endl(), filein, first_strip_index, TCalibSCAEvt::id, k, TCalibSCAEvt::layer, LAYERS_sca, lines, python::multivaluedict::map(), my_scaValue, my_scaValueMean, myIndex, myNcham, name, Nddu, NULL, Number_sca, out, TCalibSCAEvt::scaMeanVal, TCalibSCAEvt::scanumber, CSCMapItem::MapItem::sector, sector, TCalibSCAEvt::strip, CSCMapItem::MapItem::stripIndex, CSCMapItem::MapItem::strips, strips_per_layer, STRIPS_sca, sum_weightSCAnr, and value_adc_mean.
00174 { 00175 00176 //get time of Run file for DB transfer 00177 filein.open("../test/CSCsca.cfg"); 00178 filein.ignore(1000,'\n'); 00179 00180 while(filein != NULL){ 00181 lines++; 00182 getline(filein,PSet); 00183 00184 if (lines==2){ 00185 name=PSet; 00186 } 00187 } 00188 00189 //get name of run file from .cfg and name root output after that 00190 std::string::size_type runNameStart = name.find("\"",0); 00191 std::string::size_type runNameEnd = name.find("raw",0); 00192 std::string::size_type rootStart = name.find("SCAPed",0); 00193 int nameSize = runNameEnd+3-runNameStart; 00194 int myRootSize = rootStart-runNameStart+8; 00195 std::string myname= name.substr(runNameStart+1,nameSize); 00196 std::string myRootName= name.substr(runNameStart+1,myRootSize); 00197 std::string myRootEnd = "_sca.root"; 00198 std::string myASCIIFileEnd = ".dat"; 00199 std::string runFile= myRootName; 00200 std::string myRootFileName = runFile+myRootEnd; 00201 std::string myASCIIFileName= runFile+myASCIIFileEnd; 00202 const char *myNewName=myRootFileName.c_str(); 00203 const char *myFileName=myASCIIFileName.c_str(); 00204 00205 struct tm* clock; 00206 struct stat attrib; 00207 stat(myname.c_str(), &attrib); 00208 clock = localtime(&(attrib.st_mtime)); 00209 std::string myTime=asctime(clock); 00210 std::ofstream mySCAfile(myFileName,std::ios::out); 00211 00212 //root ntuple 00213 TCalibSCAEvt calib_evt; 00214 TFile calibfile(myNewName, "RECREATE"); 00215 TTree calibtree("Calibration","SCA"); 00216 calibtree.Branch("EVENT", &calib_evt, "strip/I:layer/I:cham/I:ddu/I:scaMeanVal/F:id/I:scanumber/I"); 00217 00218 //DB object and map 00219 //CSCobject *cn = new CSCobject(); 00220 //CSCobject *cn1 = new CSCobject(); 00221 CSCMapItem::MapItem mapitem; 00222 cscmap1 *map = new cscmap1(); 00223 //condbon *dbon = new condbon(); 00224 00225 for (int dduiter=0;dduiter<Nddu;dduiter++){ 00226 for (int cham=0;cham<myNcham;cham++){ 00227 00228 //get chamber ID from DB mapping 00229 int new_crateID = crateID[cham]; 00230 int new_dmbID = dmbID[cham]; 00231 00232 std::cout<<" Crate: "<<new_crateID<<" and DMB: "<<new_dmbID<<std::endl; 00233 //map->crate_chamber(new_crateID,new_dmbID,&chamber_id,&chamber_num,§or,&first_strip_index,&strips_per_layer,&chamber_index); 00234 //new mapping 00235 map->cratedmb(new_crateID,new_dmbID,&mapitem); 00236 chamber_num=mapitem.chamberId; 00237 sector= mapitem.sector; 00238 first_strip_index=mapitem.stripIndex; 00239 strips_per_layer=mapitem.strips; 00240 chamber_index=mapitem.chamberId; 00241 chamber_type = mapitem.chamberLabel; 00242 00243 std::cout<<"Data is for chamber:: "<< chamber_type<<" "<<chamber_id<<" in sector: "<<sector<<" index "<<first_strip_index<<std::endl; 00244 00245 calib_evt.id = chamber_num; 00246 00247 for (int layeriter=0; layeriter<LAYERS_sca; layeriter++){ 00248 //int layer_id=chamber_num+layeriter+1; 00249 00250 for (int stripiter=0; stripiter<STRIPS_sca; stripiter++){ 00251 //std::cout<<"strip2222 "<<scaNr[dduiter][cham][layeriter][stripiter]<<std::endl; 00252 //my_scaValue = scaNr[dduiter][cham][layeriter][stripiter]; 00253 00254 //calib_evt.scanumber=my_scaValue; 00255 //std::cout<<"strip2222 "<<stripiter<<" "<<layeriter<<" "<<cham<<" "<<dduiter<<" SCA nr "<<scaNr[dduiter][cham][layeriter][stripiter]<<std::endl; 00256 for (int k=0;k<Number_sca;k++){ 00257 //value_adc[dduiter][cham][layeriter][stripiter][k]; 00258 //my_scaValueMean = value_adc_mean[dduiter][cham][layeriter][stripiter][k]; 00259 //my_scaValueMean = div[dduiter][cham][layeriter][stripiter][k]; 00260 if(count_adc_mean[dduiter][cham][layeriter][stripiter][k] !=0){ 00261 my_scaValue = sum_weightSCAnr[dduiter][cham][layeriter][stripiter][k]/count_adc_mean[dduiter][cham][layeriter][stripiter][k]; 00262 my_scaValueMean =value_adc_mean[dduiter][cham][layeriter][stripiter][k]/count_adc_mean[dduiter][cham][layeriter][stripiter][k]; 00263 } 00264 counter++; 00265 myIndex = first_strip_index+counter-1; 00266 mySCAfile<<" "<<myIndex<<" "<<chamber_num<<" "<<layeriter<<" "<<stripiter<<" "<<my_scaValue<<" "<<my_scaValueMean<<std::endl; 00267 00268 00269 //std::cout<<"Ch "<<cham<<" Layer "<<layeriter<<" strip "<<stripiter<<" sca_nr "<<k<<" weighted SCAnr "<<my_scaValue <<std::endl; 00270 calib_evt.strip=stripiter; 00271 calib_evt.layer=layeriter; 00272 calib_evt.cham=cham; 00273 calib_evt.ddu=dduiter; 00274 00275 calib_evt.scaMeanVal=my_scaValueMean; 00276 calib_evt.scanumber=my_scaValue; 00277 00278 calibtree.Fill(); 00279 } 00280 } 00281 } 00282 } 00283 } 00284 calibfile.Write(); 00285 calibfile.Close(); 00286 }
void CSCscaAnalyzer::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
get a reference to chamber data
Implements edm::EDAnalyzer.
Definition at line 65 of file CSCscaAnalyzer.cc.
References adc, cap, CSCDMBHeader::cfebAvailable(), chamber, count_adc, count_adc_mean, GenMuonPlsPt100GeV_cfg::cout, crateID, FEDRawData::data(), dmbID, lat::endl(), eventNumber, evt, first, edm::Event::getByLabel(), edm::Event::getByType(), FEDNumbering::getCSCFEDIds(), i, id, layer, CSCCFEBSCAControllerWord::lct_phase, lctPhase, maxDDU, maxStrip, misMatch, myNcham, NChambers, Nddu, power, reportedChambers, CSCCFEBSCAControllerWord::sca_blk, scaBlock, CSCCFEBTimeSlice::scaControllerWord(), scaNr, scaNumber, FEDRawData::size(), strip, sum_weightSCAnr, CSCCFEBData::timeSlice(), tmp, CSCCFEBSCAControllerWord::trig_time, trigTime, and value_adc_mean.
00065 { 00066 00067 edm::Handle<CSCStripDigiCollection> strips; 00068 e.getByLabel("cscunpacker","MuonCSCStripDigi",strips); 00069 edm::Handle<FEDRawDataCollection> rawdata; 00070 e.getByType(rawdata); //before 0_7_0_pre4 use getByLabel("DaqSource", rawdata) 00071 //myevt=e.id().event(); 00072 //counterzero=counterzero+1; 00073 //evt=(counterzero+1)/2; 00074 int conv_blk[16]={0,1,2,3,4,5,6,7,8,0,9,0,10,0,11,0}; 00075 00076 for (int id=FEDNumbering::getCSCFEDIds().first; 00077 id<=FEDNumbering::getCSCFEDIds().second; ++id){ //for each of our DCCs 00078 00080 const FEDRawData& fedData = rawdata->FEDData(id); 00081 if (fedData.size()){ 00082 00084 CSCDCCEventData dccData((short unsigned int *) fedData.data()); 00085 00086 const std::vector<CSCDDUEventData> & dduData = dccData.dduData(); 00087 00088 //evt++; 00089 for (unsigned int iDDU=0; iDDU<dduData.size(); ++iDDU) { 00090 if(iDDU > maxDDU){ 00091 maxDDU=iDDU; 00092 } 00093 00095 const std::vector<CSCEventData> & cscData = dduData[iDDU].cscData(); 00096 Nddu = dduData.size(); 00097 reportedChambers += dduData[iDDU].header().ncsc(); 00098 NChambers = cscData.size(); 00099 int repChambers = dduData[iDDU].header().ncsc(); 00100 std::cout << " Reported Chambers = " << repChambers <<" "<<NChambers<< std::endl; 00101 if (NChambers!=repChambers) { std::cout<< "misMatched size!!!" << std::endl; misMatch++; continue;} 00102 if(NChambers > myNcham){ 00103 myNcham=NChambers; 00104 } 00105 if(NChambers !=0) evt++; 00106 00107 for (int chamber = 0; chamber < NChambers; chamber++){ 00108 const CSCDMBHeader * thisDMBheader = cscData[chamber].dmbHeader(); 00109 00110 if (cscData[chamber].dmbHeader() && thisDMBheader->cfebAvailable()){ 00111 dmbID[chamber] = cscData[chamber].dmbHeader()->dmbID(); 00112 crateID[chamber] = cscData[chamber].dmbHeader()->crateID(); 00113 if(crateID[chamber] == 255) continue; 00114 00115 for (int icfeb=0; icfeb<5;icfeb++) {//loop over cfebs in a given chamber 00116 CSCCFEBData * mycfebData = cscData[chamber].cfebData(icfeb); 00117 if (!mycfebData) continue; 00118 00119 for (unsigned int layer = 1; layer <= 6; layer++){ 00120 std::vector<CSCStripDigi> digis = cscData[chamber].stripDigis(layer) ; 00121 00122 int blk_strt=0; 00123 for (int itime=0;itime<8;itime++){ 00124 const CSCCFEBTimeSlice * mytimeSlice = mycfebData->timeSlice(itime); 00125 if (!mytimeSlice)continue; 00126 00127 scaBlock = mytimeSlice->scaControllerWord(layer).sca_blk; 00128 trigTime = mytimeSlice->scaControllerWord(layer).trig_time; 00129 lctPhase = mytimeSlice->scaControllerWord(layer).lct_phase; 00130 int tmp=1; 00131 for(power=0;power<8;power++){if(trigTime==tmp) lctPhase=power; tmp=tmp*2;} 00132 if(trigTime!=0){ 00133 cap = lctPhase+itime; 00134 blk_strt=itime; 00135 }else{ 00136 cap=itime-blk_strt-1; 00137 } 00138 scaNumber=8*conv_blk[scaBlock]+cap; 00139 // printf(" -> itime %d scaBlock %d trigTime %d cap %d scaNumber %d \n",itime,scaBlock,trigTime,cap,scaNumber); 00140 00141 for (unsigned int i=0; i<digis.size(); i++){ 00142 int strip = digis[i].getStrip(); 00143 if (strip > maxStrip){ 00144 maxStrip=strip; 00145 } 00146 adc = digis[i].getADCCounts(); 00147 00148 scaNr[iDDU][chamber][layer][strip] = scaNumber; 00149 //std::cout<<"strip11111 "<<strip<<" "<<layer<<" "<<chamber<<" "<<iDDU<<" SCA nr "<<scaNumber<<std::endl; 00150 00151 value_adc_mean[iDDU][chamber][layer][strip][scaNumber] += adc[itime]; 00152 count_adc[iDDU][chamber][layer][strip][scaNumber]=1; 00153 count_adc_mean[iDDU][chamber][layer][strip][scaNumber] +=1; 00154 sum_weightSCAnr[iDDU][chamber][layer][strip][scaNumber] +=count_adc[iDDU][chamber][layer][strip][scaNumber] * scaNumber; 00155 //sum_weightedMean[iDDU][chamber][layer][strip][scaNumber] = sum_weightSCAnr[iDDU][chamber][layer][strip][scaNumber]/count_adc_mean[iDDU][chamber][layer][strip][scaNumber]; 00156 00157 //std::cout<<"ADC mean "<<value_adc_mean[iDDU][chamber][layer][strip][scaNumber] <<" "<<count_adc_mean[iDDU][chamber][layer][strip][scaNumber]<<std::endl; 00158 } 00159 //std::cout<<"strip1111 "<<scaNr[iDDU][chamber][layer][strip]<<std::endl; 00160 }//8 timeslice 00161 }//layer 00162 }//CFEBs 00163 }//CFEB available 00164 }//chamber 00165 00166 eventNumber++; 00167 edm::LogInfo ("CSCscaAnalyzer") << "end of event number " << eventNumber<<" and non-zero event "<<evt; 00168 00169 } 00170 } 00171 } 00172 }
std::vector<int> CSCscaAnalyzer::adc [private] |
TCalibSCAEvt CSCscaAnalyzer::calib_evt [private] |
TBranch* CSCscaAnalyzer::calibevt [private] |
Definition at line 75 of file CSCscaAnalyzer.h.
TFile* CSCscaAnalyzer::calibfile [private] |
TTree* CSCscaAnalyzer::calibtree [private] |
int CSCscaAnalyzer::cap [private] |
int CSCscaAnalyzer::chamber [private] |
std::string CSCscaAnalyzer::chamber_id [private] |
int CSCscaAnalyzer::chamber_index [private] |
int CSCscaAnalyzer::chamber_num [private] |
std::string CSCscaAnalyzer::chamber_type [private] |
int CSCscaAnalyzer::count_adc[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] [private] |
int CSCscaAnalyzer::count_adc_mean[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] [private] |
Definition at line 60 of file CSCscaAnalyzer.h.
Referenced by analyze(), CSCscaAnalyzer(), and ~CSCscaAnalyzer().
int CSCscaAnalyzer::counter [private] |
Definition at line 68 of file CSCscaAnalyzer.h.
Referenced by CSCscaAnalyzer(), and ~CSCscaAnalyzer().
int CSCscaAnalyzer::counterzero [private] |
Definition at line 68 of file CSCscaAnalyzer.h.
int CSCscaAnalyzer::crateID[CHAMBERS_sca] [private] |
bool CSCscaAnalyzer::debug [private] |
float CSCscaAnalyzer::div[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] [private] |
int CSCscaAnalyzer::dmbID[CHAMBERS_sca] [private] |
int CSCscaAnalyzer::eventNumber [private] |
int CSCscaAnalyzer::evt [private] |
int CSCscaAnalyzer::fff [private] |
Definition at line 54 of file CSCscaAnalyzer.h.
std::ifstream CSCscaAnalyzer::filein [private] |
int CSCscaAnalyzer::first_strip_index [private] |
int CSCscaAnalyzer::flag [private] |
int CSCscaAnalyzer::layer [private] |
int CSCscaAnalyzer::lctPhase [private] |
int CSCscaAnalyzer::length [private] |
int CSCscaAnalyzer::lines [private] |
unsigned int CSCscaAnalyzer::maxDDU [private] |
int CSCscaAnalyzer::maxStrip [private] |
int CSCscaAnalyzer::misMatch [private] |
float CSCscaAnalyzer::my_scaValue [private] |
float CSCscaAnalyzer::my_scaValueMean [private] |
int CSCscaAnalyzer::myevt [private] |
int CSCscaAnalyzer::myIndex [private] |
Definition at line 64 of file CSCscaAnalyzer.h.
Referenced by CSCscaAnalyzer(), and ~CSCscaAnalyzer().
int CSCscaAnalyzer::myNcham [private] |
Definition at line 71 of file CSCscaAnalyzer.h.
Referenced by analyze(), CSCscaAnalyzer(), and ~CSCscaAnalyzer().
std::string CSCscaAnalyzer::name [private] |
int CSCscaAnalyzer::NChambers [private] |
int CSCscaAnalyzer::Nddu [private] |
Definition at line 54 of file CSCscaAnalyzer.h.
Referenced by analyze(), CSCscaAnalyzer(), and ~CSCscaAnalyzer().
float CSCscaAnalyzer::pedMean [private] |
int CSCscaAnalyzer::power [private] |
std::string CSCscaAnalyzer::PSet [private] |
Definition at line 66 of file CSCscaAnalyzer.h.
int CSCscaAnalyzer::reportedChambers [private] |
int CSCscaAnalyzer::ret_code [private] |
Definition at line 54 of file CSCscaAnalyzer.h.
int CSCscaAnalyzer::run [private] |
Definition at line 55 of file CSCscaAnalyzer.h.
int CSCscaAnalyzer::scaBlock [private] |
int CSCscaAnalyzer::scaNr[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca] [private] |
int CSCscaAnalyzer::scaNumber [private] |
int CSCscaAnalyzer::sector [private] |
int CSCscaAnalyzer::size[CHAMBERS_sca] [private] |
Definition at line 56 of file CSCscaAnalyzer.h.
int CSCscaAnalyzer::strip [private] |
int CSCscaAnalyzer::strips_per_layer [private] |
float CSCscaAnalyzer::sum_weightSCAnr[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] [private] |
Definition at line 61 of file CSCscaAnalyzer.h.
Referenced by analyze(), CSCscaAnalyzer(), and ~CSCscaAnalyzer().
int CSCscaAnalyzer::trigTime [private] |
int CSCscaAnalyzer::value_adc[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] [private] |
float CSCscaAnalyzer::value_adc_mean[DDU_sca][CHAMBERS_sca][LAYERS_sca][STRIPS_sca][Number_sca] [private] |
Definition at line 59 of file CSCscaAnalyzer.h.
Referenced by analyze(), CSCscaAnalyzer(), and ~CSCscaAnalyzer().