10 float theCutToAvoidSignal,
11 int theEventInitNumber,
12 int theEventIterNumber){
14 theAlgorithmType_ = theAlgorithmType;
15 theNumCMstripsInGroup_ = theNumCMstripsInGroup;
16 theMaskCalcFlag_ = theMaskCalcFlag;
17 theMaskNoiseCut_ = theMaskNoiseCut;
18 theMaskDeadCut_ = theMaskDeadCut;
19 theMaskTruncCut_ = theMaskTruncCut;
20 theCutToAvoidSignal_ = theCutToAvoidSignal;
21 theEventInitNumber_ = theEventInitNumber;
22 theEventIterNumber_ = theEventIterNumber;
31 theAlgorithmType_ = pset.
getParameter<
string>(
"CalculatorAlgorithm");
32 theNumCMstripsInGroup_ = pset.
getParameter<
int>(
"NumCMstripsInGroup");
33 theMaskCalcFlag_ = pset.
getParameter<
int>(
"MaskCalculationFlag");
35 theMaskNoiseCut_ = pset.
getParameter<
double>(
"MaskNoiseCut");
36 theMaskDeadCut_ = pset.
getParameter<
double>(
"MaskDeadCut");
37 theMaskTruncCut_ = pset.
getParameter<
double>(
"MaskTruncationCut");
38 theCutToAvoidSignal_ = pset.
getParameter<
double>(
"CutToAvoidSignal");
40 theEventInitNumber_ = pset.
getParameter<
int>(
"NumberOfEventsForInit");
41 theEventIterNumber_ = pset.
getParameter<
int>(
"NumberOfEventsForIteration");
48 ApvAnalysisFactory::ApvAnalysisMap::iterator it = apvMap_.begin();
49 for(;it!=apvMap_.end();it++)
51 vector<ApvAnalysis*>::iterator myApv = (*it).second.begin();
52 for(;myApv!=(*it).second.end();myApv++)
63 ApvAnalysisFactory::ApvAnalysisMap::iterator CPos = apvMap_.find(detId);
64 if(CPos != apvMap_.end()) {
65 cout <<
" APVs for Detector Id " << detId <<
" already created !!!" << endl;;
68 vector< ApvAnalysis* >
temp;
69 for(
int i=0;
i<numberOfApvs;
i++)
73 constructAuxiliaryApvClasses(apvTmp,detId,
i);
74 temp.push_back(apvTmp);
76 apvMap_.insert(pair< uint32_t, vector< ApvAnalysis* > >(detId, temp));
82 ApvAnalysisMap::const_iterator _apvAnalysisIter = apvMap_.find( nDET_ID);
84 return apvMap_.end() != _apvAnalysisIter ? _apvAnalysisIter->second : std::vector<ApvAnalysis *>();
108 if( theAlgorithmType_ ==
"TT6") {
109 theMask =
new TT6ApvMask(theMaskCalcFlag_,theMaskNoiseCut_,theMaskDeadCut_,theMaskTruncCut_);
110 theNoise =
new TT6NoiseCalculator(theEventInitNumber_, theEventIterNumber_, theCutToAvoidSignal_);
111 thePedestal =
new TT6PedestalCalculator(theEventInitNumber_, theEventIterNumber_, theCutToAvoidSignal_);
113 }
else if(
"TT6NT" == theAlgorithmType_) {
120 theCutToAvoidSignal_);
124 theCutToAvoidSignal_);
125 }
else if (theAlgorithmType_ ==
"MIX") {
127 theMask =
new TT6ApvMask(theMaskCalcFlag_,theMaskNoiseCut_,theMaskDeadCut_,theMaskTruncCut_);
133 if (theCMType_ ==
"Median"){
136 cout <<
"Sorry Only Median is available for now, Mean and FastLinear are coming soon" << endl;
142 theCM->
setCM(theCommonMode);
159 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
160 if(apvAnalysisIt != apvMap_.end())
164 for(vector<ApvAnalysis*>::const_iterator apvIt = (apvAnalysisIt->second).begin(); apvIt != (apvAnalysisIt->second).
end(); apvIt++)
167 if (iter==pairNumber*2 || iter==(2*pairNumber+1)){
173 tmpRawDigi.
data.reserve(128);
175 size_t startStrip = 128*(iter%2);
176 size_t stopStrip = startStrip + 128;
178 for(
size_t istrip = startStrip; istrip < stopStrip;istrip++)
180 if(in.
data.size() <= istrip) tmpRawDigi.
data.push_back( 0);
181 else tmpRawDigi.
data.push_back(in.
data[istrip]);
184 (*apvIt)->newEvent();
185 (*apvIt)->updateCalibration(tmpRawDigi);
201 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
202 if(apvAnalysisIt != apvMap_.end())
205 for(vector<ApvAnalysis*>::const_iterator apvIt = (apvAnalysisIt->second).begin(); apvIt != (apvAnalysisIt->second).
end(); apvIt++)
209 tmpRawDigi.
data.reserve(128);
210 size_t startStrip = 128*
i;
211 size_t stopStrip = startStrip + 128;
213 for(
size_t istrip = startStrip; istrip < stopStrip;istrip++)
215 if( in.
data.size() <= istrip) tmpRawDigi.
data.push_back(0);
216 else tmpRawDigi.
data.push_back(in.
data[istrip]);
219 (*apvIt)->newEvent();
220 (*apvIt)->updateCalibration(tmpRawDigi);
233 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
234 if(apvAnalysisIt != apvMap_.end())
236 vector<ApvAnalysis*> myApvs = apvAnalysisIt->second;
237 peds = myApvs[apvNumber]->pedestalCalculator().pedestal();
246 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
247 if(apvAnalysisIt != apvMap_.end())
249 vector<ApvAnalysis* > theApvs = apvAnalysisIt->second;
250 for(vector<ApvAnalysis*>::const_iterator it = theApvs.begin(); it != theApvs.end();it++)
253 for(ApvAnalysis::PedestalType::const_iterator pit =tmp.begin(); pit!=tmp.end(); pit++)
254 peds.push_back(*pit);
262 int apvNumb = int(stripNumber / 128.);
263 int stripN = (stripNumber - apvNumb*128);
265 getPedestal(detId, apvNumb, temp);
273 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
274 if(apvAnalysisIt != apvMap_.end())
276 vector<ApvAnalysis* > theApvs = apvAnalysisIt->second;
278 noise = theApvs[apvNumber]->noiseCalculator().noise();
286 int apvNumb = int(stripNumber / 128.);
287 int stripN = (stripNumber - apvNumb*128);
289 getNoise(detId, apvNumb, temp);
298 map<uint32_t, vector<ApvAnalysis* > >::const_iterator theApvs_map = apvMap_.find(detId);
299 if(theApvs_map != apvMap_.end())
301 vector<ApvAnalysis*>::const_iterator theApvs = (theApvs_map->second).
begin();
302 for(; theApvs != (theApvs_map->second).
end();theApvs++)
305 for(ApvAnalysis::PedestalType::const_iterator pit =tmp.begin(); pit!=tmp.end(); pit++)
306 peds.push_back(*pit);
316 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
317 if(apvAnalysisIt != apvMap_.end())
319 vector<ApvAnalysis* > theApvs = apvAnalysisIt->second;
321 noise = theApvs[apvNumber]->pedestalCalculator().rawNoise();
329 int apvNumb = int(stripNumber / 128.);
330 int stripN = (stripNumber - apvNumb*128);
332 getRawNoise(detId, apvNumb, temp);
341 map<uint32_t, vector<ApvAnalysis* > >::const_iterator theApvs_map = apvMap_.find(detId);
342 if(theApvs_map != apvMap_.end())
344 vector<ApvAnalysis*>::const_iterator theApvs = (theApvs_map->second).
begin();
345 for(; theApvs != (theApvs_map->second).
end();theApvs++)
348 for(ApvAnalysis::PedestalType::const_iterator pit =tmp.begin(); pit!=tmp.end(); pit++)
349 peds.push_back(*pit);
360 map<uint32_t, vector<ApvAnalysis* > >::const_iterator theApvs_map = apvMap_.find(detId);
361 if(theApvs_map != apvMap_.end())
363 vector<ApvAnalysis* > theApvs = theApvs_map->second;
365 tmp = theApvs[apvNumber]->commonModeCalculator().commonMode()->returnAsVector();
372 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
373 if(apvAnalysisIt != apvMap_.end())
375 vector<ApvAnalysis* > theApvs = apvAnalysisIt->second;
376 for(
unsigned int i=0;
i< theApvs.size();
i++)
379 vector<float> tmp_cm = theApvs[
i]->commonModeCalculator().commonMode()->returnAsVector();
380 for(
unsigned int it = 0; it < tmp_cm.size(); it++)
381 tmp.push_back( tmp_cm[it]);
389 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(det_id);
390 if(apvAnalysisIt != apvMap_.end()) {
391 vector<ApvAnalysis* > theApvs = apvAnalysisIt->second;
392 for(
unsigned int i=0;
i< theApvs.size();
i++)
397 for(
unsigned int ii=0;
ii<theMaskType.size();
ii++)
399 tmp.push_back(theMaskType[
ii]);
407 bool updating =
true;
408 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
409 if(apvAnalysisIt != apvMap_.end())
411 for(vector<ApvAnalysis*>::const_iterator apvIt = (apvAnalysisIt->second).begin(); apvIt != (apvAnalysisIt->second).
end(); apvIt++)
413 if(!( (*apvIt)->pedestalCalculator().status()->isUpdating() ))
424 delete &(apv->
mask());
435 map<uint32_t, vector<ApvAnalysis* > >::const_iterator theApvs_map = apvMap_.find(detId);
437 if(theApvs_map != apvMap_.end()) {
438 vector<ApvAnalysis* > theApvs = theApvs_map->second;
439 tmp = theApvs[apvNumber]->commonModeCalculator().getCMSlope();
447 map<uint32_t, vector<ApvAnalysis*> >::const_iterator apvAnalysisIt = apvMap_.find(detId);
448 if(apvAnalysisIt != apvMap_.end()) {
449 vector<ApvAnalysis* > theApvs = apvAnalysisIt->second;
450 for(
unsigned int i=0;
i< theApvs.size();
i++) {
451 tmp.push_back(theApvs[
i]->commonModeCalculator().getCMSlope());
std::vector< StripMaskType > MaskType
T getParameter(std::string const &) const
std::vector< float > PedestalType
virtual void setCM(TkCommonMode *)=0
TkCommonModeCalculator & commonModeCalculator()
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
void getCommonModeSlope(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
void getNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
void update(uint32_t det_id, const edm::DetSet< SiStripRawDigi > &in)
void getMask(uint32_t det_id, TkApvMask::MaskType &tmp)
float getStripNoise(uint32_t det_id, int stripNumber)
virtual TkCommonMode * commonMode()=0
void getRawNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
void deleteApv(ApvAnalysis *apv)
float getStripRawNoise(uint32_t det_id, int stripNumber)
virtual void setTopology(TkCommonModeTopology *in)
void updatePair(uint32_t det_id, size_t apvPair, const edm::DetSet< SiStripRawDigi > &in)
void setMask(TkApvMask &in)
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
void setPedestalCalculator(TkPedestalCalculator &in)
void setNoiseCalculator(TkNoiseCalculator &in)
void setCommonModeCalculator(TkCommonModeCalculator &in)
TkPedestalCalculator & pedestalCalculator()
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
virtual TkCommonModeTopology & topology()
ApvAnalysisVector getApvAnalysis(const uint32_t nDET_ID)
std::vector< std::vector< double > > tmp
ApvAnalysisFactory(std::string theAlgorithmType, int theNumCMstripsInGroup, int theMaskCalcFlag, float theMaskNoiseCut, float theMaskDeadCut, float theMaskTruncCut, float theCutToAvoidSignal, int theEventInitNumber, int theEventIterNumber)
void constructAuxiliaryApvClasses(ApvAnalysis *theApv, uint32_t det_id, int thisApv)
float getStripPedestal(uint32_t det_id, int stripNumber)
bool isUpdating(uint32_t detId)
TkNoiseCalculator & noiseCalculator()