16 Int_t NofMax=0; Int_t recur255=1; Int_t recur254=1;
17 bool MaxOnStart=
false;
bool MaxInMiddle=
false, MaxOnEnd =
false;
20 if(ampls.size()!=1 && ((ampls[0]>ampls[1])
21 || (ampls.size()>2 && ampls[0]==ampls[1] && ampls[1]>ampls[2] && ampls[0]!=254 && ampls[0]!=255)
22 || (ampls.size()==2 && ampls[0]==ampls[1] && ampls[0]!=254 && ampls[0]!=255)) ){
23 NofMax=NofMax+1; MaxOnStart=
true; }
27 for (
unsigned int i =1;
i < ampls.size()-1U;
i++) {
28 if( (ampls[
i]>ampls[
i-1] && ampls[
i]>ampls[
i+1])
29 || (ampls.size()>3 &&
i>0 &&
i<ampls.size()-2U && ampls[
i]==ampls[
i+1] && ampls[
i]>ampls[
i-1] && ampls[
i]>ampls[
i+2] && ampls[
i]!=254 && ampls[
i]!=255) ){
30 NofMax=NofMax+1; MaxInMiddle=
true; MaxPos=
i;
32 if(ampls[
i]==255 && ampls[
i]==ampls[
i-1]) {
34 MaxPos=
i-(recur255/2);
35 if(ampls[
i]>ampls[
i+1]){NofMax=NofMax+1;MaxInMiddle=
true;}
37 if(ampls[
i]==254 && ampls[
i]==ampls[
i-1]) {
39 MaxPos=
i-(recur254/2);
40 if(ampls[
i]>ampls[
i+1]){NofMax=NofMax+1;MaxInMiddle=
true;}
46 if(ampls[ampls.size()-1]>ampls[ampls.size()-2]
47 || (ampls.size()>2 && ampls[ampls.size()-1]==ampls[ampls.size()-2] && ampls[ampls.size()-2]>ampls[ampls.size()-3] )
48 || ampls[ampls.size()-1]==255){
49 NofMax=NofMax+1; MaxOnEnd=
true; }
52 if(ampls.size()==1){ NofMax=1;}
73 Float_t C_M=0.0; Float_t C_D=0.0; Float_t C_Mn=10000; Float_t C_Dn=10000; Float_t C_Mnn=10000; Float_t C_Dnn=10000;
75 Float_t coeff1=1.7; Float_t coeff2=2.0;
76 Float_t coeffn=0.10; Float_t coeffnn=0.02; Float_t noise=4.0;
81 C_M=(Float_t)ampls[0]; C_D=(Float_t)ampls[1];
82 if(ampls.size()<3) shapecdtn=
true ;
83 else if(ampls.size()==3){C_Dn=(Float_t)ampls[2] ;
if(C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255) shapecdtn=
true;}
84 else if(ampls.size()>3){ C_Dn=(Float_t)ampls[2]; C_Dnn=(Float_t)ampls[3] ;
85 if((C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255)
86 && C_Dnn<=coeff1*coeffn*C_Dn+coeff2*coeffnn*C_D+2*noise){
92 C_M=(Float_t)ampls[ampls.size()-1]; C_D=(Float_t)ampls[ampls.size()-2];
93 if(ampls.size()<3) shapecdtn=
true ;
94 else if(ampls.size()==3){C_Dn=(Float_t)ampls[0] ;
if(C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255) shapecdtn=
true;}
95 else if(ampls.size()>3){C_Dn=(Float_t)ampls[ampls.size()-3] ; C_Dnn=(Float_t)ampls[ampls.size()-4] ;
96 if((C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255)
97 && C_Dnn<=coeff1*coeffn*C_Dn+coeff2*coeffnn*C_D+2*noise){
102 if(MaxInMiddle==
true){
103 C_M=(Float_t)ampls[MaxPos];
104 int LeftOfMaxPos=MaxPos-1;
if(LeftOfMaxPos<=0)LeftOfMaxPos=0;
105 int RightOfMaxPos=MaxPos+1;
if(RightOfMaxPos>=(
int)ampls.size())RightOfMaxPos=ampls.size()-1;
107 if(ampls[LeftOfMaxPos]<ampls[RightOfMaxPos]){ C_D=(Float_t)ampls[RightOfMaxPos]; C_Mn=(Float_t)ampls[LeftOfMaxPos];CDPos=RightOfMaxPos;}
else{ C_D=(Float_t)ampls[LeftOfMaxPos]; C_Mn=(Float_t)ampls[RightOfMaxPos];CDPos=LeftOfMaxPos;}
108 if(C_Mn<coeff1*coeffn*C_M+coeff2*coeffnn*C_D+2*noise || C_M==255){
109 if(ampls.size()==3) shapecdtn=
true ;
110 else if(ampls.size()>3){
112 if(ampls.size()-CDPos-1==0){
115 if(ampls.size()-CDPos-1==1){
116 C_Dn=(Float_t)ampls[CDPos+1];
119 if(ampls.size()-CDPos-1>1){
120 C_Dn=(Float_t)ampls[CDPos+1];
121 C_Dnn=(Float_t)ampls[CDPos+2];
124 C_Mnn=(Float_t)ampls[MaxPos-2];
126 else if(MaxPos<2) C_Mnn=0;
133 C_Dn=(Float_t)ampls[0];
137 C_Dn=(Float_t)ampls[CDPos-1];
138 C_Dnn=(Float_t)ampls[CDPos-2];
140 if(ampls.size()-LeftOfMaxPos>1 && MaxPos+2<(int)(ampls.size())-1){
141 C_Mnn=(Float_t)ampls[MaxPos+2];
144 if((C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255)
145 && C_Mnn<=coeff1*coeffn*C_Mn+coeff2*coeffnn*C_M+2*noise
146 && C_Dnn<=coeff1*coeffn*C_Dn+coeff2*coeffnn*C_D+2*noise) {
154 if(ampls.size()==1){shapecdtn=
true;}
167 for(
unsigned int i=0;
i<Ampls.size();
i++){
168 int calibratedCharge = Ampls[
i];
170 if(calibGains.size()!=0){
171 auto & gains = calibGains[detUnit.
index()-m_off];
172 calibratedCharge = (int)(calibratedCharge / gains[(cluster->
firstStrip()+
i)/128] );
173 if(calibratedCharge>=1024){
174 calibratedCharge = 255;
175 }
else if(calibratedCharge>=255){
176 calibratedCharge = 254;
180 charge+=calibratedCharge;
181 if(calibratedCharge>=254)nSatStrip++;
190 auto const & dus = tkGeom.
detUnits();
191 calibGains.resize(dus.size()-m_off);
193 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
194 t1->Add(m_calibrationPath.c_str());
196 unsigned int tree_DetId;
197 unsigned char tree_APVId;
199 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
200 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
201 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
203 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
204 t1->GetEntry(ientry);
206 if(gains.size()<(size_t)(tree_APVId+1)){gains.resize(tree_APVId+1);}
207 gains[tree_APVId] = tree_Gain;
216 if( strcmp(Reccord.c_str(),
"SiStripDeDxMip_3D_Rcd")==0){
218 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxPion_3D_Rcd")==0){
220 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxKaon_3D_Rcd")==0){
222 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxProton_3D_Rcd")==0){
224 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxElectron_3D_Rcd")==0){
227 throw cms::Exception(
"WrongReccord for dEdx") <<
"The reccord : " << Reccord <<
"is unknown\n";
230 float xmin = deDxMapHandle->rangeX().min;
231 float xmax = deDxMapHandle->rangeX().max;
232 float ymin = deDxMapHandle->rangeY().min;
233 float ymax = deDxMapHandle->rangeY().max;
234 float zmin = deDxMapHandle->rangeZ().min;
235 float zmax = deDxMapHandle->rangeZ().max;
237 if(Prob_ChargePath)
delete Prob_ChargePath;
238 Prob_ChargePath =
new TH3F (
"Prob_ChargePath" ,
"Prob_ChargePath" , deDxMapHandle->numberOfBinsX(),
xmin,
xmax, deDxMapHandle->numberOfBinsY() ,
ymin,
ymax, deDxMapHandle->numberOfBinsZ(),
zmin,
zmax);
240 if(strcmp(ProbabilityMode.c_str(),
"Accumulation")==0){
241 for(
int i=0;
i<=Prob_ChargePath->GetXaxis()->GetNbins()+1;
i++){
242 for(
int j=0;
j<=Prob_ChargePath->GetYaxis()->GetNbins()+1;
j++){
244 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){ Ni+=deDxMapHandle->binContent(
i,
j,
k);}
245 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){
247 for(
int l=0;
l<=
k;
l++){ tmp+=deDxMapHandle->binContent(
i,
j,
l);}
249 Prob_ChargePath->SetBinContent (
i,
j,
k, tmp/Ni);
251 Prob_ChargePath->SetBinContent (
i,
j,
k, 0);
256 }
else if(strcmp(ProbabilityMode.c_str(),
"Integral")==0){
257 for(
int i=0;
i<=Prob_ChargePath->GetXaxis()->GetNbins()+1;
i++){
258 for(
int j=0;
j<=Prob_ChargePath->GetYaxis()->GetNbins()+1;
j++){
260 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){ Ni+=deDxMapHandle->binContent(
i,
j,
k);}
261 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){
262 float tmp = deDxMapHandle->binContent(
i,
j,
k);
264 Prob_ChargePath->SetBinContent (
i,
j,
k, tmp/Ni);
266 Prob_ChargePath->SetBinContent (
i,
j,
k, 0);
272 throw cms::Exception(
"WrongConfig for dEdx") <<
"The ProbabilityMode: " << ProbabilityMode <<
"is unknown\n";
280 if(FirstStrip==0 )
return true;
281 if(FirstStrip==128 )
return true;
282 if(FirstStrip==256 )
return true;
283 if(FirstStrip==384 )
return true;
284 if(FirstStrip==512 )
return true;
285 if(FirstStrip==640 )
return true;
287 if(FirstStrip<=127 && FirstStrip+ClusterSize>127)
return true;
288 if(FirstStrip<=255 && FirstStrip+ClusterSize>255)
return true;
289 if(FirstStrip<=383 && FirstStrip+ClusterSize>383)
return true;
290 if(FirstStrip<=511 && FirstStrip+ClusterSize>511)
return true;
291 if(FirstStrip<=639 && FirstStrip+ClusterSize>639)
return true;
293 if(FirstStrip+ClusterSize==127 )
return true;
294 if(FirstStrip+ClusterSize==255 )
return true;
295 if(FirstStrip+ClusterSize==383 )
return true;
296 if(FirstStrip+ClusterSize==511 )
return true;
297 if(FirstStrip+ClusterSize==639 )
return true;
298 if(FirstStrip+ClusterSize==767 )
return true;
305 if (dynamic_cast<const StripGeomDetUnit*>(it)==0 && dynamic_cast<const PixelGeomDetUnit*>(it)==0) {
306 edm::LogInfo(
"DeDxTools::IsFarFromBorder") <<
"this detID doesn't seem to belong to the Tracker" << std::endl;
314 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
315 const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
317 double DistFromBorder = 1.0;
321 if(trapezoidalBounds)
323 std::array<const float, 4>
const &
parameters = (*trapezoidalBounds).parameters();
324 HalfLength = parameters[3];
327 }
else if(rectangularBounds){
333 if (fabs(HitLocalPos.y())+HitLocalError.
yy() >= (HalfLength - DistFromBorder) )
return false;
virtual const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual float length() const =0
LocalPoint localPosition() const
const Bounds & bounds() const
uint16_t firstStrip() const
const Plane & surface() const
The nominal surface of the GeomDet.
LocalError positionError() const
virtual const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.
const LocalTrajectoryError & localError() const
std::vector< std::vector< double > > tmp
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::LocalCoordinateSystemTag > LocalPoint
point in local coordinate system
const std::vector< uint8_t > & amplitudes() const